diff options
Diffstat (limited to 'guts/readlinkat.c')
-rw-r--r-- | guts/readlinkat.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/guts/readlinkat.c b/guts/readlinkat.c new file mode 100644 index 0000000..13eeeb2 --- /dev/null +++ b/guts/readlinkat.c @@ -0,0 +1,25 @@ +/* + * static ssize_t + * wrap_readlinkat(int dirfd, const char *path, char *buf, size_t bufsiz) { + * ssize_t rc = -1; + */ + rc = real_readlinkat(dirfd, path, buf, bufsiz); + + if (rc > 0) { + /* strip out a leading chrooted part */ + if (pseudo_chroot_len && + !memcmp(buf, pseudo_chroot, pseudo_chroot_len)) { + if (buf[pseudo_chroot_len] == '/') { + memmove(buf, buf + pseudo_chroot_len, rc - pseudo_chroot_len); + rc -= pseudo_chroot_len; + } else if (buf[pseudo_chroot_len] == '\0') { + buf[0] = '/'; + rc = 1; + } + /* otherwise, it's not really a match... */ + } + } + +/* return rc; + * } + */ |