1
/***************************************************************************
2
passwd.cpp - description
4
begin : Tue June 6 2002
5
copyright : (C) 2002 by Jan Schaefer
6
email : janschaefer@users.sourceforge.net
7
***************************************************************************/
9
/******************************************************************************
11
* This file is part of KSambaPlugin. *
13
* KSambaPlugin is free software; you can redistribute it and/or modify *
14
* it under the terms of the GNU General Public License as published by *
15
* the Free Software Foundation; either version 2 of the License, or *
16
* (at your option) any later version. *
18
* KSambaPlugin is distributed in the hope that it will be useful, *
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21
* GNU General Public License for more details. *
23
* You should have received a copy of the GNU General Public License *
24
* along with KSambaPlugin; if not, write to the Free Software *
25
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
27
******************************************************************************/
30
#include <sys/types.h>
37
UnixUserList getUnixUserList()
43
while ((p = getpwent()))
47
UnixUser *u = new UnixUser();
60
QStringList getUnixUsers()
66
while ((p = getpwent()))
69
list.append(QString(p->pw_name));
79
QStringList getUnixGroups()
85
while ((g = getgrent()))
88
list.append(QString(g->gr_name));
98
int getUserUID(const QString & name)
100
if (name.isNull()) return -1;
104
p = getpwnam(name.toLocal8Bit());
112
int getUserGID(const QString & name)
114
if (name.isNull()) return -1;
118
p = getpwnam(name.toLocal8Bit());
126
int getGroupGID(const QString & name)
128
if (name.isNull()) return -1;
132
g = getgrnam(name.toLocal8Bit());
140
bool isUserInGroup(const QString & user, const QString & group) {
143
while ((g = getgrent()))
145
if (g && QString(g->gr_name) == group) {
146
char** names = g->gr_mem;
149
char* name = names[0];
152
if (QString(name) == user) {