Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 615212

Summary: sys-apps/portage: properly support FreeBSD filesystem or filesystem mounted with grpid|bsdgroups with FEATURE="userpriv"
Product: Portage Development Reporter: i.Dark_Templar <idarktemplar>
Component: UnclassifiedAssignee: Portage team <dev-portage>
Status: RESOLVED OBSOLETE    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: freebsd-uid-gid-install.patch

Description i.Dark_Templar 2017-04-10 21:12:25 UTC
On UFS filesystem or EXT* filesystem mounted with option grpid or bsdgroups entries inherit group of parent directory, not current group of process. If such filesystem is used with FEATURE="userpriv" of portage, it may lead to installed files and directories being in group portage, if they're created via 'do*' or 'new*' portage helpers.

Reproducible: Always

Steps to Reproduce:
1. Use UFS filesystem on Gentoo/FreeBSD or ext* on Gentoo/Linux with option 'bsdgroups' for PORTAGE_TMPDIR
2. emerge -1 tcp-wrappers
3. ls -la /usr/share/doc/tcp-wrappers-*/
Actual Results:  
gentoo_freebsd ~ # ls -la /usr/share/doc/tcp-wrappers-7.6.22-r1/
total 96
drwxr-xr-x    2 root  wheel      512 Apr 10 23:55 .
drwxr-xr-x  104 root  wheel     3584 Apr 10 23:08 ..                                                                                                                                
-rw-r--r--    1 root  portage   1038 Apr 10 23:55 BLURB.bz2                                                                                                                         
-rw-r--r--    1 root  portage   7567 Apr 10 23:55 CHANGES.bz2                                                                                                                       
-rw-r--r--    1 root  portage    416 Apr 10 23:55 DISCLAIMER.bz2                                                                                                                    
-rw-r--r--    1 root  portage   1335 Apr 10 23:55 README.IRIX.bz2                                                                                                                   
-rw-r--r--    1 root  portage   2439 Apr 10 23:55 README.NIS.bz2                                                                                                                    
-rw-r--r--    1 root  portage  15567 Apr 10 23:55 README.bz2                       

Expected Results:  
gentoo_freebsd ~ # ls -la /usr/share/doc/tcp-wrappers-7.6.22-r1/
total 96
drwxr-xr-x    2 root  wheel      512 Apr 10 23:55 .
drwxr-xr-x  104 root  wheel     3584 Apr 10 23:08 ..                                                                                                                                
-rw-r--r--    1 root  wheel   1038 Apr 10 23:55 BLURB.bz2                                                                                                                         
-rw-r--r--    1 root  wheel   7567 Apr 10 23:55 CHANGES.bz2                                                                                                                       
-rw-r--r--    1 root  wheel    416 Apr 10 23:55 DISCLAIMER.bz2                                                                                                                    
-rw-r--r--    1 root  wheel   1335 Apr 10 23:55 README.IRIX.bz2                                                                                                                   
-rw-r--r--    1 root  wheel   2439 Apr 10 23:55 README.NIS.bz2                                                                                                                    
-rw-r--r--    1 root  wheel  15567 Apr 10 23:55 README.bz2                       

Here're steps to reproduce it on Gentoo/Linux box:
1. dd if=/dev/zero of=/tmp/tmpfs bs=1M count=100
2. mkfs.ext3 /tmp/tmpfs
3. mkdir /tmp/tmpfsmounted
4. mount /tmp/tmpfs /tmp/tmpfsmounted -o bsdgroups
5. FEATURES="userpriv" PORTAGE_TMPDIR=/tmp/tmpfsmounted/ ebuild /usr/portage/sys-apps/tcp-wrappers/tcp-wrappers-7.6.22-r1.ebuild install
6. ls -la /tmp/tmpfsmounted/portage/sys-apps/tcp-wrappers-7.6.22-r1/image/usr/share/doc/tcp-wrappers-*/
Comment 1 i.Dark_Templar 2017-04-10 21:16:02 UTC
Created attachment 469660 [details, diff]
freebsd-uid-gid-install.patch

This is a patch with proposed solution to fix this issue by fixing uid/gid of EROOT directory of install image, i.e. ${ED} or ${D}
Comment 2 Zac Medico gentoo-dev 2017-04-10 21:25:50 UTC
(In reply to i.Dark_Templar from comment #1)
> Created attachment 469660 [details, diff] [details, diff]
> freebsd-uid-gid-install.patch
> 
> This is a patch with proposed solution to fix this issue by fixing uid/gid
> of EROOT directory of install image, i.e. ${ED} or ${D}

Are the getent calls really necessary? I would think that this should work:]

   chown "${PORTAGE_INST_UID}:${PORTAGE_INST_GID}" "${_x}"
Comment 3 i.Dark_Templar 2017-04-10 21:40:42 UTC
chown command takes username/groupname both in form of name and in form of ID, and I preferred to get rid of this ambiguity in the patch. This possible issue aside, I think getent call may be omitted.