summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/substitute.c6
-rw-r--r--source3/lib/username.c19
-rw-r--r--source3/param/loadparm.c66
-rw-r--r--source3/smbd/service.c4
4 files changed, 51 insertions, 44 deletions
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
@@ -43,6 +43,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;
/* Ensure the user exists. */
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index f6771b85d9..d19d20f3f9 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3104,15 +3104,16 @@ static void dump_copy_map(BOOL *pcopymap)
/***************************************************************************
Return TRUE if the passed service number is within range.
***************************************************************************/
+
BOOL lp_snum_ok(int iService)
{
return (LP_SNUM_OK(iService) && ServicePtrs[iService]->bAvailable);
}
-
/***************************************************************************
-auto-load some home services
+ Auto-load some home services.
***************************************************************************/
+
static void lp_add_auto_services(char *str)
{
char *s;
@@ -3128,34 +3129,30 @@ static void lp_add_auto_services(char *str)
homes = lp_servicenumber(HOMES_NAME);
- for (p = strtok(s, LIST_SEP); p; p = strtok(NULL, LIST_SEP))
- {
- char *home = get_user_home_dir(p);
+ for (p = strtok(s, LIST_SEP); p; p = strtok(NULL, LIST_SEP)) {
+ char *home = get_user_service_home_dir(p);
if (lp_servicenumber(p) >= 0)
continue;
if (home && homes >= 0)
- {
lp_add_home(p, homes, home);
- }
}
SAFE_FREE(s);
}
/***************************************************************************
-auto-load one printer
+ Auto-load one printer.
***************************************************************************/
+
void lp_add_one_printer(char *name, char *comment)
{
int printers = lp_servicenumber(PRINTERS_NAME);
int i;
- if (lp_servicenumber(name) < 0)
- {
+ if (lp_servicenumber(name) < 0) {
lp_add_printer(name, printers);
- if ((i = lp_servicenumber(name)) >= 0)
- {
+ if ((i = lp_servicenumber(name)) >= 0) {
string_set(&ServicePtrs[i]->comment, comment);
ServicePtrs[i]->autoloaded = True;
}
@@ -3163,59 +3160,57 @@ void lp_add_one_printer(char *name, char *comment)
}
/***************************************************************************
-have we loaded a services file yet?
+ Have we loaded a services file yet?
***************************************************************************/
+
BOOL lp_loaded(void)
{
return (bLoaded);
}
/***************************************************************************
-unload unused services
+ Unload unused services.
***************************************************************************/
+
void lp_killunused(BOOL (*snumused) (int))
{
int i;
- for (i = 0; i < iNumServices; i++)
- {
+ for (i = 0; i < iNumServices; i++) {
if (!VALID(i))
continue;
- if (!snumused || !snumused(i))
- {
+ if (!snumused || !snumused(i)) {
ServicePtrs[i]->valid = False;
free_service(ServicePtrs[i]);
}
}
}
-
/***************************************************************************
-unload a service
+ Unload a service.
***************************************************************************/
+
void lp_killservice(int iServiceIn)
{
- if (VALID(iServiceIn))
- {
+ if (VALID(iServiceIn)) {
ServicePtrs[iServiceIn]->valid = False;
free_service(ServicePtrs[iServiceIn]);
}
}
/***************************************************************************
-save the curent values of all global and sDefault parameters into the
-defaults union. This allows swat and testparm to show only the
-changed (ie. non-default) parameters.
+ Save the curent values of all global and sDefault parameters into the
+ defaults union. This allows swat and testparm to show only the
+ changed (ie. non-default) parameters.
***************************************************************************/
+
static void lp_save_defaults(void)
{
int i;
- for (i = 0; parm_table[i].label; i++)
- {
+ for (i = 0; parm_table[i].label; i++) {
if (i > 0 && parm_table[i].ptr == parm_table[i - 1].ptr)
continue;
- switch (parm_table[i].type)
- {
+ switch (parm_table[i].type) {
case P_LIST:
lp_list_copy(&(parm_table[i].def.lvalue),
*(char ***)parm_table[i].ptr);
@@ -3255,16 +3250,15 @@ static void lp_save_defaults(void)
/*******************************************************************
Set the server type we will announce as via nmbd.
********************************************************************/
+
static void set_server_role(void)
{
server_role = ROLE_STANDALONE;
- switch (lp_security())
- {
+ switch (lp_security()) {
case SEC_SHARE:
{
- if (lp_domain_logons())
- {
+ if (lp_domain_logons()) {
DEBUG(0,
("Server's Role (logon server) conflicts with share-level security\n"));
}
@@ -3274,8 +3268,7 @@ static void set_server_role(void)
case SEC_DOMAIN:
case SEC_ADS:
{
- if (lp_domain_logons())
- {
+ if (lp_domain_logons()) {
server_role = ROLE_DOMAIN_BDC;
break;
}
@@ -3284,8 +3277,7 @@ static void set_server_role(void)
}
case SEC_USER:
{
- if (lp_domain_logons())
- {
+ if (lp_domain_logons()) {
server_role = ROLE_DOMAIN_PDC;
break;
}
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index 9b6f38f2ec..b25e696c8d 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -127,7 +127,7 @@ int find_service(fstring service)
/* now handle the special case of a home directory */
if (iService < 0)
{
- char *phome_dir = get_user_home_dir(service);
+ char *phome_dir = get_user_service_home_dir(service);
if(!phome_dir)
{
@@ -136,7 +136,7 @@ int find_service(fstring service)
* be a Windows to unix mapped user name.
*/
if(map_username(service))
- phome_dir = get_user_home_dir(service);
+ phome_dir = get_user_service_home_dir(service);
}
DEBUG(3,("checking for home directory %s gave %s\n",service,