homes bug - two different solutions

Jeremy Allison jra at samba.org
Thu Jul 15 00:57:32 GMT 2004


On Wed, Jul 14, 2004 at 09:01:51PM +0200, Michael Collin Nielsen wrote:
> Hi
> 
> I'm running samba-3.0.4 on a solaris 8 box and is investigating a setup 
> where samba acts as a domain member in a windows 2000 domain with 
> windows XP sp1 clients.
>
> ...
> 
> Here is what I this is hapening:
> The computer is started and the guest user connects to samba and instals 
> printers, my testuser then logs in, and register_vuid registers a homes 
> share in his session and in the global service table. The user then logs 
> off, and the computer is rebootet. After the reboot, the test user again 
> connects to samba, register_vuid again tries to register a homes share, 
> but now the service is already registered in the global service table, 
> and therefore register_vuid does not register the homes share in the 
> user session, and sets vuser->homes_snum = -1
> 
> ...
>
> I have made two diffs against samba-3.0.4 source:
> password-reuse-service.diff is the patch that reuses the servicenumber
> password-update-service.diff is the patch that updates the service
> They are available at: http://www.hum.aau.dk/~michael/samba3/
> 
> Hope you will take look at these :-)

Thanks a lot Michael,

Here is the fix I came up with. If you could test it out I'd
appreciate it.

Thanks,

	Jeremy.
-------------- next part --------------
Index: smbd/password.c
===================================================================
--- smbd/password.c	(revision 1502)
+++ smbd/password.c	(working copy)
@@ -253,19 +253,23 @@
 
 	/* Register a home dir service for this user iff
 	   (a) This is not a guest connection,
-	   (b) we have a home directory defined, and
-	   (c) there s not an existing static share by that name */
+	   (b) we have a home directory defined 
+	   If a share exists by this name (autoloaded or not) reuse it so
+	   long as the home directory is the same as the share directory. */
 
-	if ( (!vuser->guest) 
-		&& vuser->unix_homedir 
-		&& *(vuser->unix_homedir) 
-		&& (lp_servicenumber(vuser->user.unix_name) == -1) ) 
-	{
-			DEBUG(3, ("Adding/updating homes service for user '%s' using home directory: '%s'\n", 
+	if ( (!vuser->guest) && vuser->unix_homedir && *(vuser->unix_homedir)) {
+		int servicenumber = lp_servicenumber(vuser->user.unix_name);
+		if ( servicenumber == -1 ) {
+			DEBUG(3, ("Adding homes service for user '%s' using home directory: '%s'\n", 
 				vuser->user.unix_name, vuser->unix_homedir));
+			vuser->homes_snum = add_home_service(vuser->user.unix_name, 
+						vuser->user.unix_name, vuser->unix_homedir);
+		} else if (strcmp(lp_pathname(servicenumber),vuser->unix_homedir) == 0) {
+			DEBUG(3, ("Reusing homes service for user '%s' using home directory: '%s'\n", 
+				vuser->user.unix_name, vuser->unix_homedir));
 
-			vuser->homes_snum = add_home_service(vuser->user.unix_name, 
-				vuser->user.unix_name, vuser->unix_homedir);
+			vuser->homes_snum = servicenumber;
+		}
 	} else {
 		vuser->homes_snum = -1;
 	}


More information about the samba-technical mailing list