1 |
#include <stdio.h> |
#include <stdio.h> |
2 |
|
#include <unistd.h> |
3 |
#include <string.h> |
#include <string.h> |
4 |
#include <errno.h> |
#include <errno.h> |
5 |
#include <unistd.h> |
#include <limits.h> |
6 |
#include <sys/types.h> |
#include <sys/types.h> |
7 |
#include <sys/stat.h> |
#include <sys/stat.h> |
8 |
#include <fcntl.h> |
#include <fcntl.h> |
21 |
int |
int |
22 |
create_homedir(void) |
create_homedir(void) |
23 |
{ |
{ |
24 |
if (home != NULL) |
char hd[PATH_MAX]; |
|
if (chdir(home)) |
|
|
error("could not change directory; %s\n", |
|
|
strerror(errno)); |
|
25 |
|
|
26 |
if (!exists_dir(PATHNAME_HOME_DIR)) { |
snprintf(hd, PATH_MAX, "%s/%s", home, PATHNAME_HOME_DIR); |
27 |
if (mkdir(PATHNAME_HOME_DIR, S_IRUSR | S_IWUSR | S_IXUSR)) |
|
28 |
error("could not create directory %s; %s\n", |
if (!exists_dir(hd)) { |
29 |
PATHNAME_HOME_DIR, strerror(errno)); |
if (mkdir(hd, S_IRUSR | S_IWUSR | S_IXUSR)) |
30 |
|
error("could not create directory %s; %s\n", hd, |
31 |
|
strerror(errno)); |
32 |
} |
} |
33 |
#ifdef CHECK_PERMISSIONS |
#ifdef CHECK_PERMISSIONS |
34 |
else { |
else { |
35 |
check_dir_perms(PATHNAME_HOME_DIR, S_IRUSR | S_IWUSR | S_IXUSR); |
check_dir_perms(hd, S_IRUSR | S_IWUSR | S_IXUSR); |
36 |
} |
} |
37 |
#endif |
#endif |
38 |
|
|