SOLVED /etc/profile error when logging in

Operating System & Version
CENTOS 7.8 xen hvm
cPanel & WHM Version
90.0.16

coursevector

Well-Known Member
Feb 23, 2015
154
19
68
cPanel Access Level
Root Administrator
This is a continuation of my original thread here: /etc/profile error when logging in

My last question to @cPanelLauren was:
" Is there a way to reset it? I have a script i run on the servers but it only updates /etc/environment to get rid of warnings from Perl for locale issues. "

I checked my servers recently and found that the majority of the servers have a /etc/profile file size in the kilobytes. But i have a couple where it is 2-5Mb of mostly empty space. Again, no idea the cause. Is there a way to reset it though?
 
Last edited by a moderator:

kodeslogic

Well-Known Member
Apr 26, 2020
334
128
118
IN
cPanel Access Level
Root Administrator
It seems something has gone wrong with your /etc/profile file you can hire a certified SafeAdmin from System Administration Services to fix your problem.
 

coursevector

Well-Known Member
Feb 23, 2015
154
19
68
cPanel Access Level
Root Administrator
I see you are first on the list of the service list, which I'm sure is the reason you suggested it. I'll await a response from cPanel, thanks!
 

andrew.n

Well-Known Member
Jun 9, 2020
676
209
43
EU
cPanel Access Level
Root Administrator
It's random, sometimes I'm the first one :D so for the issue have you tried to copy the default /etc/profile from one of your other servers with the same OS version?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,519
1,028
313
cPanel Access Level
Root Administrator
I'm not finding a good way to restore that file on the system. That file is controlled by the "setup" package on the machine, which we can see here on a test server running CentOS 7:

Code:
# rpm -qf /etc/profile
setup-2.8.71-11.el7.noarch
Reinstalling that package does replace the file, but doesn't include the cPanel code we add to it. I ran "yum reinstall setup-2.8.71-11.el7.noarch" and got this output when comparing the new and the original:

Screen Shot 2020-11-03 at 9.16.24 AM.png

Pulling this from another cPanel server may be the best way to resolve that.
 

coursevector

Well-Known Member
Feb 23, 2015
154
19
68
cPanel Access Level
Root Administrator
Understood, and looks like something I can do. I downloaded the profile files from the 3 servers having issues. Two of them seems to just have a LOT of blank lines inserted in it. By a lot, i mean, one had 1.5m blank lines in it. But when I removed all the blank lines and compared it to the normal file, they were exactly the same. So for those two I'll just replace it out-right sans the extra blank lines. The third had a lot of blank lines AND had a few lines missing and probably where the error was coming from.

Bash:
pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
# ---------- START MISSING
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac
}

if [ -x /usr/bin/id ]; then
    if [ -z "$EUID" ]; then
        # ksh workaround
        EUID=`/usr/bin/id -u`
# ---------- END MISSING
        UID=`/usr/bin/id -ru`
    fi
    USER="`/usr/bin/id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
fi
It was also missing "#cPanel Added Limit Protections" which is at the end of the file on the clean version. Where does that come from?
 

coursevector

Well-Known Member
Feb 23, 2015
154
19
68
cPanel Access Level
Root Administrator
Thanks @cPRex, i replaced the remaining file with a clean version and that resolved the issue. Although when I went to check I found something curious which I suspect may have been the cause of the issue. Please see below:

Bash:
[[email protected] etc]# ls -lah | grep profile
-rw-r--r--.   1 root       root       3.2K Nov  3 10:21 profile
drwxr-xr-x.   2 root       root       4.0K Apr 28  2020 profile.d
-rw-r--r--.   2 root       root         36 Jul  3 11:39 profile.lock
-rw-r--r--.   2 root       root         36 Jul  3 11:39 profile.lock-141197dbba22-e6ba5fff-148e
-rw-r--r--.   1 root       root         35 Jan 10  2020 profile.lock-e9adaf7a4e9b-1dcdd770f-8ff
-rw-r--r--.   1 root       root       5.9M Nov  3 10:22 profile.original
It looks like during some sort of update, the file was locked and prevented it from being updated properly. Would you agree? Do you think it's ok to delete those .lock files?