aboutsummaryrefslogtreecommitdiff
path: root/lib/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src')
-rw-r--r--lib/src/rdsvc.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/src/rdsvc.c b/lib/src/rdsvc.c
index 54c6d24..ee898c3 100644
--- a/lib/src/rdsvc.c
+++ b/lib/src/rdsvc.c
@@ -28,14 +28,6 @@
#include "service.h"
#include "util.h"
-static int svc_name(service_t *svc, char *arg,
- const char *filename, size_t lineno)
-{
- (void)filename; (void)lineno;
- svc->name = arg;
- return 0;
-}
-
static int svc_desc(service_t *svc, char *arg,
const char *filename, size_t lineno)
{
@@ -166,7 +158,6 @@ static const struct {
int (*handle)(service_t *svc, char *arg,
const char *filename, size_t lineno);
} svc_params[] = {
- { "name", svc_name },
{ "description", svc_desc },
{ "exec", svc_exec },
{ "type", svc_type },
@@ -207,6 +198,19 @@ service_t *rdsvc(int dirfd, const char *filename)
return NULL;
}
+ if (arg != NULL) {
+ svc->name = strndup(filename, arg - filename);
+ } else {
+ svc->name = strdup(filename);
+ }
+
+ if (svc->name == NULL) {
+ free(svc);
+ fputs("out of memory\n", stderr);
+ close(fd);
+ return NULL;
+ }
+
for (lineno = 1; ; ++lineno) {
errno = 0;
line = rdline(fd);