};
int
-service_start_early(char *name, char *cmdline)
+service_start_early(char *name, char *cmdline, char *user, char *group)
{
void *instances, *instance, *command, *respawn;
char *t;
blobmsg_add_string(&b, NULL, "1");
blobmsg_add_string(&b, NULL, "0");
blobmsg_close_array(&b, respawn);
+ if (user)
+ blobmsg_add_string(&b, "user", user);
+ if (group)
+ blobmsg_add_string(&b, "group", group);
+
blobmsg_close_table(&b, instance);
blobmsg_close_table(&b, instances);
void service_validate_add(struct service *s, struct blob_attr *attr);
void service_validate_dump(struct blob_buf *b, struct service *s);
void service_validate_dump_all(struct blob_buf *b, char *p, char *s);
-int service_start_early(char *name, char *cmdline);
+int service_start_early(char *name, char *cmdline, char *user, char *group);
void service_stopped(struct service *s);
void service_validate_del(struct service *s);
void service_event(const char *type, const char *service, const char *instance);
*/
#include <fcntl.h>
+#include <pwd.h>
#include <sys/reboot.h>
#include <stdio.h>
#include <stdlib.h>
static void state_enter(void)
{
char ubus_cmd[] = "/sbin/ubusd";
+ struct passwd *p;
switch (state) {
case STATE_EARLY:
watchdog_init(0);
set_stdio("console");
LOG("- ubus -\n");
+ p = getpwnam("ubus");
+ if (p) {
+ mkdir(p->pw_dir, 0755);
+ chown(p->pw_dir, p->pw_uid, p->pw_gid);
+ }
procd_connect_ubus();
- service_start_early("ubus", ubus_cmd);
+ service_start_early("ubus", ubus_cmd, p?"ubus":NULL, p?"ubus":NULL);
break;
case STATE_INIT: