From 71b59c918b144f7e39fdaada94a5b0303e195dde Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Sun, 21 Jun 2020 21:01:50 +1000 Subject: [PATCH] Improve diagnostic on attempt to add dependency from service to itself --- src/dinitctl.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dinitctl.cc b/src/dinitctl.cc index b884be3..6077bf1 100644 --- a/src/dinitctl.cc +++ b/src/dinitctl.cc @@ -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(add ? (char)DINIT_CP_ADD_DEP : (char)DINIT_CP_REM_DEP) .append(static_cast(dep_type)) -- 2.25.1