20 #include "UserManager.h" 23 #include "modules/Module.h" 24 #include "modules/system/config/Config.h" 25 #include "pedigree/kernel/Log.h" 26 #include "pedigree/kernel/process/Process.h" 27 #include "pedigree/kernel/process/Thread.h" 28 #include "pedigree/kernel/processor/Processor.h" 29 #include "pedigree/kernel/processor/ProcessorInformation.h" 30 #include "pedigree/kernel/utilities/Iterator.h" 31 #include "pedigree/kernel/utilities/utility.h" 39 UserManager::~UserManager()
43 void UserManager::initialiseGroups()
49 for (
size_t i = 0; i < pResult->
rows(); i++)
54 gid = pResult->
getNum(i,
"gid") - 1;
55 name = pResult->
getStr(i,
"name");
63 void UserManager::initialiseUsers()
69 for (
size_t i = 0; i < pResult->
rows(); i++)
72 String username, fullname, groupname, homedir, shell, password;
74 uid = pResult->
getNum(i,
"uid") - 1;
75 username = pResult->
getStr(i,
"username");
76 fullname = pResult->
getStr(i,
"fullname");
77 groupname = pResult->
getStr(i,
"groupname");
78 homedir = pResult->
getStr(i,
"homedir");
79 shell = pResult->
getStr(i,
"shell");
80 password = pResult->
getStr(i,
"password");
82 addUser(uid, username, fullname, groupname, homedir, shell, password);
98 User *pU = it.value();
115 Group *pG = it.value();
122 void UserManager::addUser(
130 "USERS: Not inserting user '" << username <<
"' with uid " << uid
140 "USERS: Not inserting user '" << username <<
"': group '" << group
141 <<
"' does not exist.");
146 "USERS: Adding user {" << uid <<
",'" << username <<
"','" << fullName
149 new User(uid, username, fullName, pGroup, home, shell, password);
154 void UserManager::addGroup(
size_t gid,
String name)
160 "USERS: Not inserting group '" << name <<
"' with gid " << gid
165 NOTICE(
"USERS: Adding group {" << gid <<
",'" << name <<
"'}");
173 addGroup(0,
String(
"root"));
185 FATAL(
"USERS: Unable to set default user (no such user for uid 0)");
203 static void destroy()
207 MODULE_INFO(
"users", &init, &destroy,
"config");
size_t rows()
Returns the number of rows.
Tree< size_t, User * > m_Users
User * getUser(size_t id)
Tree< size_t, Group * > m_Groups
std::string getStr(size_t row, size_t col, size_t buffSz=256)
Returns the value in column 'col' of the result, in string form.
static ProcessorInformation & information()
Group * getGroup(size_t id)
void insert(const K &key, const E &value)
size_t getNum(size_t row, size_t col)
Returns the value in column 'col' of the result, in number form.
Result * query(const char *sql)
Group * getDefaultGroup()
bool succeeded()
Returns true if the result is valid, false if there was an error.
static UserManager & instance()
void setUser(User *pUser)
std::string errorMessage(size_t buffSz=256)
Returns the error message.
void setGroup(Group *pGroup)
E lookup(const K &key) const