summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-02-18 09:42:39 +0000
committerJeremy Allison <jra@samba.org>1998-02-18 09:42:39 +0000
commit0041a439a61424488f7656e57974d1038001fa05 (patch)
tree391db74e4f62e1562c40d39142d5667fdfaa7823 /source
parentb8d7f8decbade53437c350e73271949bcd69ef0f (diff)
downloadsamba-0041a439a61424488f7656e57974d1038001fa05.tar.gz
samba-0041a439a61424488f7656e57974d1038001fa05.tar.xz
samba-0041a439a61424488f7656e57974d1038001fa05.zip
Fix to implement %p substitution from jkf@soton.ac.uk.
It also makes automount code tidier. Jeremy.
Diffstat (limited to 'source')
-rw-r--r--source/include/proto.h1
-rw-r--r--source/lib/util.c126
-rw-r--r--source/passdb/smbpass.c8
-rw-r--r--source/smbd/server.c9
-rw-r--r--source/smbd/trans2.c4
5 files changed, 118 insertions, 30 deletions
diff --git a/source/include/proto.h b/source/include/proto.h
index 97017e77b0b..65798be002b 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -1485,6 +1485,7 @@ void reset_globals_after_fork();
char *client_name(void);
char *client_addr(void);
char *automount_server(char *user_name);
+char *automount_path(char *user_name);
void standard_sub_basic(char *str);
BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
int PutUniCode(char *dst,char *src);
diff --git a/source/lib/util.c b/source/lib/util.c
index fa5f6ae4003..a7a579a94a0 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -3713,44 +3713,88 @@ char *client_addr(void)
return addr_buf;
}
+/*******************************************************************
+ Patch from jkf@soton.ac.uk
+ Split Luke's automount_server into YP lookup and string splitter
+ so can easily implement automount_path().
+ As we may end up doing both, cache the last YP result.
+*******************************************************************/
+
+#if (defined(NETGROUP) && defined(AUTOMOUNT))
+static char *automount_lookup(char *user_name)
+{
+ static fstring last_key = "";
+ static pstring last_value = "";
+
+ int nis_error; /* returned by yp all functions */
+ char *nis_result; /* yp_match inits this */
+ int nis_result_len; /* and set this */
+ char *nis_domain; /* yp_get_default_domain inits this */
+ char *nis_map = (char *)lp_nis_home_map_name();
+
+ if ((nis_error = yp_get_default_domain(&nis_domain)) != 0)
+ {
+ DEBUG(3, ("YP Error: %s\n", yperr_string(nis_error)));
+ return last_value;
+ }
+
+ DEBUG(5, ("NIS Domain: %s\n", nis_domain));
+
+ if (!strcmp(user_name, last_key))
+ {
+ nis_result = last_value;
+ nis_result_len = strlen(last_value);
+ nis_error = 0;
+ }
+ else
+ {
+ if ((nis_error = yp_match(nis_domain, nis_map,
+ user_name, strlen(user_name),
+ &nis_result, &nis_result_len)) != 0)
+ {
+ DEBUG(3, ("YP Error: \"%s\" while looking up \"%s\" in map \"%s\"\n",
+ yperr_string(nis_error), user_name, nis_map));
+ }
+ if (!nis_error && nis_result_len >= sizeof(pstring))
+ {
+ nis_result_len = sizeof(pstring)-1;
+ }
+ fstrcpy(last_key, user_name);
+ strncpy(last_value, nis_result, nis_result_len);
+ last_value[nis_result_len] = '\0';
+ }
+
+ DEBUG(4, ("YP Lookup: %s resulted in %s\n", user_name, last_value));
+ return last_value;
+}
+#endif
+
+/*******************************************************************
+ Patch from jkf@soton.ac.uk
+ This is Luke's original function with the NIS lookup code
+ moved out to a separate function.
+*******************************************************************/
+
char *automount_server(char *user_name)
{
static pstring server_name;
#if (defined(NETGROUP) && defined (AUTOMOUNT))
- int nis_error; /* returned by yp all functions */
- char *nis_result; /* yp_match inits this */
- int nis_result_len; /* and set this */
- char *nis_domain; /* yp_get_default_domain inits this */
- char *nis_map = (char *)lp_nis_home_map_name();
int home_server_len;
/* set to default of local machine */
pstrcpy(server_name, local_machine);
- if ((nis_error = yp_get_default_domain(&nis_domain)) != 0)
+ if (lp_nis_home_map())
{
- DEBUG(3, ("YP Error: %s\n", yperr_string(nis_error)));
- }
-
- DEBUG(5, ("NIS Domain: %s\n", nis_domain));
-
- if ((nis_error = yp_match(nis_domain, nis_map,
- user_name, strlen(user_name),
- &nis_result, &nis_result_len)) != 0)
- {
- DEBUG(3, ("YP Error: %s\n", yperr_string(nis_error)));
- }
-
- if (!nis_error && lp_nis_home_map())
- {
- home_server_len = strcspn(nis_result,":");
+ char *automount_value = automount_lookup(user_name);
+ home_server_len = strcspn(automount_value,":");
DEBUG(5, ("NIS lookup succeeded. Home server length: %d\n",home_server_len));
if (home_server_len > sizeof(pstring))
{
home_server_len = sizeof(pstring);
}
- strncpy(server_name, nis_result, home_server_len);
+ strncpy(server_name, automount_value, home_server_len);
server_name[home_server_len] = '\0';
}
#else
@@ -3764,6 +3808,44 @@ char *automount_server(char *user_name)
}
/*******************************************************************
+ Patch from jkf@soton.ac.uk
+ Added this to implement %p (NIS auto-map version of %H)
+*******************************************************************/
+
+char *automount_path(char *user_name)
+{
+ static pstring server_path;
+
+#if (defined(NETGROUP) && defined (AUTOMOUNT))
+ char *home_path_start;
+
+ /* set to default of no string */
+ server_path[0] = 0;
+
+ if (lp_nis_home_map())
+ {
+ char *automount_value = automount_lookup(user_name);
+ home_path_start = strchr(automount_value,':');
+ if (home_path_start != NULL)
+ {
+ DEBUG(5, ("NIS lookup succeeded. Home path is: %s\n",
+ home_path_start?(home_path_start+1):""));
+ strcpy(server_path, home_path_start+1);
+ }
+ }
+#else
+ /* use the passwd entry instead of the auto-map server entry */
+ /* pstrcpy() copes with get_home_dir() returning NULL */
+ pstrcpy(server_path, get_home_dir(user_name));
+#endif
+
+ DEBUG(4,("Home server path: %s\n", server_path));
+
+ return server_path;
+}
+
+
+/*******************************************************************
sub strings with useful parameters
Rewritten by Stefaan A Eeckels <Stefaan.Eeckels@ecc.lu> and
Paul Rippin <pr3245@nopc.eurostat.cec.be>
diff --git a/source/passdb/smbpass.c b/source/passdb/smbpass.c
index ea386bfa9df..fbda8949bcb 100644
--- a/source/passdb/smbpass.c
+++ b/source/passdb/smbpass.c
@@ -225,9 +225,7 @@ struct smb_passwd *get_smbpwd_entry(char *name, int smb_userid)
p++; /* Go past ':' */
if (!isdigit(*p)) {
DEBUG(0, ("get_smbpwd_entry: malformed password entry (uid not number)\n"));
- fclose(fp);
- pw_file_unlock(lockfd);
- return NULL;
+ continue;
}
uidval = atoi((char *) p);
@@ -240,9 +238,7 @@ struct smb_passwd *get_smbpwd_entry(char *name, int smb_userid)
if (*p != ':')
{
DEBUG(0, ("get_smbpwd_entry: malformed password entry (no : after uid)\n"));
- fclose(fp);
- pw_file_unlock(lockfd);
- return NULL;
+ continue;
}
if (name != NULL)
diff --git a/source/smbd/server.c b/source/smbd/server.c
index c2880b0e890..9c25a21000f 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -4569,6 +4569,15 @@ void standard_sub(int cnum,char *str)
case 'S' : string_sub(p,"%S",lp_servicename(Connections[cnum].service)); break;
case 'g' : string_sub(p,"%g",gidtoname(Connections[cnum].gid)); break;
case 'u' : string_sub(p,"%u",Connections[cnum].user); break;
+ /*
+ * Patch from jkf@soton.ac.uk
+ * Left the %N (NIS server name) in standard_sub_basic as it
+ * is a feature for logon servers, hence uses the username.
+ * The %p (NIS server path) code is here as it is used
+ * instead of the default "path =" string in [homes] and so
+ * needs the service name, not the username.
+ */
+ case 'p' : string_sub(p,"%p",automount_path(lp_servicename(Connections[cnum].service))); break;
case '\0' : p++; break; /* don't run off the end of the string */
default : p+=2; break;
}
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index 6eda891e328..893f1adc66b 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -977,7 +977,7 @@ static int call_trans2qfsinfo(char *inbuf, char *outbuf, int length, int bufsize
* Add volume serial number - hash of a combination of
* the called hostname and the service name.
*/
- SIVAL(pdata,0,str_checksum(lp_servicename(snum)) ^ str_checksum(local_machine) );
+ SIVAL(pdata,0,str_checksum(lp_servicename(snum)) ^ (str_checksum(local_machine)<<16) );
SCVAL(pdata,l2_vol_cch,volname_len);
StrnCpy(pdata+l2_vol_szVolLabel,vname,volname_len);
DEBUG(5,("call_trans2qfsinfo : time = %x, namelen = %d, name = %s\n",st.st_ctime, volname_len,
@@ -1002,7 +1002,7 @@ static int call_trans2qfsinfo(char *inbuf, char *outbuf, int length, int bufsize
* Add volume serial number - hash of a combination of
* the called hostname and the service name.
*/
- SIVAL(pdata,8,str_checksum(lp_servicename(snum)) ^ str_checksum(local_machine) );
+ SIVAL(pdata,8,str_checksum(lp_servicename(snum)) ^ (str_checksum(local_machine)<<16) );
SIVAL(pdata,12,2*strlen(vname));
PutUniCode(pdata+18,vname);
DEBUG(5,("call_trans2qfsinfo : SMB_QUERY_FS_VOLUME_INFO namelen = %d, vol = %s\n", strlen(vname),