What happened to /etc/profile?

Some time ago, my servers started ignoring the content of /etc/profile

I have lines there that export LANG, LC_ALL, and EDITOR. It used to work. What’s the problem?
 
I'm going to guess you're not using a bourne (or compatible) shell (sh(1), bash(1), etc), those are the only ones that actually read it, csh(1) and tcsh(1) don't.

Note that you should NOT set LC_ALL to change your locale(1) settings. It's used to overrule all other locale(1) settings. It's not meant to be used as a "user" setting.
 
I have been using bash since the dawn of history. I didn’t change the server config but upgraded them as well as the CI servers. It stopped working everywhere.

Code:
# finger root && cat /etc/profile | grep export && locale && echo $EDITOR
Login: root                       Name: Charlie Root
Directory: /root                        Shell: /usr/local/bin/bash
Last login Mon Nov 16 04:52 (CET) on ttyv0
No Mail.
No Plan.
# BLOCKSIZE=K; export BLOCKSIZE
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export EDITOR=nano
LANG=
LC_CTYPE="C"
LC_COLLATE="C"
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=

#
 
Hmm. Something I overlooked with regards to bash (I don't use it):
Code:
20200716:
  AFFECTS: users of shells/bash, shells/bash-static
  AUTHOR: ehaupt@FreeBSD.org

  In order to cleanly decouple bash from base, bash now reads `profile` from
  LOCALBASE/etc insead of from /etc. If you are using system wide bash
  configuration in /etc/profile please migrate to LOCALBASE/etc/profile

  # cp /etc/profile /usr/local/etc/profile

  or create a symlink

  # ln -s /etc/profile /usr/local/etc/

  If you encounter the following error, you may have the obsolete
  /lib/libreadline.so.8 lying around after an incomplete base update:

  ld-elf.so.1: Undefined symbol "rl_signal_event_hook" referenced from COPY relocation in /usr/local/bin/bash

  Please refer to to (23.5.6.2) in the FreeBSD Handbook on how to
  safely check for outdated files and libraries:

  https://www.freebsd.org/doc/en/books/handbook/makeworld.html
 
Yes, it started about a half year ago. Thank you, SirDice. I didn’t find it.

Although I don’t find this change logical. The point of /etc/profile is to set it for all users and any shell. Bash should read both /etc/profile and something like /usr/local/etc/bash_profile
 
A link (ln -s /etc/profile /usr/local/etc/) causes /etc/profile to be loaded twice. This leads to loading /etc/profile.d/* and /usr/local/etc/profile.d/* twice as well. The issue is that /etc/profile (at least in 14.0-RELEASE) is trying to avoid this recursion by checking whether it tries to load itself. But since "/usr/local/etc/profile" is not equal to "/etc/profile", this check fails. If the profile settings are just setting variables, this is probably not an issue (just a bit of waste time). However, if making output like a login banner (e.g. using the "td-system-tools" package, which installs /usr/local/etc/profile.d/system-info.sh for this purpose), the output is made twice.

A work around is to have a script /usr/local/etc/profile, which checks whether it is called by /etc/profile (/etc/profile sets a variable _loaded; if it is set, then just do not try to load /etc/profile again):
if [ "${_loaded}" = "" ] ; then
if [ -e /etc/profile ] ; then
. /etc/profile
fi
fi
 
Back
Top