From root@magichamster.com  Sat May 27 18:23:24 2006
Return-Path: <root@magichamster.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id F1AA016C976
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 27 May 2006 18:23:24 +0000 (UTC)
	(envelope-from root@magichamster.com)
Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 31DE143D55
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 27 May 2006 18:23:24 +0000 (GMT)
	(envelope-from root@magichamster.com)
Received: from [80.229.231.20] (helo=movens.plus.com)
	 by ptb-relay03.plus.net with esmtp (Exim) id 1Fk3Ra-0002fm-Lt
	for FreeBSD-gnats-submit@freebsd.org; Sat, 27 May 2006 19:23:22 +0100
Received: by postbag.magichamster.com (Postfix, from userid 0)
	id 9930C1CC7C; Sat, 27 May 2006 19:24:22 +0100 (BST)
Message-Id: <20060527182422.9930C1CC7C@postbag.magichamster.com>
Date: Sat, 27 May 2006 19:24:22 +0100 (BST)
From: Mark Ovens <marko@freebsd.org>
Reply-To: Mark Ovens <marko@freebsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] sysutils/portmanager dumps core if not run as root
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         98032
>Category:       ports
>Synopsis:       [PATCH] sysutils/portmanager dumps core if not run as root
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pav
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat May 27 18:30:20 GMT 2006
>Closed-Date:    Sun May 28 20:42:14 GMT 2006
>Last-Modified:  Sun May 28 20:42:14 GMT 2006
>Originator:     Mark Ovens
>Release:        FreeBSD 6.1-RELEASE i386
>Organization:
>Environment:
System: FreeBSD redshift 6.1-RC FreeBSD 6.1-RC #0: Mon May  1 14:05:04 BST 2006     root@redshift:/usr/obj/usr/src/sys/REDSHIFT  i386


	
>Description:

If portmanager is run as a user other than root it dumps core because the user does not have write perms for /usr/local/share/portmanager/ignore.db. This is not very graceful!

/home/mark{4}% portmanager
touch: /usr/local/share/portmanager/ignore.db: Permission denied
MGdbCreate error, lstat of /usr/local/share/portmanager/ignore.db failed
lstat: No such file or directory
Assertion failed: (0), function MGdbCreate, file MGdbCreate.c, line 64.
Abort (core dumped)
/home/mark{5}%
	
>How-To-Repeat:
Run portmanager as a non-root user
	
>Fix:
Apply the following patch
	

--- portmanager.c.diff begins here ---
--- portmanager/portmanager.c.orig	Tue Dec 13 00:20:58 2005
+++ portmanager/portmanager.c	Sat May 27 18:08:32 2006
@@ -34,7 +34,13 @@
 int	main( int argc, char** argv, char** argp)
 {
 	int	errorCode	= 0;
-	
+
+	if ( getuid() != 0 )
+	{
+		fprintf( stderr, "%s must be run as root\n", argv[0] );
+		exit( 1 );
+	}
+
 	errorCode	= MGPMrCommandLine( argc, (char**)argv, (char**)argp ); 
 	exit( errorCode );
 }
--- portmanager.c.diff ends here ---


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: pav 
State-Changed-When: Sun May 28 12:16:42 UTC 2006 
State-Changed-Why:  
Wouldn't it be better to check permissions on that file and bail out 
only when the permissions are not met? 


Responsible-Changed-From-To: freebsd-ports-bugs->pav 
Responsible-Changed-By: pav 
Responsible-Changed-When: Sun May 28 12:16:42 UTC 2006 
Responsible-Changed-Why:  
Track 

http://www.freebsd.org/cgi/query-pr.cgi?pr=98032 

From: Mark Ovens <marko@freebsd.org>
To: bug-followup@FreeBSD.org,  marko@freebsd.org
Cc:  
Subject: Re: ports/98032: [PATCH] sysutils/portmanager dumps core if not run
 as root
Date: Sun, 28 May 2006 18:39:11 +0100

 I thought about that, but since you need to be root to use the ports 
 system it seems to make sense to only allow portmanager to run as root.
State-Changed-From-To: feedback->open 
State-Changed-By: pav 
State-Changed-When: Sun May 28 19:56:49 UTC 2006 
State-Changed-Why:  
Feedback received 

http://www.freebsd.org/cgi/query-pr.cgi?pr=98032 
State-Changed-From-To: open->closed 
State-Changed-By: pav 
State-Changed-When: Sun May 28 20:42:07 UTC 2006 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=98032 
>Unformatted:
