Loading include/client/hooks.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ int hook_writev(unsigned long fd, const struct iovec * iov, unsigned long iovcnt int hook_pwritev(unsigned long fd, const struct iovec * iov, unsigned long iovcnt, unsigned long pos_l, unsigned long pos_h); int hook_unlinkat(int dirfd, const char * cpath, int flags); int hook_symlinkat(const char * oldname, int newdfd, const char * newname); int hook_access(const char* path, int mask); int hook_faccessat(int dirfd, const char * cpath, int mode); int hook_lseek(unsigned int fd, off_t offset, unsigned int whence); Loading src/client/hooks.cpp +33 −0 Original line number Diff line number Diff line Loading @@ -209,6 +209,39 @@ int hook_unlinkat(int dirfd, const char * cpath, int flags) { } } int hook_symlinkat(const char * oldname, int newdfd, const char * newname) { CTX->log()->trace("{}() called with oldname '{}', new fd {}, new name '{}'", __func__, oldname, newdfd, newname); std::string oldname_resolved; if (CTX->relativize_path(oldname, oldname_resolved)) { CTX->log()->warn("{}() operation not supported", __func__); return -ENOTSUP; } std::string newname_resolved; auto rstatus = CTX->relativize_fd_path(newdfd, newname, newname_resolved, false); switch(rstatus) { case RelativizeStatus::fd_unknown: return syscall_no_intercept(SYS_symlinkat, oldname, newdfd, newname); case RelativizeStatus::external: return syscall_no_intercept(SYS_symlinkat, oldname, newdfd, newname_resolved.c_str()); case RelativizeStatus::fd_not_a_dir: return -ENOTDIR; case RelativizeStatus::internal: CTX->log()->warn("{}() operation not supported", __func__); return -ENOTSUP; default: CTX->log()->error("{}() relativize status unknown", __func__); return -EINVAL; } } int hook_access(const char* path, int mask) { CTX->log()->trace("{}() called path '{}', mask {}", __func__, path, mask); std::string rel_path; Loading src/client/intercept.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,18 @@ static inline int hook(long syscall_number, AT_REMOVEDIR); break; case SYS_symlink: *result = hook_symlinkat(reinterpret_cast<const char *>(arg0), AT_FDCWD, reinterpret_cast<const char *>(arg1)); break; case SYS_symlinkat: *result = hook_symlinkat(reinterpret_cast<const char *>(arg0), static_cast<int>(arg1), reinterpret_cast<const char *>(arg2)); break; case SYS_access: *result = hook_access(reinterpret_cast<const char*>(arg0), static_cast<int>(arg1)); Loading Loading
include/client/hooks.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ int hook_writev(unsigned long fd, const struct iovec * iov, unsigned long iovcnt int hook_pwritev(unsigned long fd, const struct iovec * iov, unsigned long iovcnt, unsigned long pos_l, unsigned long pos_h); int hook_unlinkat(int dirfd, const char * cpath, int flags); int hook_symlinkat(const char * oldname, int newdfd, const char * newname); int hook_access(const char* path, int mask); int hook_faccessat(int dirfd, const char * cpath, int mode); int hook_lseek(unsigned int fd, off_t offset, unsigned int whence); Loading
src/client/hooks.cpp +33 −0 Original line number Diff line number Diff line Loading @@ -209,6 +209,39 @@ int hook_unlinkat(int dirfd, const char * cpath, int flags) { } } int hook_symlinkat(const char * oldname, int newdfd, const char * newname) { CTX->log()->trace("{}() called with oldname '{}', new fd {}, new name '{}'", __func__, oldname, newdfd, newname); std::string oldname_resolved; if (CTX->relativize_path(oldname, oldname_resolved)) { CTX->log()->warn("{}() operation not supported", __func__); return -ENOTSUP; } std::string newname_resolved; auto rstatus = CTX->relativize_fd_path(newdfd, newname, newname_resolved, false); switch(rstatus) { case RelativizeStatus::fd_unknown: return syscall_no_intercept(SYS_symlinkat, oldname, newdfd, newname); case RelativizeStatus::external: return syscall_no_intercept(SYS_symlinkat, oldname, newdfd, newname_resolved.c_str()); case RelativizeStatus::fd_not_a_dir: return -ENOTDIR; case RelativizeStatus::internal: CTX->log()->warn("{}() operation not supported", __func__); return -ENOTSUP; default: CTX->log()->error("{}() relativize status unknown", __func__); return -EINVAL; } } int hook_access(const char* path, int mask) { CTX->log()->trace("{}() called path '{}', mask {}", __func__, path, mask); std::string rel_path; Loading
src/client/intercept.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,18 @@ static inline int hook(long syscall_number, AT_REMOVEDIR); break; case SYS_symlink: *result = hook_symlinkat(reinterpret_cast<const char *>(arg0), AT_FDCWD, reinterpret_cast<const char *>(arg1)); break; case SYS_symlinkat: *result = hook_symlinkat(reinterpret_cast<const char *>(arg0), static_cast<int>(arg1), reinterpret_cast<const char *>(arg2)); break; case SYS_access: *result = hook_access(reinterpret_cast<const char*>(arg0), static_cast<int>(arg1)); Loading