aboutsummaryrefslogtreecommitdiff
path: root/src/rc/start-stop-daemon.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-03-17 13:25:56 +0000
committerRoy Marples <roy@marples.name>2008-03-17 13:25:56 +0000
commit4c1466642351ddb01cc7353601153a79326f18f7 (patch)
treecb9da1a90aa9480ef276626f40c556379222ec51 /src/rc/start-stop-daemon.c
parent50a7697bf207e4919ce893bfc1604fd3a9d807de (diff)
Punt the rc_strcatpaths function and use snprintf instead to save on expensive malloc calls.
Diffstat (limited to 'src/rc/start-stop-daemon.c')
-rw-r--r--src/rc/start-stop-daemon.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/rc/start-stop-daemon.c b/src/rc/start-stop-daemon.c
index 9b1c109e..6aec70b5 100644
--- a/src/rc/start-stop-daemon.c
+++ b/src/rc/start-stop-daemon.c
@@ -51,6 +51,7 @@
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
+#include <limits.h>
#include <grp.h>
#include <pwd.h>
#include <signal.h>
@@ -590,6 +591,7 @@ int start_stop_daemon(int argc, char **argv)
bool setuser = false;
char *p;
char *tmp;
+ char exec_file[PATH_MAX];
struct passwd *pw;
struct group *gr;
char line[130];
@@ -773,14 +775,13 @@ int start_stop_daemon(int argc, char **argv)
/* Validate that the binary exists if we are starting */
if (exec) {
- if (ch_root)
- tmp = rc_strcatpaths(ch_root, exec, (char *) NULL);
- else
+ if (ch_root) {
+ snprintf(exec_file, sizeof(exec_file), "%s/%s", ch_root, exec);
+ tmp = exec_file;
+ } else
tmp = exec;
if (start && ! exists(tmp)) {
eerror("%s: %s does not exist", applet, tmp);
- if (ch_root)
- free(tmp);
exit(EXIT_FAILURE);
}
@@ -807,15 +808,10 @@ int start_stop_daemon(int argc, char **argv)
applet, line + 2, exec);
eerror("%s: or you should specify a pidfile"
" or process name", applet);
- if (ch_root)
- free(tmp);
exit(EXIT_FAILURE);
}
}
}
-
- if (ch_root)
- free(tmp);
}
/* Add exec to our arguments */