jsd@esl.ESL.COM (Jeff Dalton) (09/11/90)
> eric@hpfcda.HP.COM (Eric Flink) writes: > > For example, move /usr/bin/X11/X to /usr/bin/X11/X.real. Then recreate > /usr/bin/X11/X as a shell script which looks like: Assuming this works for starting X, shouldn't it work for starting xsession? And if so, then since xsession is passed the PID of user logging on then shouldn't I beable to make xsession into a script and load the user's environment (".kshrc" and ".profile" or whatever) and then exec xsession.real? I tried the following script and it didn't work. Should it have worked? #! /bin/ksh if [ $1 = "-userId" ] then Home=$(grep $2 /etc/passwd | cut -d: -f6) . $Home/.profile . $Home/.kshrc fi exec /usr/bin/X11/xsession.real $* -- Jeff Dalton, ESL Inc. Real programmers can write jsd@esl.com Fortran in any language.
eric@hpfcda.HP.COM (Eric Flink) (09/14/90)
I wrote: >> For example, move /usr/bin/X11/X to /usr/bin/X11/X.real. Then recreate >> /usr/bin/X11/X as a shell script which looks like: Jeff Dalton replied: > Assuming this works for starting X, shouldn't it work for starting xsession? > I tried the following script and it didn't work. Should it have worked? Your script should have worked; the reason it failed is that xsession requires that its name (basename) be "xsession". If you rename the "real" xsession to something like /usr/lib/X11/xsession, it should work. However, I STRONGLY recommend AGAINST doing this, as xsession runs as "root". You would permit any user to run anything as superuser. However, you can do essentially the same trick with "xctrl" (the control panel window), so that all of its children at least have the same environment. I have included a modified version of your script which does this. You can move the xctrl program into /usr/lib/X11/xctrl, and put this script in its place to achieve the effect you want. As you may know, HP has introduced a product called Visual User Environment (aka. VUE) which is a more sophisticated user interface than that provided with Instant Ignition / X Environment. VUE deals with the user dot-file problem through a new file named ".vueprofile"; it can contain shell commands which are interpreted by the user's favorite shell at login time. In order to provide some forward compatibility with VUE, I configured the script below to reference vueprofile. I suggest against actually sourcing the user's .profile, .kshrc or other shell start up files, because the standard I/O of the dot files will not be connected to anything. The script connects the standard file descriptors to /dev/null, but depending on what the user has in his or her .profile the screen contents might be jumbled (ie. output escapes to the ITE "behind" the root window) or possibly hangs the system waiting for input which it cannot receive. So have users put commands in their .vueprofile which sets up the environment, but which do not require I/O from/to a terminal. Standard disclaimer: The script is provided as is; HP makes no claim as to the validity or reliability of this code, nor warrants its suitability for any particular use. To install this script, first unpack it somewhere like /tmp. Move the "real" xctrl from /usr/bin/X11/xctrl to /usr/lib/X11/xctrl. Move the script to /usr/bin/X11/xctrl, and make sure it is publicly executable. Hope this helps. Regards, Eric Flink eric_flink@fc.hp.com (303) 229-2313 This posting does not reflect the official position of Hewlett-Packard Company. # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by Eric Flink <eric@hpfcenf> on Thu Sep 13 11:11:12 1990 # # This archive contains: # xctrl # LANG=""; export LANG PATH=/bin:/usr/bin:$PATH; export PATH echo x - xctrl cat >xctrl <<'@EOF' #! /bin/ksh # # NOTICE: The script is provided as is; HP makes no claim as to the # validity or reliability of this code, nor warrants its suitability # for any particular use. # # This script is a "wrapper" for the xctrl command. It's job is to # execute the user's PROFILE script (if one exists) before launching # the real xctrl program. The user can place normal shell commands # in the PROFILE script - run commands or set environment variables. # # However, the standard I/O of PROFILE is connected to /dev/null. # Coomands in the PROFILE file should not attempt to do input or output, # as unexpected results may occur. # # XCTRL is the path to the "real" xctrl program. XCTRL="/usr/lib/X11/xctrl" # The xlogin program should have put HOME and SHELL in the environment for us. # If they are not there for some reason, simply exec the xctrl program. if [ -z "$HOME" -o -z "$SHELL" ] then exec $XCTRL "$@" fi # PROFILE is the name of the file to be sourced. # (Use .vueprofile to be forward compatible with HP Visual User Environment.) PROFILE="$HOME/.vueprofile" # If the PROFILE file exists, interpret it with the user's shell # then exec the real xctrl. if [ -r "$PROFILE" ] then case "$SHELL" in /bin/sh) exec /bin/sh -c ". $PROFILE < /dev/null > /dev/null 2>&1 ; exec $XCTRL $@" ;; /bin/ksh) exec /bin/ksh -c ". $PROFILE < /dev/null > /dev/null 2>&1 ; exec $XCTRL $@" ;; /bin/csh) exec /bin/csh -c "source $PROFILE < /dev/null >& /dev/null ; exec $XCTRL $@" ;; esac fi # If for some reason the above code did not exec XCTRL, then do so here. exec $XCTRL "$@" @EOF chmod 666 xctrl exit 0