Accepting request 94377 from home:elvigia:branches:network

- Add systemd startup units

OBS-URL: https://build.opensuse.org/request/show/94377
OBS-URL: https://build.opensuse.org/package/show/network/openssh?expand=0&rev=16
This commit is contained in:
Minh Ngo 2011-11-29 19:55:10 +00:00 committed by Git OBS Bridge
parent e4e9974691
commit 2401590e48
4 changed files with 67 additions and 0 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Nov 29 19:48:29 UTC 2011 - crrodriguez@opensuse.org
- Add systemd startup units
-------------------------------------------------------------------
Sat Oct 29 22:41:55 UTC 2011 - pcerny@suse.com

View File

@ -44,6 +44,8 @@ Source7: ssh.reg
Source8: ssh-askpass
Source9: sshd.fw
Source10: sysconfig.ssh
Source11: sshd-gen-keys-start
Source12: sshd.service
Patch: %{name}-5.9p1-sshd_config.diff
Patch1: %{name}-5.9p1-askpass-fix.diff
Patch2: %{name}-5.9p1-pam-fix2.diff
@ -64,6 +66,11 @@ Patch18: %{name}-5.9p1-sshconfig-knownhostschanges.diff
Patch19: %{name}-5.9p1-host_ident.diff
Patch20: converter-linking.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} > 1140
BuildRequires: systemd
%{?systemd_requires}
%define has_systemd 1
%endif
%package askpass
License: BSD3c(or similar) ; MIT License (or similar)
@ -175,20 +182,36 @@ sed -i -e s@/usr/libexec@%{_libexecdir}@g %{buildroot}%{_sysconfdir}/ssh/sshd_co
#%{_datadir}/SuSEfirewall2/services/TEMPLATE
mkdir -p %{buildroot}%{_fwdefdir}
install -m 644 %{S:9} %{buildroot}%{_fwdefdir}/sshd
%if 0%{?has_systemd}
install -D -m 0755 %{SOURCE11} %{buildroot}%{_sbindir}/sshd-gen-keys-start
install -D -m 0644 %{SOURCE12} %{buildroot}%{_unitdir}/sshd.service
%endif
%pre
getent group sshd >/dev/null || %{_sbindir}/groupadd -o -r sshd
getent passwd sshd >/dev/null || %{_sbindir}/useradd -r -g sshd -d /var/lib/sshd -s /bin/false -c "SSH daemon" sshd
%if 0%{?has_systemd}
%service_add_pre sshd.service
%endif
%post
%{fillup_and_insserv -n ssh sshd}
%if 0%{?has_systemd}
%service_add_post sshd.service
%endif
%preun
%stop_on_removal sshd
%if 0%{?has_systemd}
%service_del_preun sshd.service
%endif
%postun
%restart_on_update sshd
%{insserv_cleanup}
%if 0%{?has_systemd}
%service_del_postun sshd.service
%endif
%files
%defattr(-,root,root)
@ -226,6 +249,10 @@ getent passwd sshd >/dev/null || %{_sbindir}/useradd -r -g sshd -d /var/lib/sshd
%config %{_sysconfdir}/slp.reg.d/ssh.reg
/var/adm/fillup-templates/sysconfig.ssh
%config %{_fwdefdir}/sshd
%if 0%{?has_systemd}
%{_sbindir}/sshd-gen-keys-start
%{_unitdir}/sshd.service
%endif
%files askpass
%defattr(-,root,root)

21
sshd-gen-keys-start Normal file
View File

@ -0,0 +1,21 @@
#!/bin/bash
if ! grep -q '^[[:space:]]*HostKey[[:space:]]' /etc/ssh/sshd_config; then
if ! test -f /etc/ssh/ssh_host_key ; then
echo Generating /etc/ssh/ssh_host_key.
ssh-keygen -t rsa1 -b 2048 -f /etc/ssh/ssh_host_key -N ''
fi
if ! test -f /etc/ssh/ssh_host_dsa_key ; then
echo Generating /etc/ssh/ssh_host_dsa_key.
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
fi
if ! test -f /etc/ssh/ssh_host_rsa_key ; then
echo Generating /etc/ssh/ssh_host_rsa_key.
ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N ''
fi
if ! test -f /etc/ssh/ssh_host_ecdsa_key ; then
echo Generating /etc/ssh/ssh_host_ecdsa_key.
ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N ''
fi
fi

14
sshd.service Normal file
View File

@ -0,0 +1,14 @@
[Unit]
Description=OpenSSH Daemon
After=syslog.target network.target
[Service]
EnvironmentFile=/etc/sysconfig/ssh
ExecStartPre=/usr/sbin/sshd-gen-keys-start
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
[Install]
WantedBy=multi-user.target