Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 May 2000 09:20:02 -0700 (PDT)
From:      Ben Smithurst <ben@scientia.demon.co.uk>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/18373: pkg_delete shouldn't insist on root
Message-ID:  <200005051620.JAA14070@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/18373; it has been noted by GNATS.

From: Ben Smithurst <ben@scientia.demon.co.uk>
To: Neil Blakey-Milner <nbm@mithrandr.moria.org>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/18373: pkg_delete shouldn't insist on root
Date: Fri, 5 May 2000 17:11:17 +0100

 --HcAYCG3uE/tztfnV
 Content-Type: text/plain; charset=us-ascii
 
 Ben Smithurst wrote:
 
 > Neil Blakey-Milner wrote:
 > 
 >> Why not compare the owner of the PKG_DBDIR and the caller?  Overloading
 >> '-f' might cause problems, so maybe another flag is necessary.
 > 
 > How about '-r' for consistency with newsyslog?
 
 The attached patch implements this, and seems to work fine when I set
 PKG_DELETE='pkg_delete -r'.
 
 -- 
 Ben Smithurst / ben@scientia.demon.co.uk / PGP: 0x99392F7D
 
 --HcAYCG3uE/tztfnV
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="pkg_delete.diff"
 
 Index: main.c
 ===================================================================
 RCS file: /usr/cvs/src/usr.sbin/pkg_install/delete/main.c,v
 retrieving revision 1.17
 diff -u -r1.17 main.c
 --- main.c	2000/02/18 07:00:01	1.17
 +++ main.c	2000/05/05 16:10:44
 @@ -28,11 +28,12 @@
  #include "lib.h"
  #include "delete.h"
  
 -static char Options[] = "hvDdnfp:";
 +static char Options[] = "hvDdnfp:r";
  
  char	*Prefix		= NULL;
  Boolean	NoDeInstall	= FALSE;
  Boolean	CleanDirs	= FALSE;
 +Boolean	NeedRoot	= TRUE;
  
  static void usage __P((void));
  
 @@ -58,6 +59,10 @@
  	    Prefix = optarg;
  	    break;
  
 +	case 'r':
 +	    NeedRoot = FALSE;
 +	    break;
 +
  	case 'D':
  	    NoDeInstall = TRUE;
  	    break;
 @@ -107,8 +112,12 @@
      if (pkgs == start)
  	warnx("missing package name(s)"), usage();
      *pkgs = NULL;
 -    if (!Fake && getuid() != 0)
 -	errx(1, "you must be root to delete packages");
 +    if (!Fake && getuid() != 0) {
 +	warnx("you must be root to delete packages%s",
 +	  NeedRoot ? "" : " (proceeding anyway)");
 +	if (NeedRoot)
 +	    return EXIT_FAILURE;
 +    }
      if ((error = pkg_perform(start)) != 0) {
  	if (Verbose)
  	    warnx("%d package deletion(s) failed", error);
 Index: pkg_delete.1
 ===================================================================
 RCS file: /usr/cvs/src/usr.sbin/pkg_install/delete/pkg_delete.1,v
 retrieving revision 1.16
 diff -u -r1.16 pkg_delete.1
 --- pkg_delete.1	2000/02/29 15:13:53	1.16
 +++ pkg_delete.1	2000/05/05 16:04:28
 @@ -25,7 +25,7 @@
  .Nd a utility for deleting previously installed software package distributions
  .Sh SYNOPSIS
  .Nm
 -.Op Fl vDdnf
 +.Op Fl vDdnfr
  .Op Fl p Ar prefix
  .Ar pkg-name ...
  .Sh DESCRIPTION
 @@ -95,6 +95,13 @@
  .It Fl f
  Force removal of the package, even if a dependency is recorded or the
  deinstall or require script fails.
 +.It Fl r
 +This flag removes the restriction that
 +.Nm
 +to be run by root, which can be useful for porters if the port has
 +been installed to a directory writable by that user, and if
 +.Ev PKG_DBDIR
 +has been set to a directory writable by that user.
  .El
  
  .Pp
 
 --HcAYCG3uE/tztfnV--
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200005051620.JAA14070>