diff options
Diffstat (limited to 'contrib/cygwin/ssh-host-config')
-rw-r--r-- | contrib/cygwin/ssh-host-config | 30 |
1 files changed, 16 insertions, 14 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 | ||
62 | sshd_config_configured=no | 62 | sshd_config_configured=no |
63 | port_number=22 | 63 | port_number=22 |
64 | service_name=sshd | ||
64 | strictmodes=yes | 65 | strictmodes=yes |
65 | privsep_used=yes | 66 | privsep_used=yes |
66 | cygwin_value="" | 67 | cygwin_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." |