MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / private_regular_file_snapshot

Function private_regular_file_snapshot

src/daemon/ipc.c:735–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

733}
734
735static bool private_regular_file_snapshot(int directory_fd, const char *base_name, int fd,
736 nlink_t expected_links, struct stat *status_out) {
737 struct stat by_handle;
738 struct stat by_path;
739 bool valid = directory_fd >= 0 && base_name && base_name[0] != '\0' && fd >= 0 &&
740 fstat(fd, &by_handle) == 0 &&
741 fstatat(directory_fd, base_name, &by_path, AT_SYMLINK_NOFOLLOW) == 0 &&
742 S_ISREG(by_handle.st_mode) && S_ISREG(by_path.st_mode) &&
743 by_handle.st_uid == geteuid() && by_path.st_uid == geteuid() &&
744 by_handle.st_nlink == expected_links && by_path.st_nlink == expected_links &&
745 (by_handle.st_mode & 07777) == 0600 && (by_path.st_mode & 07777) == 0600 &&
746 by_handle.st_dev == by_path.st_dev && by_handle.st_ino == by_path.st_ino &&
747 cbm_macos_extended_acl_fd_is_empty(directory_fd) &&
748 cbm_macos_extended_acl_fd_is_empty(fd);
749 if (valid && status_out) {
750 *status_out = by_handle;
751 }
752 return valid;
753}
754
755static bool private_regular_file_at_is_safe(int directory_fd, const char *base_name,
756 nlink_t expected_links) {

Calls 1

Tested by

no test coverage detected