chiark / gitweb /
tmpdir.c: Be more helpful if owner lacks permissions on the directory.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 7 Jul 2024 21:01:34 +0000 (22:01 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 7 Jul 2024 21:01:34 +0000 (22:01 +0100)
Previously, we'd report `non-owner access permitted', which was exactly
wrong.

This is a functionality check rather than a security check, so I'm not
completely convinced that this is something tmpdir(1) should be
checking.  But it always has done so there's not much reason to stop
now.

tmpdir.c

index bcebf8d067a2ca14037639512144cc8335dd8a9c..7b6fc64e111660b3fa1688324f92bbe801eef68c 100644 (file)
--- a/tmpdir.c
+++ b/tmpdir.c
@@ -122,8 +122,10 @@ static int ok(const char *p, int *f)
     complain(p, "not a directory", 0);
   else if (st.st_uid != me)
     complain(p, "not owner", 0);
-  else if ((st.st_mode & 0777) != 0700)
+  else if (st.st_mode & 0077)
     complain(p, "non-owner access permitted", 0);
+  else if (~st.st_mode & 0700)
+    complain(p, "owner lacks permissions", 0);
   else
     return (1);
   return (0);