aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/env-update.c2
-rw-r--r--src/librc-daemon.c12
-rw-r--r--src/librc-depend.c12
-rw-r--r--src/librc-misc.c4
-rw-r--r--src/librc.c4
-rw-r--r--src/rc-plugin.c2
-rw-r--r--src/rc.c4
-rw-r--r--src/runscript.c15
-rw-r--r--src/start-stop-daemon.c2
9 files changed, 27 insertions, 30 deletions
diff --git a/src/env-update.c b/src/env-update.c
index f3f4f3b8..e0aa63f9 100644
--- a/src/env-update.c
+++ b/src/env-update.c
@@ -131,7 +131,7 @@ int main (int argc, char **argv)
"%s%s", isspecial_spaced ? " " : ":", value);
} else {
free (envs[k - 1]);
- envs[k - 1] = strdup (entry);
+ envs[k - 1] = rc_xstrdup (entry);
}
replaced = true;
}
diff --git a/src/librc-daemon.c b/src/librc-daemon.c
index 23dfc01a..b59460dd 100644
--- a/src/librc-daemon.c
+++ b/src/librc-daemon.c
@@ -305,21 +305,21 @@ void rc_set_service_daemon (const char *service, const char *exec,
mexec = rc_xmalloc (sizeof (char *) * i);
snprintf (mexec, i, "exec=%s", exec);
} else
- mexec = strdup ("exec=");
+ mexec = rc_xstrdup ("exec=");
if (name) {
i = strlen (name) + 6;
mname = rc_xmalloc (sizeof (char *) * i);
snprintf (mname, i, "name=%s", name);
} else
- mname = strdup ("name=");
+ mname = rc_xstrdup ("name=");
if (pidfile) {
i = strlen (pidfile) + 9;
mpidfile = rc_xmalloc (sizeof (char *) * i);
snprintf (mpidfile, i, "pidfile=%s", pidfile);
} else
- mpidfile = strdup ("pidfile=");
+ mpidfile = rc_xstrdup ("pidfile=");
/* Regardless, erase any existing daemon info */
if (rc_is_dir (dirpath)) {
@@ -479,15 +479,15 @@ bool rc_service_daemons_crashed (const char *service)
if (strcmp (token, "exec") == 0) {
if (exec)
free (exec);
- exec = strdup (p);
+ exec = rc_xstrdup (p);
} else if (strcmp (token, "name") == 0) {
if (name)
free (name);
- name = strdup (p);
+ name = rc_xstrdup (p);
} else if (strcmp (token, "pidfile") == 0) {
if (pidfile)
free (pidfile);
- pidfile = strdup (p);
+ pidfile = rc_xstrdup (p);
}
}
fclose (fp);
diff --git a/src/librc-depend.c b/src/librc-depend.c
index 1c3c764c..6aecd04f 100644
--- a/src/librc-depend.c
+++ b/src/librc-depend.c
@@ -109,7 +109,7 @@ rc_depinfo_t *rc_load_deptree (void)
depinfo = depinfo->next;
}
memset (depinfo, 0, sizeof (rc_depinfo_t));
- depinfo->service = strdup (e);
+ depinfo->service = rc_xstrdup (e);
deptype = NULL;
continue;
}
@@ -138,7 +138,7 @@ rc_depinfo_t *rc_load_deptree (void)
}
if (! deptype->type)
- deptype->type = strdup (type);
+ deptype->type = rc_xstrdup (type);
deptype->services = rc_strlist_addsort (deptype->services, e);
}
@@ -661,7 +661,7 @@ int rc_update_deptree (bool force)
depinfo = last_depinfo->next;
}
memset (depinfo, 0, sizeof (rc_depinfo_t));
- depinfo->service = strdup (service);
+ depinfo->service = rc_xstrdup (service);
}
/* We may not have any depends */
@@ -689,7 +689,7 @@ int rc_update_deptree (bool force)
deptype = last_deptype->next;
}
memset (deptype, 0, sizeof (rc_deptype_t));
- deptype->type = strdup (type);
+ deptype->type = rc_xstrdup (type);
}
/* Now add each depend to our type.
@@ -730,7 +730,7 @@ int rc_update_deptree (bool force)
last_depinfo->next = rc_xmalloc (sizeof (rc_depinfo_t));
di = last_depinfo->next;
memset (di, 0, sizeof (rc_depinfo_t));
- di->service = strdup (service);
+ di->service = rc_xstrdup (service);
}
}
}
@@ -779,7 +779,7 @@ int rc_update_deptree (bool force)
dt = last_deptype->next;
}
memset (dt, 0, sizeof (rc_deptype_t));
- dt->type = strdup (deppairs[i].addto);
+ dt->type = rc_xstrdup (deppairs[i].addto);
}
already_added = false;
diff --git a/src/librc-misc.c b/src/librc-misc.c
index b728e8c9..62000fa3 100644
--- a/src/librc-misc.c
+++ b/src/librc-misc.c
@@ -59,7 +59,7 @@ char *rc_xstrdup (const char *str)
if (! str)
return (NULL);
- value = strdup (str);
+ value = rc_xstrdup (str);
if (value)
return (value);
@@ -490,7 +490,7 @@ char **rc_filter_env (void)
/* Now go through the env var and only add bits not in our PREFIX */
sep = env_var;
while ((token = strsep (&sep, ":"))) {
- char *np = strdup (PATH_PREFIX);
+ char *np = rc_xstrdup (PATH_PREFIX);
char *npp = np;
char *tok = NULL;
while ((tok = strsep (&npp, ":")))
diff --git a/src/librc.c b/src/librc.c
index c2da2347..a0d09c7d 100644
--- a/src/librc.c
+++ b/src/librc.c
@@ -136,7 +136,7 @@ char *rc_resolve_service (const char *service)
r = readlink (file, buffer, sizeof (buffer));
free (file);
if (r > 0)
- return strdup (buffer);
+ return (rc_xstrdup (buffer));
}
snprintf (buffer, sizeof (buffer), RC_INITDIR "%s", service);
@@ -467,7 +467,7 @@ static pid_t _exec_service (const char *service, const char *arg)
}
if ((pid = fork ()) == 0) {
- char *myarg = strdup (arg);
+ char *myarg = rc_xstrdup (arg);
int e = 0;
execl (file, file, myarg, (char *) NULL);
e = errno;
diff --git a/src/rc-plugin.c b/src/rc-plugin.c
index d5476c81..8a39e97d 100644
--- a/src/rc-plugin.c
+++ b/src/rc-plugin.c
@@ -77,7 +77,7 @@ void rc_plugin_load (void)
plugin = plugins = rc_xmalloc (sizeof (plugin_t));
memset (plugin, 0, sizeof (plugin_t));
- plugin->name = strdup (file);
+ plugin->name = rc_xstrdup (file);
plugin->handle = h;
plugin->hook = f;
}
diff --git a/src/rc.c b/src/rc.c
index 4a583ad8..d2468dc2 100644
--- a/src/rc.c
+++ b/src/rc.c
@@ -161,7 +161,7 @@ static int do_e (int argc, char **argv)
}
if (message)
- fmt = strdup ("%s");
+ fmt = rc_xstrdup ("%s");
if (strcmp (applet, "einfo") == 0)
einfo (fmt, message);
@@ -482,7 +482,7 @@ int main (int argc, char **argv)
char ksoftbuffer [PATH_MAX];
if (argv[0])
- applet = strdup (basename (argv[0]));
+ applet = rc_xstrdup (basename (argv[0]));
if (! applet)
eerrorx ("arguments required");
diff --git a/src/runscript.c b/src/runscript.c
index 6f372270..4ebd7917 100644
--- a/src/runscript.c
+++ b/src/runscript.c
@@ -15,16 +15,13 @@
#include <dlfcn.h>
#include <errno.h>
#include <getopt.h>
+#include <libgen.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#ifndef __linux__
-#include <libgen.h>
-#endif
-
#include "einfo.h"
#include "rc.h"
#include "rc-misc.h"
@@ -802,7 +799,7 @@ static void svc_restart (const char *service, bool deps)
if (inactive) {
rc_schedule_start_service (service, svc);
ewarn ("WARNING: %s is scheduled to started when %s has started",
- svc, basename (service));
+ svc, applet);
} else
rc_start_service (svc);
}
@@ -821,11 +818,11 @@ static struct option longopts[] = {
{ "help", 0, NULL, 'h'},
{ NULL, 0, NULL, 0}
};
-#include "_usage.c"
+// #include "_usage.c"
int main (int argc, char **argv)
{
- const char *service = argv[1];
+ char *service = argv[1];
int i;
bool deps = true;
bool doneone = false;
@@ -840,7 +837,7 @@ int main (int argc, char **argv)
applet, strerror (errno));
}
- applet = strdup (basename (service));
+ applet = rc_xstrdup (basename (service));
atexit (cleanup);
#ifdef __linux__
@@ -956,7 +953,7 @@ int main (int argc, char **argv)
that is being called and not any dependents */
if (getenv ("IN_BACKGROUND")) {
in_background = rc_is_env ("IN_BACKGROUND", "true");
- ibsave = strdup (getenv ("IN_BACKGROUND"));
+ ibsave = rc_xstrdup (getenv ("IN_BACKGROUND"));
unsetenv ("IN_BACKGROUND");
}
diff --git a/src/start-stop-daemon.c b/src/start-stop-daemon.c
index 82270668..6bf54138 100644
--- a/src/start-stop-daemon.c
+++ b/src/start-stop-daemon.c
@@ -567,7 +567,7 @@ int main (int argc, char **argv)
char *cu = strsep (&p, ":");
struct passwd *pw = NULL;
- changeuser = strdup (cu);
+ changeuser = rc_xstrdup (cu);
if (sscanf (cu, "%d", &tid) != 1)
pw = getpwnam (cu);
else