DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
User.hpp
Go to the documentation of this file.
1// DUNE DAQ modification notice:
2// This file has been modified from the original ATLAS system source for the DUNE DAQ project.
3// Fork baseline commit: system-00-00-20 (2020-09-25).
4// Renamed since fork: yes (from system/User.h to include/okssystem/User.hpp).
5
6/*
7 * User.h
8 * OksSystem
9 *
10 * Created by Matthias Wiesmann on 03.02.05.
11 * Copyright 2005 CERN. All rights reserved.
12 *
13 */
14
15#ifndef OKSSYSTEM_USER
16#define OKSSYSTEM_USER
17
18#include <unistd.h>
19#include <sys/types.h>
20#include <string>
21
22namespace OksSystem {
23
29
30 class User {
31
32protected:
33 uid_t m_user_id ;
34 mutable std::string m_user_name ;
35 mutable std::string m_user_home ;
36 mutable std::string m_user_real_name ;
37 void resolve() const ;
38 void resolve_safe() const throw() ;
39public:
40 static const User ROOT ;
41 User() throw() ;
42 User(uid_t user_id) throw() ;
43 User(const std::string &name);
44 User(const User &other) throw() ;
45 operator uid_t() const throw() ;
46 operator std::string() const ;
47 operator const char *() const ;
48 uid_t identity() const throw() ;
49 const std::string & name() const ;
50 const std::string & name_safe() const throw() ;
51 const std::string & home() const ;
52 const std::string & real_name() const ;
53 void setuid() const ;
54 }; // User
55
56} // OksSystem
57
58std::ostream& operator<<(std::ostream& stream, const OksSystem::User& user) throw() ;
59
60
61bool operator ==(const OksSystem::User &a, const OksSystem::User &b) throw();
62bool operator !=(const OksSystem::User &a, const OksSystem::User &b) throw();
63
64
65#endif
66
void resolve() const
resolve information from user-id
Definition User.cpp:111
void resolve_safe() const
resolve without throwing exceptions
Definition User.cpp:157
static const User ROOT
constant for root user
Definition User.hpp:40
const std::string & name() const
username
Definition User.cpp:200
uid_t identity() const
user-id
Definition User.cpp:101
const std::string & home() const
home directory name
Definition User.cpp:218
std::string m_user_real_name
cached real user name
Definition User.hpp:36
const std::string & real_name() const
real name
Definition User.cpp:227
uid_t m_user_id
the actual user id
Definition User.hpp:33
const std::string & name_safe() const
username - no exception
Definition User.cpp:209
void setuid() const
tries to set the uid of current process
Definition User.cpp:237
std::string m_user_home
cached user home directory
Definition User.hpp:35
std::string m_user_name
cached user name
Definition User.hpp:34
User()
constructor for current user
Definition User.cpp:27