diff options
Diffstat (limited to 'contrib/cygwin/ssh-user-config')
-rw-r--r-- | contrib/cygwin/ssh-user-config | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/contrib/cygwin/ssh-user-config b/contrib/cygwin/ssh-user-config index 8708b7a58..33dc0cbea 100644 --- a/contrib/cygwin/ssh-user-config +++ b/contrib/cygwin/ssh-user-config | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | # | 2 | # |
3 | # ssh-user-config, Copyright 2000-2008 Red Hat Inc. | 3 | # ssh-user-config, Copyright 2000-2014 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 | # |
@@ -75,19 +75,18 @@ readonly -f create_identity | |||
75 | # pwdhome | 75 | # pwdhome |
76 | # ====================================================================== | 76 | # ====================================================================== |
77 | check_user_homedir() { | 77 | check_user_homedir() { |
78 | local uid=$(id -u) | 78 | pwdhome=$(getent passwd $UID | awk -F: '{ print $6; }') |
79 | pwdhome=$(awk -F: '{ if ( $3 == '${uid}' ) print $6; }' < ${SYSCONFDIR}/passwd) | ||
80 | if [ "X${pwdhome}" = "X" ] | 79 | if [ "X${pwdhome}" = "X" ] |
81 | then | 80 | then |
82 | csih_error_multi \ | 81 | csih_error_multi \ |
83 | "There is no home directory set for you in ${SYSCONFDIR}/passwd." \ | 82 | "There is no home directory set for you in the account database." \ |
84 | 'Setting $HOME is not sufficient!' | 83 | 'Setting $HOME is not sufficient!' |
85 | fi | 84 | fi |
86 | 85 | ||
87 | if [ ! -d "${pwdhome}" ] | 86 | if [ ! -d "${pwdhome}" ] |
88 | then | 87 | then |
89 | csih_error_multi \ | 88 | csih_error_multi \ |
90 | "${pwdhome} is set in ${SYSCONFDIR}/passwd as your home directory" \ | 89 | "${pwdhome} is set in the account database as your home directory" \ |
91 | 'but it is not a valid directory. Cannot create user identity files.' | 90 | 'but it is not a valid directory. Cannot create user identity files.' |
92 | fi | 91 | fi |
93 | 92 | ||
@@ -96,7 +95,7 @@ check_user_homedir() { | |||
96 | if [ "X${pwdhome}" = "X/" ] | 95 | if [ "X${pwdhome}" = "X/" ] |
97 | then | 96 | then |
98 | # But first raise a warning! | 97 | # But first raise a warning! |
99 | csih_warning "Your home directory in ${SYSCONFDIR}/passwd is set to root (/). This is not recommended!" | 98 | csih_warning "Your home directory in the account database is set to root (/). This is not recommended!" |
100 | if csih_request "Would you like to proceed anyway?" | 99 | if csih_request "Would you like to proceed anyway?" |
101 | then | 100 | then |
102 | pwdhome='' | 101 | pwdhome='' |
@@ -106,7 +105,7 @@ check_user_homedir() { | |||
106 | fi | 105 | fi |
107 | fi | 106 | fi |
108 | 107 | ||
109 | if [ -d "${pwdhome}" -a csih_is_nt -a -n "`chmod -c g-w,o-w "${pwdhome}"`" ] | 108 | if [ -d "${pwdhome}" -a -n "`chmod -c g-w,o-w "${pwdhome}"`" ] |
110 | then | 109 | then |
111 | echo | 110 | echo |
112 | csih_warning 'group and other have been revoked write permission to your home' | 111 | csih_warning 'group and other have been revoked write permission to your home' |
@@ -149,9 +148,10 @@ readonly -f check_user_dot_ssh_dir | |||
149 | # pwdhome -- check_user_homedir() | 148 | # pwdhome -- check_user_homedir() |
150 | # ====================================================================== | 149 | # ====================================================================== |
151 | fix_authorized_keys_perms() { | 150 | fix_authorized_keys_perms() { |
152 | if [ csih_is_nt -a -e "${pwdhome}/.ssh/authorized_keys" ] | 151 | if [ -e "${pwdhome}/.ssh/authorized_keys" ] |
153 | then | 152 | then |
154 | if ! setfacl -m "u::rw-,g::---,o::---" "${pwdhome}/.ssh/authorized_keys" | 153 | setfacl -b "${pwdhome}/.ssh/authorized_keys" 2>/dev/null || echo -n |
154 | if ! chmod u-x,g-wx,o-wx "${pwdhome}/.ssh/authorized_keys" | ||
155 | then | 155 | then |
156 | csih_warning "Setting correct permissions to ${pwdhome}/.ssh/authorized_keys" | 156 | csih_warning "Setting correct permissions to ${pwdhome}/.ssh/authorized_keys" |
157 | csih_warning "failed. Please care for the correct permissions. The minimum requirement" | 157 | csih_warning "failed. Please care for the correct permissions. The minimum requirement" |
@@ -243,15 +243,6 @@ done | |||
243 | # Action! | 243 | # Action! |
244 | # ====================================================================== | 244 | # ====================================================================== |
245 | 245 | ||
246 | # Check passwd file | ||
247 | if [ ! -f ${SYSCONFDIR}/passwd ] | ||
248 | then | ||
249 | csih_error_multi \ | ||
250 | "${SYSCONFDIR}/passwd is nonexistant. Please generate an ${SYSCONFDIR}/passwd file" \ | ||
251 | 'first using mkpasswd. Check if it contains an entry for you and' \ | ||
252 | 'please care for the home directory in your entry as well.' | ||
253 | fi | ||
254 | |||
255 | check_user_homedir | 246 | check_user_homedir |
256 | check_user_dot_ssh_dir | 247 | check_user_dot_ssh_dir |
257 | create_identity id_rsa rsa "SSH2 RSA" | 248 | create_identity id_rsa rsa "SSH2 RSA" |