Separate review for PR231653.
Use the path specified using -V when writing pw.conf if one wasn't expicitly specified using -C.
I'm not entirely sure that this is a correct way to go as man page wording isn't clear here:
-V If this switch is specified, the system /etc/pw.conf will not be sourced for default configuration data, but the file pw.conf in the specified directory will be used instead (or none, if it does not exist).
-D Set default values in /etc/pw.conf configuration file, or a different named configuration file if the -C config option is used.
So -D description doesn't say anything about -V, and that's exactly what I'm seeing when truss'ing pw:
# pw -V /newetc adduser -D -w random: ... open("/newetc/pw.conf",O_RDONLY,0666) ERR#2 'No such file or directory' openat(AT_FDCWD,"/etc/pw.conf",O_RDWR|O_EXLOCK|O_CREAT|O_TRUNC,0644) = 4 (0x4) ... write(4,"#\n# pw.conf - user/group config"...,1367) = 1367 (0x557) close(4) = 0 (0x0) ...
This behavior looks strange to me, and I would expect to write to pw.conf file in the same path specified using -V from which we did read the values initially (unless -C is specified explicitly, of course), and this change does just that.
I noticed this while adding test cases for PR231649/D17299 assuming -V set by test helpers should be used. If this is really "not a bug", I can easily use -C there.