allow custom service name for sshd on Cygwin

Permits the use of multiple sshd running with different service names.

Patch by Florian Friesdorf via Corinna Vinschen
This commit is contained in:
Damien Miller 2014-11-26 13:20:35 +11:00
parent 08c0eebf55
commit 8b66f36291
1 changed files with 13 additions and 6 deletions

View File

@ -61,6 +61,7 @@ LOCALSTATEDIR=/var
sshd_config_configured=no sshd_config_configured=no
port_number=22 port_number=22
service_name=sshd
strictmodes=yes strictmodes=yes
privsep_used=yes privsep_used=yes
cygwin_value="" cygwin_value=""
@ -408,7 +409,7 @@ install_service() {
local ret=0 local ret=0
echo echo
if /usr/bin/cygrunsrv -Q sshd >/dev/null 2>&1 if /usr/bin/cygrunsrv -Q ${service_name} >/dev/null 2>&1
then then
csih_inform "Sshd service is already installed." csih_inform "Sshd service is already installed."
check_service_files_ownership "" || let ret+=$? check_service_files_ownership "" || let ret+=$?
@ -464,7 +465,7 @@ install_service() {
fi fi
if [ -z "${password}" ] if [ -z "${password}" ]
then then
if /usr/bin/cygrunsrv -I sshd -d "CYGWIN sshd" -p /usr/sbin/sshd \ if /usr/bin/cygrunsrv -I ${service_name} -d "CYGWIN ${service_name}" -p /usr/sbin/sshd \
-a "-D" -y tcpip "${cygwin_env[@]}" -a "-D" -y tcpip "${cygwin_env[@]}"
then then
echo echo
@ -474,20 +475,20 @@ 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 /usr/bin/cygrunsrv -I sshd -d "CYGWIN sshd" -p /usr/sbin/sshd \ if /usr/bin/cygrunsrv -I ${service_name} -d "CYGWIN ${service_name}" -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
/usr/bin/editrights -u "${run_service_as}" -a SeServiceLogonRight /usr/bin/editrights -u "${run_service_as}" -a SeServiceLogonRight
echo echo
csih_inform "The sshd service has been installed under the '${run_service_as}'" csih_inform "The sshd service has been installed under the '${run_service_as}'"
csih_inform "account. To start the service now, call \`net start sshd' or" csih_inform "account. To start the service now, call \`net start ${service_name}' or"
csih_inform "\`cygrunsrv -S sshd'. Otherwise, it will start automatically" csih_inform "\`cygrunsrv -S ${service_name}'. Otherwise, it will start automatically"
csih_inform "after the next reboot." csih_inform "after the next reboot."
fi fi
fi fi
if /usr/bin/cygrunsrv -Q sshd >/dev/null 2>&1 if /usr/bin/cygrunsrv -Q ${service_name} >/dev/null 2>&1
then then
check_service_files_ownership "${run_service_as}" || let ret+=$? check_service_files_ownership "${run_service_as}" || let ret+=$?
else else
@ -561,6 +562,11 @@ do
shift shift
;; ;;
-N | --name )
service_name=$1
shift
;;
-p | --port ) -p | --port )
port_number=$1 port_number=$1
shift shift
@ -590,6 +596,7 @@ do
echo " --yes -y Answer all questions with \"yes\" automatically." echo " --yes -y Answer all questions with \"yes\" automatically."
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 " --name -N <name> sshd windows service name."
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, default 'cyg_server'." echo " --user -u <account> privileged user for service, default 'cyg_server'."
echo " --pwd -w <passwd> Use \"pwd\" as password for privileged user." echo " --pwd -w <passwd> Use \"pwd\" as password for privileged user."