]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
Detect errors when starting tftpd
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 17 Jul 2014 11:46:57 +0000 (13:46 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 17 Jul 2014 14:10:04 +0000 (16:10 +0200)
No we start tftpd without forking in novaboot (but in tftpd itself), which
allows us to detect when it does not start correctly. For example when
a system daemon already runs.

README.md
novaboot
sudoers.novaboot

index e4191898b243eb469cb0126eae00d63b80edb5ed..76942db5c053cc42d1286167e52313bd69e15e6b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -317,7 +317,7 @@ to a particular location, e.g. to a TFTP boot server or to the
     _/etc/sudoers_ to allow running the necessary commands without
     asking for password.
 
-        Cmnd_Alias NOVABOOT = /bin/ip a add 10.23.23.1/24 dev eth0, /bin/ip l set dev eth0 up, /usr/sbin/dhcpd -d -cf dhcpd.conf -lf dhcpd.leases -pf dhcpd.pid, /usr/sbin/in.tftpd --foreground --secure -v -v -v --pidfile tftpd.pid *, /usr/bin/touch dhcpd.leases, /usr/bin/pkill --pidfile=dhcpd.pid, /usr/bin/pkill --pidfile=tftpd.pid
+        Cmnd_Alias NOVABOOT = /bin/ip a add 10.23.23.1/24 dev eth0, /bin/ip l set dev eth0 up, /usr/sbin/dhcpd -d -cf dhcpd.conf -lf dhcpd.leases -pf dhcpd.pid, /usr/sbin/in.tftpd --listen --secure -v -v -v --pidfile tftpd.pid *, /usr/bin/touch dhcpd.leases, /usr/bin/pkill --pidfile=dhcpd.pid, /usr/bin/pkill --pidfile=tftpd.pid
         your_login ALL=NOPASSWD: NOVABOOT
 
 - --tftp
@@ -330,7 +330,7 @@ to a particular location, e.g. to a TFTP boot server or to the
     the following to _/etc/sudoers_ to allow running the necessary
     commands without asking for password.
 
-        Cmnd_Alias NOVABOOT =  /usr/sbin/in.tftpd --foreground --secure -v -v -v --pidfile tftpd.pid *, /usr/bin/pkill --pidfile=tftpd.pid
+        Cmnd_Alias NOVABOOT =  /usr/sbin/in.tftpd --listen --secure -v -v -v --pidfile tftpd.pid *, /usr/bin/pkill --pidfile=tftpd.pid
         your_login ALL=NOPASSWD: NOVABOOT
 
 - --iso\[=filename\]
index 1909fd046f63bce262c226badcc9deeba5140987..4d9c8fbb8786b9931686ab5846745869c9c35bf2 100755 (executable)
--- a/novaboot
+++ b/novaboot
@@ -903,12 +903,14 @@ host server {
 }
 
 if (defined $dhcp_tftp || defined $tftp) {
-    $tftpd_pid = fork();
-    exec_verbose("sudo in.tftpd --foreground --secure -v -v -v --pidfile tftpd.pid $builddir") if ($tftpd_pid == 0);
+    system_verbose("sudo in.tftpd --listen --secure -v -v -v --pidfile tftpd.pid $builddir");
 
     # Kill server when we die
     $SIG{__DIE__} = sub { system_verbose('sudo pkill --pidfile=dhcpd.pid') if (defined $dhcp_tftp);
                          system_verbose('sudo pkill --pidfile=tftpd.pid'); };
+
+    # We have to kill tftpd explicitely, because it is not in our process group
+    $SIG{INT} = sub { system_verbose('sudo pkill --pidfile=tftpd.pid'); exit(0); };
 }
 
 ### Reset target (IP relay, AMT, ...)
@@ -1366,7 +1368,7 @@ uses C<sudo> command to obtain those. You can put the following to
 I</etc/sudoers> to allow running the necessary commands without
 asking for password.
 
- Cmnd_Alias NOVABOOT = /bin/ip a add 10.23.23.1/24 dev eth0, /bin/ip l set dev eth0 up, /usr/sbin/dhcpd -d -cf dhcpd.conf -lf dhcpd.leases -pf dhcpd.pid, /usr/sbin/in.tftpd --foreground --secure -v -v -v --pidfile tftpd.pid *, /usr/bin/touch dhcpd.leases, /usr/bin/pkill --pidfile=dhcpd.pid, /usr/bin/pkill --pidfile=tftpd.pid
+ Cmnd_Alias NOVABOOT = /bin/ip a add 10.23.23.1/24 dev eth0, /bin/ip l set dev eth0 up, /usr/sbin/dhcpd -d -cf dhcpd.conf -lf dhcpd.leases -pf dhcpd.pid, /usr/sbin/in.tftpd --listen --secure -v -v -v --pidfile tftpd.pid *, /usr/bin/touch dhcpd.leases, /usr/bin/pkill --pidfile=dhcpd.pid, /usr/bin/pkill --pidfile=tftpd.pid
  your_login ALL=NOPASSWD: NOVABOOT
 
 =item --tftp
@@ -1379,7 +1381,7 @@ port and C<novaboot> uses C<sudo> command to obtain those. You can put
 the following to I</etc/sudoers> to allow running the necessary
 commands without asking for password.
 
- Cmnd_Alias NOVABOOT =  /usr/sbin/in.tftpd --foreground --secure -v -v -v --pidfile tftpd.pid *, /usr/bin/pkill --pidfile=tftpd.pid
+ Cmnd_Alias NOVABOOT =  /usr/sbin/in.tftpd --listen --secure -v -v -v --pidfile tftpd.pid *, /usr/bin/pkill --pidfile=tftpd.pid
  your_login ALL=NOPASSWD: NOVABOOT
 
 =item --iso[=filename]
index 4404cc01b72071ed4f01a5487113a898d615412e..961ebc416855085a5edd06fb86ec063e3a5feada 100644 (file)
@@ -5,5 +5,5 @@
 # your_login ALL=NOPASSWD: NOVABOOT_DHCP
 
 # Uncomment the following lines to enable --dhcp-tftp and --tftp options
-# Cmnd_Alias NOVABOOT_TFTP =  /usr/sbin/in.tftpd --foreground --secure -v -v -v --pidfile tftpd.pid *, /usr/bin/pkill --pidfile=tftpd.pid
+# Cmnd_Alias NOVABOOT_TFTP =  /usr/sbin/in.tftpd --listen --secure -v -v -v --pidfile tftpd.pid *, /usr/bin/pkill --pidfile=tftpd.pid
 # your_login ALL=NOPASSWD: NOVABOOT_TFTP