annotate lib/write-any-file.c @ 17249:e542fd46ad6f

maint: update all copyright year number ranges Run "make update-copyright". Compare to commit 1602f0a from last year. Signed-off-by: Eric Blake <eblake@redhat.com>
author Eric Blake <eblake@redhat.com>
date Tue, 01 Jan 2013 00:50:58 +0000
parents 9009d83acea4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8504
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
1 /* Determine whether we can write any file.
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
2
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16951
diff changeset
3 Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
8504
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
4
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8592
diff changeset
5 This program is free software: you can redistribute it and/or modify
8504
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
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: 8592
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: 8592
diff changeset
8 (at your option) any later version.
8504
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
9
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
13 GNU General Public License for more details.
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
14
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
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: 8592
diff changeset
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
8504
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
17
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
18 /* Written by Paul Eggert. */
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
19
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
20 #include <config.h>
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
21
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
22 #include "write-any-file.h"
11538
af683213eeb0 priv-set: new module and accompanying tests; adapt write-any-file
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents: 9309
diff changeset
23 #include "priv-set.h"
16951
9009d83acea4 root-uid: new module
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
24 #include "root-uid.h"
8504
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
25
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
26 #include <unistd.h>
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
27
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
28 /* Return true if we know that we can write any file, including
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
29 writing directories. */
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
30
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
31 bool
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
32 can_write_any_file (void)
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
33 {
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
34 static bool initialized;
8592
e91286e73129 * lib/write-any-file.c (can_write_any_file): Fix else-else bug
Paul Eggert <eggert@cs.ucla.edu>
parents: 8504
diff changeset
35 static bool can_write;
8504
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
36
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
37 if (! initialized)
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
38 {
8592
e91286e73129 * lib/write-any-file.c (can_write_any_file): Fix else-else bug
Paul Eggert <eggert@cs.ucla.edu>
parents: 8504
diff changeset
39 bool can = false;
11538
af683213eeb0 priv-set: new module and accompanying tests; adapt write-any-file
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents: 9309
diff changeset
40 #if defined PRIV_FILE_DAC_WRITE
af683213eeb0 priv-set: new module and accompanying tests; adapt write-any-file
David Bartley <dtbartle@csclub.uwaterloo.ca>
parents: 9309
diff changeset
41 can = (priv_set_ismember (PRIV_FILE_DAC_WRITE) == 1);
8504
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
42 #else
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
43 /* In traditional Unix, only root can unlink directories. */
16951
9009d83acea4 root-uid: new module
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
44 can = (geteuid () == ROOT_UID);
8504
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
45 #endif
8592
e91286e73129 * lib/write-any-file.c (can_write_any_file): Fix else-else bug
Paul Eggert <eggert@cs.ucla.edu>
parents: 8504
diff changeset
46 can_write = can;
8504
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
47 initialized = true;
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
48 }
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
49
8592
e91286e73129 * lib/write-any-file.c (can_write_any_file): Fix else-else bug
Paul Eggert <eggert@cs.ucla.edu>
parents: 8504
diff changeset
50 return can_write;
8504
24420da38757 * MODULES.html.sh (File system functions): New module write-any-file.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
51 }