EPkgIdExists,
EGetPkgId,
EGetPrivilegeGroups,
+ EGetUserApps,
};
class PrivilegeDb {
{ QueryType::EPkgIdExists, "SELECT * FROM pkg WHERE name=?" },
{ QueryType::EGetPkgId, " SELECT pkg_name FROM app_pkg_view WHERE app_name = ?" },
{ QueryType::EGetPrivilegeGroups, " SELECT name FROM privilege_group_view WHERE privilege_name = ?" },
+ { QueryType::EGetUserApps, "SELECT name FROM app WHERE uid=?" },
};
/**
void GetPrivilegeGroups(const std::string &privilege,
std::vector<std::string> &grp_names);
+ /**
+ * Retrieve list of apps assigned to user
+ *
+ * @param uid - user identifier
+ * @param[out] apps - list of apps assigned to user,
+ * this parameter do not need to be empty, but
+ * it is being overwritten during function call.
+ * @exception DB::SqlConnection::Exception::InternalError on internal error
+ */
+ void GetUserApps(uid_t uid, std::vector<std::string> &apps);
};
} //namespace SecurityManager
});
}
+void PrivilegeDb::GetUserApps(uid_t uid, std::vector<std::string> &apps)
+{
+ try_catch<void>([&] {
+ DB::SqlConnection::DataCommandAutoPtr command =
+ mSqlConnection->PrepareDataCommand(
+ Queries.at(QueryType::EGetUserApps));
+ command->BindInteger(1, static_cast<unsigned int>(uid));
+ apps.clear();
+ while (command->Step()) {
+ std::string app = command->GetColumnString(0);
+ LogDebug("User " << uid << " has app " << app << " installed");
+ apps.push_back(app);
+ };
+ });
+}
+
} //namespace SecurityManager