manager: allow become_manager in work profile.
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "ksu.h"
|
#include "ksu.h"
|
||||||
|
|
||||||
@@ -29,7 +30,14 @@ static bool ksuctl(int cmd, void* arg1, void* arg2) {
|
|||||||
|
|
||||||
bool become_manager(const char* pkg) {
|
bool become_manager(const char* pkg) {
|
||||||
char param[128];
|
char param[128];
|
||||||
sprintf(param, "/data/data/%s", pkg);
|
uid_t uid = getuid();
|
||||||
|
uint32_t userId = uid / 100000;
|
||||||
|
if (userId == 0) {
|
||||||
|
sprintf(param, "/data/data/%s", pkg);
|
||||||
|
} else {
|
||||||
|
snprintf(param, 10, "/data/user/%d/%s", userId, pkg);
|
||||||
|
}
|
||||||
|
|
||||||
return ksuctl(CMD_BECOME_MANAGER, param, nullptr);
|
return ksuctl(CMD_BECOME_MANAGER, param, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user