Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Nov 2007 16:22:47 +0100 (CET)
From:      Stefan Sperling <stsp@stsp.name>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/117976: misc/gnomehier creates bad mtree file when built as non-root
Message-ID:  <200711111522.lABFMl1P016094@ted.stsp.lan>
Resent-Message-ID: <200711111530.lABFU1iC027038@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         117976
>Category:       ports
>Synopsis:       misc/gnomehier creates bad mtree file when built as non-root
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 11 15:30:01 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator:     Stefan Sperling
>Release:        FreeBSD 6.2-RELEASE-p8 i386
>Organization:
>Environment:
System: FreeBSD ted.stsp.lan 6.2-RELEASE-p8 FreeBSD 6.2-RELEASE-p8 #0: Sun Oct 14 21:01:47 CEST 2007 stsp@ted.stsp.lan:/usr/obj/usr/src/sys/TED i386


	
>Description:
	
	
	I use the SU_CMD feature in make.conf to avoid compiling
	ports as root.

	If I run 'make' in misc/gnomehier, it creates an mtree
	file that contains my normal user and group IDs as owners
	for all directories in the mtree file.

	So when mtree is used to create the gnome hierarchy,
	the corresponding directories under /usr/local/ end up
	being owned by my normal user.
	
	This leads to various problems, including ldconfig
	refusing to create symlinks in /usr/local/lib.
	
>How-To-Repeat:
	
	
	As non-root user who can write to /usr/obj, run:

	$ echo 'SU_CMD="/usr/bin/su root -c"' >> /etc/make.conf
	$ cd /usr/ports/misc/gnomehier
	$ make clean deinstall reinstall
	$ head /usr/local/etc/mtree/BSD.gnome.dist

	The first line of the file will show your own user
	in uname and gname fields, even though it should be:

	/set type=dir uname=root gname=wheel mode=0755

>Fix:
	

	The problem is that the pre-install target creates
	a directory tree by simply running 'mkdir' for each
	directory that needs to be in the gnome hierarchy.

	One obvious way of trying to solve this is prefixing the mkdir
	commands with ${SU_CMD}. This is has a problem though:
	If /usr/obj is owned by a group other than wheel (say, "wobj")
	to allow users in that group to write to it (as on my system),
	the resulting mtree file will still specify a wrong group
	ownership (not "wheel", but "wobj" in my case).

	I could not find an mtree flag to override ownership
	information it picks up from the filesystem.

	Of course, more commands could added to the "mkdir loop" to
	ensure the ownership of all directories is set to root:wheel.
	But this would running 'make clean' as a normal user impossible,
	which is slightly annoying.

	So I decided to pipe mtree's output through sed instead
	and carry out the necessary substitutions there.

	This works fine for me:

Index: Makefile
===================================================================
RCS file: /usr/ncvs/ports/misc/gnomehier/Makefile,v
retrieving revision 1.38
diff -u -r1.38 Makefile
--- Makefile	24 Oct 2007 23:36:07 -0000	1.38
+++ Makefile	11 Nov 2007 14:48:51 -0000
@@ -47,7 +47,9 @@
 	${CHGRP} games ${WRKSRC}/share/games
 	${CHMOD} g=rwXs ${WRKSRC}/share/games
 	cd ${WRKSRC} && \
-		${MTREE_CMD} -U -d -n -i -c -k "uname, gname, mode" \
+		${MTREE_CMD} -U -d -n -i -c -k "uname, gname, mode" | \
+		${SED} -e 's|uname=[A-Za-z0-9_]*|uname=root|' \
+			-e 's|gname=[A-Za-z0-9_]*|gname=wheel|' \
 			> ${WRKDIR}/${GNOME_MTREE}
 
 do-install:
>Release-Note:
>Audit-Trail:
>Unformatted:



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