closefd(_stderr);
}
- if (in->uid || in->gid) {
- if (setuid(in->uid) || setgid(in->gid)) {
- ERROR("failed to set uid:%d, gid:%d\n", in->uid, in->gid);
- exit(127);
- }
+ if (in->gid && setgid(in->gid)) {
+ ERROR("failed to set group id %d: %d (%s)\n", in->gid, errno, strerror(errno));
+ exit(127);
+ }
+ if (in->uid && setuid(in->uid)) {
+ ERROR("failed to set user id %d: %d (%s)\n", in->uid, errno, strerror(errno));
+ exit(127);
}
+
execvp(argv[0], argv);
exit(127);
}
char *newline, *str, *arg0, ident[32];
int len;
+ arg0 = basename(blobmsg_data(blobmsg_data(in->command)));
+ snprintf(ident, sizeof(ident), "%s[%d]", arg0, in->proc.pid);
+ ulog_open(ULOG_SYSLOG, LOG_DAEMON, ident);
+
do {
str = ustream_get_read_buf(s, NULL);
if (!str)
break;
*newline = 0;
- len = newline + 1 - str;
-
- arg0 = basename(blobmsg_data(blobmsg_data(in->command)));
- snprintf(ident, sizeof(ident), "%s[%d]", arg0, in->proc.pid);
-
- ulog_open(ULOG_SYSLOG, LOG_DAEMON, ident);
ulog(prio, "%s\n", str);
- ulog_open(ULOG_SYSLOG, LOG_DAEMON, "procd");
+ len = newline + 1 - str;
ustream_consume(s, len);
} while (1);
+
+ ulog_open(ULOG_SYSLOG, LOG_DAEMON, "procd");
}
static void
{
void *i;
+ if (!in->valid)
+ return;
+
i = blobmsg_open_table(b, in->name);
blobmsg_add_u8(b, "running", in->proc.pending);
if (in->proc.pending)
if (in->respawn) {
void *r = blobmsg_open_table(b, "respawn");
- blobmsg_add_u32(b, "timeout", in->respawn_timeout);
blobmsg_add_u32(b, "threshold", in->respawn_threshold);
+ blobmsg_add_u32(b, "timeout", in->respawn_timeout);
blobmsg_add_u32(b, "retry", in->respawn_retry);
blobmsg_close_table(b, r);
}