Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Sep 2013 10:12:18 +0200
From:      Stefan Esser <se@freebsd.org>
To:        freebsd-hackers@freebsd.org
Subject:   Re: Trying to use /bin/sh
Message-ID:  <52468F62.6010404@freebsd.org>
In-Reply-To: <20130927221459.GA27990@stack.nl>
References:  <1380309632.84323.3.camel@localhost> <20130927221459.GA27990@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
Am 28.09.2013 00:14, schrieb Jilles Tjoelker:
> sh's model of startup files (only login shells use startup files with
> fixed names, other interactive shells only use $ENV) assumes that every
> session will load /etc/profile and ~/.profile at some point. This
> includes graphical sessions. The ENV file typically contains only shell
> options, aliases, function definitions and unexported variables but no
> environment variables.
> 
> Some graphical environments actually source shell startup files like
> ~/.profile when logging in. I remember this from CDE for example. It is
> important to have some rule where this should happen to avoid doing it
> twice or never in "strange" configurations. As a workaround, I made
> ~/.xsession a script interpreted by my login shell and source some
> startup files. A problem here is that different login shells have
> incompatible startup files.

I used to modify Xsession to do the final exec with a forced login
shell of the user. This worked for users of all shells.

The script identified the shell to use and then used argv0 to start
a "login shell" to execute the display manager.

A simplified version of my Xsession script is:

------------------------------------------------------------------
#!/bin/sh

LIB=/usr/local/lib

SH=$SHELL
[ -n "$SH" ] || SH="/bin/sh"
SHNAME=`basename $SH`

echo "exec $LIB/xdm/Xsession.real $*" | \
	/usr/local/bin/argv0 $SH -$SHNAME
------------------------------------------------------------------

The argv0 command is part of "sysutils/ucspi-tcp", BTW.

This script prepends a "-" to the name of the shell that is
started to execute the real "Xsession", which had been renamed
to Xession.real.

I know that the script could be further simplified by using "modern"
variable expansion/substitution commands, but this script was in use
some 25 years ago on a variety of Unix systems (SunOS, Ultrix, HP-UX)
and I only used the minimal set of Bourne Shell facilities, then.

You may want a command to source standard profiles or environment
settings before the final exec, in case the users shell does not
load them.

Regards, STefan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?52468F62.6010404>