Improve diagnostic on attempt to add dependency from service to itself
authorDavin McCall <davmac@davmac.org>
Sun, 21 Jun 2020 11:01:50 +0000 (21:01 +1000)
committerDavin McCall <davmac@davmac.org>
Sun, 21 Jun 2020 11:01:50 +0000 (21:01 +1000)
src/dinitctl.cc

index b884be31aa57afa830d6d155d0a78eb835d18b87..6077bf11a0f2c76f4357eb25a19f731131d2755f 100644 (file)
@@ -978,6 +978,11 @@ static int add_remove_dependency(int socknum, cpbuffer_t &rbuffer, bool add,
         return 1;
     }
 
+    if (from_handle == to_handle) {
+        cerr << "dinitctl: Can not add/remove a dependency from a service to itself" << endl;
+        return 1;
+    }
+
     auto m = membuf()
             .append<char>(add ? (char)DINIT_CP_ADD_DEP : (char)DINIT_CP_REM_DEP)
             .append(static_cast<char>(dep_type))