Bug 1478651
Summary: | For sudo --login [command], .bash_profile is not read by shell | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Don Swaner <Gecko8211> |
Component: | sudo | Assignee: | Marek Tamaskovic <mtamasko> |
Status: | CLOSED NOTABUG | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | 25 | CC: | dkopecek, jvymazal, kzak, mattdm, mtamasko, rsroka, tosykora |
Target Milestone: | --- | Keywords: | Reopened |
Target Release: | --- | ||
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2017-10-12 21:10:07 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Don Swaner
2017-08-05 16:18:23 UTC
In doumentation is specified, when using --login, that only .profile and .login will be read by shell. Everything else will be erased including variables. What do you mean by clarification in man pages? The .login file is for the tcsh shell, and .profile is maybe used by some installations for the bash shell. In Fedora, this file corresponds to .bash_profile for the bash shell. I'm not suggesting that the references to .login and .profile need to be changed (even though they are not used in Fedora). What I mean by clarification is: ASSUMING THAT THE CURRENT "sudo --login" BEHAVIOR IS DEEMED TO BE CORRECT, then the man page could be changed as follows: The sudo man page currently reads: ... -i, --login Run the shell specified by the target user's password database entry as a login shell. This means that login-specific resource files such as .profile or .login will be read by the shell. If a command is specified, it is passed to the shell for execution via the shell's -c option. If no command is specified, an interactive shell is executed. ... This sudo man page section, could be changed to something like: ... -i, --login Run the shell specified by the target user's password database entry as a login shell. This means that login-specific resource files such as .profile or .login will be read by the shell IF NO COMMAND IS SPECIFIED. If a command is specified, it is passed to the shell for execution via the shell's -c option, HOWEVER IN THIS CASE, .PROFILE or .LOGIN ARE NOT READ. If no command is specified, an interactive shell is executed. ... Or, perhaps better would be: ... -i, --login Run the shell specified by the target user's password database entry as a login shell. This means that login-specific resource files such as .profile or .login will be read by the shell. If a command is specified, it is passed to the shell for execution via the shell's -c option, AND THE --login OPTION IS IGNORED, AND .profile OR .login ARE NOT READ. If no command is specified, an interactive shell is executed. ... Try consult this changes with upstream. There is the right place to suggest improvements in documentation. https://bugzilla.sudo.ws/index.cgi Added comments to: https://bugzilla.sudo.ws/show_bug.cgi?id=806 Resolution from bugzilla.sudo.ws: Comment # 8 on bug 806 from Todd C Miller From the bash manual: Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt (see the description of shopt under SHELL BUILTIN COMMANDS below). When you run a command via "sudo -i" the shell is not in interactive mode so aliases are not applied. If you use a shell function instead of an alias this is not an issue. Adding "shopt -s expand_aliases" to the top of .bash_profile should give you the behavior you want. Sorry, but the proposed solution does not work. Original symptoms are unchanged with "shopt -s expand_aliases" (in both .bash_profile and .bashrc). I will comment at bugzilla.sudo.ws. The proposed solution does work, if the "shopt -s expand_aliases" is added to root's .bash_profile, not the user's profile. |