[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: SU Problems



 I just do:
8<----------------------------------------------------------------->8
~ # pwd
/root
~ # ln -s /home/karlheg/.Xauthority .
8<----------------------------------------------------------------->8

 I've also got "~karlheg/.emacs" and several other files like it
symlinked in the same way for 'root'.

 I always use the computer logged in as myself, from XDM, and have
entries in "/etc/super.tab" (man super) like this:
8<----------------------------------------------------------------->8
xemacs /usr/local/bin/xemacs karlheg @localhost \
	setenv="DISPLAY=unix:0" \
	setenv="PATH=/usr/local/bin:/usr/bin:/bin:/usr/lib/texmf/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/X11:/usr/games" \
	password=n \
	uid=root gid=root\
	info="XEmacs editor as 'root'" 

tkps	/usr/bin/X11/tkps karlheg @localhost \
	setenv="DISPLAY=unix:0" \
	setenv="PATH=/usr/bin:/bin" \
	password=n \
	uid=root gid=root \
	info="TkPs process table tool; X-Windows Tk interface"

gitps	/usr/bin/gitps karlheg @localhost \
	setenv="PATH=/usr/bin:/bin" \
	password=n \
	uid=root gid=root \
	info="gitps process table tool; Console ncurses interface"

xterm	/usr/X11R6/bin/xterm karlheg @localhost \
	setenv="DISPLAY=unix:0" \
	setenv="PATH=/usr/local/bin:/usr/bin:/bin:/usr/lib/texmf/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/games:/usr/bin/X11" \
	password=n \
	uid=root gid=root \
	info="XTerm"
8<----------------------------------------------------------------->8

... And I have menu entries on my Fvwm2 menu that `exec super xterm`
and `exec super xemacs`, so that I can fire off an xterm or xemacs and
be 'root' anytime I need to.  In my
"/usr/local/lib/xemacs-20.2/lisp/site-start.el" file, I have this:
8<----------------------------------------------------------------->8
;; FSF Emacs has this function already; no defalias needed.
(defalias 'shell-command-to-string 'exec-to-string)

(let ((string (shell-command-to-string "whoami")))
  (setq logname (substring string 0 (1- (length string)))))
8<----------------------------------------------------------------->8
... and then, from the XEmacs customize menu
(Options|Customize|Variable...), I made the titlebar string be:

 '(frame-title-format (quote ("" logname (":%b"))) t)

 Since "~/.emacs", as root, is a symlink to "~karlheg/.emacs", I get
the same setting as either user... but a `super xemacs` will say
'root:filename' in the titlebar, and a normal one will say
'karlheg:filename'.  I have my "~karlheg" directory SGID, so that if
'root' makes any changes to the ".emacs", 'karlheg' will still be able
to write to the file.

 In "/etc/profile", I have this:
8<----------------------------------------------------------------->8
# Display the status of the last command if non-zero
status_after_prompt() { 
    prompt_status=$?
    if [ $prompt_status != 0 ]
    then
	echo "[status $prompt_status]"
    fi
}
export -f status_after_prompt
export PROMPT_COMMAND=status_after_prompt

# Set the titlebar of XTerms to reflect our current working directory.
if [ $TERM == emacs ]
then
  export PS1='\w\n\$ '
elif [ "$TERM" = "xterm" -o "$TERM" = "xterm-color" ]
then
	# There are real control chars here.
  set_titlebar () { echo -n "]2;$*"; }
  export -f set_titlebar

  my_dirname () {
    if [ "${PWD#$HOME}" != "$PWD" ]
    then
      echo '~'${PWD#$HOME}
    else
      echo $PWD
    fi
  }
  export -f my_dirname

  export PS1='\n\!\$ '

  PROMPT_COMMAND=$PROMPT_COMMAND';eval set_titlebar "${LOGNAME}@${HOSTNAME}:$(my_dirname)"'
  export PROMPT_COMMAND

else
  export PS1='\n\u@\h:\w\n\!\$ '
fi

# this is a beat-the-television style kludge to get color working right.
if [ "$TERM" = "xterm" ]
then
  export TERM="xterm-color"
  tset 2> /dev/null
fi
8<----------------------------------------------------------------->8
... and now xterms have the titlebar set in the similar fashion; and I 
can tell by looking whether it's a `super xterm` or a normal one.

 Get all that?  :-)

-- 
Karl M. Hegbloom <karlheg@inetarena.com>
http://www.inetarena.com/~karlheg
Portland, OR  USA
Debian GNU 1.2  Linux 2.1.36 AMD K5 PR-133


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: