31 static struct passwd *
34 struct passwd *new_pw = tor_malloc_zero(
sizeof(
struct passwd));
36 new_pw->pw_name = tor_strdup(pw->pw_name);
38 new_pw->pw_dir = tor_strdup(pw->pw_dir);
39 new_pw->pw_uid = pw->pw_uid;
40 new_pw->pw_gid = pw->pw_gid;
45 #define tor_passwd_free(pw) \
46 FREE_AND_NULL(struct passwd, tor_passwd_free_, (pw))
74 if (username == NULL) {
80 if ((pw = getpwnam(username))) {
83 log_info(
LD_GENERAL,
"Caching new entry %s for %s",
105 const struct passwd *
110 if ((pw = getpwuid(uid))) {
129 const struct passwd *pw;
133 log_err(
LD_CONFIG,
"User \"%s\" not found.", username);
136 return tor_strdup(pw->pw_dir);
Headers for util_malloc.c.
const struct passwd * tor_getpwuid(uid_t uid)
static void tor_passwd_free_(struct passwd *pw)
static struct passwd * passwd_cached
const struct passwd * tor_getpwnam(const char *username)
static struct passwd * tor_passwd_dup(const struct passwd *pw)
char * get_user_homedir(const char *username)
Macros to manage assertions, fatal and non-fatal.