From 08019e8a337c5e378ec9dfc70698adb73b9b7676 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 16 Jan 2002 23:53:10 +0000 Subject: Separate out get_user_home_dir() from get_user_home_service_dir(). Jeremy. (This used to be commit c1b97226db63daf64359e79083a4754e7c7f8054) --- source3/lib/substitute.c | 6 +----- source3/lib/username.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index deef085c99..5a2bc1d890 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -97,10 +97,7 @@ static char *automount_path(const char *user_name) /* use the passwd entry as the default */ /* this will be the default if WITH_AUTOMOUNT is not used or fails */ - if (((pass = Get_Pwnam(user_name))!=NULL) && (pass->pw_dir != NULL)) - pstrcpy(server_path, pass->pw_dir ); - else - *server_path = '\0'; + pstrcpy(server_path, get_user_home_dir(user_name)); #if (defined(HAVE_NETGROUP) && defined (WITH_AUTOMOUNT)) @@ -117,7 +114,6 @@ static char *automount_path(const char *user_name) } } else { /* NIS key lookup failed: default to user home directory from password file */ - pstrcpy(server_path, get_user_home_dir(user_name)); DEBUG(5, ("NIS lookup failed. Using Home path from passwd file. Home path is: %s\n", server_path )); } } diff --git a/source3/lib/username.c b/source3/lib/username.c index c7e25b7cd1..81408f4569 100644 --- a/source3/lib/username.c +++ b/source3/lib/username.c @@ -41,6 +41,25 @@ BOOL name_is_local(const char *name) ****************************************************************************/ char *get_user_home_dir(const char *user) +{ + static struct passwd *pass; + + /* Ensure the user exists. */ + + pass = Get_Pwnam(user); + + if (!pass) + return(NULL); + /* Return home directory from struct passwd. */ + + return(pass->pw_dir); +} + +/**************************************************************************** + Get a users service home directory. +****************************************************************************/ + +char *get_user_service_home_dir(const char *user) { static struct passwd *pass; int snum; -- cgit