From 6ff4a83d591c77acc268db8a5b8c0b2011adbf31 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 13 Apr 2007 16:00:25 +0000 Subject: More basename compliance. --- src/librc-daemon.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/librc-daemon.c') diff --git a/src/librc-daemon.c b/src/librc-daemon.c index 4473cc16..23dfc01a 100644 --- a/src/librc-daemon.c +++ b/src/librc-daemon.c @@ -284,7 +284,8 @@ void rc_set_service_daemon (const char *service, const char *exec, const char *name, const char *pidfile, bool started) { - char *dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename (service), + char *svc = rc_xstrdup (service); + char *dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename (svc), (char *) NULL); char **files = NULL; char *file; @@ -295,6 +296,7 @@ void rc_set_service_daemon (const char *service, const char *exec, char *mpidfile; int nfiles = 0; + free (svc); if (! exec && ! name && ! pidfile) return; @@ -379,12 +381,16 @@ bool rc_service_started_daemon (const char *service, const char *exec, int i; char *mexec; bool retval = false; + char *svc; if (! service || ! exec) return (false); - dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename (service), + svc = rc_xstrdup (service); + dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename (svc), (char *) NULL); + free (svc); + if (! rc_is_dir (dirpath)) { free (dirpath); return (false); @@ -432,12 +438,16 @@ bool rc_service_daemons_crashed (const char *service) char *p; char *token; bool retval = false; + char *svc; if (! service) return (false); - dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename (service), + svc = rc_xstrdup (service); + dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename (svc), (char *) NULL); + free (svc); + if (! rc_is_dir (dirpath)) { free (dirpath); return (false); -- cgit v1.2.3