diff --git a/src/library/sysadm-usermanager.cpp b/src/library/sysadm-usermanager.cpp index 9586bf6..929d5e3 100644 --- a/src/library/sysadm-usermanager.cpp +++ b/src/library/sysadm-usermanager.cpp @@ -16,7 +16,7 @@ UserManager::UserManager(QString chroot) loadShells(); } -void UserManager::NewUser(QString fullName, QString userName, QString password, QString shell) +void UserManager::NewUser(QString fullName, QString userName, QString password, QString shell, int uid, int gid) { User user; user.UserName = userName; @@ -44,6 +44,16 @@ void UserManager::NewUser(QString fullName, QString userName, QString password, args << "-m"; //create the user's home directory args << "-s"; //set the user's shell args << shell; //to this + if(gid != -1) + { + args << "-g"; + args << gid; + } + if(uid != -1) + { + args << "-u"; + args << uid; + } args << "-G"; //additionally add the user to args << "operator"; //the operator's group @@ -89,7 +99,7 @@ void UserManager::DeleteUser(User user) if ( ! chroot.isEmpty() ) General::RunCommand("chroot", args); else - General::RunCommand("pw", args); + General::RunCommand("pw", args); loadUsers(); loadGroups(); diff --git a/src/library/sysadm-usermanager.h b/src/library/sysadm-usermanager.h index cc908c8..77ae8b8 100644 --- a/src/library/sysadm-usermanager.h +++ b/src/library/sysadm-usermanager.h @@ -21,6 +21,7 @@ public: HomeFolder = ""; Shell = ""; GroupID = -1; + Encrypted = false; } QString FullName; @@ -29,6 +30,7 @@ public: QString HomeFolder; QString Shell; int GroupID; + bool Encrypted; friend bool operator<(const User lhs, const User rhs){ return std::tie(lhs.ID,lhs.UserName) < std::tie(rhs.ID,rhs.UserName); } @@ -62,7 +64,7 @@ public: class UserManager { -public: +public: UserManager(QString chroot = ""); //#section user actions @@ -72,8 +74,10 @@ public: * @param userName The username of the user * @param password The user's password * @param shell the user's shell, defaults to /bin/tcsh + * @param uid the user id of the user + * @param gid the group id of the user */ - void NewUser(QString fullName, QString userName, QString password, QString shell = "/bin/tcsh"); + void NewUser(QString fullName, QString userName, QString password, QString shell = "/bin/tcsh", int uid = -1, int gid = -1); /** * @brief DeleteUser Deletes a user * @param user the user to delete