aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-04-05 15:01:09 +0000
committerRoy Marples <roy@marples.name>2007-04-05 15:01:09 +0000
commit308042c87bd920d787265f1854bf1695bdbab8e4 (patch)
treed82ee57f02e53c08bd5d66909d326942a4bb9fba /src
parent6fb700e52c1684637dcc77a89ea2fc7a1b2050b1 (diff)
We now compile on OpenBSD (no idea if it works or not yet)
Diffstat (limited to 'src')
-rw-r--r--src/env-update.c2
-rw-r--r--src/librc-daemon.c37
-rw-r--r--src/librc-depend.c5
-rw-r--r--src/librc-misc.c5
-rw-r--r--src/librc.c75
-rw-r--r--src/rc.c27
-rw-r--r--src/rc.h6
-rw-r--r--src/runscript.c27
-rw-r--r--src/start-stop-daemon.c4
9 files changed, 112 insertions, 76 deletions
diff --git a/src/env-update.c b/src/env-update.c
index c04974b1..8be37b8d 100644
--- a/src/env-update.c
+++ b/src/env-update.c
@@ -79,7 +79,7 @@ int main (int argc, char **argv)
STRLIST_FOREACH (files, file, i)
{
- char *path = rc_strcatpaths (ENVDIR, file, NULL);
+ char *path = rc_strcatpaths (ENVDIR, file, (char *) NULL);
char **entries = NULL;
char *entry;
int j;
diff --git a/src/librc-daemon.c b/src/librc-daemon.c
index 02d0d937..13362d8c 100644
--- a/src/librc-daemon.c
+++ b/src/librc-daemon.c
@@ -8,7 +8,8 @@
#include <sys/types.h>
#include <sys/stat.h>
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined (__OpenBSD__)
+#if defined(__DragonFly__) || defined(__FreeBSD__) || \
+ defined(__NetBSD__) || defined (__OpenBSD__)
#include <sys/param.h>
#include <sys/user.h>
#include <sys/sysctl.h>
@@ -178,18 +179,20 @@ pid_t *rc_find_pids (const char *exec, const char *cmd,
return (pids);
}
-#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#elif defined(__DragonFly__) || defined(__FreeBSD__) || \
+ defined(__NetBSD__) || defined(__OpenBSD__)
-# if defined(__FreeBSD__)
+# if defined(__DragonFly__) || defined(__FreeBSD__)
+# ifndef KERN_PROC_PROC
+# define KERN_PROC_PROC KERN_PROC_ALL
+# endif
# define _KINFO_PROC kinfo_proc
-# define _KVM_GETPROCS kvm_getprocs
# define _KVM_GETARGV kvm_getargv
# define _GET_KINFO_UID(kp) (kp.ki_ruid)
# define _GET_KINFO_COMM(kp) (kp.ki_comm)
# define _GET_KINFO_PID(kp) (kp.ki_pid)
# else
# define _KINFO_PROC kinfo_proc2
-# define _KVM_GETPROCS kvm_getprocs2
# define _KVM_GETARGV kvm_getargv2
# define _GET_KINFO_UID(kp) (kp.p_ruid)
# define _GET_KINFO_COMM(kp) (kp.p_comm)
@@ -212,7 +215,12 @@ pid_t *rc_find_pids (const char *exec, const char *cmd,
if ((kd = kvm_openfiles (NULL, NULL, NULL, O_RDONLY, errbuf)) == NULL)
eerrorx ("kvm_open: %s", errbuf);
- kp = _KVM_GETPROCS (kd, KERN_PROC_PROC, 0, &processes);
+#if defined(__DragonFly__) || defined( __FreeBSD__)
+ kp = kvm_getprocs (kd, KERN_PROC_PROC, 0, &processes);
+#else
+ kp = kvm_getproc2 (kd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc2),
+ &processes);
+#endif
for (i = 0; i < processes; i++)
{
pid_t p = _GET_KINFO_PID (kp[i]);
@@ -260,7 +268,7 @@ static bool _match_daemon (const char *path, const char *file,
const char *mpidfile)
{
char buffer[RC_LINEBUFFER];
- char *ffile = rc_strcatpaths (path, file, NULL);
+ char *ffile = rc_strcatpaths (path, file, (char *) NULL);
FILE *fp;
int lc = 0;
int m = 0;
@@ -314,7 +322,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), NULL);
+ char *dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename (service),
+ (char *) NULL);
char **files = NULL;
char *file;
char *ffile = NULL;
@@ -361,7 +370,7 @@ void rc_set_service_daemon (const char *service, const char *exec,
files = rc_ls_dir (NULL, dirpath, 0);
STRLIST_FOREACH (files, file, i)
{
- ffile = rc_strcatpaths (dirpath, file, NULL);
+ ffile = rc_strcatpaths (dirpath, file, (char *) NULL);
nfiles++;
if (! oldfile)
@@ -396,7 +405,7 @@ void rc_set_service_daemon (const char *service, const char *exec,
eerror ("mkdir `%s': %s", dirpath, strerror (errno));
snprintf (buffer, sizeof (buffer), "%03d", nfiles + 1);
- file = rc_strcatpaths (dirpath, buffer, NULL);
+ file = rc_strcatpaths (dirpath, buffer, (char *) NULL);
if ((fp = fopen (file, "w")) == NULL)
eerror ("fopen `%s': %s", file, strerror (errno));
else
@@ -425,7 +434,8 @@ bool rc_service_started_daemon (const char *service, const char *exec,
if (! service || ! exec)
return (false);
- dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename (service), NULL);
+ dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename (service),
+ (char *) NULL);
if (! rc_is_dir (dirpath))
{
free (dirpath);
@@ -480,7 +490,8 @@ bool rc_service_daemons_crashed (const char *service)
if (! service)
return (false);
- dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename (service), NULL);
+ dirpath = rc_strcatpaths (RC_SVCDIR, "daemons", basename (service),
+ (char *) NULL);
if (! rc_is_dir (dirpath))
{
free (dirpath);
@@ -491,7 +502,7 @@ bool rc_service_daemons_crashed (const char *service)
files = rc_ls_dir (NULL, dirpath, 0);
STRLIST_FOREACH (files, file, i)
{
- path = rc_strcatpaths (dirpath, file, NULL);
+ path = rc_strcatpaths (dirpath, file, (char *) NULL);
fp = fopen (path, "r");
free (path);
if (! fp)
diff --git a/src/librc-depend.c b/src/librc-depend.c
index 0da93aa5..707b954a 100644
--- a/src/librc-depend.c
+++ b/src/librc-depend.c
@@ -489,7 +489,8 @@ char **rc_order_services (rc_depinfo_t *deptree, const char *runlevel,
/* If we're not the boot runlevel then add that too */
if (strcmp (runlevel, RC_LEVEL_BOOT) != 0)
{
- char *path = rc_strcatpaths (RC_RUNLEVELDIR, RC_LEVEL_BOOT, NULL);
+ char *path = rc_strcatpaths (RC_RUNLEVELDIR, RC_LEVEL_BOOT,
+ (char *) NULL);
list = rc_ls_dir (list, path, RC_LS_INITD);
free (path);
}
@@ -534,7 +535,7 @@ static bool is_newer_than (const char *file, const char *target)
bool newer = true;
STRLIST_FOREACH (targets, t, i)
{
- char *path = rc_strcatpaths (target, t, NULL);
+ char *path = rc_strcatpaths (target, t, (char *) NULL);
newer = is_newer_than (file, path);
free (path);
if (! newer)
diff --git a/src/librc-misc.c b/src/librc-misc.c
index 604c5518..69b717c8 100644
--- a/src/librc-misc.c
+++ b/src/librc-misc.c
@@ -237,7 +237,8 @@ char **rc_ls_dir (char **list, const char *dir, int options)
if (options & RC_LS_INITD)
{
int l = strlen (d->d_name);
- char *init = rc_strcatpaths (RC_INITDIR, d->d_name, NULL);
+ char *init = rc_strcatpaths (RC_INITDIR, d->d_name,
+ (char *) NULL);
bool ok = rc_exists (init);
free (init);
if (! ok)
@@ -283,7 +284,7 @@ bool rc_rm_dir (const char *pathname, bool top)
{
if (strcmp (d->d_name, ".") != 0 && strcmp (d->d_name, "..") != 0)
{
- char *tmp = rc_strcatpaths (pathname, d->d_name, NULL);
+ char *tmp = rc_strcatpaths (pathname, d->d_name, (char *) NULL);
if (d->d_type == DT_DIR)
{
if (! rc_rm_dir (tmp, true))
diff --git a/src/librc.c b/src/librc.c
index d9c4a539..8e8f4ea5 100644
--- a/src/librc.c
+++ b/src/librc.c
@@ -69,7 +69,7 @@ char **rc_get_runlevels (void)
STRLIST_FOREACH (dirs, dir, i)
{
- char *path = rc_strcatpaths (RC_RUNLEVELDIR, dir, NULL);
+ char *path = rc_strcatpaths (RC_RUNLEVELDIR, dir, (char *) NULL);
if (rc_is_dir (path))
runlevels = rc_strlist_addsort (runlevels, dir);
free (path);
@@ -121,7 +121,7 @@ bool rc_runlevel_exists (const char *runlevel)
if (! runlevel)
return (false);
- path = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, NULL);
+ path = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, (char *) NULL);
retval = rc_is_dir (path);
free (path);
return (retval);
@@ -140,11 +140,11 @@ char *rc_resolve_service (const char *service)
if (service[0] == '/')
return (strdup (service));
- file = rc_strcatpaths (RC_SVCDIR, "started", service, NULL);
+ file = rc_strcatpaths (RC_SVCDIR, "started", service, (char *) NULL);
if (! rc_is_link (file))
{
free (file);
- file = rc_strcatpaths (RC_SVCDIR, "inactive", service, NULL);
+ file = rc_strcatpaths (RC_SVCDIR, "inactive", service, (char *) NULL);
if (! rc_is_link (file))
{
free (file);
@@ -200,7 +200,8 @@ bool rc_service_in_runlevel (const char *service, const char *runlevel)
if (! rc_service_exists (service))
return (false);
- file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename (service), NULL);
+ file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename (service),
+ (char *) NULL);
retval = rc_exists (file);
free (file);
@@ -229,7 +230,8 @@ bool rc_mark_service (const char *service, const rc_service_state_t state)
return (false);
}
- file = rc_strcatpaths (RC_SVCDIR, rc_service_state_names[state], base, NULL);
+ file = rc_strcatpaths (RC_SVCDIR, rc_service_state_names[state], base,
+ (char *) NULL);
if (rc_exists (file))
unlink (file);
i = symlink (init, file);
@@ -262,7 +264,8 @@ bool rc_mark_service (const char *service, const rc_service_state_t state)
i != rc_service_crashed) &&
(! skip_wasinactive || i != rc_service_wasinactive))
{
- file = rc_strcatpaths (RC_SVCDIR, rc_service_state_names[i], base, NULL);
+ file = rc_strcatpaths (RC_SVCDIR, rc_service_state_names[i], base,
+ (char *) NULL);
if (rc_exists (file))
{
if ((state == rc_service_starting ||
@@ -271,7 +274,7 @@ bool rc_mark_service (const char *service, const rc_service_state_t state)
{
char *wasfile = rc_strcatpaths (RC_SVCDIR,
rc_service_state_names[rc_service_wasinactive],
- base, NULL);
+ base, (char *) NULL);
if (symlink (init, wasfile) != 0)
eerror ("symlink `%s' to `%s': %s", init, wasfile,
@@ -296,7 +299,7 @@ bool rc_mark_service (const char *service, const rc_service_state_t state)
state == rc_service_stopped ||
state == rc_service_inactive)
{
- file = rc_strcatpaths (RC_SVCDIR, "exclusive", base, NULL);
+ file = rc_strcatpaths (RC_SVCDIR, "exclusive", base, (char *) NULL);
if (rc_exists (file))
if (unlink (file) != 0)
eerror ("unlink `%s': %s", file, strerror (errno));
@@ -306,13 +309,13 @@ bool rc_mark_service (const char *service, const rc_service_state_t state)
/* Remove any options and daemons the service may have stored */
if (state == rc_service_stopped)
{
- char *dir = rc_strcatpaths (RC_SVCDIR, "options", base, NULL);
+ char *dir = rc_strcatpaths (RC_SVCDIR, "options", base, (char *) NULL);
if (rc_is_dir (dir))
rc_rm_dir (dir, true);
free (dir);
- dir = rc_strcatpaths (RC_SVCDIR, "daemons", base, NULL);
+ dir = rc_strcatpaths (RC_SVCDIR, "daemons", base, (char *) NULL);
if (rc_is_dir (dir))
rc_rm_dir (dir, true);
free (dir);
@@ -323,15 +326,15 @@ bool rc_mark_service (const char *service, const rc_service_state_t state)
/* These are final states, so remove us from scheduled */
if (state == rc_service_started || state == rc_service_stopped)
{
- char *sdir = rc_strcatpaths (RC_SVCDIR, "scheduled", NULL);
+ char *sdir = rc_strcatpaths (RC_SVCDIR, "scheduled", (char *) NULL);
char **dirs = rc_ls_dir (NULL, sdir, 0);
char *dir;
int serrno;
STRLIST_FOREACH (dirs, dir, i)
{
- char *bdir = rc_strcatpaths (sdir, dir, NULL);
- file = rc_strcatpaths (bdir, base, NULL);
+ char *bdir = rc_strcatpaths (sdir, dir, (char *) NULL);
+ file = rc_strcatpaths (bdir, base, (char *) NULL);
if (rc_exists (file))
if (unlink (file) != 0)
eerror ("unlink `%s': %s", file, strerror (errno));
@@ -382,7 +385,7 @@ bool rc_service_state (const char *service, const rc_service_state_t state)
/* Now we just check if a file by the service name rc_exists
in the state dir */
file = rc_strcatpaths (RC_SVCDIR, rc_service_state_names[state],
- basename (service), NULL);
+ basename (service), (char*) NULL);
retval = rc_exists (file);
free (file);
return (retval);
@@ -392,8 +395,9 @@ bool rc_get_service_option (const char *service, const char *option,
char *value)
{
FILE *fp;
- char buffer[1024];
- char *file = rc_strcatpaths (RC_SVCDIR, "options", service, option, NULL);
+ char buffer[RC_LINEBUFFER];
+ char *file = rc_strcatpaths (RC_SVCDIR, "options", service, option,
+ (char *) NULL);
bool retval = false;
if (rc_exists (file))
@@ -421,8 +425,8 @@ bool rc_set_service_option (const char *service, const char *option,
const char *value)
{
FILE *fp;
- char *path = rc_strcatpaths (RC_SVCDIR, "options", service, NULL);
- char *file = rc_strcatpaths (path, option, NULL);
+ char *path = rc_strcatpaths (RC_SVCDIR, "options", service, (char *) NULL);
+ char *file = rc_strcatpaths (path, option, (char *) NULL);
bool retval = false;
if (! rc_is_dir (path))
@@ -468,7 +472,8 @@ static pid_t _exec_service (const char *service, const char *arg)
}
/* We create a fifo so that other services can wait until we complete */
- fifo = rc_strcatpaths (RC_SVCDIR, "exclusive", basename (service), NULL);
+ fifo = rc_strcatpaths (RC_SVCDIR, "exclusive", basename (service),
+ (char *) NULL);
if (mkfifo (fifo, 0600) != 0 && errno != EEXIST)
{
@@ -482,7 +487,7 @@ static pid_t _exec_service (const char *service, const char *arg)
{
char *myarg = strdup (arg);
int e = 0;
- execl (file, file, myarg, NULL);
+ execl (file, file, myarg, (char *) NULL);
e = errno;
free (myarg);
unlink (fifo);
@@ -545,7 +550,8 @@ void rc_schedule_start_service (const char *service,
if (! rc_service_exists (service) || ! rc_service_exists (service_to_start))
return;
- dir = rc_strcatpaths (RC_SVCDIR, "scheduled", basename (service), NULL);
+ dir = rc_strcatpaths (RC_SVCDIR, "scheduled", basename (service),
+ (char *) NULL);
if (! rc_is_dir (dir))
if (mkdir (dir, 0755) != 0)
{
@@ -555,7 +561,7 @@ void rc_schedule_start_service (const char *service,
}
init = rc_resolve_service (service_to_start);
- file = rc_strcatpaths (dir, basename (service_to_start), NULL);
+ file = rc_strcatpaths (dir, basename (service_to_start), (char *) NULL);
if (! rc_exists (file) && symlink (init, file) != 0)
eerror ("symlink `%s' to `%s': %s", init, file, strerror (errno));
@@ -566,7 +572,8 @@ void rc_schedule_start_service (const char *service,
void rc_schedule_clear (const char *service)
{
- char *dir = rc_strcatpaths (RC_SVCDIR, "scheduled", basename (service), NULL);
+ char *dir = rc_strcatpaths (RC_SVCDIR, "scheduled", basename (service),
+ (char *) NULL);
if (rc_is_dir (dir))
rc_rm_dir (dir, true);
@@ -575,7 +582,8 @@ void rc_schedule_clear (const char *service)
bool rc_wait_service (const char *service)
{
- char *fifo = rc_strcatpaths (RC_SVCDIR, "exclusive", basename (service), NULL);
+ char *fifo = rc_strcatpaths (RC_SVCDIR, "exclusive", basename (service),
+ (char *) NULL);
struct timeval tv;
struct timeval stopat;
struct timeval now;
@@ -632,7 +640,7 @@ char **rc_services_in_runlevel (const char *runlevel)
strcmp (runlevel, RC_LEVEL_SINGLE) == 0)
return (NULL);
- dir = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, NULL);
+ dir = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, (char *) NULL);
if (! rc_is_dir (dir))
eerror ("runlevel `%s' does not exist", runlevel);
else
@@ -644,7 +652,8 @@ char **rc_services_in_runlevel (const char *runlevel)
char **rc_services_in_state (rc_service_state_t state)
{
- char *dir = rc_strcatpaths (RC_SVCDIR, rc_service_state_names[state], NULL);
+ char *dir = rc_strcatpaths (RC_SVCDIR, rc_service_state_names[state],
+ (char *) NULL);
char **list = NULL;
if (rc_is_dir (dir))
@@ -673,7 +682,8 @@ bool rc_service_add (const char *runlevel, const char *service)
}
init = rc_resolve_service (service);
- file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename (service), NULL);
+ file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename (service),
+ (char *) NULL);
retval = (symlink (init, file) == 0);
free (init);
free (file);
@@ -688,7 +698,8 @@ bool rc_service_delete (const char *runlevel, const char *service)
if (! runlevel || ! service)
return (false);
- file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename (service), NULL);
+ file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename (service),
+ (char *) NULL);
if (unlink (file) == 0)
retval = true;
@@ -705,7 +716,8 @@ char **rc_services_scheduled_by (const char *service)
STRLIST_FOREACH (dirs, dir, i)
{
- char *file = rc_strcatpaths (RC_SVCDIR "scheduled", dir, service, NULL);
+ char *file = rc_strcatpaths (RC_SVCDIR "scheduled", dir, service,
+ (char *) NULL);
if (rc_exists (file))
list = rc_strlist_add (list, file);
free (file);
@@ -717,7 +729,8 @@ char **rc_services_scheduled_by (const char *service)
char **rc_services_scheduled (const char *service)
{
- char *dir = rc_strcatpaths (RC_SVCDIR, "scheduled", basename (service), NULL);
+ char *dir = rc_strcatpaths (RC_SVCDIR, "scheduled", basename (service),
+ (char *) NULL);
char **list = NULL;
if (rc_is_dir (dir))
diff --git a/src/rc.c b/src/rc.c
index b9b4c82e..12851c50 100644
--- a/src/rc.c
+++ b/src/rc.c
@@ -395,7 +395,7 @@ static void sulogin (bool cont)
newenv = rc_filter_env ();
mycmd = rc_xstrdup ("/sbin/sulogin");
myarg = rc_xstrdup (getenv ("CONSOLE"));
- execle (mycmd, mycmd, myarg, NULL, newenv);
+ execle (mycmd, mycmd, myarg, (char *) NULL, newenv);
eerrorx ("%s: unable to exec `/sbin/sulogin': %s", applet, strerror (errno));
}
waitpid (pid, &status, 0);
@@ -406,7 +406,7 @@ static void sulogin (bool cont)
newenv = rc_filter_env ();
mycmd = rc_xstrdup ("/sbin/sulogin");
myarg = rc_xstrdup (getenv ("CONSOLE"));
- execle (mycmd, mycmd, myarg, NULL, newenv);
+ execle (mycmd, mycmd, myarg, (char *) NULL, newenv);
eerrorx ("%s: unable to exec `/sbin/sulogin': %s", applet, strerror (errno));
}
#else
@@ -599,7 +599,7 @@ int main (int argc, char **argv)
if (pid == 0)
{
mycmd = rc_xstrdup (INITSH);
- execl (mycmd, mycmd, NULL);
+ execl (mycmd, mycmd, (char *) NULL);
eerrorx ("%s: unable to exec `" INITSH "': %s",
applet, strerror (errno));
}
@@ -699,7 +699,7 @@ int main (int argc, char **argv)
{
mycmd = rc_xstrdup ("/sbin/telinit");
myarg = rc_xstrdup (lvl);
- execl (mycmd, mycmd, myarg, NULL);
+ execl (mycmd, mycmd, myarg, (char *) NULL);
eerrorx ("%s: unable to exec `/sbin/telinit': %s",
applet, strerror (errno));
}
@@ -732,7 +732,7 @@ int main (int argc, char **argv)
#ifdef __linux__
mycmd = rc_xstrdup ("/sbin/telinit");
myarg = rc_xstrdup ("S");
- execl (mycmd, mycmd, myarg, NULL);
+ execl (mycmd, mycmd, myarg, (char *) NULL);
eerrorx ("%s: unable to exec `/%s': %s",
mycmd, applet, strerror (errno));
#else
@@ -751,7 +751,7 @@ int main (int argc, char **argv)
mycmd = rc_xstrdup ("/sbin/shutdown");
myarg = rc_xstrdup ("-r");
tmp = rc_xstrdup ("now");
- execl (mycmd, mycmd, myarg, tmp, NULL);
+ execl (mycmd, mycmd, myarg, tmp, (char *) NULL);
eerrorx ("%s: unable to exec `%s': %s",
mycmd, applet, strerror (errno));
}
@@ -768,7 +768,7 @@ int main (int argc, char **argv)
myarg = rc_xstrdup ("-p");
#endif
tmp = rc_xstrdup ("now");
- execl (mycmd, mycmd, myarg, tmp, NULL);
+ execl (mycmd, mycmd, myarg, tmp, (char *) NULL);
eerrorx ("%s: unable to exec `%s': %s",
mycmd, applet, strerror (errno));
}
@@ -830,7 +830,7 @@ int main (int argc, char **argv)
/* Check if runlevel is valid if we're changing */
if (newlevel && strcmp (runlevel, newlevel) != 0 && ! going_down)
{
- tmp = rc_strcatpaths (RC_RUNLEVELDIR, newlevel, NULL);
+ tmp = rc_strcatpaths (RC_RUNLEVELDIR, newlevel, (char *) NULL);
if (! rc_is_dir (tmp))
eerrorx ("%s: is not a valid runlevel", newlevel);
CHAR_FREE (tmp);
@@ -949,7 +949,8 @@ int main (int argc, char **argv)
}
printf ("\n");
}
- tmp = rc_strcatpaths (RC_RUNLEVELDIR, newlevel ? newlevel : runlevel, NULL);
+ tmp = rc_strcatpaths (RC_RUNLEVELDIR, newlevel ? newlevel : runlevel,
+ (char *) NULL);
start_services = rc_ls_dir (start_services, tmp, RC_LS_INITD);
CHAR_FREE (tmp);
}
@@ -969,7 +970,7 @@ int main (int argc, char **argv)
start_services = rc_strlist_add (start_services, service);
tmp = rc_strcatpaths (RC_RUNLEVELDIR,
- newlevel ? newlevel : runlevel, NULL);
+ newlevel ? newlevel : runlevel, (char *) NULL);
start_services = rc_ls_dir (start_services, tmp, RC_LS_INITD);
CHAR_FREE (tmp);
}
@@ -1017,7 +1018,7 @@ int main (int argc, char **argv)
tmp = rc_xmalloc (strlen (service) + strlen (runlevel) + 2);
sprintf (tmp, "%s.%s", service, runlevel);
- conf = rc_strcatpaths (RC_CONFDIR, tmp, NULL);
+ conf = rc_strcatpaths (RC_CONFDIR, tmp, (char *) NULL);
found = rc_exists (conf);
CHAR_FREE (conf);
CHAR_FREE (tmp);
@@ -1025,7 +1026,7 @@ int main (int argc, char **argv)
{
tmp = rc_xmalloc (strlen (service) + strlen (newlevel) + 2);
sprintf (tmp, "%s.%s", service, newlevel);
- conf = rc_strcatpaths (RC_CONFDIR, tmp, NULL);
+ conf = rc_strcatpaths (RC_CONFDIR, tmp, (char *) NULL);
found = rc_exists (conf);
CHAR_FREE (conf);
CHAR_FREE (tmp);
@@ -1092,7 +1093,7 @@ int main (int argc, char **argv)
{
mycmd = rc_xstrdup (HALTSH);
myarg = rc_xstrdup (runlevel);
- execl (mycmd, mycmd, myarg, NULL);
+ execl (mycmd, mycmd, myarg, (char *) NULL);
eerrorx ("%s: unable to exec `%s': %s",
applet, HALTSH, strerror (errno));
}
diff --git a/src/rc.h b/src/rc.h
index 3ba7cc56..69999114 100644
--- a/src/rc.h
+++ b/src/rc.h
@@ -8,6 +8,10 @@
#ifndef __RC_H__
#define __RC_H__
+#ifdef __GNUC__
+# define SENTINEL __attribute__ ((__sentinel__))
+#endif
+
#include <sys/types.h>
#include <stdbool.h>
@@ -145,7 +149,7 @@ void *rc_xrealloc (void *ptr, size_t size);
char *rc_xstrdup (const char *str);
/* Concat paths adding '/' if needed. */
-char *rc_strcatpaths (const char *path1, const char *paths, ...);
+char *rc_strcatpaths (const char *path1, const char *paths, ...) SENTINEL;
bool rc_is_env (const char *variable, const char *value);
bool rc_exists (const char *pathname);
diff --git a/src/runscript.c b/src/runscript.c
index bca1195b..ee8ed76f 100644
--- a/src/runscript.c
+++ b/src/runscript.c
@@ -165,7 +165,7 @@ static bool in_control ()
while (tests[i])
{
- path = rc_strcatpaths (RC_SVCDIR, tests[i], applet, NULL);
+ path = rc_strcatpaths (RC_SVCDIR, tests[i], applet, (char *) NULL);
if (rc_exists (path))
{
int m = get_mtime (path, false);
@@ -184,7 +184,8 @@ static bool in_control ()
static void uncoldplug (char *service)
{
- char *cold = rc_strcatpaths (RC_SVCDIR "coldplugged", basename (service), NULL);
+ char *cold = rc_strcatpaths (RC_SVCDIR "coldplugged", basename (service),
+ (char *) NULL);
if (rc_exists (cold) && unlink (cold) != 0)
eerror ("%s: unlink `%s': %s", applet, cold, strerror (errno));
free (cold);
@@ -283,13 +284,15 @@ static bool svc_exec (const char *service, const char *arg1, const char *arg2)
if (rc_exists (RC_SVCDIR "runscript.sh"))
{
- execl (RC_SVCDIR "runscript.sh", mycmd, mycmd, myarg1, myarg2, NULL);
+ execl (RC_SVCDIR "runscript.sh", mycmd, mycmd, myarg1, myarg2,
+ (char *) NULL);
eerrorx ("%s: exec `" RC_SVCDIR "runscript.sh': %s",
service, strerror (errno));
}
else
{
- execl (RC_LIBDIR "sh/runscript.sh", mycmd, mycmd, myarg1, myarg2, NULL);
+ execl (RC_LIBDIR "sh/runscript.sh", mycmd, mycmd, myarg1, myarg2,
+ (char *) NULL);
eerrorx ("%s: exec `" RC_LIBDIR "sh/runscript.sh': %s",
service, strerror (errno));
}
@@ -364,14 +367,14 @@ static void make_exclusive (const char *service)
/* We create a fifo so that other services can wait until we complete */
if (! exclusive)
- exclusive = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, NULL);
+ exclusive = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, (char *) NULL);
if (mkfifo (exclusive, 0600) != 0 && errno != EEXIST &&
(errno != EACCES || geteuid () == 0))
eerrorx ("%s: unable to create fifo `%s': %s",
applet, exclusive, strerror (errno));
- path = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, NULL);
+ path = rc_strcatpaths (RC_SVCDIR, "exclusive", applet, (char *) NULL);
i = strlen (path) + 16;
mtime_test = rc_xmalloc (sizeof (char *) * i);
snprintf (mtime_test, i, "%s.%d", path, getpid ());
@@ -854,7 +857,7 @@ int main (int argc, char **argv)
/* Show help if insufficient args */
if (argc < 3)
{
- execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, NULL);
+ execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, (char *) NULL);
eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s",
applet, strerror (errno));
}
@@ -867,7 +870,7 @@ int main (int argc, char **argv)
eerror ("%s: cannot run until sysvinit completes", applet);
if (mkdir ("/dev/.rcboot", 0755) != 0 && errno != EEXIST)
eerrorx ("%s: mkdir `/dev/.rcboot': %s", applet, strerror (errno));
- tmp = rc_strcatpaths ("/dev/.rcboot", applet, NULL);
+ tmp = rc_strcatpaths ("/dev/.rcboot", applet, (char *) NULL);
symlink (service, tmp);
exit (EXIT_FAILURE);
}
@@ -932,7 +935,7 @@ int main (int argc, char **argv)
char *eb;
snprintf (ebname, sizeof (ebname), "%s.%s", applet, pid);
- eb = rc_strcatpaths (RC_SVCDIR "ebuffer", ebname, NULL);
+ eb = rc_strcatpaths (RC_SVCDIR "ebuffer", ebname, (char *) NULL);
setenv ("RC_EBUFFER", eb, 1);
free (eb);
}
@@ -965,7 +968,7 @@ int main (int argc, char **argv)
setenv ("RC_DEBUG", "yes", 1);
else if (strcmp (argv[i], "--help") == 0)
{
- execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, NULL);
+ execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, (char *) NULL);
eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s",
applet, strerror (errno));
}
@@ -1071,7 +1074,7 @@ int main (int argc, char **argv)
}
else if (strcmp (argv[i], "help") == 0)
{
- execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, "help", NULL);
+ execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, "help", (char *) NULL);
eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s",
applet, strerror (errno));
}
@@ -1088,7 +1091,7 @@ int main (int argc, char **argv)
if (! doneone)
{
- execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, NULL);
+ execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, (char *) NULL);
eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s",
applet, strerror (errno));
}
diff --git a/src/start-stop-daemon.c b/src/start-stop-daemon.c
index e5dae783..fef416cb 100644
--- a/src/start-stop-daemon.c
+++ b/src/start-stop-daemon.c
@@ -12,6 +12,8 @@
#define POLL_INTERVAL 20000
#define START_WAIT 100000
+#include <sys/types.h>
+#include <sys/ioctl.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/termios.h>
@@ -727,7 +729,7 @@ int main (int argc, char **argv)
{
char *tmp;
if (ch_root)
- tmp = rc_strcatpaths (ch_root, exec, NULL);
+ tmp = rc_strcatpaths (ch_root, exec, (char *) NULL);
else
tmp = exec;
if (! rc_is_file (tmp))