Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 69896 - doins modifies parent directory's permissions
Summary: doins modifies parent directory's permissions
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Ebuild Support (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
: 73854 73856 74857 74975 74977 77406 77558 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-11-02 15:19 UTC by André Malo
Modified: 2005-05-25 05:34 UTC (History)
9 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description André Malo 2004-11-02 15:19:34 UTC
doins modifies parent directory's permissions

As of portage_2_0_51_rc9 (taken from cvs tag) the doins utility modifies the permission of the parent directory of where the stuff is to be installed, because it executes a `dodir` on that dir. That way it assigns the permissions of the most recent diropts call.

One could even consider this as a security issue, because it can lead to information disclosure on a multiuser system in conclusion with ebuilds that don't know the problem.

Workaround for ebuild authors: Put all dodir stuff at the end of the install function (not that intuitive :-)

Reproducible: Always
Steps to Reproduce:
write a sample ebuild, which contains for example the following:

src_install() {
  diropts -m 700
  dodir /etc/foo
  diropts -m 755
  dodir /usr/lib/bar

  insinto /etc/foo
  # the following implicitly calls dodir /etc/foo with diropts -m 755!
  # which is obviously wrong.
  doins baz
}
Actual Results:  
/etc/foo has 755 permissions.

Expected Results:  
keep 700 permissions.

Portage 2.0.51-r2 (default-x86-1.4, gcc-3.3.4, glibc-2.3.4.20040808-r1, 2.4.27 i686)
Comment 1 SpanKY gentoo-dev 2004-11-02 16:08:41 UTC
my fault, here's a patch:
Index: doins
===================================================================
RCS file: /var/cvsroot/gentoo-src/portage/bin/doins,v
retrieving revision 1.7
diff -u -B -r1.7 doins
--- doins       10 Oct 2004 10:07:20 -0000      1.7
+++ doins       3 Nov 2004 00:08:36 -0000
@@ -20,7 +20,7 @@
        exit 1
 fi
 
-dodir "${INSDESTTREE}"
+[ ! -d "${INSDESTTREE}" ] && dodir "${INSDESTTREE}"
 
 for x in "$@" ; do
        if [ -L "$x" ] ; then
Comment 2 Johan Kiviniemi 2004-12-04 07:37:30 UTC
Shouldn't it be
[ ! -d "${D}${INSDESTTREE}" ] && dodir "${INSDESTTREE}"
instead of
[ ! -d "${INSDESTTREE}" ] && dodir "${INSDESTTREE}"
?
Comment 3 Sven Wegener gentoo-dev 2004-12-08 19:05:24 UTC
*** Bug 73854 has been marked as a duplicate of this bug. ***
Comment 4 Sven Wegener gentoo-dev 2004-12-08 19:06:09 UTC
*** Bug 73856 has been marked as a duplicate of this bug. ***
Comment 5 Ed Catmur 2004-12-11 14:59:17 UTC
Sven, the issue in comment 2 also breaks net-fs/nfs-utils. Will this be fixed at least in CVS?
Comment 6 SpanKY gentoo-dev 2004-12-12 00:54:08 UTC
it's already in cvs and has been for a while

Keywords on this bug lists 'InCVS'
Comment 7 Ed Catmur 2004-12-13 07:44:19 UTC
No, it is not.

http://www.gentoo.org/cgi-bin/viewcvs.cgi/portage/bin/doins?rev=1.8&root=gentoo-src&content-type=text/vnd.viewcvs-markup

Line 23:
[ ! -d "${INSDESTTREE}" ] && dodir "${INSDESTTREE}"

As noted in comment 2, this should be
[ ! -d "${D}${INSDESTTREE}" ] && dodir "${INSDESTTREE}"

Look at bug 73854 and bug 73856 - these are marked as a duplicate of this bug for a reason. Because the "${D}" is missing from the -d test, the target directory is not created inside ${D}.
Comment 8 Ed Catmur 2004-12-14 09:38:03 UTC
Sorry, wrong link; that should have been http://www.gentoo.org/cgi-bin/viewcvs.cgi/portage/bin/doins?rev=HEAD&root=gentoo-src&content-type=text/vnd.viewcvs-markup

Anyway, it still needs fixing.
Comment 9 SpanKY gentoo-dev 2004-12-18 19:33:27 UTC
*** Bug 74857 has been marked as a duplicate of this bug. ***
Comment 10 Ed Catmur 2004-12-19 06:51:46 UTC
OK, it's fixed on portage_2_0 now, but MAIN is still broken.
Comment 11 SpanKY gentoo-dev 2004-12-19 07:19:25 UTC
who cares is HEAD is broken really, releases arent done from HEAD
Comment 12 Sven Wegener gentoo-dev 2004-12-19 15:06:26 UTC
*** Bug 74975 has been marked as a duplicate of this bug. ***
Comment 13 Sven Wegener gentoo-dev 2004-12-19 15:11:05 UTC
*** Bug 74977 has been marked as a duplicate of this bug. ***
Comment 14 SpanKY gentoo-dev 2005-01-01 12:50:22 UTC
*** Bug 76317 has been marked as a duplicate of this bug. ***
Comment 15 Tuan Van (RETIRED) gentoo-dev 2005-01-10 12:59:17 UTC
*** Bug 77406 has been marked as a duplicate of this bug. ***
Comment 16 Gert-Jan Rodenburg 2005-01-11 04:24:51 UTC
2 months since this bug was filed, a 'fix' was implemented, got into ~x86 (amongst things) and causes all files destined for /etc/conf.d (via newconfd -> doins) _not_ to be installed.

Comment Nr 7. has the solution.

Note: This is something that bites anyone with a ~x86 in the ass, possibly more people with other ~XXX settings. It is _not_ something that only lives in CVS, moreso, the proposed fix (see comment nr7) is not implemented yet.

No matter wether releases are done or not via HEAD in cvs, the bug is there, people are being bitten by it, the fix is here, and is (quite) trivial, but not a hint of a fix somewhere in here. Just a growing list of 'duplicates' (which should be a hint). 

Any ETA on the real fix getting into portage somewhere?
Comment 17 Chris Smith 2005-01-11 07:12:51 UTC
>2 months since this bug was filed
>the bug is there, people are being bitten by it

I'm still getting bit by this and it has been awhile. Can't build up an ~x86 system without jumping through hoops.
I am wondering as well why portage still remains broken and this hasn't been resolved yet. This isn't, AFAIK, just a trivial application in Gentoo-land.
Is the proposed fix not really a total or proper solution? Does it lead to more breakage somewhere else?
Comment 18 SpanKY gentoo-dev 2005-01-12 20:49:26 UTC
*** Bug 77558 has been marked as a duplicate of this bug. ***
Comment 19 gent_bz 2005-05-23 21:05:45 UTC
After running into this bug (part of 93636), just wondering if there's a reason
noone has committed such a trivial fix?
Comment 20 SpanKY gentoo-dev 2005-05-23 21:11:26 UTC
this has already been fixed & released
Comment 21 gent_bz 2005-05-23 21:18:17 UTC
Sorry, was referring to HEAD.
Comment 22 Brian Harring (RETIRED) gentoo-dev 2005-05-24 23:50:28 UTC
Spanky, care to check into head on this?
Comment 23 SpanKY gentoo-dev 2005-05-25 05:34:03 UTC
i already did :p