summaryrefslogtreecommitdiff
path: root/contrib/cygwin/ssh-user-config
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/cygwin/ssh-user-config')
-rw-r--r--contrib/cygwin/ssh-user-config64
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
8SYSCONFDIR=/etc
9
7progname=$0 10progname=$0
8auto_answer="" 11auto_answer=""
9auto_passphrase="no" 12auto_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
43if [ $_nt -gt 0 ]
44then
45 _nt2003=`uname | awk -F- '{print ( $2 >= 5.2 ) ? 1 : 0;}'`
46fi
47
36# Check options 48# Check options
37 49
38while : 50while :
@@ -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
87if [ ! -f /etc/passwd ] 99if [ ! -f ${SYSCONFDIR}/passwd ]
88then 100then
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
93fi 105fi
94 106
95uid=`id -u` 107uid=`id -u`
96pwdhome=`awk -F: '{ if ( $3 == '${uid}' ) print $6; }' < /etc/passwd` 108pwdhome=`awk -F: '{ if ( $3 == '${uid}' ) print $6; }' < ${SYSCONFDIR}/passwd`
97 109
98if [ "X${pwdhome}" = "X" ] 110if [ "X${pwdhome}" = "X" ]
99then 111then
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
103fi 115fi
104 116
105if [ ! -d "${pwdhome}" ] 117if [ ! -d "${pwdhome}" ]
106then 118then
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
110fi 122fi
@@ -114,7 +126,7 @@ fi
114if [ "X${pwdhome}" = "X/" ] 126if [ "X${pwdhome}" = "X/" ]
115then 127then
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
124fi 136fi
125 137
138if [ -d "${pwdhome}" -a $_nt -gt 0 -a -n "`chmod -c g-w,o-w "${pwdhome}"`" ]
139then
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
147fi
148
126if [ -e "${pwdhome}/.ssh" -a ! -d "${pwdhome}/.ssh" ] 149if [ -e "${pwdhome}/.ssh" -a ! -d "${pwdhome}/.ssh" ]
127then 150then
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
140fi 163fi
141 164
165if [ $_nt -gt 0 ]
166then
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
178fi
179
142if [ ! -f "${pwdhome}/.ssh/identity" ] 180if [ ! -f "${pwdhome}/.ssh/identity" ]
143then 181then
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
197fi 235fi
198 236
237if [ $_nt -gt 0 -a -e "${pwdhome}/.ssh/authorized_keys" ]
238then
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
247fi
248
199echo 249echo
200echo "Configuration finished. Have fun!" 250echo "Configuration finished. Have fun!"