[Hostname-devel] hostname -s behaviour should be consistent with other unixes (and with documentation)

Michael Meskes meskes at debian.org
Tue Oct 27 12:07:21 UTC 2009


Just a short comment on the patch.

On Wed, Oct 21, 2009 at 05:39:35AM -0400, Jiri Popelka wrote:
> diff -up hostname/hostname.c.hostnameshort hostname/hostname.c
> --- hostname/hostname.c.hostnameshort	2007-12-27 12:45:12.000000000 +0100
> +++ hostname/hostname.c	2009-10-21 11:19:46.000000000 +0200
> @@ -83,11 +83,12 @@ localdomain()
>   * If something goes wrong, 0 is returned, and errno set.
>   */
>  char *
> -localhost()
> +localhost(enum type_t type)
>  {
>  	char *buf = 0;
>  	size_t buf_len = 0;
>  	int myerror = 0;
> +	char *p;
>  
>  	do {
>  		errno = 0;
> @@ -108,6 +109,11 @@ localhost()
>  	if (myerror)
>  		err(1, NULL);
>  
> +	if (type == SHORT) {
> +		if (p = strchr(buf, '.'))
> +			*p = '\0';  
> +	}
> +	
>  	return buf;
>  }
>  

Either your version is different from ours or this whole part is not needed. We
have this code snippet right in front of your patch:

	/*
         * a hostname must not contain a dot, so if we find one,
         * we also have a domain in here, which we better remove
         */
        *(strchrnul(buf, '.')) = '\0';

Michael

-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes at jabber.org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!



More information about the Hostname-devel mailing list