You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
973 B

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <syslog.h>
#define MAXLINE 512
execlog (const char *incmd)
FILE *output;
char cmd[strlen (incmd) + 6];
char line[MAXLINE];
strcpy (cmd, incmd);
openlog ("installer", LOG_PID | LOG_PERROR, LOG_USER);
syslog (LOG_DEBUG, "running cmd '%s'", cmd);
/* FIXME: this can cause the shell command if there's redirection
already in the passed string */
strcat (cmd, " 2>&1");
output = popen (cmd, "r");
while (fgets (line, MAXLINE, output) != NULL)
syslog (LOG_DEBUG, line);
closelog ();
/* FIXME we aren't getting the return value from the actual command
executed, not sure how to do that cleanly */
return (pclose (output));
check_dir (const char *dirname)
struct stat check;
if (stat (dirname, &check) == -1)
return -1;
return S_ISDIR (check.st_mode);