13 |
|
|
14 |
|
|
15 |
extern char *home; |
extern char *home; |
16 |
|
extern unsigned int options; |
17 |
|
|
18 |
|
|
19 |
/* |
/* |
31 |
error("could not create directory %s; %s\n", hd, |
error("could not create directory %s; %s\n", hd, |
32 |
strerror(errno)); |
strerror(errno)); |
33 |
} |
} |
|
#ifdef CHECK_PERMISSIONS |
|
|
else { |
|
|
check_dir_perms(hd, S_IRUSR | S_IWUSR | S_IXUSR); |
|
|
} |
|
|
#endif |
|
|
|
|
34 |
return 0; |
return 0; |
35 |
} |
} |
36 |
|
|
98 |
} |
} |
99 |
|
|
100 |
|
|
|
#ifdef CHECK_PERMISSIONS |
|
101 |
/* |
/* |
102 |
* Check the permissions of a file. |
* Check the permissions of a file. |
103 |
*/ |
*/ |
106 |
{ |
{ |
107 |
struct stat fs; |
struct stat fs; |
108 |
|
|
109 |
|
if (!(options & OPTION_PERMISSIONS)) |
110 |
|
return 0; |
111 |
|
|
112 |
if (stat(fname, &fs)) { |
if (stat(fname, &fs)) { |
113 |
error("getting file %s status; %s\n", fname, |
error("getting file %s status; %s\n", fname, |
114 |
strerror(errno)); |
strerror(errno)); |
119 |
return ERROR_TRIVIAL; |
return ERROR_TRIVIAL; |
120 |
} |
} |
121 |
if ((fs.st_mode & 00777) != mode) { |
if ((fs.st_mode & 00777) != mode) { |
122 |
error("warning: improper file %s permissions\n", fname); |
error("warning: file's %s mode should be %o not %o\n", fname, |
123 |
error("warning: file's mode should be %o not %o\n", mode, |
mode, fs.st_mode & 00777); |
|
fs.st_mode & 00777); |
|
124 |
return ERROR_TRIVIAL; |
return ERROR_TRIVIAL; |
125 |
} |
} |
126 |
return 0; |
return 0; |
129 |
|
|
130 |
/* |
/* |
131 |
* Check the permissions of a directory. |
* Check the permissions of a directory. |
132 |
*/ |
* |
133 |
int |
int |
134 |
check_dir_perms(char *dname, mode_t mode) |
check_dir_perms(char *dname, mode_t mode) |
135 |
{ |
{ |
136 |
struct stat ds; |
struct stat ds; |
137 |
|
|
138 |
|
if (!(options & OPTION_PERMISSIONS)) |
139 |
|
return 0; |
140 |
|
|
141 |
if (stat(dname, &ds)) { |
if (stat(dname, &ds)) { |
142 |
error("getting file %s status; %s\n", dname, |
error("getting file %s status; %s\n", dname, |
143 |
strerror(errno)); |
strerror(errno)); |
148 |
return ERROR_TRIVIAL; |
return ERROR_TRIVIAL; |
149 |
} |
} |
150 |
if ((ds.st_mode & 00777) != mode) { |
if ((ds.st_mode & 00777) != mode) { |
151 |
error("warning: improper dir %s permissions\n", dname); |
error("warning: dir's %s mode should be %o not %o\n", dname, |
152 |
error("warning: dir's mode should be %o not %o\n", mode, |
mode, ds.st_mode & 00777); |
|
ds.st_mode & 00777); |
|
153 |
return ERROR_TRIVIAL; |
return ERROR_TRIVIAL; |
154 |
} |
} |
155 |
return 0; |
return 0; |
156 |
} |
}*/ |
|
#endif /* CHECK_PERMISSIONS */ |
|