mirror of
https://github.com/troglobit/finit.git
synced 2026-10-17 10:49:34 +00:00
Warn if a new service asserts the same condition as an existing one
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
b175b4a2ae
commit
5fbcf6814c
3 files changed
+37
-3
No files matched your search
@@ -141,6 +141,37 @@ int svc_del(svc_t *svc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* svc_validate - Check if service asserts same condition as another service
|
||||
* @svc: Pointer to an &svc_t object
|
||||
*
|
||||
* Logs to syslog if there is a name clash with existing services.
|
||||
*/
|
||||
void svc_validate(svc_t *svc)
|
||||
{
|
||||
char ident[MAX_IDENT_LEN];
|
||||
char cond[MAX_COND_LEN];
|
||||
svc_t *iter = NULL;
|
||||
svc_t *s;
|
||||
|
||||
mkcond(svc, cond, sizeof(cond));
|
||||
svc_ident(svc, ident, sizeof(ident));
|
||||
|
||||
for (s = svc_iterator(&iter, 1); s; s = svc_iterator(&iter, 0)) {
|
||||
char c[MAX_COND_LEN];
|
||||
|
||||
if (s == svc)
|
||||
continue;
|
||||
|
||||
mkcond(s, c, sizeof(c));
|
||||
if (!string_compare(cond, c))
|
||||
continue;
|
||||
|
||||
logit(LOG_WARNING, "%s (%s) asserts the same condition as %s (%s) => %s",
|
||||
svc->cmd, ident, s->cmd, svc_ident(s, NULL, 0), c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* svc_iterator - Naive iterator over all registered services.
|
||||
* @iter: Iterator, must be a valid pointer
|
||||
|
||||
Reference in new issue
Block a user