Subject: Re: Anyone resolved "failed to lock SMB passwd file"?
From: Fulvio Corno <[email-masked]>
To: Robert Dahlem <[email-masked]>
Cc: Multiple recipients of list <[email-masked]>
Date: Thu, 29 Oct 1998 13:58:37 +0100

Robert,
thank you for the very useful insight.

Robert Dahlem wrote:
> Samba locks smbpasswd when it runs with "update encryted = yes" and does not find
> the user to be updated in smbpasswd. Make sure you have *all* users in smbpasswd
> and the problem will disappear.

Indeed, it seems fixed now.

> Perhaps someone has a bit of spare time to proove this and report to samba-bugs. I
> feel discouraged to do so because I reported several problems and never got
> something back but the machine generated reply to be patient ...

I found the (possible) source of the error, in smbpass.c line 620+

        /* We have a write lock on the file. */
        /*
        * Scan the file, a line at a time and check if the name matches.
        */
        while (!feof(fp))
        {
               ....omissis....
        }
        if (!found_entry) return False;   /* line 707 */

If no entry is found, the procedure returns without releasing the lock.
I modified the last statement as:

        if (!found_entry)                 /* line 707 */
        {
                fclose(fp);
                pw_file_unlock(lockfd);
                return False;
        }

as it appears in other parts of the code. For now, it seems to have
corrected the problem.

thanks again, and happy sambing
	Fulvio

------------------------------

*** smbpass.c.dist	Wed May 13 11:10:37 1998
--- smbpass.c	Mon Nov  9 12:49:22 1998
***************
*** 704,710 ****
  		}
  	}
  
! 	if (!found_entry) return False;
  
  	DEBUG(6, ("mod_smbpwd_entry: entry exists\n"));
  
--- 704,715 ----
  		}
  	}
  
! 	if (!found_entry)
! 	{
! 	    fclose(fp);
! 	    pw_file_unlock(lockfd);
! 	    return False;
! 	}
  
  	DEBUG(6, ("mod_smbpwd_entry: entry exists\n"));