]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/auth.c
Use systemd's sd_notify with option up_sdnotify
[ppp.git] / pppd / auth.c
index 7b269b805b2b7eb06ec9792c7e24c222a6c4b3c8..7457eda227bf19c2d09b79dd4e0b031da6bc1bf9 100644 (file)
 #endif
 #include <time.h>
 
+#ifdef SYSTEMD
+#include <systemd/sd-daemon.h>
+#endif
+
 #include "pppd.h"
 #include "fsm.h"
 #include "lcp.h"
@@ -553,6 +557,7 @@ link_required(unit)
 void start_link(unit)
     int unit;
 {
+    status = EXIT_CONNECT_FAILED;
     new_phase(PHASE_SERIALCONN);
 
     hungup = 0;
@@ -665,9 +670,11 @@ link_terminated(unit)
        (*the_channel->cleanup)();
 
     if (doing_multilink && multilink_master) {
-       if (!bundle_terminating)
+       if (!bundle_terminating) {
            new_phase(PHASE_MASTER);
-       else
+           if (master_detach && !detached)
+               detach();
+       } else
            mp_bundle_terminated();
     } else
        new_phase(PHASE_DEAD);
@@ -1096,8 +1103,15 @@ np_up(unit, proto)
        /*
         * Detach now, if the updetach option was given.
         */
-       if (updetach && !nodetach)
+       if (updetach && !nodetach) {
+           dbglog("updetach is set. Now detaching.");
            detach();
+#ifdef SYSTEMD
+       } else if (nodetach && up_sdnotify) {
+           dbglog("up_sdnotify is set. Now notifying systemd: READY=1");
+           sd_notify(0, "READY=1");
+#endif
+       }
     }
     ++num_np_up;
 }