D("sync: '%s' '%s'\n", (char*) &msg.req, name);
if (should_drop_privileges() && !verify_sync_rule(name)) {
- set_sdk_user_privileges();
+ if (getuid() != g_sdk_user_id && set_sdk_user_privileges() < 0) {
+ fail_message(fd, "failed to set SDK user privileges.");
+ goto fail;
+ }
}
switch(msg.req.id) {
if (sdbd_set_groups() < 0) {
D("set groups failed (errno: %d)\n", errno);
+ return -1;
}
if (setgid(g_sdk_group_id) != 0) {
D("set group id failed (errno: %d)\n", errno);
+ return -1;
}
if (setuid(g_sdk_user_id) != 0) {
D("set user id failed (errno: %d)\n", errno);
+ return -1;
}
if (chdir(g_sdk_home_dir) < 0) {
// do nothing
D("sdb: executes root commands!!:%s\n", argv[2]);
} else {
- set_sdk_user_privileges();
+ if (getuid() != g_sdk_user_id && set_sdk_user_privileges() < 0) {
+ fprintf(stderr, "failed to set SDK user privileges\n");
+ exit(-1);
+ }
}
}
redirect_and_exec(pts, cmd, argv, envp);