Summary: | Non-interactive Bash needs to be able to load a global bashrc/profile. | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Robin Johnson <robbat2> |
Component: | [OLD] Core system | Assignee: | Gentoo's Team for Core System packages <base-system> |
Status: | RESOLVED WONTFIX | ||
Severity: | normal | ||
Priority: | High | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: | Implement /etc/profile.global |
Description
Robin Johnson
2005-07-21 10:11:21 UTC
works fine for me # cd ~ # mv .bashrc{,.old} # echo echo bashrc > /etc/bash/bashrc # ssh root@localhost ls /dev/null root@localhost's password: bashrc .bashrc /dev/null # err that wasnt everything i did ... i also did this before ssh-ing # mv /etc/bash/bashrc{,.old} # echo echo .bashrc > .bashrc hmm, ok. still one flaw. I can't put . /etc/profile in /etc/bash/bashrc as then there is an infinite loop. so shouldn't the profile.env/PATH/umask stuff be in /etc/bash/bashrc instead of /etc/profile, to ensure that they are always set? not a flaw, put '. /etc/profile' in your ~/.bashrc as for moving stuff from /etc/profile to bashrc, i dont think that makes much sense /etc/profile is used by more shells than just bash using ~/.bashrc is not possible. I need to ensure that it takes place for ALL users, regardless of their ~/.bashrc. the other possibility is to move the profile.env/PATH/umask stuff to a new file, and source that from the profile and global bashrc. This keeps the profile working for non-bash shells. so add it to /etc/skel/.bashrc ;) at any rate, propose a clean solution and we'll consider it ... ok, reopening this to work on the problem. did the baselayout work move to SVN? I'll write up something and generate up to date diffs against the current tree. Ok, a patch that implements profile.global is attached now. Output with some debug info that shows how it works (I put echo statements at each entry and exit point of the scripts, note that bashrc has two exit points). Run a shell script, this should NOT exec any of the stuff node001 ~ # bash test.sh node001 ~ # Test a login shell: node001 ~ # bash --login Start of /etc/profile Start of /etc/profile.global End of /etc/profile.global Start of /etc/bash/bashrc Interactive End of /etc/bash/bashrc End of /etc/profile node001 ~ # logout Don't load profile. node001 ~ # bash --noprofile Start of /etc/bash/bashrc Interactive End of /etc/bash/bashrc Don't load any startup scripts. node001 ~ # bash --norc bash-3.00# exit Posix compliant, startup scripts from different location. node001 ~ # bash --posix bash-3.00# exit Interactive SSH login node001 ~ # ssh node002 Last login: Thu Jul 21 23:06:06 2005 from node001 Start of /etc/profile Start of /etc/profile.global End of /etc/profile.global Start of /etc/bash/bashrc Interactive End of /etc/bash/bashrc End of /etc/profile node002 ~ # logout Connection to node002 closed. Non-interactive login node001 ~ # ssh node002 /bin/true Start of /etc/bash/bashrc Start of /etc/profile.global End of /etc/profile.global Non-Interactive End of /etc/bash/bashrc node001 ~ # Created attachment 64029 [details, diff]
Implement /etc/profile.global
The non-bash shells will need some entries like the change in bashrc to ensure they load /etc/profile.global when they are in their non-interactive case. that's pretty confusing/ugly should be a better way to do this without creating another file It looks like its doing the right thing without --noprofile and --norc, but that is to be expected, and if your users/whoever does that and expect things to work like usual, they should be beaten with a big club. As for --posix .. that really means emulate old sh, and anybody doing that and not expecting a bare shell without all the bells and wistles... nuff said. As for the other example about running something via ssh .. that is as expected as well ... if you really want all the bells and wistles with that, do something like: $ssh node002 bash -l -c /bin/true Or make a script. Or add to /etc/bash/bashrc: [[ ${-/i/} != "$-" ]] && { old_version=$BASH_VERSION unset BASH_VERSION source /etc/profile export BASH_VERSION=$old_version } So really, I do not see the issue, as running a command via ssh should not by default provide 'some environment for users'. cheers |