diff options
author | Alexis211 <alexis211@gmail.com> | 2009-11-08 12:58:27 +0100 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-11-08 12:58:27 +0100 |
commit | ec6a6922d074da4b64976282333e308deb39aeec (patch) | |
tree | 60d5e4a63095af75fc3ddae38021fa4c92ffd361 /Source/Kernel/UserManager | |
parent | 962b8e892ce060b9690a35b0bcf6bae9a882c330 (diff) | |
download | Melon-ec6a6922d074da4b64976282333e308deb39aeec.tar.gz Melon-ec6a6922d074da4b64976282333e308deb39aeec.zip |
Introduced PaperWork : our init/login manager.
Login with user=root;pass=admin or user=alexis211;pass=iamgod
Diffstat (limited to 'Source/Kernel/UserManager')
-rw-r--r-- | Source/Kernel/UserManager/User.class.h | 9 | ||||
-rw-r--r-- | Source/Kernel/UserManager/Usr.ns.cpp | 15 |
2 files changed, 16 insertions, 8 deletions
diff --git a/Source/Kernel/UserManager/User.class.h b/Source/Kernel/UserManager/User.class.h index ae02281..9d13ef1 100644 --- a/Source/Kernel/UserManager/User.class.h +++ b/Source/Kernel/UserManager/User.class.h @@ -8,13 +8,13 @@ class User { friend void Usr::load(); private: - String m_username, m_completeName; + String m_username, m_completeName, m_password; u32int m_uid; Group* m_group; Vector<Group*> m_extraGroups; - User(String username, String completeName, Group* group, String extragroups, u32int uid) - : m_username(username), m_completeName(completeName), m_uid(uid), m_group(group) { + User(String username, String completeName, String password, Group* group, String extragroups, u32int uid) + : m_username(username), m_completeName(completeName), m_password(password), m_uid(uid), m_group(group) { Vector<String> eg = extragroups.split(","); for (u32int i = 0; i < eg.size(); i++) { Group* g = Usr::group(eg[i].toInt()); @@ -25,6 +25,7 @@ class User { public: String getUserName() { return m_username; } String getCompleteName() { return m_completeName; } + String getPassword() { return m_password; } u32int getUid() { return m_uid; } Group* getGroup() { return m_group; } bool isInGroup(u32int gid) { @@ -45,6 +46,7 @@ class User { if (m_extraGroups[i] == g) return true; return false; } + bool vrfyPassword(String pw) { return pw == m_password; } String getGroups() { String ret; @@ -57,6 +59,7 @@ class User { void setUserName(String wat) { m_username = wat; Usr::save(); } void setCompleteName(String wat) { m_completeName = wat; Usr::save(); } + void setPassword(String wat) { m_password = wat; Usr::save(); } void setGroup(Group* group) { m_group = group; Usr::save(); } void addGroup(u32int gid) { Group* g = Usr::group(gid); diff --git a/Source/Kernel/UserManager/Usr.ns.cpp b/Source/Kernel/UserManager/Usr.ns.cpp index db371ae..ecf9bae 100644 --- a/Source/Kernel/UserManager/Usr.ns.cpp +++ b/Source/Kernel/UserManager/Usr.ns.cpp @@ -5,10 +5,11 @@ #include <SimpleList.class.h> #include <TaskManager/Task.ns.h> #include <TextFile.class.h> +#include <VFS/VFS.ns.h> /* * Syntax for Users and Groups configuration files : one entry per line - * syntax for Users : <uid>:<username>:<basegroup>:<extragroup>,<extragroup>:<completename> + * syntax for Users : <uid>:<username>:<basegroup>:<extragroup>,<extragroup>:<completename>:<password> * syntax for Groups : <gid>:<name> */ @@ -22,6 +23,8 @@ void load() { if (m_groups != 0) delete m_groups; m_users = 0, m_groups = 0; + if (VFS::find("/System/Configuration/Groups")) VFS::find("/System/Configuration/Groups")->setPermissions(0600); + if (VFS::find("/System/Configuration/Users")) VFS::find("/System/Configuration/Users")->setPermissions(0600); TextFile groups("/System/Configuration/Groups", FM_READ); while (!groups.eof()) { String s = groups.readLine(); @@ -38,13 +41,14 @@ void load() { TextFile users("/System/Configuration/Users", FM_READ); while (!users.eof()) { String s = users.readLine(); + if (s == "" or s[0] == WChar("#")) continue; Vector<String> data = s.split(":"); - if (data.size() == 5 and !(s[0] == WChar("#"))) { - m_users = m_users->cons(User(data[1], data[4], group(data[2].toInt()), data[3], data[0].toInt())); + if (data.size() == 6) { + m_users = m_users->cons(User(data[1], data[4], data[5], group(data[2].toInt()), data[3], data[0].toInt())); } } if (m_users == 0) { - m_users = m_users->cons(User("melon", "MelOS", group(0), "", 0)); + m_users = m_users->cons(User("melon", "MelOS", "", group(0), "", 0)); Log::log(KL_WARNING, "Usr.ns : users file invalid, had to add default users."); } } @@ -58,7 +62,8 @@ void save() { for (SimpleList<User> *iter = m_users; iter != 0; iter = iter->next()) { users.write(String::number(iter->v().getUid()) + ":" + iter->v().getUserName() + ":" + String::number(iter->v().getGroup()->getGid()) + ":" - + iter->v().getGroups() + ":" + iter->v().getCompleteName(), true); + + iter->v().getGroups() + ":" + iter->v().getCompleteName() + ":" + + iter->v().getPassword(), true); } } |