const std::string KRATE_REMOVE_HOOK_PATH = "/etc/gumd/userdel.d";
std::string KRATE_DEFAULT_OWNER;
+std::string KRATE_ID_PREFIX;
std::list<std::string> createdKrateList;
static std::atomic<bool> isKrateForeground(false);
user = (GumUser*) src_list->data;
if (user) {
g_object_get(G_OBJECT(user), "username", &username, NULL);
- createdKrateList.push_back(username);
+ std::string name = username;
g_free(username);
+
+ name = name.substr(KRATE_ID_PREFIX.size());
+
+ createdKrateList.push_back(name);
}
}
runtime::Cgroup::create(CGROUP_SUBSYSTEM, CGROUP_SUBSYSTEM);
KRATE_DEFAULT_OWNER = ::tzplatform_getenv(TZ_SYS_DEFAULT_USER);
+ KRATE_ID_PREFIX = gum_user_type_to_prefix(GUM_USERTYPE_SECURITY);
PackageManager& packageManager = PackageManager::instance();
packageManager.setEventCallback(packageEventHandler, this);
initializeCreatedKrateList();
for (std::string& name : createdKrateList) {
- runtime::User krate(name);
+ runtime::User krate(KRATE_ID_PREFIX + name);
notification_register_detailed_changed_cb_for_uid(notiProxyCallback, &name, krate.getUid());
}
}
throw runtime::Exception("Failed to remove user (" + name + ") by gumd");
}
- runtime::User user(name);
+ runtime::User user(name + KRATE_ID_PREFIX);
maskUserServices(user);
std::unique_ptr<xml::Document> manifestFile;
bool canRemove = false;
- runtime::User user(name);
+ runtime::User user(KRATE_ID_PREFIX + name);
::tzplatform_set_user(user.getUid());
std::string confPath(::tzplatform_getenv(TZ_USER_HOME));
confPath += "/.config/krate";
return -1;
}
- if (lockKrate(name) != 0) {
- return -1;
- }
+ //lock the user
+ setKrateState(user.getUid(), 0);
- auto remove = [name, this] {
+ auto remove = [name, user, this] {
//wait for krate session close
sleep(1);
try {
- runtime::User user(name);
-
//umount TZ_USER_CONTENT
::tzplatform_set_user(user.getUid());
if (::umount2(::tzplatform_getenv(TZ_USER_CONTENT), MNT_FORCE) != 0) {
int Manager::lockKrate(const std::string& name)
{
try {
- runtime::User user(name);
+ runtime::User user(KRATE_ID_PREFIX + name);
setKrateState(user.getUid(), 0);
} catch (runtime::Exception& e) {
ERROR(e.what());
int Manager::unlockKrate(const std::string& name)
{
try {
- runtime::User user(name);
+ runtime::User user(KRATE_ID_PREFIX + name);
setKrateState(user.getUid(), 1);
} catch (runtime::Exception& e) {
ERROR(e.what());
}
try {
- runtime::User user(name);
+ runtime::User user(KRATE_ID_PREFIX + name);
try {
dbus::Connection& systemDBus = dbus::Connection::getSystem();
const dbus::Variant& var = systemDBus.methodcall
int Manager::resetKratePassword(const std::string& name, const std::string& newPassword)
{
try {
- runtime::User user(name);
+ runtime::User user(KRATE_ID_PREFIX + name);
int ret = auth_passwd_reset_passwd(AUTH_PWD_NORMAL, user.getUid(), newPassword.c_str());
if (ret != AUTH_PASSWD_API_SUCCESS) {
throw runtime::Exception("Failed to reset password for " + name);