diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-05-29 06:34:37 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-05-29 06:34:37 -0700 |
commit | 3961307b692a49f5463b909c1a7bc2a930e9fa8c (patch) | |
tree | b7a37e05a5f97b2e743ecfeaadb24789ada79cc1 /share | |
parent | a2279254bc56443ce4c9f0dd4cc51cf627332c4d (diff) | |
download | txr-3961307b692a49f5463b909c1a7bc2a930e9fa8c.tar.gz txr-3961307b692a49f5463b909c1a7bc2a930e9fa8c.tar.bz2 txr-3961307b692a49f5463b909c1a7bc2a930e9fa8c.zip |
path-private-to-me-p: bugfix: not including superuser.
* share/txr/stdlib/path-test.tl (path-private-to-me,
path-strictly-private-to-me): These functions were neglecting
to trust the root user, as documented. If the file is owned
by root, we treat it as if it were owned by the caller.
Furthermore, if we have to process the group membership, we
allow the group to contain the superuser's name.
* txr.1: Documentation improved, and the treatment of
groups documented.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/path-test.tl | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/share/txr/stdlib/path-test.tl b/share/txr/stdlib/path-test.tl index 77384fa3..3a7146a8 100644 --- a/share/txr/stdlib/path-test.tl +++ b/share/txr/stdlib/path-test.tl @@ -114,25 +114,36 @@ (sys:path-test (s stat path) (let ((m s.mode) (euid (geteuid))) - (mlet ((g (getgrgid s.gid))) - (and (eql euid s.uid) + (mlet ((g (getgrgid s.gid)) + (name (let ((pw (getpwuid euid))) + (if pw pw.name))) + (suname (let ((pw (getpwuid 0))) + (if pw pw.name)))) + (and (or (zerop s.uid) + (eql euid s.uid)) (zerop (logand m s-iwoth)) (or (zerop (logand m s-iwgrp)) (null g.mem) - (and (not (rest g.mem)) - (equal (getpwuid euid).name (first g.mem))))))))) + (and (all g.mem (orf (op equal name) + (op equal suname)))))))))) (defun path-strictly-private-to-me-p (path) (sys:path-test (s stat path) (let ((m s.mode) (euid (geteuid))) - (mlet ((g (getgrgid s.gid))) - (and (eql euid s.uid) + (mlet ((g (getgrgid s.gid)) + (name (let ((pw (getpwuid euid))) + (if pw pw.name))) + (suname (let ((pw (getpwuid 0))) + (if pw pw.name)))) + (and (or (zerop s.uid) + (eql euid s.uid)) (zerop (logand m (logior s-iroth s-iwoth))) (or (zerop (logand m (logior s-iroth s-iwgrp))) (null g.mem) - (and (not (rest g.mem)) - (equal (getpwuid euid).name (first g.mem))))))))) + (and (all g.mem (orf (op equal name) + (op equal suname)))))))))) + (defmacro sys:path-examine ((sym statfun path) . body) ^[sys:do-path-test ,statfun ,path |