- (dtucker) [contrib/cygwin/ssh-host-config] better support for automated

scripts and fix usage of eval.  Patch from Corinna Vinschen.
This commit is contained in:
Darren Tucker 2009-07-07 21:19:11 +10:00
parent de0c025e3c
commit 4d4fdc0f7d
2 changed files with 29 additions and 7 deletions

View File

@ -1,3 +1,8 @@
20090707
- (dtucker) [contrib/cygwin/ssh-host-config] better support for automated
scripts and fix usage of eval. Patch from Corinna Vinschen.
20090705
- (dtucker) OpenBSD CVS Sync - (dtucker) OpenBSD CVS Sync
- andreas@cvs.openbsd.org 2009/06/27 09:29:06 - andreas@cvs.openbsd.org 2009/06/27 09:29:06
[packet.h packet.c] [packet.h packet.c]

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# #
# ssh-host-config, Copyright 2000, 2001, 2002, 2003 Red Hat Inc. # ssh-host-config, Copyright 2000-2009 Red Hat Inc.
# #
# This file is part of the Cygwin port of OpenSSH. # This file is part of the Cygwin port of OpenSSH.
@ -26,7 +26,9 @@ port_number=22
privsep_configured=no privsep_configured=no
privsep_used=yes privsep_used=yes
cygwin_value="" cygwin_value=""
user_account=
password_value= password_value=
opt_force=no
# ====================================================================== # ======================================================================
# Routine: create_host_keys # Routine: create_host_keys
@ -287,6 +289,11 @@ install_service() {
csih_inform "sshd requires. You need to have or to create a privileged" csih_inform "sshd requires. You need to have or to create a privileged"
csih_inform "account. This script will help you do so." csih_inform "account. This script will help you do so."
echo echo
[ "${opt_force}" = "yes" ] && opt_f=-f
[ -n "${user_account}" ] && opt_u="-u ""${user_account}"""
csih_select_privileged_username ${opt_f} ${opt_u} sshd
if ! csih_create_privileged_user "${password_value}" if ! csih_create_privileged_user "${password_value}"
then then
csih_error_recoverable "There was a serious problem creating a privileged user." csih_error_recoverable "There was a serious problem creating a privileged user."
@ -316,12 +323,12 @@ install_service() {
if [ -n "${csih_cygenv}" ] if [ -n "${csih_cygenv}" ]
then then
cygwin_env="-e CYGWIN=\"${csih_cygenv}\"" cygwin_env=( -e "CYGWIN=${csih_cygenv}" )
fi fi
if [ -z "${password}" ] if [ -z "${password}" ]
then then
if eval cygrunsrv -I sshd -d \"CYGWIN sshd\" -p /usr/sbin/sshd \ if cygrunsrv -I sshd -d "CYGWIN sshd" -p /usr/sbin/sshd \
-a "-D" -y tcpip ${cygwin_env} -a "-D" -y tcpip "${cygwin_env[@]}"
then then
echo echo
csih_inform "The sshd service has been installed under the LocalSystem" csih_inform "The sshd service has been installed under the LocalSystem"
@ -330,8 +337,8 @@ install_service() {
csih_inform "will start automatically after the next reboot." csih_inform "will start automatically after the next reboot."
fi fi
else else
if eval cygrunsrv -I sshd -d \"CYGWIN sshd\" -p /usr/sbin/sshd \ if cygrunsrv -I sshd -d "CYGWIN sshd" -p /usr/sbin/sshd \
-a "-D" -y tcpip ${cygwin_env} \ -a "-D" -y tcpip "${cygwin_env[@]}" \
-u "${run_service_as}" -w "${password}" -u "${run_service_as}" -w "${password}"
then then
echo echo
@ -378,11 +385,13 @@ if [ "$PROGDIR" = "/etc/postinstall" ]
then then
csih_auto_answer="no" csih_auto_answer="no"
csih_disable_color csih_disable_color
opt_force=yes
fi fi
if [ -n "${SSH_HOST_CONFIG_AUTO_ANSWER_NO}" ] if [ -n "${SSH_HOST_CONFIG_AUTO_ANSWER_NO}" ]
then then
csih_auto_answer="no" csih_auto_answer="no"
csih_disable_color csih_disable_color
opt_force=yes
fi fi
# ====================================================================== # ======================================================================
@ -407,10 +416,12 @@ do
-y | --yes ) -y | --yes )
csih_auto_answer=yes csih_auto_answer=yes
opt_force=yes
;; ;;
-n | --no ) -n | --no )
csih_auto_answer=no csih_auto_answer=no
opt_force=yes
;; ;;
-c | --cygwin ) -c | --cygwin )
@ -423,6 +434,11 @@ do
shift shift
;; ;;
-u | --user )
user_account="$1"
shift
;;
-w | --pwd ) -w | --pwd )
password_value="$1" password_value="$1"
shift shift
@ -443,6 +459,7 @@ do
echo " --no -n Answer all questions with \"no\" automatically." echo " --no -n Answer all questions with \"no\" automatically."
echo " --cygwin -c <options> Use \"options\" as value for CYGWIN environment var." echo " --cygwin -c <options> Use \"options\" as value for CYGWIN environment var."
echo " --port -p <n> sshd listens on port n." echo " --port -p <n> sshd listens on port n."
echo " --user -u <account> privileged user for service."
echo " --pwd -w <passwd> Use \"pwd\" as password for privileged user." echo " --pwd -w <passwd> Use \"pwd\" as password for privileged user."
echo " --privileged On Windows NT/2k/XP, require privileged user" echo " --privileged On Windows NT/2k/XP, require privileged user"
echo " instead of LocalSystem for sshd service." echo " instead of LocalSystem for sshd service."
@ -489,7 +506,7 @@ then
fi fi
# Create /var/empty file used as chroot jail for privilege separation # Create /var/empty file used as chroot jail for privilege separation
csih_make_dir "${LOCALSTATEDIR}/empty" "Cannot create log directory." csih_make_dir "${LOCALSTATEDIR}/empty" "Cannot create ${LOCALSTATEDIR}/empty directory."
chmod 755 "${LOCALSTATEDIR}/empty" chmod 755 "${LOCALSTATEDIR}/empty"
setfacl -m u:system:rwx "${LOCALSTATEDIR}/empty" setfacl -m u:system:rwx "${LOCALSTATEDIR}/empty"