masqmail
diff src/masqmail.c @ 425:a19e47ebbb33
Create the spool and log dirs on program startup if missing.
They are not anymore created during installation.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Wed, 30 May 2012 11:38:03 +0200 |
parents | f37384470855 |
children |
line diff
1.1 --- a/src/masqmail.c Wed May 30 11:24:33 2012 +0200 1.2 +++ b/src/masqmail.c Wed May 30 11:38:03 2012 +0200 1.3 @@ -114,9 +114,12 @@ 1.4 char path[PATH_MAX]; 1.5 char *cp, *c; 1.6 int had_an_error = 0; 1.7 + mode_t savedmask; 1.8 1.9 c = strncpy(path, dir, sizeof(path)); 1.10 1.11 + savedmask = umask(0); 1.12 + 1.13 while (!had_an_error && (c = strchr(c+1, '/'))) { 1.14 *c = '\0'; 1.15 /* Create an outer directory. */ 1.16 @@ -126,7 +129,7 @@ 1.17 had_an_error = 1; 1.18 } 1.19 *c = '/'; 1.20 - } 1.21 + } 1.22 1.23 /* 1.24 ** Create the innermost nested subdirectory of the 1.25 @@ -136,7 +139,8 @@ 1.26 fprintf(stderr, "unable to create `%s': %s\n", 1.27 dir, strerror(errno)); 1.28 had_an_error = 1; 1.29 - } 1.30 + } 1.31 + umask(savedmask); 1.32 1.33 return (had_an_error) ? 0 : 1; 1.34 } 1.35 @@ -758,12 +762,15 @@ 1.36 logwrite(LOG_NOTICE, "Using spool directory `%s' for " 1.37 "lock files.\n", conf.spool_dir); 1.38 conf.lock_dir = conf.spool_dir; 1.39 + makedir_rec(conf.spool_dir, 0755); 1.40 + makedir_rec(conf.log_dir, 0755); 1.41 } else { 1.42 - int olduid, oldgid; 1.43 - 1.44 - set_euidgid(conf.mail_uid, conf.mail_gid, &olduid, &oldgid); 1.45 makedir_rec(conf.lock_dir, 0775); 1.46 - set_euidgid(olduid, oldgid, NULL, NULL); 1.47 + chown(conf.lock_dir, conf.mail_uid, conf.mail_gid); 1.48 + makedir_rec(conf.spool_dir, 0755); 1.49 + chown(conf.spool_dir, conf.mail_uid, conf.mail_gid); 1.50 + makedir_rec(conf.log_dir, 0755); 1.51 + chown(conf.log_dir, conf.mail_uid, conf.mail_gid); 1.52 } 1.53 1.54 if (!logopen()) {