diff options
Diffstat (limited to 'contrib/cygwin/ssh-user-config')
-rw-r--r-- | contrib/cygwin/ssh-user-config | 64 |
1 files changed, 57 insertions, 7 deletions
diff --git a/contrib/cygwin/ssh-user-config b/contrib/cygwin/ssh-user-config index 4da113181..fe07ce360 100644 --- a/contrib/cygwin/ssh-user-config +++ b/contrib/cygwin/ssh-user-config | |||
@@ -1,9 +1,12 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # | 2 | # |
3 | # ssh-user-config, Copyright 2000, Red Hat Inc. | 3 | # ssh-user-config, Copyright 2000, 2001, 2002, 2003, Red Hat Inc. |
4 | # | 4 | # |
5 | # This file is part of the Cygwin port of OpenSSH. | 5 | # This file is part of the Cygwin port of OpenSSH. |
6 | 6 | ||
7 | # Directory where the config files are stored | ||
8 | SYSCONFDIR=/etc | ||
9 | |||
7 | progname=$0 | 10 | progname=$0 |
8 | auto_answer="" | 11 | auto_answer="" |
9 | auto_passphrase="no" | 12 | auto_passphrase="no" |
@@ -33,6 +36,15 @@ request() | |||
33 | fi | 36 | fi |
34 | } | 37 | } |
35 | 38 | ||
39 | # Check if running on NT | ||
40 | _sys="`uname -a`" | ||
41 | _nt=`expr "$_sys" : "CYGWIN_NT"` | ||
42 | # If running on NT, check if running under 2003 Server or later | ||
43 | if [ $_nt -gt 0 ] | ||
44 | then | ||
45 | _nt2003=`uname | awk -F- '{print ( $2 >= 5.2 ) ? 1 : 0;}'` | ||
46 | fi | ||
47 | |||
36 | # Check options | 48 | # Check options |
37 | 49 | ||
38 | while : | 50 | while : |
@@ -84,27 +96,27 @@ done | |||
84 | 96 | ||
85 | # Ask user if user identity should be generated | 97 | # Ask user if user identity should be generated |
86 | 98 | ||
87 | if [ ! -f /etc/passwd ] | 99 | if [ ! -f ${SYSCONFDIR}/passwd ] |
88 | then | 100 | then |
89 | echo '/etc/passwd is nonexistant. Please generate an /etc/passwd file' | 101 | echo "${SYSCONFDIR}/passwd is nonexistant. Please generate an ${SYSCONFDIR}/passwd file" |
90 | echo 'first using mkpasswd. Check if it contains an entry for you and' | 102 | echo 'first using mkpasswd. Check if it contains an entry for you and' |
91 | echo 'please care for the home directory in your entry as well.' | 103 | echo 'please care for the home directory in your entry as well.' |
92 | exit 1 | 104 | exit 1 |
93 | fi | 105 | fi |
94 | 106 | ||
95 | uid=`id -u` | 107 | uid=`id -u` |
96 | pwdhome=`awk -F: '{ if ( $3 == '${uid}' ) print $6; }' < /etc/passwd` | 108 | pwdhome=`awk -F: '{ if ( $3 == '${uid}' ) print $6; }' < ${SYSCONFDIR}/passwd` |
97 | 109 | ||
98 | if [ "X${pwdhome}" = "X" ] | 110 | if [ "X${pwdhome}" = "X" ] |
99 | then | 111 | then |
100 | echo 'There is no home directory set for you in /etc/passwd.' | 112 | echo "There is no home directory set for you in ${SYSCONFDIR}/passwd." |
101 | echo 'Setting $HOME is not sufficient!' | 113 | echo 'Setting $HOME is not sufficient!' |
102 | exit 1 | 114 | exit 1 |
103 | fi | 115 | fi |
104 | 116 | ||
105 | if [ ! -d "${pwdhome}" ] | 117 | if [ ! -d "${pwdhome}" ] |
106 | then | 118 | then |
107 | echo "${pwdhome} is set in /etc/passwd as your home directory" | 119 | echo "${pwdhome} is set in ${SYSCONFDIR}/passwd as your home directory" |
108 | echo 'but it is not a valid directory. Cannot create user identity files.' | 120 | echo 'but it is not a valid directory. Cannot create user identity files.' |
109 | exit 1 | 121 | exit 1 |
110 | fi | 122 | fi |
@@ -114,7 +126,7 @@ fi | |||
114 | if [ "X${pwdhome}" = "X/" ] | 126 | if [ "X${pwdhome}" = "X/" ] |
115 | then | 127 | then |
116 | # But first raise a warning! | 128 | # But first raise a warning! |
117 | echo 'Your home directory in /etc/passwd is set to root (/). This is not recommended!' | 129 | echo "Your home directory in ${SYSCONFDIR}/passwd is set to root (/). This is not recommended!" |
118 | if request "Would you like to proceed anyway?" | 130 | if request "Would you like to proceed anyway?" |
119 | then | 131 | then |
120 | pwdhome='' | 132 | pwdhome='' |
@@ -123,6 +135,17 @@ then | |||
123 | fi | 135 | fi |
124 | fi | 136 | fi |
125 | 137 | ||
138 | if [ -d "${pwdhome}" -a $_nt -gt 0 -a -n "`chmod -c g-w,o-w "${pwdhome}"`" ] | ||
139 | then | ||
140 | echo | ||
141 | echo 'WARNING: group and other have been revoked write permission to your home' | ||
142 | echo " directory ${pwdhome}." | ||
143 | echo ' This is required by OpenSSH to allow public key authentication using' | ||
144 | echo ' the key files stored in your .ssh subdirectory.' | ||
145 | echo ' Revert this change ONLY if you know what you are doing!' | ||
146 | echo | ||
147 | fi | ||
148 | |||
126 | if [ -e "${pwdhome}/.ssh" -a ! -d "${pwdhome}/.ssh" ] | 149 | if [ -e "${pwdhome}/.ssh" -a ! -d "${pwdhome}/.ssh" ] |
127 | then | 150 | then |
128 | echo "${pwdhome}/.ssh is existant but not a directory. Cannot create user identity files." | 151 | echo "${pwdhome}/.ssh is existant but not a directory. Cannot create user identity files." |
@@ -139,6 +162,21 @@ then | |||
139 | fi | 162 | fi |
140 | fi | 163 | fi |
141 | 164 | ||
165 | if [ $_nt -gt 0 ] | ||
166 | then | ||
167 | _user="system" | ||
168 | if [ $_nt2003 -gt 0 ] | ||
169 | then | ||
170 | grep -q '^sshd_server:' ${SYSCONFDIR}/passwd && _user="sshd_server" | ||
171 | fi | ||
172 | if ! setfacl -m "u::rwx,u:${_user}:r--,g::---,o::---" "${pwdhome}/.ssh" | ||
173 | then | ||
174 | echo "${pwdhome}/.ssh couldn't be given the correct permissions." | ||
175 | echo "Please try to solve this problem first." | ||
176 | exit 1 | ||
177 | fi | ||
178 | fi | ||
179 | |||
142 | if [ ! -f "${pwdhome}/.ssh/identity" ] | 180 | if [ ! -f "${pwdhome}/.ssh/identity" ] |
143 | then | 181 | then |
144 | if request "Shall I create an SSH1 RSA identity file for you?" | 182 | if request "Shall I create an SSH1 RSA identity file for you?" |
@@ -196,5 +234,17 @@ then | |||
196 | fi | 234 | fi |
197 | fi | 235 | fi |
198 | 236 | ||
237 | if [ $_nt -gt 0 -a -e "${pwdhome}/.ssh/authorized_keys" ] | ||
238 | then | ||
239 | if ! setfacl -m "u::rw-,u:${_user}:r--,g::---,o::---" "${pwdhome}/.ssh/authorized_keys" | ||
240 | then | ||
241 | echo | ||
242 | echo "WARNING: Setting correct permissions to ${pwdhome}/.ssh/authorized_keys" | ||
243 | echo "failed. Please care for the correct permissions. The minimum requirement" | ||
244 | echo "is, the owner and ${_user} both need read permissions." | ||
245 | echo | ||
246 | fi | ||
247 | fi | ||
248 | |||
199 | echo | 249 | echo |
200 | echo "Configuration finished. Have fun!" | 250 | echo "Configuration finished. Have fun!" |