Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 684232 - emerge modifies owner, group and permissions of /dev/null
Summary: emerge modifies owner, group and permissions of /dev/null
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 683434
  Show dependency tree
 
Reported: 2019-04-24 07:21 UTC by Harald Becker
Modified: 2019-06-23 18:32 UTC (History)
0 users

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 Harald Becker 2019-04-24 07:21:29 UTC
As I have been asked from a Gentoo forum admin to report this here:

https://forums.gentoo.org/viewtopic-p-8328560.html#8328560

I stumbled on several problems on my system which could be tracked down in the first approach to suddenly changed owner, group and permissions of /dev/null. After some search it has been found to happen when emerging packages to the system, e.g.

before: /dev/null is root:root, 0666

$ emerge -a -1 busybox

after: /dev/null is portage:portage,0660

(but no such change with emerge -p busybox)

After some searching and additional hints in the forum, I found at least one reason for the problem:

As I dislike continuously writing /var/log/emerge.log on my SSD without any need, and the lack of an emerge option to disable this, I replaced /var/log/emerge.log with a symlink to /dev/null. But emerge does not respect my wish to silently disable the log and bumps into changing system wide permissions of /dev/null :(

Searching through the script sources (with my rough Python knowledge), I found the reason in emergelog.py:

existing_log = os.path.isfile(file_path)
...
if not existing_log: 
   portage.util.apply_secpass_permissions(file_path, 
   uid=portage.portage_uid, gid=portage.portage_gid, 
   mode=0o660)

After changing os.path.isfile to os.path.exists the problem has been solved (at first). So this change in emergelog.py shall be considered upstream.

Sadly this single change does not seam to be the only one required. Today another time the permissions of /dev/null has been changed ... through the /var/log/emerge-fetch.log I expect, but didn't had the time to track that down yet. 

Can anyone with knowledge of the emerge system help to fix those issues.

Searching through the net, I even found several similar reports with /dev/null + emerge issues, but somehow unspecific. May be they are due to those problems.
Comment 1 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2019-04-24 07:27:50 UTC
While your finding looks valid and should be fixed, another question that comes to my mind is if there's really no other possibility to disable logging of portage except of symlinking the log files to /dev/null.
If not, this should be addresses and perhaps fixed as well.
Comment 2 Larry the Git Cow gentoo-dev 2019-04-24 18:54:02 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=71f6a23c497980f4424fca51ac3e2864608ab08d

commit 71f6a23c497980f4424fca51ac3e2864608ab08d
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2019-04-24 18:50:42 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2019-04-24 18:52:57 +0000

    emergelog: handle /dev/null symlink (bug 684232)
    
    If the log path is a symlink to /dev/null, os.path.isfile returns
    False, so use os.path.exists in order to avoid chown/chmod in
    this case.
    
    Reported-by: Harald Becker <hb-xxl@web.de>
    Bug: https://bugs.gentoo.org/684232
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/_emerge/emergelog.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 3 Zac Medico gentoo-dev 2019-04-24 18:57:08 UTC
(In reply to Lars Wendler (Polynomial-C) from comment #1)
> While your finding looks valid and should be fixed, another question that
> comes to my mind is if there's really no other possibility to disable
> logging of portage except of symlinking the log files to /dev/null.
> If not, this should be addresses and perhaps fixed as well.

Maybe we could use an empty EMERGE_LOG_DIR setting for that.
Comment 4 Harald Becker 2019-04-24 23:03:03 UTC
(In reply to Lars Wendler (Polynomial-C) from comment #1)
> While your finding looks valid and should be fixed, another question that
> comes to my mind is if there's really no other possibility to disable
> logging of portage except of symlinking the log files to /dev/null.
> If not, this should be addresses and perhaps fixed as well.
I won't say I'm familiar with Portage and the emerge system, but I'm no Unix/Linux novice and able to read manpages. Looking through 'emerge(1)', 'make.conf(5)' and 'portage(5)' manpages, I could not find any hint how to disable 'emerge.log' and/or 'emerge-fetch.log'. If there is such a feature it's hidden anywhere very deep in the docs or the source.

I'd like to see two more options for 'make.conf':
  EMERGE_LOG=<path_to_logfile>
  EMERGE_FETCH_LOG=<path_to_logfile>

When unset they shall revert to current values, when set to an empty string they shall behave like a setting to /dev/null.
Comment 5 Harald Becker 2019-04-24 23:08:42 UTC
(In reply to Zac Medico from comment #3)
> (In reply to Lars Wendler (Polynomial-C) from comment #1)
> > While your finding looks valid and should be fixed, another question that
> > comes to my mind is if there's really no other possibility to disable
> > logging of portage except of symlinking the log files to /dev/null.
> > If not, this should be addresses and perhaps fixed as well.
> 
> Maybe we could use an empty EMERGE_LOG_DIR setting for that.
Why specifying a log directory and not the full name of the log file, which also allows changes of the log file name. If an EMERGE_LOG specifies an existing directory, the default 'emerge.log' may be appended.
Comment 6 Harald Becker 2019-04-24 23:13:12 UTC
To: Larry the Git Cow from comment #2

Thanks to your very quick response. I'm going to look into the second permission change that occurred yesterday, soon.
Comment 7 Zac Medico gentoo-dev 2019-04-24 23:14:41 UTC
(In reply to Harald Becker from comment #5)
> (In reply to Zac Medico from comment #3)
> > (In reply to Lars Wendler (Polynomial-C) from comment #1)
> > > While your finding looks valid and should be fixed, another question that
> > > comes to my mind is if there's really no other possibility to disable
> > > logging of portage except of symlinking the log files to /dev/null.
> > > If not, this should be addresses and perhaps fixed as well.
> > 
> > Maybe we could use an empty EMERGE_LOG_DIR setting for that.
> Why specifying a log directory and not the full name of the log file, which
> also allows changes of the log file name. If an EMERGE_LOG specifies an
> existing directory, the default 'emerge.log' may be appended.

Sure we can add separate variables. EMERGE_LOG_DIR is just the variable that's currently supported but we can make the new variables take precedence.
Comment 8 Larry the Git Cow gentoo-dev 2019-04-26 03:00:48 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=eca0a8648ae7cee5c10081224432e15bc31f05ba

commit eca0a8648ae7cee5c10081224432e15bc31f05ba
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2019-04-26 02:53:25 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2019-04-26 03:00:38 +0000

    sys-apps/portage: version bump to 2.3.65
    
     #478544 fix duplicate repo warning triggered by PORTDIR
     #553224 emerge --info per-package FEATURES
     #684232 don't set permissions on /dev/null emerge.log symlink
    
    Bug: https://bugs.gentoo.org/683434
    Bug: https://bugs.gentoo.org/478544
    Bug: https://bugs.gentoo.org/553224
    Bug: https://bugs.gentoo.org/684232
    Package-Manager: Portage-2.3.65, Repoman-2.3.12
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-2.3.65.ebuild | 259 +++++++++++++++++++++++++++++++++
 2 files changed, 260 insertions(+)