[PATCH 1/2] Use systemd to startup sshd when desired

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds another chunk to the anaconda-generator that will figure out
what services go where.  In this case, we enable the sshd service when
inst.sshd or sshd is found as a command line option, or if we're on
s390x (because the console sucks there).
---
 data/systemd/Makefile.am           |    2 +-
 data/systemd/anaconda-generator    |   12 ++++++++++++
 data/systemd/anaconda-sshd.service |   10 ++++++++++
 dracut/parse-anaconda-options.sh   |    3 +++
 4 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 data/systemd/anaconda-sshd.service

diff --git a/data/systemd/Makefile.am b/data/systemd/Makefile.am
index ae89c18..108d7e5 100644
--- a/data/systemd/Makefile.am
+++ b/data/systemd/Makefile.am
@@ -19,6 +19,6 @@
 
 systemddir = /lib/systemd/system
 generatordir = /lib/systemd/system-generators
-dist_systemd_DATA = anaconda-shell@.service anaconda.target anaconda@.service instperf.service
+dist_systemd_DATA = anaconda-shell@.service anaconda.target anaconda@.service instperf.service anaconda-sshd.service
 dist_generator_SCRIPTS = anaconda-generator
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/data/systemd/anaconda-generator b/data/systemd/anaconda-generator
index 6545572..cb47040 100755
--- a/data/systemd/anaconda-generator
+++ b/data/systemd/anaconda-generator
@@ -1,6 +1,9 @@
 #!/bin/bash
 # anaconda-generator: generate services needed for anaconda operation
 
+# Source in the dracut lib so we can parse cmd line arguments
+. /run/initramfs/usr/lib/dracut-lib.sh
+
 # set up dirs
 systemd_dir=/lib/systemd/system
 target_dir=$systemd_dir/anaconda.target.wants
@@ -32,3 +35,12 @@ for tty in tty2 hvc0 hvc1 xvc0 hvsi0 hvsi1 hvsi2; do
         [ "$tty" != "tty2" ] && break
     fi
 done
+
+# enable the ssh service
+# NOTE: We have a match for s390x here because the console sucks on that
+# platform.  Really any platform with a crappy console that can't do curses
+# or have multiple VTs should get sshd spawned automatically, but we don't
+# yet have a good way of detecting these platforms.
+if getargbool 0 inst.sshd || [ $(uname -m) = "s390x" ]; then
+    ln -sf $systemd_dir/anaconda-sshd.service $target_dir/anaconda-sshd.service
+fi
diff --git a/data/systemd/anaconda-sshd.service b/data/systemd/anaconda-sshd.service
new file mode 100644
index 0000000..ca1f87c
--- /dev/null
+++ b/data/systemd/anaconda-sshd.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=OpenSSH server daemon
+Before=anaconda.target
+After=syslog.target network.target
+
+[Service]
+EnvironmentFile=/etc/sysconfig/sshd
+ExecStartPre=/usr/sbin/sshd-keygen
+ExecStart=/usr/sbin/sshd -D $OPTIONS -f /etc/ssh/sshd_config.anaconda
+ExecReload=/bin/kill -HUP $MAINPID
diff --git a/dracut/parse-anaconda-options.sh b/dracut/parse-anaconda-options.sh
index 1343ebc..2fb82a3 100755
--- a/dracut/parse-anaconda-options.sh
+++ b/dracut/parse-anaconda-options.sh
@@ -74,6 +74,9 @@ check_removed_arg() {
 check_depr_args "blacklist=" "inst.blacklist=%s"
 check_depr_arg "nofirewire" "inst.blacklist=firewire_ohci"
 
+# ssh
+check_depr_arg "sshd" "inst.sshd"
+
 # serial was never supposed to be used for anything!
 check_removed_arg serial "To change the console use 'console=' instead."
 # USB is built-in and can't be disabled anymore. DEAL WITH IT.
-- 
1.7.10.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux