summaryrefslogtreecommitdiff
path: root/contrib/cygwin
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/cygwin')
-rw-r--r--contrib/cygwin/ssh-host-config30
-rw-r--r--contrib/cygwin/ssh-user-config27
2 files changed, 25 insertions, 32 deletions
diff --git a/contrib/cygwin/ssh-host-config b/contrib/cygwin/ssh-host-config
index a7ea3e0d2..d934d09b5 100644
--- a/contrib/cygwin/ssh-host-config
+++ b/contrib/cygwin/ssh-host-config
@@ -1,6 +1,6 @@
1#!/bin/bash 1#!/bin/bash
2# 2#
3# ssh-host-config, Copyright 2000-2011 Red Hat Inc. 3# ssh-host-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#
@@ -61,6 +61,7 @@ LOCALSTATEDIR=/var
61 61
62sshd_config_configured=no 62sshd_config_configured=no
63port_number=22 63port_number=22
64service_name=sshd
64strictmodes=yes 65strictmodes=yes
65privsep_used=yes 66privsep_used=yes
66cygwin_value="" 67cygwin_value=""
@@ -353,11 +354,9 @@ check_service_files_ownership() {
353 fi 354 fi
354 if [ -z "${run_service_as}" ] 355 if [ -z "${run_service_as}" ]
355 then 356 then
356 csih_warning "Couldn't determine name of user running sshd service from /etc/passwd!" 357 csih_warning "Couldn't determine name of user running sshd service from account database!"
357 csih_warning "As a result, this script cannot make sure that the files used" 358 csih_warning "As a result, this script cannot make sure that the files used"
358 csih_warning "by the sshd service belong to the user running the service." 359 csih_warning "by the sshd service belong to the user running the service."
359 csih_warning "Please re-run the mkpasswd tool to make sure the /etc/passwd"
360 csih_warning "file is in a good shape."
361 return 1 360 return 1
362 fi 361 fi
363 fi 362 fi
@@ -410,7 +409,7 @@ install_service() {
410 local ret=0 409 local ret=0
411 410
412 echo 411 echo
413 if /usr/bin/cygrunsrv -Q sshd >/dev/null 2>&1 412 if /usr/bin/cygrunsrv -Q ${service_name} >/dev/null 2>&1
414 then 413 then
415 csih_inform "Sshd service is already installed." 414 csih_inform "Sshd service is already installed."
416 check_service_files_ownership "" || let ret+=$? 415 check_service_files_ownership "" || let ret+=$?
@@ -466,7 +465,7 @@ install_service() {
466 fi 465 fi
467 if [ -z "${password}" ] 466 if [ -z "${password}" ]
468 then 467 then
469 if /usr/bin/cygrunsrv -I sshd -d "CYGWIN sshd" -p /usr/sbin/sshd \ 468 if /usr/bin/cygrunsrv -I ${service_name} -d "CYGWIN ${service_name}" -p /usr/sbin/sshd \
470 -a "-D" -y tcpip "${cygwin_env[@]}" 469 -a "-D" -y tcpip "${cygwin_env[@]}"
471 then 470 then
472 echo 471 echo
@@ -476,20 +475,20 @@ install_service() {
476 csih_inform "will start automatically after the next reboot." 475 csih_inform "will start automatically after the next reboot."
477 fi 476 fi
478 else 477 else
479 if /usr/bin/cygrunsrv -I sshd -d "CYGWIN sshd" -p /usr/sbin/sshd \ 478 if /usr/bin/cygrunsrv -I ${service_name} -d "CYGWIN ${service_name}" -p /usr/sbin/sshd \
480 -a "-D" -y tcpip "${cygwin_env[@]}" \ 479 -a "-D" -y tcpip "${cygwin_env[@]}" \
481 -u "${run_service_as}" -w "${password}" 480 -u "${run_service_as}" -w "${password}"
482 then 481 then
483 /usr/bin/editrights -u "${run_service_as}" -a SeServiceLogonRight 482 /usr/bin/editrights -u "${run_service_as}" -a SeServiceLogonRight
484 echo 483 echo
485 csih_inform "The sshd service has been installed under the '${run_service_as}'" 484 csih_inform "The sshd service has been installed under the '${run_service_as}'"
486 csih_inform "account. To start the service now, call \`net start sshd' or" 485 csih_inform "account. To start the service now, call \`net start ${service_name}' or"
487 csih_inform "\`cygrunsrv -S sshd'. Otherwise, it will start automatically" 486 csih_inform "\`cygrunsrv -S ${service_name}'. Otherwise, it will start automatically"
488 csih_inform "after the next reboot." 487 csih_inform "after the next reboot."
489 fi 488 fi
490 fi 489 fi
491 490
492 if /usr/bin/cygrunsrv -Q sshd >/dev/null 2>&1 491 if /usr/bin/cygrunsrv -Q ${service_name} >/dev/null 2>&1
493 then 492 then
494 check_service_files_ownership "${run_service_as}" || let ret+=$? 493 check_service_files_ownership "${run_service_as}" || let ret+=$?
495 else 494 else
@@ -563,6 +562,11 @@ do
563 shift 562 shift
564 ;; 563 ;;
565 564
565 -N | --name )
566 service_name=$1
567 shift
568 ;;
569
566 -p | --port ) 570 -p | --port )
567 port_number=$1 571 port_number=$1
568 shift 572 shift
@@ -592,6 +596,7 @@ do
592 echo " --yes -y Answer all questions with \"yes\" automatically." 596 echo " --yes -y Answer all questions with \"yes\" automatically."
593 echo " --no -n Answer all questions with \"no\" automatically." 597 echo " --no -n Answer all questions with \"no\" automatically."
594 echo " --cygwin -c <options> Use \"options\" as value for CYGWIN environment var." 598 echo " --cygwin -c <options> Use \"options\" as value for CYGWIN environment var."
599 echo " --name -N <name> sshd windows service name."
595 echo " --port -p <n> sshd listens on port n." 600 echo " --port -p <n> sshd listens on port n."
596 echo " --user -u <account> privileged user for service, default 'cyg_server'." 601 echo " --user -u <account> privileged user for service, default 'cyg_server'."
597 echo " --pwd -w <passwd> Use \"pwd\" as password for privileged user." 602 echo " --pwd -w <passwd> Use \"pwd\" as password for privileged user."
@@ -625,10 +630,7 @@ then
625 csih_warning "However, it seems your account does not have these privileges." 630 csih_warning "However, it seems your account does not have these privileges."
626 csih_warning "Here's the list of groups in your user token:" 631 csih_warning "Here's the list of groups in your user token:"
627 echo 632 echo
628 for i in $(/usr/bin/id -G) 633 /usr/bin/id -Gnz | xargs -0n1 echo " "
629 do
630 /usr/bin/awk -F: "/[^:]*:[^:]*:$i:/{ print \" \" \$1; }" /etc/group
631 done
632 echo 634 echo
633 csih_warning "This usually means you're running this script from a non-admin" 635 csih_warning "This usually means you're running this script from a non-admin"
634 csih_warning "desktop session, or in a non-elevated shell under UAC control." 636 csih_warning "desktop session, or in a non-elevated shell under UAC control."
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# ======================================================================
77check_user_homedir() { 77check_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# ======================================================================
151fix_authorized_keys_perms() { 150fix_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
247if [ ! -f ${SYSCONFDIR}/passwd ]
248then
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.'
253fi
254
255check_user_homedir 246check_user_homedir
256check_user_dot_ssh_dir 247check_user_dot_ssh_dir
257create_identity id_rsa rsa "SSH2 RSA" 248create_identity id_rsa rsa "SSH2 RSA"