File: sdm-login

package info (click to toggle)
sdm 0.4.0a-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 188 kB
  • ctags: 4
  • sloc: sh: 68; makefile: 66
file content (103 lines) | stat: -rwxr-xr-x 2,223 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/ash
#/usr/sbin/sdm-login

# Copyright 2003 under the terms of the GNU General Public
# License, version 2 or any later version. vagrant@freegeek.org


# getLogin is used to set up login information
getLogin() {
  if [ -x "$(which Xdialog)" ]; then
    user=$(Xdialog --stdout $justify $icon --ok-label login \
      --cancel-label shutdown --inputbox \
      "$login_text" 0 0 "")

    status="$?"
    case $status in
      0) ;;
      1) shutdown=$(xmessage -center -print -buttons shutdown,reboot,sdm \
         "shutdown or reboot or return to sdm?")
	case $shutdown in
		shutdown) halt
			exit 10 ;;
		reboot) reboot 
			exit 20 ;;
		sdm) exit 30 ;;
        esac
	;;
      255) xmessage -center "login failed, misconfigured getLogin function? $status"
        echo "login failed, misconfigured getLogin function? $status"
        exit 1 ;;
    esac
  else
    message="Xdialog not found, either install Xdialog or configure sdm for autologin"
    xmessage -timeout -center "$message"
    echo "$message"
  fi
}

# source generic config file
if [ -r /etc/sdm/sdm.config ]; then
	. /etc/sdm/sdm.config
fi

# source host-specific config file
if [ -r /etc/sdm/sdm.config.$(hostname) ]; then
	. /etc/sdm/sdm.config.$(hostname)
fi

if [ -n "$xsetroot" ]; then
	xsetroot $xsetroot
fi

if [ -z "$server" ]; then
	server=xapp
fi

if [ -z "$sshopts" ]; then
	sshopts="-A -X -T -n"
fi

if [ -r "$key" ]; then
  sshopts="$sshopts -i $key"
fi

if [ -r "$login_icon" ]; then
  icon="--icon $login_icon"
fi

if [ -z "$login_text" ]; then
  login_text="Welcome to $server"
fi

if [ -e /tmp/sdm.autologin.once ]; then
   autologin="no"
fi

case $autologin in
	yes|y|Y|Yes) ;;
  once) touch /tmp/sdm.autologin.once ;;
	*) getLogin ;;
esac

if [ -n "$(echo $user | egrep @)" ]; then
  server=$(echo $user | awk -F @ '{print $2}')
  user=$(echo $user | awk -F @ '{print $1}')
fi

if [ -z "$user" ]; then
	# assume user is the same as hostname
	user=$(hostname)
	if [ -n "$anon_server" ]; then
		server=$anon_server
	fi
fi

if [ ! -x "$SSH_ASKPASS" -o -z "$SSH_ASKPASS" ]; then
  if [ -x "/usr/bin/ssh-askpass" ]; then
  	SSH_ASKPASS="/usr/bin/ssh-askpass"
  fi
fi
export SSH_ASKPASS

ssh $sshopts $user@$server $sdmsession $command