Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 99616 - ebuild.sh's chown-ing and chgrp-ing of symlinks installed as portage:portage changes original file on some platforms
Summary: ebuild.sh's chown-ing and chgrp-ing of symlinks installed as portage:portage ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: PPC OS X
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
: 111019 (view as bug list)
Depends on:
Blocks: 108082
  Show dependency tree
 
Reported: 2005-07-19 21:21 UTC by Jonathan Sailor
Modified: 2005-11-01 03:21 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Test case 1 (bug99616test-1.ebuild,1.32 KB, text/plain)
2005-07-19 21:28 UTC, Jonathan Sailor
Details
Test Case 2 (bug99616test-2.ebuild,1.40 KB, text/plain)
2005-07-19 21:32 UTC, Jonathan Sailor
Details
Test Case 3 (bug99616test-3.ebuild,1.50 KB, text/plain)
2005-07-19 21:39 UTC, Jonathan Sailor
Details
Modify symlinks with custom lchown and lchgrp (99616_overridable_lchown_lchgrp.patch,1.36 KB, patch)
2005-07-21 07:08 UTC, Jason Stubbs (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Sailor 2005-07-19 21:21:02 UTC
On some platforms, including OS X, and probably more BSDs, the chown and chgrp commands, when 
called on a symlink, operate on the original files by default instead of the links. When ebuild.sh checks 
to see if any files have an owner or group of portage, if it finds a link, it thus changes the owner/group 
of the original file.

This is a Bad Thing because:
 - the original file might not supposed to be owned by root:wheel
 - if the original file was setuid or setgid, it'll loose the setuid/setgid bits when its owner/group are 
changed
 - if the symlink is absolute, the chown/chgrp will cause a sandbox violation (bug 94199, back from the 
dead again!)

The solution: either pass the -h option to chgrp and chown, which tells it not to dereference symlinks, 
or to not call chown or chgrp on symlinks at all, or do something I didn't think of.

(I'm filing this as a separate bug from bug 94199 because, though chowning and chgrping these 
symlinks on OSX/BSD could, in some cases, cause sandbox violations, that is just one of the possible 
things that could go wrong and, even then, only in certain cases (symlinks with absolute paths).)
Comment 1 Jonathan Sailor 2005-07-19 21:28:49 UTC
Created attachment 63847 [details]
Test case 1

This is an ebuild for a package with two files: /usr/share/bug99616test/foo
(owned by daemon:daemon) and /usr/bin/bug99616test, which confirms that the
former is owned by daemon:daemon.
Comment 2 Jonathan Sailor 2005-07-19 21:32:54 UTC
Created attachment 63848 [details]
Test Case 2

This is an ebuild for a package with three files:
  /usr/share/bug99616test/foo (owned by daemon:daemon)
  /usr/share/bug99616test/bar, a symlink owned by portage:portage pointing to
"foo"
  /usr/bin/bug99616test, which confirms that the former is owned by
daemon:daemon. 

When installed on Linux (i.e. GNU userland), ebuild.sh's chown and chgrp should
modify bar, and running bug99616test reports that foo is still owned by
daemon:daemon. However, on OS X (BSD userland), ebuild.sh's chown and chgrp
should modify foo; bug99616test reports that foo isn't owned by daemon:daemon.
Comment 3 Jonathan Sailor 2005-07-19 21:39:08 UTC
Created attachment 63849 [details]
Test Case 3

This is an ebuild for a package with four files:
  /usr/share/bug99616test/foo (owned by daemon:daemon)
  /usr/share/bug99616test/bar, a symlink owned by portage:portage pointing to
"foo"
  /usr/share/bug99616test/baz, a symlink owned by portage:portage pointing to
"/usr/share/bug99616test/foo"
  /usr/bin/bug99616test, which confirms that the foo is owned by daemon:daemon.


When installed on Linux (i.e. GNU userland), ebuild.sh's chown and chgrp should
modify bar and baz, and running bug99616test reports that foo is still owned by
daemon:daemon. However, on OS X (BSD userland), ebuild.sh's chown and chgrp
should modify foo (when trying to modify bar) and should then cause a sandbox
error when trying to modify baz.
Comment 4 Jakub Moc (RETIRED) gentoo-dev 2005-07-20 00:56:04 UTC
Flameeyes, sending your way. I remember a similar bug, maybe even posted by you,
but cannot find it.
Comment 5 Diego Elio Pettenò (RETIRED) gentoo-dev 2005-07-20 01:06:25 UTC
Moving to dev-portage, cc: bsd@g.o and osx@g.o. 
 
Comment 6 Jason Stubbs (RETIRED) gentoo-dev 2005-07-20 04:04:29 UTC

*** This bug has been marked as a duplicate of 94199 ***
Comment 7 Jonathan Sailor 2005-07-20 13:34:51 UTC
This bug is not a duplicate of bug 94199.
94199 is about sandbox violations caused by ebuild.sh's chmod'ing symlinks with absolute paths.
This bug is about multiple problems (including but not limited to sandbox violations) caused by 
ebuild.sh's chown'ing and chgrp'ing symlinks on a BSD-ish userland.
The two bugs are similar, and even related, but not the same.
Comment 8 Jason Stubbs (RETIRED) gentoo-dev 2005-07-20 16:33:46 UTC
Bug 94199 describes one symptom of the issue. This bug describes another 
symptom. The issue is still the same. The other bug contains the fix. The fix 
is released in a stable portage. 

*** This bug has been marked as a duplicate of 94199 ***
Comment 9 Jonathan Sailor 2005-07-20 16:43:28 UTC
The fix is not released in a stable portage version. That bug is talking about problems due to chmod'ing 
symlinks; this bug discusses problems with ch*own*'ing a ch*grp*'ing symlinks. The patch to the stable 
version of portage disables chmod'ing symlinks, but still runs chown and chgrp. Therefore, this bug is 
not fixed, and it will not be fixed until Portage either excludes symlinks from getting chown'd and 
chgrp'd (as well as excluding them from chmod'ing) or until it uses the -h option to chown and chgrp, 
as explained in the original bug report for this bug. (I believe the -h option is the best choice.)
Comment 10 Jason Stubbs (RETIRED) gentoo-dev 2005-07-21 07:08:57 UTC
Created attachment 63985 [details, diff]
Modify symlinks with custom lchown and lchgrp 

Apologies. Too much bug wrangling late at night and early in the morning.

This patch separates the handling of symlinks and adds default no-op lchown and
lchgrp implementations. These would be overidden by whatever profile is in use
so as to allow the appropriate method for modifying permissions on symlinks.

Is this acceptable for the BSD and Darwin people?
Comment 11 Jason Stubbs (RETIRED) gentoo-dev 2005-10-03 16:30:02 UTC
This patch is applied to 2.0.53. However, the default lchown and lchgrp 
implementations specify "-h" as per the GNU tools method. If these don't work 
in the other USERLANDs, they'll need to be overrided in the profiles. 
Comment 12 Jason Stubbs (RETIRED) gentoo-dev 2005-10-23 04:21:27 UTC
Fixed in 2.0.53 
Comment 13 Jason Stubbs (RETIRED) gentoo-dev 2005-11-01 03:21:33 UTC
*** Bug 111019 has been marked as a duplicate of this bug. ***