Annoying Minor Bug In Winbind 2.2.x

Esh, Andrew Andrew_Esh at adaptec.com
Tue Feb 18 21:21:06 GMT 2003


It's probably a line count thing. The head of the patch contains a certain
range of lines that the patch should apply to. If you truncated the patch at
the bottom, the header could be telling patch it needs to add, for example,
30 lines, while the patch text only contains 28.

Go back to the email and copy/paste lines from the email into your patch
file at the bottom, down to but not including the two dashes above Martin's
signature, and see if that helps. That line of stars is part of the patch,
and maybe a few blank lines below it. Make the part of the patch at the
bottom, below the lines with the plus signs, match what is already in the
target file.

> -----Original Message-----
> From: Boyce, Nick [mailto:nick.boyce at eds.com]
> Sent: Tuesday, February 18, 2003 2:58 PM
> To: samba-technical at lists.samba.org
> Cc: 'Martin Pool'
> Subject: RE: Annoying Minor Bug In Winbind 2.2.x
> 
> 
> On 18 Feb 2003, Martin Pool wrote :
> 
> > Jeremy already committed my patch to SAMBA_2_2 CVS.  
> > Here's the patch.
> > 
> > Index: util_sock.c
> > ===================================================================
> > RCS file: /data/cvs/samba/source/lib/util_sock.c,v
> > retrieving revision 1.16.4.36
> > retrieving revision 1.16.4.37
> > diff -u -u -p -r1.16.4.36 -r1.16.4.37
> [snip]
> 
> I'm sorry - I'm probably doing something dumb, but I still 
> get failures even
> with this patch - first, if I save the patch as it appeared 
> in my Outlook
> window, then line 25 consists of a single left brace char, 
> which results in
> :
> 
>    MYBOX:/usr/local/src/samba-2.2.7a/source/lib# patch util_sock.c
> patch-util_sock-20030218
>    patching file util_sock.c
>    patch: **** malformed patch at line 25: {
> 
> So assuming line-wrap did something Bad to that line, I 
> edited the patch
> file to stick that line onto the end of line 24, resulting in :
> 
>    MYBOX:/usr/local/src/samba-2.2.7a/source/lib# patch util_sock.c
> patch-util_sock-20030218
>    patching file util_sock.c
>    Hunk #1 FAILED at 1021.
>    1 out of 1 hunk FAILED -- saving rejects to file util_sock.c.rej
> 
> and I don't know enough about what I'm looking at to figure it out.
> 
> > In general the best thing to do now is leave the main diff 
> alone, and
> > only work on the rejected parts in the .rej file.  
> Basically you need
> > to work out why patch thinks the 2.2 source file doesn't 
> look like the
> > "before" version of the rejected patch.
> 
> OK - hang on ... right, it seems the real original 2.2.7a 
> util_sock.c really
> *does* have the "{" on line 25 all by itself - but since that gave me
> "malformed patch", I assume the patch needs a "rediff" ???  
> Here goes :
> 
>    MYBOX:/usr/local/src/samba-2.2.7a/source/lib# rediff
> patch-util_sock-20030218.orig patch-util_sock-20030218
>    Index: util_sock.c
>    ===================================================================
>    RCS file: /data/cvs/samba/source/lib/util_sock.c,v
>    retrieving revision 1.16.4.36
>    retrieving revision 1.16.4.37
>    diff -u -u -p -r1.16.4.36 -r1.16.4.37
>    rediff: Not supported: -{
> 
> OK - I give up for now ... heeeelp :(
> [sorry .. for all this trouble over such a minor thing]
> 
> Nick Boyce
> EDS Southwest Solution Centre, Bristol, UK
> 
> 
> 
> -----Original Message-----
> From: 'Martin Pool' [mailto:mbp at sourcefrog.net]
> Sent: 17 February 2003 23:08
> To: Boyce, Nick
> Cc: samba-technical at lists.samba.org
> Subject: Re: Annoying Minor Bug In Winbind 2.2.x
> 
> 
> Oh, Jeremy already committed my patch to SAMBA_2_2 CVS.  Here's the
> patch.
> 
> 
> 
> 
> Index: util_sock.c
> ===================================================================
> RCS file: /data/cvs/samba/source/lib/util_sock.c,v
> retrieving revision 1.16.4.36
> retrieving revision 1.16.4.37
> diff -u -u -p -r1.16.4.36 -r1.16.4.37
> --- util_sock.c	26 Aug 2002 20:07:13 -0000	1.16.4.36
> +++ util_sock.c	7 Feb 2003 22:04:37 -0000	1.16.4.37
> @@ -1021,102 +1021,97 @@ char *get_socket_addr(int fd)
>  /*******************************************************************
>   Create protected unix domain socket.
>  
> - some unixen cannot set permissions on a ux-dom-sock, so we
> + Some unixes cannot set permissions on a ux-dom-sock, so we
>   have to make sure that the directory contains the protection
> - permissions, instead.
> + permissions instead.
>   ******************************************************************/
> +
>  int create_pipe_sock(const char *socket_dir,
> -					const char *socket_name,
> -					mode_t dir_perms)
> +		     const char *socket_name,
> +		     mode_t dir_perms)
>  {
> -        struct sockaddr_un sunaddr;
> -        struct stat st;
> -        int sock;
> -        mode_t old_umask;
> -        pstring path;
> -        
> -        /* Create the socket directory or reuse the existing one */
> -        
> -        if (lstat(socket_dir, &st) == -1) {
> -                
> -                if (errno == ENOENT) {
> -                        
> -                        /* Create directory */
> -                        
> -                        if (mkdir(socket_dir, dir_perms) == -1) {
> -                                DEBUG(0, ("error creating 
> socket directory
> "
> -                                          "%s: %s\n", socket_dir, 
> -                                          strerror(errno)));
> -                                return -1;
> -                        }
> -                        
> -                } else {
> -                        
> -                        DEBUG(0, ("lstat failed on socket 
> directory %s:
> %s\n",
> -                                  socket_dir, strerror(errno)));
> -                        return -1;
> -                }
> -                
> -        } else {
> -                
> -                /* Check ownership and permission on 
> existing directory */
> -                
> -                if (!S_ISDIR(st.st_mode)) {
> -                        DEBUG(0, ("socket directory %s isn't a
> directory\n",
> -                                  socket_dir));
> -                        return -1;
> -                }
> -                
> -                if ((st.st_uid != sec_initial_uid()) || 
> -                    ((st.st_mode & 0777) != dir_perms)) {
> -                        DEBUG(0, ("invalid permissions on 
> socket directory
> "
> -                                  "%s\n", socket_dir));
> -                        return -1;
> -                }
> -        }
> -        
> -        /* Create the socket file */
> -        
> -        old_umask = umask(0);
> -        
> -        sock = socket(AF_UNIX, SOCK_STREAM, 0);
> -        
> -        if (sock == -1) {
> -                perror("socket");
> -		umask(old_umask);
> -                return -1;
> -        }
> -        
> -        snprintf(path, sizeof(path), "%s/%s", socket_dir, 
> socket_name);
> -        
> -        unlink(path);
> -        memset(&sunaddr, 0, sizeof(sunaddr));
> -        sunaddr.sun_family = AF_UNIX;
> -        safe_strcpy(sunaddr.sun_path, path, 
> sizeof(sunaddr.sun_path)-1);
> -        
> -        if (bind(sock, (struct sockaddr *)&sunaddr, 
> sizeof(sunaddr)) == -1)
> {
> -                DEBUG(0, ("bind failed on pipe socket %s: %s\n",
> -                          path,
> -                          strerror(errno)));
> -                close(sock);
> -		umask(old_umask);
> -                return -1;
> -        }
> -        
> -        if (listen(sock, 5) == -1) {
> -                DEBUG(0, ("listen failed on pipe socket %s: %s\n",
> -                          path,
> -                          strerror(errno)));
> -                close(sock);
> -		umask(old_umask);
> -                return -1;
> -        }
> -        
> -        umask(old_umask);
> -        
> -        /* Success! */
> -        
> -        return sock;
> +#ifdef HAVE_UNIXSOCKET
> +	struct sockaddr_un sunaddr;
> +	struct stat st;
> +	int sock;
> +	mode_t old_umask;
> +	pstring path;
> +        
> +	old_umask = umask(0);
> +        
> +	/* Create the socket directory or reuse the existing one */
> +        
> +	if (lstat(socket_dir, &st) == -1) {
> +		if (errno == ENOENT) {
> +			/* Create directory */
> +			if (mkdir(socket_dir, dir_perms) == -1) {
> +				DEBUG(0, ("error creating 
> socket directory "
> +					"%s: %s\n", socket_dir, 
> +					strerror(errno)));
> +				goto out_umask;
> +			}
> +		} else {
> +			DEBUG(0, ("lstat failed on socket directory %s:
> %s\n",
> +				socket_dir, strerror(errno)));
> +			goto out_umask;
> +		}
> +	} else {
> +		/* Check ownership and permission on existing 
> directory */
> +		if (!S_ISDIR(st.st_mode)) {
> +			DEBUG(0, ("socket directory %s isn't a 
> directory\n",
> +				socket_dir));
> +			goto out_umask;
> +		}
> +		if ((st.st_uid != sec_initial_uid()) || 
> +				((st.st_mode & 0777) != dir_perms)) {
> +			DEBUG(0, ("invalid permissions on 
> socket directory "
> +				"%s\n", socket_dir));
> +			goto out_umask;
> +		}
> +	}
> +        
> +	/* Create the socket file */
> +        
> +	sock = socket(AF_UNIX, SOCK_STREAM, 0);
> +        
> +	if (sock == -1) {
> +		perror("socket");
> +                goto out_umask;
> +	}
> +        
> +	snprintf(path, sizeof(path), "%s/%s", socket_dir, socket_name);
> +        
> +	unlink(path);
> +	memset(&sunaddr, 0, sizeof(sunaddr));
> +	sunaddr.sun_family = AF_UNIX;
> +	safe_strcpy(sunaddr.sun_path, path, sizeof(sunaddr.sun_path)-1);
> +        
> +	if (bind(sock, (struct sockaddr *)&sunaddr, 
> sizeof(sunaddr)) == -1)
> {
> +		DEBUG(0, ("bind failed on pipe socket %s: %s\n", path,
> +			strerror(errno)));
> +		goto out_close;
> +	}
> +        
> +	if (listen(sock, 5) == -1) {
> +		DEBUG(0, ("listen failed on pipe socket %s: %s\n", path,
> +			strerror(errno)));
> +		goto out_close;
> +	}
> +        
> +	umask(old_umask);
> +	return sock;
> +
> +out_close:
> +	close(sock);
> +
> +out_umask:
> +	umask(old_umask);
> +	return -1;
> +
> +#else
> +        DEBUG(0, ("create_pipe_sock: No Unix sockets on this 
> system\n"));
> +        return -1;
> +#endif /* HAVE_UNIXSOCKET */
>  }
>  
>  /*******************************************************************
> 
> 
> 
> -- 
> Martin 
> 


More information about the samba-technical mailing list