Mercurial > hg > octave-kai > gnulib-hg
annotate lib/unlinkdir.c @ 17409:26a04e61f560
stdio: use __REDIRECT for fwrite, fwrite_unlocked
* lib/stdio.in.h (fwrite):
When working around bug 11959, use __REDIRECT rather than '#define
fwrite(...) ... fwrite (...) ...'. This is a more-targeted way to
fix the -Wunused-value issue with clang, and it works with GCC too.
Problem with targeting reported by Eric Blake in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-05/msg00067.html>.
(fwrite_unlocked): Treat like fwrite. I ran into this issue while
debugging the fwrite issue.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Wed, 15 May 2013 15:52:42 -0700 |
parents | e542fd46ad6f |
children |
rev | line source |
---|---|
11538
af683213eeb0
priv-set: new module and accompanying tests; adapt write-any-file
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
11257
diff
changeset
|
1 /* unlinkdir.c - determine whether we can unlink directories |
5852 | 2 |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16951
diff
changeset
|
3 Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc. |
5852 | 4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
5852 | 6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
8 (at your option) any later version. |
5852 | 9 |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
5852 | 17 |
11538
af683213eeb0
priv-set: new module and accompanying tests; adapt write-any-file
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
11257
diff
changeset
|
18 /* Written by Paul Eggert, Jim Meyering, and David Bartley. */ |
5852 | 19 |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6275
diff
changeset
|
20 #include <config.h> |
5852 | 21 |
22 #include "unlinkdir.h" | |
11538
af683213eeb0
priv-set: new module and accompanying tests; adapt write-any-file
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
11257
diff
changeset
|
23 #include "priv-set.h" |
16951 | 24 #include "root-uid.h" |
6275 | 25 #include <unistd.h> |
5852 | 26 |
27 #if ! UNLINK_CANNOT_UNLINK_DIR | |
28 | |
29 /* Return true if we cannot unlink directories, false if we might be | |
11538
af683213eeb0
priv-set: new module and accompanying tests; adapt write-any-file
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
11257
diff
changeset
|
30 able to unlink directories. */ |
5852 | 31 |
32 bool | |
33 cannot_unlink_dir (void) | |
34 { | |
35 static bool initialized; | |
36 static bool cannot; | |
37 | |
38 if (! initialized) | |
39 { | |
11538
af683213eeb0
priv-set: new module and accompanying tests; adapt write-any-file
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
11257
diff
changeset
|
40 # if defined PRIV_SYS_LINKDIR |
5852 | 41 /* We might be able to unlink directories if we cannot |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11538
diff
changeset
|
42 determine our privileges, or if we have the |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11538
diff
changeset
|
43 PRIV_SYS_LINKDIR privilege. */ |
11538
af683213eeb0
priv-set: new module and accompanying tests; adapt write-any-file
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents:
11257
diff
changeset
|
44 cannot = (priv_set_ismember (PRIV_SYS_LINKDIR) == 0); |
5852 | 45 # else |
46 /* In traditional Unix, only root can unlink directories. */ | |
16951 | 47 cannot = (geteuid () != ROOT_UID); |
5852 | 48 # endif |
49 initialized = true; | |
50 } | |
51 | |
52 return cannot; | |
53 } | |
54 | |
55 #endif |