diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-11-10 14:23:31 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-11-10 14:23:31 +0000 |
commit | 8de9cfe184b0db2b8341776a9e78f21a6014267d (patch) | |
tree | 0fc98144bea1015b7842954c0d8a91fb03b45bb8 /src/common/compat.c | |
parent | 987cb2b93a6d5c670639c347535f289723b7d1dc (diff) | |
download | tor-8de9cfe184b0db2b8341776a9e78f21a6014267d.tar.gz tor-8de9cfe184b0db2b8341776a9e78f21a6014267d.zip |
Resolve FIXME items: make expand_filename handle ~ and ~username
svn:r2789
Diffstat (limited to 'src/common/compat.c')
-rw-r--r-- | src/common/compat.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index ce99db1c12..395194b37f 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -390,6 +390,23 @@ int switch_id(char *user, char *group) { return -1; } +#ifdef HAVE_PWD_H +/** Allocate and return a string containing the home directory for the + * user <b>username</b>. Only works on posix-like systems */ +char * +get_user_homedir(const char *username) +{ + struct passwd *pw; + tor_assert(username); + + if (!(pw = getpwnam(username))) { + log_fn(LOG_ERR,"User '%s' not found.", username); + return NULL; + } + return tor_strdup(pw->pw_dir); +} +#endif + /** Set *addr to the IP address (in dotted-quad notation) stored in c. * Return 1 on success, 0 if c is badly formatted. (Like inet_aton(c,addr), * but works on Windows and Solaris.) |