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

Re: Which files do what: .bashrc and friends

On Wednesday 19 November 2008, "Dotan Cohen" <dotancohen@gmail.com> wrote about 'Re: Which files do 
what: .bashrc and friends':
>1) Is a login shell run when the user logs onto KDE (even though he
>does not see a konsole window)?

Nope a login shell is when bash is executed with the -l option, or having 
an argv[0] starting with '-'.

If you want things to run when KDE starts up, you can use .kde/env 
and .kde/Autostart.  All readable files in .kde/env are sourced by 
the /usr/bin/startkde script, which is run by /bin/sh.  All .desktop files 
in .kde/Autostart are "activated" (by kdeinit or somesuch, around the same 
time your session is restored; .desktop file are like things in KMenu, they 
might open a file, start a program, whatever).

>2) Is an interactive shell the term used for opening a konsole window?

Yes.  An interactive shell is any shell where stdin AND stderr are 
terminals (tty or pty).  When konsole (and other X11 terminal applications) 
use a shell, they attach stdin, stdout, and stderr to a pseudo-terminal 
(pty; slave side) created by them.

(This leaves non-interactive shells; those when stdin or stderr are not 
attached to a terminal.)

An example:
bss@monster:~$ grep keychain .bash_profile
[[ -t 0 ]] && [[ -x ~/bin/keychain-load.bash ]] && eval "$(~/bin/keychain-load.bash)"
bss@monster:~$ cat bin/keychain-load.bash
#! /bin/bash
# Starts and loads the keychain, interacting with the user as needed.
# May start gnupg-agent, but doesn't prompt for keys because gnupg-agent
# regularly times out keys.
# Since interaction is clearly available, we clear the keychain before adding
# keys (assume user is an attacker).
if [ -x /usr/bin/keychain ]; then
        eval "$(/usr/bin/keychain --eval --inherit any-once --stop others \
                --clear "${SSH_KEYS[@]}")"
bss@monster:~$ grep -A 1 keychain .bashrc
if [ -x ~/bin/keychain-start.sh ]; then
        . ~/bin/keychain-start.sh
bss@monster:~$ cat bin/keychain-start.sh
#! /bin/sh
# Starts keychain or initializes the environment, but requires no interactivity.
if [ -x /usr/bin/keychain ]; then
        { eval "$(/usr/bin/keychain --eval --quiet --inherit any-once --stop others --noask --lockwait 
0)"; } >/dev/null 2>&1
bss@monster:~$ cd .kde
bss@monster:~/.kde$ ls env Autostart

gtk-qt-engine.rc.sh  keychain-start.sh  ssh-askpass.sh
bss@monster:~/.kde$ # env/keychain-start.sh is a hard link to ~/bin/keychain-start.sh
bss@monster:~/.kde$ cat Autostart/keychain-load.desktop
[Desktop Entry]
Name=Load Keychain
Comment=Start agents and add keys to them.
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss03@volumehost.net                      ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.org/                      \_/     

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply to: