diff options
author | Yuri Pankov <yuripv@FreeBSD.org> | 2018-10-15 20:11:53 +0000 |
---|---|---|
committer | Yuri Pankov <yuripv@FreeBSD.org> | 2018-10-15 20:11:53 +0000 |
commit | 22e3ea3a26032d00c12a5fc2814d3b78966018b9 (patch) | |
tree | ccf57046e6e890b59da3956bde5724de912e5ba6 /pw/pw_conf.c | |
parent | db702f87b098c449905c03610b4111e06116f9a1 (diff) | |
download | pw-darwin-22e3ea3a26032d00c12a5fc2814d3b78966018b9.tar.gz pw-darwin-22e3ea3a26032d00c12a5fc2814d3b78966018b9.tar.zst pw-darwin-22e3ea3a26032d00c12a5fc2814d3b78966018b9.zip |
pw: respect path specified using -V when writing pw.conf, and -C is not
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
Diffstat (limited to 'pw/pw_conf.c')
-rw-r--r-- | pw/pw_conf.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/pw/pw_conf.c b/pw/pw_conf.c index 36bb8b6..f7b98f1 100644 --- a/pw/pw_conf.c +++ b/pw/pw_conf.c @@ -417,9 +417,13 @@ write_userconfig(struct userconf *cnf, const char *file) 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); |