From: Davin McCall Date: Sun, 21 Jun 2020 11:01:50 +0000 (+1000) Subject: Improve diagnostic on attempt to add dependency from service to itself X-Git-Tag: v0.8.2~4 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=71b59c918b144f7e39fdaada94a5b0303e195dde;p=oweals%2Fdinit.git Improve diagnostic on attempt to add dependency from service to itself --- 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))