diff options
author | 2000-04-20 15:24:24 +0000 | |
---|---|---|
committer | 2000-04-20 15:24:24 +0000 | |
commit | 4df1f67267beec5f1c6a89f118069fbda0e493fa (patch) | |
tree | ffeed61ae441a8ee77b86ad3d4bf71b84b4caffa | |
parent | Fix a problem that occurs when the filesystem fills up. (diff) | |
download | wireguard-openbsd-4df1f67267beec5f1c6a89f118069fbda0e493fa.tar.xz wireguard-openbsd-4df1f67267beec5f1c6a89f118069fbda0e493fa.zip |
If recover dir is not owned by root, chown it. If the mode is not
01777, fix that too. This is safe because the script is run before
user processes start.
-rw-r--r-- | usr.bin/vi/build/recover | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.bin/vi/build/recover b/usr.bin/vi/build/recover index 0b42aa86426..2abbc6e6235 100644 --- a/usr.bin/vi/build/recover +++ b/usr.bin/vi/build/recover @@ -1,8 +1,10 @@ #!/usr/bin/perl -w # -# $OpenBSD: recover,v 1.4 2000/03/09 21:24:02 millert Exp $ +# $OpenBSD: recover,v 1.5 2000/04/20 15:24:24 millert Exp $ # # Script to (safely) recover nvi edit sessions. +# NOTE: Assumes we are running *before* users may start processes. +# If that is not the case then the chown and chmod below are not safe. # use Fcntl; @@ -20,10 +22,15 @@ if (!lstat($recoverdir)) { # Sanity check the vi recovery dir if (-l _) { die "Warning! $recoverdir is a symbolic link! (ignoring)\n"; -} elsif (! -O _) { - die "Warning! $recoverdir is not owned by root! (ignoring)\n"; } elsif (! -d _) { die "Warning! $recoverdir is not a directory! (ignoring)\n"; +} elsif (! -O _) { + warn "Warning! $recoverdir is not owned by root! (fixing)\n"; + chown 0, 0, $recoverdir; +} +if (((stat(_))[2] & 07777) != 01777) { + warn "Warning! $recoverdir is not mode 01777! (fixing)\n"; + chmod(01777, $recoverdir); } chdir($recoverdir) || die "$0: can't chdir to $recoverdir: $!\n"; |