26#ifndef MYSQLROUTER_SYS_USER_OPERATIONS_INCLUDED
27#define MYSQLROUTER_SYS_USER_OPERATIONS_INCLUDED
61 virtual struct passwd *
getpwuid(uid_t uid) = 0;
62 virtual int chown(
const char *
file, uid_t owner, gid_t group) = 0;
76 int setgid(gid_t gid)
override;
79 int setuid(uid_t uid)
override;
82 int setegid(gid_t gid)
override;
85 int seteuid(uid_t uid)
override;
94 struct passwd *
getpwuid(uid_t uid)
override;
97 int chown(
const char *
file, uid_t owner, gid_t group)
override;
119 const std::string &
filepath,
const std::string &username,
120 struct passwd *user_info_arg,
134void set_user(
const std::string &username,
bool permanently =
false,
152 const std::string &username,
bool must_be_root,
Base class to allow multiple SysUserOperations implementations.
Definition: sys_user_operations.h:45
virtual ~SysUserOperationsBase()=default
virtual int initgroups(const char *user, gid_type gid)=0
virtual struct passwd * getpwuid(uid_t uid)=0
virtual int seteuid(uid_t uid)=0
virtual int setuid(uid_t uid)=0
virtual int chown(const char *file, uid_t owner, gid_t group)=0
gid_t gid_type
Definition: sys_user_operations.h:50
virtual int setgid(gid_t gid)=0
virtual int setegid(gid_t gid)=0
virtual struct passwd * getpwnam(const char *name)=0
virtual uid_t geteuid(void)=0
This class provides implementations of SysUserOperationsBase methods.
Definition: sys_user_operations.h:68
int seteuid(uid_t uid) override
Thin wrapper around system seteuid()
Definition: sys_user_operations.cc:64
int initgroups(const char *user, gid_type gid) override
Thin wrapper around system initgroups()
Definition: sys_user_operations.cc:54
SysUserOperations(const SysUserOperations &)=delete
SysUserOperations()=default
SysUserOperations operator=(const SysUserOperations &)=delete
struct passwd * getpwuid(uid_t uid) override
Thin wrapper around system getpwuid()
Definition: sys_user_operations.cc:72
uid_t geteuid() override
Thin wrapper around system geteuid()
Definition: sys_user_operations.cc:66
int setgid(gid_t gid) override
Thin wrapper around system setgid()
Definition: sys_user_operations.cc:58
int setegid(gid_t gid) override
Thin wrapper around system setegid()
Definition: sys_user_operations.cc:62
int setuid(uid_t uid) override
Thin wrapper around system setuid()
Definition: sys_user_operations.cc:60
static SysUserOperations * instance()
Definition: sys_user_operations.cc:49
int chown(const char *file, uid_t owner, gid_t group) override
Thin wrapper around system chown()
Definition: sys_user_operations.cc:76
struct passwd * getpwnam(const char *name) override
Thin wrapper around system getpwnam()
Definition: sys_user_operations.cc:68
static const char * filepath
Definition: myisamlog.cc:97
char * user
Definition: mysqladmin.cc:66
struct passwd * check_user(const std::string &username, bool must_be_root, mysqlrouter::SysUserOperationsBase *sys_user_operations)
Checks if the given user can be switched to or made an owner of a selected file.
Definition: sys_user_operations.cc:152
void set_user(const std::string &username, bool permanently=false, mysqlrouter::SysUserOperationsBase *sys_user_operations=SysUserOperations::instance())
Sets effective user of the calling process.
Definition: sys_user_operations.cc:207
void set_owner_if_file_exists(const std::string &filepath, const std::string &username, struct passwd *user_info_arg, mysqlrouter::SysUserOperationsBase *sys_user_operations)
Sets the owner of selected file/directory if it exists.
Definition: sys_user_operations.cc:80
case opt name
Definition: sslopt-case.h:29