2
Copyright (C) 2009 MySQL AB, 2009 Sun Microsystems, Inc
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; version 2 of the License.
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License
14
along with this program; if not, write to the Free Software
15
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
#include <sys/types.h>
26
* check whether the given filename points to a file the permissions
27
* of which are 0 for group and other (ie read/writable only by owner).
28
* return 0 for "OK", -1 of the file cannot be accessed or is the wrong
29
* type of file, and 1 if permissions are wrong
31
* since Windows has no concept of owner/group/other, this function
32
* just return 0 for windows
34
* FIXME? this function currently ignores ACLs
37
chassis_filemode_check(gchar *filename)
43
if (stat(filename, &stbuf) == -1) {
44
g_critical("%s: cannot stat %s: %s", G_STRLOC, filename,
49
fmode = stbuf.st_mode;
50
if ((fmode & S_IFMT) != S_IFREG) {
51
g_critical("%s: %s is not a regular file", G_STRLOC, filename);
55
#define MASK (S_IROTH|S_IWOTH|S_IXOTH)
57
if ((fmode & MASK) != 0) {
58
g_critical("%s: %s permissions not secure", G_STRLOC, filename);