diff options
author | David Bartley <dtbartle@csclub.uwaterloo.ca> | 2009-04-29 03:52:26 -0400 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-05-03 18:45:42 +0200 |
commit | 740cb7248fef99fc09b575deb650cfe9ecabafbf (patch) | |
tree | 65977eeb80b1ec19fd312c33fbbff288799202a6 /lib/write-any-file.c | |
parent | 9ccd438ce337e6fb8c95d9261f1e06a3952261c2 (diff) | |
download | gnulib-740cb7248fef99fc09b575deb650cfe9ecabafbf.tar.gz |
priv-set: new module and accompanying tests; adapt write-any-file
* lib/priv-set.c: New file.
* lib/priv-set.h: New file.
* lib/unlinkdir.c: Make cannot_unlink_dir thread-safe.
* lib/write-any-file.c: Simplify by using priv-set module.
* m4/priv-set.m4: New file.
* modules/priv-set: New file.
* modules/unlinkdir: Add dependency on priv-set module.
* modules/write-any-file: Likewise.
These changes address a problem that originally arose with GNU tar:
http://thread.gmane.org/gmane.comp.gnu.tar.bugs/3242
Tests for module 'priv-set'.
* modules/priv-set-tests: New file.
Diffstat (limited to 'lib/write-any-file.c')
-rw-r--r-- | lib/write-any-file.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/lib/write-any-file.c b/lib/write-any-file.c index 8492ac8113..26db765fa6 100644 --- a/lib/write-any-file.c +++ b/lib/write-any-file.c @@ -20,10 +20,8 @@ #include <config.h> #include "write-any-file.h" +#include "priv-set.h" -#if HAVE_PRIV_H -# include <priv.h> -#endif #include <unistd.h> /* Return true if we know that we can write any file, including @@ -38,15 +36,8 @@ can_write_any_file (void) if (! initialized) { bool can = false; -#if defined PRIV_EFFECTIVE && defined PRIV_FILE_DAC_WRITE - priv_set_t *pset = priv_allocset (); - if (pset) - { - can = - (getppriv (PRIV_EFFECTIVE, pset) == 0 - && priv_ismember (pset, PRIV_FILE_DAC_WRITE)); - priv_freeset (pset); - } +#if defined PRIV_FILE_DAC_WRITE + can = (priv_set_ismember (PRIV_FILE_DAC_WRITE) == 1); #else /* In traditional Unix, only root can unlink directories. */ can = (geteuid () == 0); |