diff options
author | 2018-04-13 16:00:26 -0500 | |
---|---|---|
committer | 2018-04-13 16:03:00 -0500 | |
commit | fddbe854c9db058d5a05830d3bcdd4233d95ee2e (patch) | |
tree | 2468159bdd2456812f25f857ef15ecf4345a330c | |
parent | 3a48dc4373d65bf1203da4899b4dc2bc17993a26 (diff) | |
download | pseudo-fddbe854c9db058d5a05830d3bcdd4233d95ee2e.tar.gz pseudo-fddbe854c9db058d5a05830d3bcdd4233d95ee2e.tar.bz2 pseudo-fddbe854c9db058d5a05830d3bcdd4233d95ee2e.zip |
Fix symlink following errors
openat() was passing its flags unaltered to pseudo_root_path(), which
assumes that a flags argument other than 0 means "don't follow symlinks
in last path component". This is completely wrong, and I have no idea
how it survived this long unnoticed.
Now, if a plain flags variable is set and not overruled by a
comment like /* flags=... */, it's masked with AT_SYMLINK_NOFOLLOW,
as there are other values fstatat() and friends can take, and the
openat() flags are just overridden with 0. (The only meaningful case
would be O_NOFOLLOW, but O_NOFOLLOW instructs us to *fail* in the
open if the path is a symlink, so we don't care.)
Signed-off-by: Seebs <seebs@seebs.net>
-rw-r--r-- | ChangeLog.txt | 1 | ||||
-rwxr-xr-x | makewrappers | 2 | ||||
-rw-r--r-- | ports/linux/wrapfuncs.in | 4 |
3 files changed, 4 insertions, 3 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index 36a1927..d6e3fca 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,7 @@ calls to diag() and debug(). * (seebs) Fix a lurking stray slash that could happen while resolving absolute symlinks. + * (seebs) fix mishandled flags for symlink following. 2018-04-02: * (seebs) Change default copyright notice in guts to diff --git a/makewrappers b/makewrappers index ff08ba0..fa514ba 100755 --- a/makewrappers +++ b/makewrappers @@ -275,7 +275,7 @@ class Function: self.specific_dirfds[arg.name[:-5]] = True self.dirfd = 'dirfd' elif arg.name == 'flags': - self.flags = 'flags' + self.flags = '(flags & AT_SYMLINK_NOFOLLOW)' elif arg.name.endswith('path'): self.paths_to_munge.append(arg.name) diff --git a/ports/linux/wrapfuncs.in b/ports/linux/wrapfuncs.in index 9be6505..e47acc3 100644 --- a/ports/linux/wrapfuncs.in +++ b/ports/linux/wrapfuncs.in @@ -5,8 +5,8 @@ int __lxstat(int ver, const char *path, struct stat *buf); /* flags=AT_SYMLINK_N int __fxstat(int ver, int fd, struct stat *buf); int lchown(const char *path, uid_t owner, gid_t group); /* flags=AT_SYMLINK_NOFOLLOW */ int __fxstatat(int ver, int dirfd, const char *path, struct stat *buf, int flags); -int openat(int dirfd, const char *path, int flags, ...{mode_t mode}); -int __openat_2(int dirfd, const char *path, int flags); +int openat(int dirfd, const char *path, int flags, ...{mode_t mode}); /* flags=0 */ +int __openat_2(int dirfd, const char *path, int flags); /* flags=0 */ int mknod(const char *path, mode_t mode, dev_t dev); /* real_func=pseudo_mknod */ int mknodat(int dirfd, const char *path, mode_t mode, dev_t dev); /* real_func=pseudo_mknodat */ int __xmknod(int ver, const char *path, mode_t mode, dev_t *dev); /* flags=AT_SYMLINK_NOFOLLOW */ |