DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
User.hpp
Go to the documentation of this file.
1/*
2 * User.h
3 * OksSystem
4 *
5 * Created by Matthias Wiesmann on 03.02.05.
6 * Copyright 2005 CERN. All rights reserved.
7 *
8 */
9
10#ifndef OKSSYSTEM_USER
11#define OKSSYSTEM_USER
12
13#include <unistd.h>
14#include <sys/types.h>
15#include <string>
16
17namespace OksSystem {
18
25 class User {
26
27protected:
28 uid_t m_user_id ;
29 mutable std::string m_user_name ;
30 mutable std::string m_user_home ;
31 mutable std::string m_user_real_name ;
32 void resolve() const ;
33 void resolve_safe() const throw() ;
34public:
35 static const User ROOT ;
36 User() throw() ;
37 User(uid_t user_id) throw() ;
38 User(const std::string &name);
39 User(const User &other) throw() ;
40 operator uid_t() const throw() ;
41 operator std::string() const ;
42 operator const char *() const ;
43 uid_t identity() const throw() ;
44 const std::string & name() const ;
45 const std::string & name_safe() const throw() ;
46 const std::string & home() const ;
47 const std::string & real_name() const ;
48 void setuid() const ;
49 }; // User
50
51} // OksSystem
52
53std::ostream& operator<<(std::ostream& stream, const OksSystem::User& user) throw() ;
54
55
56bool operator ==(const OksSystem::User &a, const OksSystem::User &b) throw();
57bool operator !=(const OksSystem::User &a, const OksSystem::User &b) throw();
58
59
60#endif
61
void resolve() const
resolve information from user-id
Definition User.cpp:106
void resolve_safe() const
resolve without throwing exceptions
Definition User.cpp:152
static const User ROOT
constant for root user
Definition User.hpp:35
const std::string & name() const
username
Definition User.cpp:195
uid_t identity() const
user-id
Definition User.cpp:96
const std::string & home() const
home directory name
Definition User.cpp:213
std::string m_user_real_name
cached real user name
Definition User.hpp:31
const std::string & real_name() const
real name
Definition User.cpp:222
uid_t m_user_id
the actual user id
Definition User.hpp:28
const std::string & name_safe() const
username - no exception
Definition User.cpp:204
void setuid() const
tries to set the uid of current process
Definition User.cpp:232
std::string m_user_home
cached user home directory
Definition User.hpp:30
std::string m_user_name
cached user name
Definition User.hpp:29