summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2000-03-24 00:21:29 +0000
committerMarc Espie <espie@cvs.openbsd.org>2000-03-24 00:21:29 +0000
commit4b315963e78b56d006e25891f6a65c4d964c1ee9 (patch)
treefbd198b60e44a7d6e2a95bc931fa7c4909af0f0e /usr.sbin
parentef3b95378b404c25eb72bc6e26b0fb32fbb0b36f (diff)
Disallow pkg_delete when the pkg_prefix is on a read-only file-system.
This avoids erasing /var/db/info while keeping the package and issuing hundreds of warnings...
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_install/delete/perform.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c
index 0893a6e7e6b..dc3a001a8ab 100644
--- a/usr.sbin/pkg_install/delete/perform.c
+++ b/usr.sbin/pkg_install/delete/perform.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: perform.c,v 1.6 1999/10/09 20:35:45 beck Exp $ */
+/* $OpenBSD: perform.c,v 1.7 2000/03/24 00:21:28 espie Exp $ */
#ifndef lint
-static const char *rcsid = "$OpenBSD: perform.c,v 1.6 1999/10/09 20:35:45 beck Exp $";
+static const char *rcsid = "$OpenBSD: perform.c,v 1.7 2000/03/24 00:21:28 espie Exp $";
#endif
/*
@@ -24,6 +24,8 @@ static const char *rcsid = "$OpenBSD: perform.c,v 1.6 1999/10/09 20:35:45 beck E
*
*/
+#include <sys/param.h>
+#include <sys/mount.h>
#include <err.h>
#include "lib.h"
#include "delete.h"
@@ -134,6 +136,20 @@ try_again:
warnx("package '%s' doesn't have a prefix", pkg);
return 1;
}
+ {
+ struct statfs buffer;
+
+ if (statfs(p->name, &buffer) == -1) {
+ warnx("package '%s' prefix (%s) does not exist", pkg, p->name);
+ return 1;
+ }
+ if (buffer.f_flags & MNT_RDONLY) {
+ warnx("package'%s' mount point %s is read-only", pkg,
+ buffer.f_mntonname);
+ return 1;
+ }
+ }
+
setenv(PKG_PREFIX_VNAME, p->name, 1);
if (fexists(REQUIRE_FNAME)) {
if (Verbose)