summaryrefslogtreecommitdiff
path: root/usr.bin/vi/build
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-04-20 15:24:25 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-04-20 15:24:25 +0000
commit9186e22322380fa1e0aa1a8fcaa95e5c9b663fbb (patch)
tree7fd932418b36380188d96cf7b121388e28ba5162 /usr.bin/vi/build
parent098dc6e2a80f813d39e1a527414b322d88bd8ec0 (diff)
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.
Diffstat (limited to 'usr.bin/vi/build')
-rw-r--r--usr.bin/vi/build/recover13
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";