explicitly specified. -V path is already used to determine which file
to read default values from, so it's only logical to write them to the
same file.
PR: 231653
Reviewed by: eugen, bapt
Approved by: re (gjb), kib (mentor)
Differential Revision: https://reviews.freebsd.org/D17566
};
#define _DEF_DIRMODE (S_IRWXU | S_IRWXG | S_IRWXO)
+#define _PW_CONF "pw.conf"
#define _PATH_PW_CONF "/etc/pw.conf"
#define _UC_MAXLINE 1024
#define _UC_MAXSHELLS 32
int i, j;
struct sbuf *buf;
FILE *fp;
+ char cfgfile[MAXPATHLEN];
- if (file == NULL)
- file = _PATH_PW_CONF;
+ if (file == NULL) {
+ snprintf(cfgfile, sizeof(cfgfile), "%s/" _PW_CONF,
+ conf.etcpath);
+ file = cfgfile;
+ }
if ((fd = open(file, O_CREAT|O_RDWR|O_TRUNC|O_EXLOCK, 0644)) == -1)
return (0);
if (config != NULL)
return (read_userconfig(config));
- snprintf(defaultcfg, sizeof(defaultcfg), "%s/pw.conf", conf.etcpath);
+ snprintf(defaultcfg, sizeof(defaultcfg), "%s/" _PW_CONF, conf.etcpath);
return (read_userconfig(defaultcfg));
}