我在/etc/profile.d /
中放置了一个脚本# default_dba.sh
if groups | grep -qw "dba" ;
then
if [ $USER != "oracle" ]; then
. /u00/scripts/oracle_alias
fi
fi
如果LDAP用户是dba组的成员,则scipt设置别名。 这可行。 LDAP用户启动python脚本。 最后一步,python脚本调用了一个新的bash shell
subprocess.call(['/bin/bash', '-i'], shell=True)
在该shell会话中,缺少特殊的别名(由/ u00 / scripts / oracle_alias脚本创建),仅存在默认的os别名。
我可以在不为LDAP用户创建主目录的情况下解决此问题吗?
答案 0 :(得分:0)
仅当将外壳程序作为“登录”外壳程序调用时,启动文件(在/ etc / profile等下)才是只读的。例如:-bash -l </ p>
有关更多详细信息,请参见man bash下的“ INVOCATION”部分。
摘要(来自手册页)
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option,
it first reads and executes commands from the file /etc/profile, if that file exists.
After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order,
and reads and executes commands from the first one that exists and is readable.
The --noprofile option may be used when the shell is started to inhibit this behavior.