Chinaunix

标题: 紧急求救 有没有哪个脚本是在/etc/profile前执行的啊? [打印本页]

作者: miaoer    时间: 2006-07-14 18:38
标题: 紧急求救 有没有哪个脚本是在/etc/profile前执行的啊?
现在碰到个问题

SUSE linux  8.0 下面

有一个用户  abis
在 /etc/passwd中可以看到该用户abis的 home目录为 /home/abis

在/etc/profile的最前面添加  echo  $HOME
当用该用户abis 登陆之后 可以看到 echo $HOME输出的为 /root
也就是说在 /etc/profile之前还有程序修改了 HOME!

各位高手看看哈!
作者: 4Aiur    时间: 2006-07-14 19:47
看你使用的是什么shell了
用户主目录下的
.bash_profile
.bashrc
.cshrc
.tcshrc
都有可能
作者: liang573728    时间: 2006-07-14 23:15
source
作者: miaoer    时间: 2006-07-15 01:12
原帖由 4Aiur 于 2006-7-14 19:47 发表
看你使用的是什么shell了
用户主目录下的
.bash_profile
.bashrc
.cshrc
.tcshrc
都有可能



使用的是bash
这些都是在/etc/profile之后执行的嘛?
作者: 4Aiur    时间: 2006-07-15 13:05
看shell就知道顺序了
cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATHHOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME="root"

export USERNAME BASH_ENV PATH

LANG=en_US
export LANG


cat  ~/.bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi


cat  ~/.bashrc
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
[root@UNI_BJ_1_565 root]# cat /etc/bashrc
# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# by default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
        umask 002
else
        umask 022
fi

# are we an interactive shell?
if [ "$PS1" ]; then
    if [ -x /usr/bin/tput ]; then
      if [ "x`tput kbs`" != "x" ]; then # We can't do this with "dumb" terminal
        stty erase `tput kbs`
      elif [ -x /usr/bin/wc ]; then
        if [ "`tput kbs|wc -c `" -gt 0 ]; then # We can't do this with "dumb" terminal
          stty erase `tput kbs`
        fi
      fi
    fi
    case $TERM in
        xterm*)
                if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
                else
                PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}{PWD/#$HOME/~}\007"'
                fi
                ;;
        screen)
                if [ -e /etc/sysconfig/bash-prompt-screen ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
                else
                PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}{PWD/#$HOME/~}\033\\"'
                fi
                ;;
        *)
                [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
            ;;
    esac
    # Turn on checkwinsize
    shopt -s checkwinsize
    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
   
    if [ "x$SHLVL" != "x1" ]; then # We're not a login shell
        for i in /etc/profile.d/*.sh; do
            if [ -r "$i" ]; then
                . $i
            fi
        done
    fi
fi
# vim:ts=4:sw=4
作者: 寂寞烈火    时间: 2006-07-15 17:48
原帖由 miaoer 于 2006-7-14 18:38 发表
现在碰到个问题

SUSE linux  8.0 下面

有一个用户  abis
在 /etc/passwd中可以看到该用户abis的 home目录为 /home/abis

在/etc/profile的最前面添加  echo  $HOME
当用该用户abis 登陆之后 可以看到 e ...

/etc/profile,/etc/bashrc等文件的作用是啥?!
作者: miaoer    时间: 2006-07-15 20:46
原帖由 4Aiur 于 2006-7-15 13:05 发表
看shell就知道顺序了
cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
...



这都是 /etc/profile 之后的事情了啊?????
作者: waker    时间: 2006-07-17 08:43
原帖由 miaoer 于 2006-7-15 01:12 发表



使用的是bash
这些都是在/etc/profile之后执行的嘛?

HOME是内置变量,不是脚本产生的
作者: miaoer    时间: 2006-07-17 19:05
原帖由 waker 于 2006-7-17 08:43 发表

HOME是内置变量,不是脚本产生的



是内置变量,但是也可以被更改啊

现在我的问题是 在/bin/login 从/etc/passwd读出该值并赋值给HOME, 到执行/etc/profile 之前
这个过程中有没有其他的 程序或者脚本会更改 HOME的值.
作者: novemberrain    时间: 2006-07-17 19:19
跟偶的问题一样,期待中......
作者: connet    时间: 2006-07-19 16:17
原帖由 miaoer 于 2006-7-17 19:05 发表



是内置变量,但是也可以被更改啊

现在我的问题是 在/bin/login 从/etc/passwd读出该值并赋值给HOME, 到执行/etc/profile 之前
这个过程中有没有其他的 程序或者脚本会更改 HOME的值.


没有 HOME 是 shell 启动后 执行 getpwuid 得到并 bind 的。bash 启动最先后执行 /etc/profile ,
执行 /etc/profile  时 HOME 一定是 passwd 中定义的, 有错误则是 "/"




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2