summaryrefslogtreecommitdiff
path: root/noncore/settings/usermanager/passwd.h
Unidiff
Diffstat (limited to 'noncore/settings/usermanager/passwd.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/usermanager/passwd.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/noncore/settings/usermanager/passwd.h b/noncore/settings/usermanager/passwd.h
new file mode 100644
index 0000000..37c41dc
--- a/dev/null
+++ b/noncore/settings/usermanager/passwd.h
@@ -0,0 +1,85 @@
1/***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9
10#ifndef PASSWD_H
11#define PASSWD_H
12
13#include <qobject.h>
14#include <qfile.h>
15#include <qstring.h>
16#include <qstringlist.h>
17#include <qtextstream.h>
18#include <qregexp.h>
19#include <qdir.h>
20
21#include <crypt.h>
22#include <pwd.h>
23#include <grp.h>
24
25class Passwd
26{
27public:
28 QStringList passwdStringList;// List of all users (name,passwd,uid,gid,gecos,dir,shell)
29 QStringList groupStringList;// List of all groups (name,gid,mem)
30
31 // pwentry
32 QString pw_name;
33 QString pw_passwd;
34 int pw_uid;
35 int pw_gid;
36 QString pw_gecos;
37 QString pw_dir;
38 QString pw_shell;
39
40 // grentry
41 QString gr_name;
42 int gr_gid;
43 QStringList gr_mem;
44
45 Passwd(void);
46 ~Passwd(void);
47 bool open(void);
48 bool close(void);
49 char *crypt_make_salt(void);
50 void splitPasswdEntry(QString &userString);
51 void splitGroupEntry(QString &groupString);
52 bool findUser(const char *username);
53 bool findUser(int uid);
54 bool addUser(QString pw_name, QString pw_passwd, int pw_uid, int pw_gid, QString pw_gecos, QString pw_dir, QString pw_shell, bool createGroup=true);
55 bool updateUser(QString login);
56 bool delUser(const char *username, bool delGroup=true);
57 bool delUser(int uid, bool delGroup=true);
58 bool findGroup(const char *groupname);
59 bool findGroup(int gid);
60 bool addGroup(QString gr_name, int gr_gid);
61 bool updateGroup(int gid);
62 bool delGroup(const char *groupname);
63 bool delGroup(int gid);
64 bool addGroupMember(QString groupname,QString member);
65 bool delGroupMember(QString groupname,QString member);
66
67private:
68 QString userString;
69 QString groupString;
70
71 int i64c(int i);
72 bool searchUser(QRegExp &userRegExp);
73 bool deleteUser(QRegExp &userRegExp, bool delGroup);
74 bool searchGroup(QRegExp &groupRegExp);
75 bool deleteGroup(QRegExp &groupRegExp);
76 QStringList userdataStringList;
77 QStringList groupdataStringList;
78
79 QFile *passwd_file;
80 QFile *group_file;
81};
82
83 extern Passwd *accounts;// Create a global object.
84
85#endif