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 <string>
19#include <sys/types.h>
20#include <unistd.h>
21
22namespace OksSystem {
23
29
30class User
31{
32
33protected:
34 uid_t m_user_id;
35 mutable std::string m_user_name;
36 mutable std::string m_user_home;
37 mutable std::string m_user_real_name;
38 void resolve() const;
39 void resolve_safe() const throw();
40public:
41 static const User ROOT;
42 User() throw();
43 User(uid_t user_id) throw();
44 User(const std::string& name);
45 User(const User& other) throw();
46 operator uid_t() const throw();
47 operator std::string() const;
48 operator const char*() const;
49 uid_t identity() const throw();
50 const std::string& name() const;
51 const std::string& name_safe() const throw();
52 const std::string& home() const;
53 const std::string& real_name() const;
54 void setuid() const;
55}; // User
56
57} // OksSystem
58
59std::ostream&
60operator<<(std::ostream& stream, const OksSystem::User& user) throw();
61
62bool
63operator==(const OksSystem::User& a, const OksSystem::User& b) throw();
64bool
65operator!=(const OksSystem::User& a, const OksSystem::User& b) throw();
66
67#endif
void resolve() const
resolve information from user-id
Definition User.cpp:122
void resolve_safe() const
resolve without throwing exceptions
Definition User.cpp:170
static const User ROOT
constant for root user
Definition User.hpp:41
const std::string & name() const
username
Definition User.cpp:215
uid_t identity() const
user-id
Definition User.cpp:110
const std::string & home() const
home directory name
Definition User.cpp:241
std::string m_user_real_name
cached real user name
Definition User.hpp:37
const std::string & real_name() const
real name
Definition User.cpp:254
uid_t m_user_id
the actual user id
Definition User.hpp:34
const std::string & name_safe() const
username - no exception
Definition User.cpp:228
void setuid() const
tries to set the uid of current process
Definition User.cpp:268
std::string m_user_home
cached user home directory
Definition User.hpp:36
std::string m_user_name
cached user name
Definition User.hpp:35
User()
constructor for current user
Definition User.cpp:27