RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1579764 - Running 'sudo -s' gives 'error': mkdir: cannot create directory ‘/home/user/.local’: Permission denied
Summary: Running 'sudo -s' gives 'error': mkdir: cannot create directory ‘/home/user/....
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: kde-settings
Version: 7.5
Hardware: All
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: Jan Grulich
QA Contact: Desktop QE
URL:
Whiteboard:
Depends On:
Blocks: 1479323 1656436
TreeView+ depends on / blocked
 
Reported: 2018-05-18 09:35 UTC by James Pearson
Modified: 2023-03-24 14:05 UTC (History)
10 users (show)

Fixed In Version: kde-settings-19-23.9.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-08-06 12:57:16 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2019:2141 0 None None None 2019-08-06 12:57:26 UTC

Description James Pearson 2018-05-18 09:35:12 UTC
Description of problem:

Running 'sudo -s' gives the error/warning :

mkdir: cannot create directory ‘/home/user/.local’: Permission denied

(where /home/user/ is the home directory of the user running sudo

The sudo command works fine - as user becomes root (in this case)


Version-Release number of selected component (if applicable):

kde-settings-19-23.7.el7

How reproducible:

Always

Steps to Reproduce:
1. Run 'sudo -s'


Actual results:

mkdir: cannot create directory ‘/home/user/.local’: Permission denied

Expected results:

No error message

Additional info:

The problem was introduced in bug 1404382 - as /etc/profile.d/kde.csh and kde.sh now does:

# Fix the user-places.xbel error pop at first user login
if ( ! -d ${HOME}/.local/share ) then
    mkdir -p ${HOME}/.local/share
endif

and:

# Fix the user-places.xbel error pop at first user login
if [ ! -d $HOME/.local/share ]; then
    mkdir -p $HOME/.local/share
fi

We have 'Defaults !env_reset' in /etc/sudoers and users' home directories are NFS mounted plus the local root user doesn't have r/w access to users'
~/.local/ directories

The simple fix is to just redirect the mkdir stderr/stdout to /dev/null - and/or also check $SUDO_USER is not set/empty

Comment 2 Steve Traylen 2018-07-13 09:58:31 UTC
You can produce the same error whenever HOME is not set. e.g.

$ env   -u HOME bash -l -c 'echo "home is ${HOME}"'
mkdir: cannot create directory ‘/.local’: Permission denied
home is

Comment 3 Steve Traylen 2018-07-13 11:17:15 UTC
Indeed this is not the way to solve bug 1404382 , kde should create the directories itself.

Comment 11 errata-xmlrpc 2019-08-06 12:57:16 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2019:2141

Comment 12 Steve Huston 2019-08-27 18:40:34 UTC
This fix seems to have broken startup scripts for csh/tcsh users due to using [ ] instead of ( ) :

erigone:~/foo/etc/profile.d# diff -urN kde.csh /etc/profile.d/kde.csh
--- kde.csh     2019-08-27 14:37:03.222817544 -0400
+++ /etc/profile.d/kde.csh      2019-08-14 04:22:09.000000000 -0400
@@ -22,7 +22,7 @@
 end
 
 # Fix the user-places.xbel error pop at first user login
-if ( ! -d ${HOME}/.local/share ) then
+if [ ! -d ${HOME}/.local/share -a -w ${HOME} ] then
     mkdir -p ${HOME}/.local/share
 endif

erigone:~# su - tcshuser
Last login: Tue Aug 27 14:20:29 EDT 2019 on pts/29
if: Expression Syntax.
[tcshuser@erigone ~]$ foreach S ( /etc/profile.d/*.csh )
foreach? echo $S
foreach? source $S
foreach? end
/etc/profile.d/256term.csh
/etc/profile.d/astro.csh
/etc/profile.d/cobbler.csh
/etc/profile.d/colorgrep.csh
/etc/profile.d/colorls.csh
/etc/profile.d/cvs.csh
/etc/profile.d/gnome-ssh-askpass.csh
/etc/profile.d/kde.csh
if: Expression Syntax.
/etc/profile.d/lang.csh
/etc/profile.d/less.csh
/etc/profile.d/mc.csh
/etc/profile.d/modules.csh
/etc/profile.d/puppet-agent.csh
/etc/profile.d/qt-graphicssystem.csh
/etc/profile.d/qt.csh
/etc/profile.d/vim.csh
/etc/profile.d/which2.csh
[tcshuser@erigone ~]$ source .cshrc
erigone:~>

Comment 13 Steve Huston 2019-08-27 18:51:37 UTC
This seems to be the proper syntax (forgot about using && instead of -a as well):

--- kde.csh.1   2019-08-27 14:44:47.141991394 -0400
+++ kde.csh.2   2019-08-27 14:49:37.950857442 -0400
@@ -22,7 +22,7 @@
 end
 
 # Fix the user-places.xbel error pop at first user login
-if [ ! -d ${HOME}/.local/share -a -w ${HOME} ] then
+if ( ! -d ${HOME}/.local/share && -w ${HOME} ) then
     mkdir -p ${HOME}/.local/share
 endif

Comment 14 James Pearson 2019-08-28 10:31:14 UTC
(In reply to Steve Huston from comment #12)
> This fix seems to have broken startup scripts for csh/tcsh users due to
> using [ ] instead of ( ) :

That's a pretty fundamental error - how did that slip past QA ???


Note You need to log in before you can comment on or make changes to this bug.