adbncfs  0.9.1
userInfo.h
Go to the documentation of this file.
1 /*
2  * $Id: userInfo.h 2 2015-12-03 19:46:25Z wejaeger $
3  *
4  * File: userInfo.h
5  * Author: Werner Jaeger
6  *
7  * Created on November 26, 2015, 8:53 PM
8  *
9  * Copyright 2015 Werner Jaeger.
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #ifndef USERINFO_H
26 #define USERINFO_H
27 
28 #include <set>
29 
37 class UserInfo
38 {
39 public:
40  UserInfo(const int iUid, const int iGid, const std::set<int>& groups) : m_iUid(iUid), m_iGid(iGid), m_Groups(groups) {}
41  UserInfo(const char* pcUserInfo);
42  virtual ~UserInfo() {}
43 
44  int access(const int iUid, const int iGid, const unsigned int uiRawMode, const int iMask) const;
45 
46 private:
47  // prevent default constructor
48  UserInfo() {}
49 
50  bool belongs2Group(const int iGuid) const;
51  int testAccesss(const int iMode, const int iMask) const;
52 
53  void parseUserInfoString(const char* pcUserInfo);
54 
55  int m_iUid;
56  int m_iGid;
57  std::set<int> m_Groups;
58 };
59 
60 #endif /* USERINFO_H */
61 
bool belongs2Group(const int iGuid) const
Tests if this user belongs to the specified group,.
Definition: userInfo.cpp:115
int m_iGid
Definition: userInfo.h:56
UserInfo(const int iUid, const int iGid, const std::set< int > &groups)
Definition: userInfo.h:40
int testAccesss(const int iMode, const int iMask) const
Test requested access permissions against the mode;.
Definition: userInfo.cpp:126
int access(const int iUid, const int iGid, const unsigned int uiRawMode, const int iMask) const
This is the similar to the access(2) system call.
Definition: userInfo.cpp:94
std::set< int > m_Groups
Definition: userInfo.h:57
void parseUserInfoString(const char *pcUserInfo)
Parse the specified user info string and store the results in the corresponding member variables...
Definition: userInfo.cpp:144
UserInfo()
Definition: userInfo.h:48
virtual ~UserInfo()
Definition: userInfo.h:42
int m_iUid
Definition: userInfo.h:55
A class to manage informations obtained from the output of the busybox applet id command.
Definition: userInfo.h:37