Make run/task/service :ID optional, default to zero/NULL

This patch makes the ':ID' field optional when registering non-inetd
run/taks/service etc.  It has always been optional in the .conf files,
but internally we defaulted to ':1'.

To open up for more useful conditions we now default to zero/NULL :ID,
meaning the user now *must* keep track of the :ID field if they have
multiple services with the same name.  This should already have been
an issue since such services would likely have conflicted with their
PID files (same name).  So it's unlikely to affect any user severely.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2020-04-23 15:21:28 +02:00
1 parent 54e5fd2a78
commit 8fe4aad53e
2 files changed
+12 -10

No files matched your search

+7 -3
View File
@@ -100,7 +100,8 @@ svc_t *svc_new(char *cmd, char *id, int type)
svc->type = type;
svc->job = job;
strlcpy(svc->id, id, sizeof(svc->id));
if (id && id[0])
strlcpy(svc->id, id, sizeof(svc->id));
strlcpy(svc->cmd, cmd, sizeof(svc->cmd));
/* Default description, if missing */
@@ -535,7 +536,10 @@ int svc_enabled(svc_t *svc)
return 1;
}
/* Same base service, return unique ID as an integer */
/*
* Same base service, return unique ID as an integer
* Note: intended for use with INETD services.
*/
int svc_next_id_int(char *cmd)
{
int n = 1;
@@ -552,7 +556,7 @@ int svc_next_id_int(char *cmd)
n++;
}
return 0;
return 1;
}
int svc_is_unique(svc_t *svc)