aboutsummaryrefslogtreecommitdiff
path: root/execute_program.c
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2011-07-08 19:22:52 +0200
committerPetr Machata <pmachata@redhat.com>2011-10-06 14:17:17 +0200
commit1b17dbf4c3754018310f22e26effffdcffde47ab (patch)
tree1d1bebe48880fd06875a4776cf09176070bf0486 /execute_program.c
parentcc947516b7a76aa21095d8c3563a19a399bf628c (diff)
downloadltrace-1b17dbf4c3754018310f22e26effffdcffde47ab.tar.gz
Streamline interfaces execute_program, open_program
Diffstat (limited to 'execute_program.c')
-rw-r--r--execute_program.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/execute_program.c b/execute_program.c
index 3651b66..47f514d 100644
--- a/execute_program.c
+++ b/execute_program.c
@@ -17,7 +17,8 @@
#include "common.h"
static void
-change_uid(Process *proc) {
+change_uid(const char * command)
+{
uid_t run_uid, run_euid;
gid_t run_gid, run_egid;
@@ -49,7 +50,7 @@ change_uid(Process *proc) {
run_euid = run_uid;
run_egid = run_gid;
- if (!stat(proc->filename, &statbuf)) {
+ if (!stat(command, &statbuf)) {
if (statbuf.st_mode & S_ISUID) {
run_euid = statbuf.st_uid;
}
@@ -68,32 +69,27 @@ change_uid(Process *proc) {
}
}
-void
-execute_program(Process *sp, char **argv) {
+pid_t
+execute_program(const char * command, char **argv)
+{
pid_t pid;
- debug(1, "Executing `%s'...", sp->filename);
+ debug(1, "Executing `%s'...", command);
pid = fork();
if (pid < 0) {
perror("ltrace: fork");
exit(1);
} else if (!pid) { /* child */
- change_uid(sp);
+ change_uid(command);
trace_me();
- execvp(sp->filename, argv);
- fprintf(stderr, "Can't execute `%s': %s\n", sp->filename,
+ execvp(command, argv);
+ fprintf(stderr, "Can't execute `%s': %s\n", command,
strerror(errno));
_exit(1);
}
debug(1, "PID=%d", pid);
- sp->pid = pid;
-
-#if defined(HAVE_LIBUNWIND)
- sp->unwind_priv = _UPT_create(pid);
-#endif /* defined(HAVE_LIBUNWIND) */
-
- return;
+ return pid;
}