summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install/delete
diff options
context:
space:
mode:
authorhoek <hoek@FreeBSD.org>2000-05-13 12:58:18 +0000
committerhoek <hoek@FreeBSD.org>2000-05-13 12:58:18 +0000
commit322ce1cd544258763ecebc360beab59f1a076d57 (patch)
tree577297b2ce3c7051a35dc73d71d7181b32bbed35 /usr.sbin/pkg_install/delete
parentcda3a229f2e349ac954aa16cec78e769487643ed (diff)
downloadFreeBSD-src-322ce1cd544258763ecebc360beab59f1a076d57.zip
FreeBSD-src-322ce1cd544258763ecebc360beab59f1a076d57.tar.gz
Finally remove the restriction introduced from NetBSD in r.1.3 that
pkg_delete be run as root. Now honours -f and checks ownership of ${PKG_DBDIR} before errx()'ing. Requested by: bin/5718, myself, bin/18373 (in order)
Diffstat (limited to 'usr.sbin/pkg_install/delete')
-rw-r--r--usr.sbin/pkg_install/delete/main.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c
index a1c5ba4..4a75d11 100644
--- a/usr.sbin/pkg_install/delete/main.c
+++ b/usr.sbin/pkg_install/delete/main.c
@@ -24,6 +24,8 @@ static const char rcsid[] =
*
*/
+#include <sys/types.h>
+#include <sys/stat.h>
#include <err.h>
#include "lib.h"
#include "delete.h"
@@ -42,6 +44,8 @@ main(int argc, char **argv)
int ch, error;
char **pkgs, **start;
char *pkgs_split;
+ char *tmp;
+ struct stat stat_s;
pkgs = start = argv;
while ((ch = getopt(argc, argv, Options)) != -1)
@@ -107,8 +111,14 @@ main(int argc, char **argv)
if (pkgs == start)
warnx("missing package name(s)"), usage();
*pkgs = NULL;
- if (!Fake && getuid() != 0)
- errx(1, "you must be root to delete packages");
+ tmp = getenv(PKG_DBDIR) ? getenv(PKG_DBDIR) : DEF_LOG_DIR;
+ (void) stat(tmp, &stat_s);
+ if (!Fake && getuid() && geteuid() != stat_s.st_uid) {
+ if (!Force)
+ errx(1, "you do not own %s, use -f to force", tmp);
+ else
+ warnx("you do not own %s (proceeding anyways)", tmp);
+ }
if ((error = pkg_perform(start)) != 0) {
if (Verbose)
warnx("%d package deletion(s) failed", error);
OpenPOWER on IntegriCloud