Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

passwd.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  ***************************************************************************/
00009 
00010 #ifndef PASSWD_H
00011 #define PASSWD_H
00012 
00013 #include <qobject.h>
00014 #include <qfile.h>
00015 #include <qstring.h>
00016 #include <qstringlist.h>
00017 #include <qtextstream.h>
00018 #include <qregexp.h>
00019 #include <qdir.h>
00020 
00021 #include <crypt.h>
00022 #include <pwd.h>
00023 #include <grp.h>
00024 
00025 class Passwd
00026 {
00027 public:
00028         QStringList passwdStringList;   // List of all users (name,passwd,uid,gid,gecos,dir,shell)
00029         QStringList groupStringList;    // List of all groups (name,gid,mem)
00030         
00031         // pwentry
00032         QString pw_name;
00033         QString pw_passwd;
00034         int pw_uid;
00035         int pw_gid;
00036         QString pw_gecos;
00037         QString pw_dir;
00038         QString pw_shell;
00039 
00040         // grentry
00041         QString gr_name;
00042         int gr_gid;
00043         QStringList gr_mem;
00044         
00045         Passwd(void);
00046         ~Passwd(void);
00047         bool open(void);
00048         bool close(void);
00049         char *crypt_make_salt(void);
00050         void splitPasswdEntry(QString &userString);
00051         void splitGroupEntry(QString &groupString);
00052         bool findUser(const char *username);
00053         bool findUser(int uid);
00054         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);
00055         bool updateUser(QString login);
00056         bool delUser(const char *username, bool delGroup=true);
00057         bool delUser(int uid, bool delGroup=true);
00058         bool findGroup(const char *groupname);
00059         bool findGroup(int gid);
00060         bool addGroup(QString gr_name, int gr_gid);
00061         bool updateGroup(int gid);
00062         bool delGroup(const char *groupname);
00063         bool delGroup(int gid);
00064         bool addGroupMember(QString groupname,QString member);
00065         bool delGroupMember(QString groupname,QString member);
00066 
00067 private:
00068         QString userString;
00069         QString groupString;
00070         
00071         int i64c(int i);
00072         bool searchUser(QRegExp &userRegExp);
00073         bool deleteUser(QRegExp &userRegExp, bool delGroup);
00074         bool searchGroup(QRegExp &groupRegExp);
00075         bool deleteGroup(QRegExp &groupRegExp);
00076         QStringList userdataStringList;
00077         QStringList groupdataStringList;
00078         
00079         QFile *passwd_file;
00080         QFile *group_file;
00081 };
00082 
00083 extern Passwd *accounts;        // Create a global object.
00084 
00085 #endif

Generated on Sat Nov 5 16:17:58 2005 for OPIE by  doxygen 1.4.2