Users may want to delete the contents of /var/db/freebsd-update (PR 273601), and it is possible that they remove /var/db/freebsd-update by accident. Recreate it if missing. PR: 263290
Details
- Reviewers
cperciva khorben_defora.org
Diff Detail
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
usr.sbin/freebsd-update/freebsd-update.sh | ||
---|---|---|
611 | I like the idea but I'm not sure this is the right place to do it. This is just setting defaults; I don't think we need to (re)create /var/db/freebsd-update if the user specified a different directory? |
usr.sbin/freebsd-update/freebsd-update.sh | ||
---|---|---|
611 | AFAICT config_WorkDir returns false if the directory is already set, so this will only create the directory if the user hasn't specified a different one. I put it here to avoid repeating /var/db/freebsd-update elsewhere |
usr.sbin/freebsd-update/freebsd-update.sh | ||
---|---|---|
611 | If we consider a scenario where a user sets -d /var/db/freebsd-update (out of habit maybe) but did not realize that the directory is gone, then the directory will not be created even though it would otherwise default to the same place. That seems counterintuitive or wrong to me. It might make more sense to do it in config_WorkDir(), with the drawback that if parse_cmd() fails, a directory might get created without freebsd-update having supposedly started to work. Another option is to do it between get_params (line 3524 in your version) and before for COMMAND in ..., in some initialization routine. Side-question: why is usage() exiting with code 0? It will be reflected as a success condition... |
usr.sbin/freebsd-update/freebsd-update.sh | ||
---|---|---|
611 | @emaste Right, I forgot how the config_* functions worked. I guess this is ok, but I still feel a bit weird having it in the "collect together configuration options" code. Would you consider adding having # Create the work directory, if set to the default value default_workdir_create () { if [ "$WORKDIR" = "/var/db/freebsd-update" ] && ! [ -d /var/db/freebsd-update ]; then echo "Creating default working directory /var/db/freebsd-update" install -u root -g wheel -m 700 -d /var/db/freebsd-update fi } and calling that from each of the _check_params functions? It's a somewhat bigger change but I think it's more in line with how the code organization. |