summaryrefslogtreecommitdiff
path: root/contrib/cygwin/ssh-host-config
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/cygwin/ssh-host-config')
-rw-r--r--contrib/cygwin/ssh-host-config43
1 files changed, 36 insertions, 7 deletions
diff --git a/contrib/cygwin/ssh-host-config b/contrib/cygwin/ssh-host-config
index 57e728fbc..b6f9511e2 100644
--- a/contrib/cygwin/ssh-host-config
+++ b/contrib/cygwin/ssh-host-config
@@ -1,8 +1,20 @@
1#!/bin/bash 1#!/bin/bash
2# 2#
3# ssh-host-config, Copyright 2000, 2001, 2002, 2003 Red Hat Inc. 3# ssh-host-config, Copyright 2000-2009 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#
7# Permission to use, copy, modify, and distribute this software for any
8# purpose with or without fee is hereby granted, provided that the above
9# copyright notice and this permission notice appear in all copies.
10#
11# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14# IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
17# THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6 18
7# ====================================================================== 19# ======================================================================
8# Initialization 20# Initialization
@@ -26,7 +38,9 @@ port_number=22
26privsep_configured=no 38privsep_configured=no
27privsep_used=yes 39privsep_used=yes
28cygwin_value="" 40cygwin_value=""
41user_account=
29password_value= 42password_value=
43opt_force=no
30 44
31# ====================================================================== 45# ======================================================================
32# Routine: create_host_keys 46# Routine: create_host_keys
@@ -287,6 +301,11 @@ install_service() {
287 csih_inform "sshd requires. You need to have or to create a privileged" 301 csih_inform "sshd requires. You need to have or to create a privileged"
288 csih_inform "account. This script will help you do so." 302 csih_inform "account. This script will help you do so."
289 echo 303 echo
304
305 [ "${opt_force}" = "yes" ] && opt_f=-f
306 [ -n "${user_account}" ] && opt_u="-u ""${user_account}"""
307 csih_select_privileged_username ${opt_f} ${opt_u} sshd
308
290 if ! csih_create_privileged_user "${password_value}" 309 if ! csih_create_privileged_user "${password_value}"
291 then 310 then
292 csih_error_recoverable "There was a serious problem creating a privileged user." 311 csih_error_recoverable "There was a serious problem creating a privileged user."
@@ -316,12 +335,12 @@ install_service() {
316 335
317 if [ -n "${csih_cygenv}" ] 336 if [ -n "${csih_cygenv}" ]
318 then 337 then
319 cygwin_env="-e CYGWIN=\"${csih_cygenv}\"" 338 cygwin_env=( -e "CYGWIN=${csih_cygenv}" )
320 fi 339 fi
321 if [ -z "${password}" ] 340 if [ -z "${password}" ]
322 then 341 then
323 if eval cygrunsrv -I sshd -d \"CYGWIN sshd\" -p /usr/sbin/sshd \ 342 if cygrunsrv -I sshd -d "CYGWIN sshd" -p /usr/sbin/sshd \
324 -a "-D" -y tcpip ${cygwin_env} 343 -a "-D" -y tcpip "${cygwin_env[@]}"
325 then 344 then
326 echo 345 echo
327 csih_inform "The sshd service has been installed under the LocalSystem" 346 csih_inform "The sshd service has been installed under the LocalSystem"
@@ -330,8 +349,8 @@ install_service() {
330 csih_inform "will start automatically after the next reboot." 349 csih_inform "will start automatically after the next reboot."
331 fi 350 fi
332 else 351 else
333 if eval cygrunsrv -I sshd -d \"CYGWIN sshd\" -p /usr/sbin/sshd \ 352 if cygrunsrv -I sshd -d "CYGWIN sshd" -p /usr/sbin/sshd \
334 -a "-D" -y tcpip ${cygwin_env} \ 353 -a "-D" -y tcpip "${cygwin_env[@]}" \
335 -u "${run_service_as}" -w "${password}" 354 -u "${run_service_as}" -w "${password}"
336 then 355 then
337 echo 356 echo
@@ -378,11 +397,13 @@ if [ "$PROGDIR" = "/etc/postinstall" ]
378then 397then
379 csih_auto_answer="no" 398 csih_auto_answer="no"
380 csih_disable_color 399 csih_disable_color
400 opt_force=yes
381fi 401fi
382if [ -n "${SSH_HOST_CONFIG_AUTO_ANSWER_NO}" ] 402if [ -n "${SSH_HOST_CONFIG_AUTO_ANSWER_NO}" ]
383then 403then
384 csih_auto_answer="no" 404 csih_auto_answer="no"
385 csih_disable_color 405 csih_disable_color
406 opt_force=yes
386fi 407fi
387 408
388# ====================================================================== 409# ======================================================================
@@ -407,10 +428,12 @@ do
407 428
408 -y | --yes ) 429 -y | --yes )
409 csih_auto_answer=yes 430 csih_auto_answer=yes
431 opt_force=yes
410 ;; 432 ;;
411 433
412 -n | --no ) 434 -n | --no )
413 csih_auto_answer=no 435 csih_auto_answer=no
436 opt_force=yes
414 ;; 437 ;;
415 438
416 -c | --cygwin ) 439 -c | --cygwin )
@@ -423,6 +446,11 @@ do
423 shift 446 shift
424 ;; 447 ;;
425 448
449 -u | --user )
450 user_account="$1"
451 shift
452 ;;
453
426 -w | --pwd ) 454 -w | --pwd )
427 password_value="$1" 455 password_value="$1"
428 shift 456 shift
@@ -443,6 +471,7 @@ do
443 echo " --no -n Answer all questions with \"no\" automatically." 471 echo " --no -n Answer all questions with \"no\" automatically."
444 echo " --cygwin -c <options> Use \"options\" as value for CYGWIN environment var." 472 echo " --cygwin -c <options> Use \"options\" as value for CYGWIN environment var."
445 echo " --port -p <n> sshd listens on port n." 473 echo " --port -p <n> sshd listens on port n."
474 echo " --user -u <account> privileged user for service."
446 echo " --pwd -w <passwd> Use \"pwd\" as password for privileged user." 475 echo " --pwd -w <passwd> Use \"pwd\" as password for privileged user."
447 echo " --privileged On Windows NT/2k/XP, require privileged user" 476 echo " --privileged On Windows NT/2k/XP, require privileged user"
448 echo " instead of LocalSystem for sshd service." 477 echo " instead of LocalSystem for sshd service."
@@ -489,7 +518,7 @@ then
489fi 518fi
490 519
491# Create /var/empty file used as chroot jail for privilege separation 520# Create /var/empty file used as chroot jail for privilege separation
492csih_make_dir "${LOCALSTATEDIR}/empty" "Cannot create log directory." 521csih_make_dir "${LOCALSTATEDIR}/empty" "Cannot create ${LOCALSTATEDIR}/empty directory."
493chmod 755 "${LOCALSTATEDIR}/empty" 522chmod 755 "${LOCALSTATEDIR}/empty"
494setfacl -m u:system:rwx "${LOCALSTATEDIR}/empty" 523setfacl -m u:system:rwx "${LOCALSTATEDIR}/empty"
495 524