Page MenuHomeFreeBSD

Verify the system can perform install/rollback
Needs ReviewPublic

Authored by aryeeteygerald_rogers.com on Jan 11 2019, 9:29 PM.

Details

Reviewers
emaste
delphij
Summary

Ensure that / and /usr have read-write permissions before install/rollback.

Ensure that chflags is supported by the file system (i.e. NFS does not support chflags).

PR: 128501

Diff Detail

Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 22036
Build 21264: arc lint + arc unit

Event Timeline

  • Ensure install flags can be removed

This is a problem for NFS users. Exit early if it isn't supported with an error message with next steps.

Also do both system checks on rollback (since the same issues can occur then as well)

aryeeteygerald_rogers.com retitled this revision from Verify that / and /usr are mounted with read-write to Verify the system can perform install/rollback.Jan 15 2019, 7:35 PM
aryeeteygerald_rogers.com edited the summary of this revision. (Show Details)

I think this is not complete. For example, /usr may be a symlink to somewhere else, and freebsd-update needs to have write access there (this applies to /boot, /var, etc. too).

usr.sbin/freebsd-update/freebsd-update.sh
2645

I really don't like this approach: what if the system have a file called "chflags_test"?

2646

I don't think this would work: chflags(1) only attempt to make modification when the old flags is different (and freebsd-update wouldn't complain if schg can't be applied at a later time).

Maybe just issue a warning if we are running over NFS (or if / and /usr is neither UFS nor ZFS) instead ?

This revision now requires changes to proceed.Jan 18 2019, 12:59 AM
usr.sbin/freebsd-update/freebsd-update.sh
2634

One idea: perhaps we could do:

for mp in / /usr /boot ...; do

if mount -p ${mp} ...

done

and examine the file system properties and issue warning or bail out?

Note that you should consider BASEDIR as well.

  • Update permissions check and chflag check

Simplify chflag test to just check if they are on NFS

Check for read-write permissions of mounted directory (using BASEDIR).

usr.sbin/freebsd-update/freebsd-update.sh
2640

Please check the return value of mount -p: it's possible that e.g. /boot is a directory, in which case checking / would covered us, but with the current code it would go to the * case and fail.

2641

Note that shell case would not fall through, therefore I think this would have covered IS_NFS case, if the file system is mounted read-write.

aryeeteygerald_rogers.com added inline comments.
usr.sbin/freebsd-update/freebsd-update.sh
2640

If $required_dir is not the mounted filesystem directory, then $mounted_dir should match the directory it's mounted on. i.e. required_dir=/boot should map to mounted_dir=/ in normal cases.

usr.sbin/freebsd-update/freebsd-update.sh
2639

Also which directories should be included here? I think you also wanted /var in this list but I assume there are others...

Also sometimes these directories (i.e. $BASEDIR/boot) don't exist, would it be reasonable to skip them?

usr.sbin/freebsd-update/freebsd-update.sh
2634

Do we have a good list of potential mount points? At least ones that would form part of the base system?

/usr/src
/usr/ports