threads / patch / 99

patchfixup GECOS handling

Subject: [patch] fixup GECOS handling

## tl;dr

16 messages between Apr 18, 2005 and Apr 25, 2005. Diffs are folded; open one to read it.

replies: 15people: 5as markdown or json

Martin Schlemmer· Apr 18, 2005, 10:36 UTC · lore
Hi,

The gecos is delimited by ',' or ';', so we should only use whatever before the first ',' or ';' for the full name, and not just strip those. Also, a '.' may be valid in the full name (Foo B. Zooman) or email (foo.zooman@bar.com).

Signed-off-by: Martin Schlemmer <azarah@gentoo.org>

commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0 --- 1/commit-tree.c +++ 2/commit-tree.c 2005-04-18 12:22:18.000000000 +0200

Show changes to diff +5 −15
@@ -96,21 +96,6 @@
                if (!c)
                        break;
        }
-
-       /*
-        * Go back, and remove crud from the end: some people
-        * have commas etc in their gecos field
-        */
-       dst--;
-       while (--dst >= p) {
-               unsigned char c = *dst;
-               switch (c) {
-               case ',': case ';': case '.':
-                       *dst = 0;
-                       continue;
-               }
-               break;
-       }
 }

 static const char *month_names[] = {
@@ -313,6 +298,11 @@
        if (!pw)
                die("You don't exist. Go away!");
        realgecos = pw->pw_gecos;
+       /* The name is seperated from the room no., tel no, etc via [,;] */
+       if (strchr(realgecos, ','))
+               realgecos[strchr(realgecos, ',') - realgecos] = '\0';
+       else if (strchr(realgecos, ';'))
+               realgecos[strchr(realgecos, ';') - realgecos] = '\0';
        len = strlen(pw->pw_name);
        memcpy(realemail, pw->pw_name, len);
        realemail[len] = '@';
-- 
Martin Schlemmer



commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c	2005-04-18 12:22:18.000000000 +0200
@@ -96,21 +96,6 @@
 		if (!c)
 			break;
 	}
-
-	/*
-	 * Go back, and remove crud from the end: some people
-	 * have commas etc in their gecos field
-	 */
-	dst--;
-	while (--dst >= p) {
-		unsigned char c = *dst;
-		switch (c) {
-		case ',': case ';': case '.':
-			*dst = 0;
-			continue;
-		}
-		break;
-	}
 }
 
 static const char *month_names[] = {
@@ -313,6 +298,11 @@
 	if (!pw)
 		die("You don't exist. Go away!");
 	realgecos = pw->pw_gecos;
+	/* The name is seperated from the room no., tel no, etc via ',' or ';' */
+	if (strchr(realgecos, ','))
+		realgecos[strchr(realgecos, ',') - realgecos] = '\0';
+	else if (strchr(realgecos, ';'))
+		realgecos[strchr(realgecos, ';') - realgecos] = '\0';
 	len = strlen(pw->pw_name);
 	memcpy(realemail, pw->pw_name, len);
 	realemail[len] = '@';
David Woodhouse· Apr 18, 2005, 12:35 UTC · re: Martin Schlemmer · lore

Re: [patch] fixup GECOS handling

On Mon, 2005-04-18 at 12:36 +0200, Martin Schlemmer wrote:
> realgecos[strchr(realgecos, ',') - realgecos] = '\0';

Er, *strchr(realgecos, ',') = 0; surely? Even if the compiler is clever enough to optimise out the gratuitous addition and subtraction, that's no real excuse for it.

-- 
dwmw2
Martin Schlemmer· Apr 18, 2005, 12:58 UTC · re: David Woodhouse · lore

Re: [patch] fixup GECOS handling

On Mon, 2005-04-18 at 22:35 +1000, David Woodhouse wrote:
Show 7 quoted lines
> On Mon, 2005-04-18 at 12:36 +0200, Martin Schlemmer wrote:
> > realgecos[strchr(realgecos, ',') - realgecos] = '\0';
> 
> Er, *strchr(realgecos, ',') = 0; surely? Even if the compiler is clever
> enough to optimise out the gratuitous addition and subtraction, that's
> no real excuse for it.
> 
Err, right.  Updated patch.

The gecos is delimited by ',' or ';', so we should only use whatever before the first ',' or ';' for the full name, and not just strip those.

Signed-off-by: Martin Schlemmer <azarah@gentoo.org>

commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0 --- 1/commit-tree.c +++ 2/commit-tree.c 2005-04-18 12:22:18.000000000 +0200

Show changes to diff +5 −15
@@ -96,21 +96,6 @@
                if (!c)
                        break;
        }
-
-       /*
-        * Go back, and remove crud from the end: some people
-        * have commas etc in their gecos field
-        */
-       dst--;
-       while (--dst >= p) {
-               unsigned char c = *dst;
-               switch (c) {
-               case ',': case ';': case '.':
-                       *dst = 0;
-                       continue;
-               }
-               break;
-       }
 }

 static const char *month_names[] = {
@@ -313,6 +298,11 @@
        if (!pw)
                die("You don't exist. Go away!");
        realgecos = pw->pw_gecos;
+       /* The name is seperated from the room no., tel no, etc via [,;] */
+       if (strchr(realgecos, ','))
+               *strchr(realgecos, ',') = 0;
+       else if (strchr(realgecos, ';'))
+               *strchr(realgecos, ';') = 0;
        len = strlen(pw->pw_name);
        memcpy(realemail, pw->pw_name, len);
        realemail[len] = '@';
-- 
Martin Schlemmer



commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c	2005-04-18 12:22:18.000000000 +0200
@@ -96,21 +96,6 @@
 		if (!c)
 			break;
 	}
-
-	/*
-	 * Go back, and remove crud from the end: some people
-	 * have commas etc in their gecos field
-	 */
-	dst--;
-	while (--dst >= p) {
-		unsigned char c = *dst;
-		switch (c) {
-		case ',': case ';': case '.':
-			*dst = 0;
-			continue;
-		}
-		break;
-	}
 }
 
 static const char *month_names[] = {
@@ -313,6 +298,11 @@
 	if (!pw)
 		die("You don't exist. Go away!");
 	realgecos = pw->pw_gecos;
+	/* The name is seperated from the room no., tel no, etc via ',' or ';' */
+	if (strchr(realgecos, ','))
+		*strchr(realgecos, ',') = 0;
+	else if (strchr(realgecos, ';'))
+		*strchr(realgecos, ';') = 0;
 	len = strlen(pw->pw_name);
 	memcpy(realemail, pw->pw_name, len);
 	realemail[len] = '@';
Martin Schlemmer· Apr 22, 2005, 14:23 UTC · re: David Woodhouse · lore
Hi,
This still applies - any reason for not doing this?
Thanks,
----

The GECOS is delimited by ',' or ';', so we should only use whatever is before the first ',' or ';' for the full name, rather than just stripping those.

Signed-off-by: Martin Schlemmer <azarah@gentoo.org>

commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0 --- 1/commit-tree.c +++ 2/commit-tree.c 2005-04-18 12:22:18.000000000 +0200

Show changes to diff +5 −15
@@ -96,21 +96,6 @@
                if (!c)
                        break;
        }
-
-       /*
-        * Go back, and remove crud from the end: some people
-        * have commas etc in their gecos field
-        */
-       dst--;
-       while (--dst >= p) {
-               unsigned char c = *dst;
-               switch (c) {
-               case ',': case ';': case '.':
-                       *dst = 0;
-                       continue;
-               }
-               break;
-       }
 }

 static const char *month_names[] = {
@@ -313,6 +298,11 @@
        if (!pw)
                die("You don't exist. Go away!");
        realgecos = pw->pw_gecos;
+       /* The name is seperated from the room no., tel no, etc via [,;] */
+       if (strchr(realgecos, ','))
+               *strchr(realgecos, ',') = 0;
+       else if (strchr(realgecos, ';'))
+               *strchr(realgecos, ';') = 0;
        len = strlen(pw->pw_name);
        memcpy(realemail, pw->pw_name, len);
        realemail[len] = '@';
-- 
Martin Schlemmer



commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c	2005-04-18 12:22:18.000000000 +0200
@@ -96,21 +96,6 @@
 		if (!c)
 			break;
 	}
-
-	/*
-	 * Go back, and remove crud from the end: some people
-	 * have commas etc in their gecos field
-	 */
-	dst--;
-	while (--dst >= p) {
-		unsigned char c = *dst;
-		switch (c) {
-		case ',': case ';': case '.':
-			*dst = 0;
-			continue;
-		}
-		break;
-	}
 }
 
 static const char *month_names[] = {
@@ -313,6 +298,11 @@
 	if (!pw)
 		die("You don't exist. Go away!");
 	realgecos = pw->pw_gecos;
+	/* The name is seperated from the room no., tel no, etc via ',' or ';' */
+	if (strchr(realgecos, ','))
+		*strchr(realgecos, ',') = 0;
+	else if (strchr(realgecos, ';'))
+		*strchr(realgecos, ';') = 0;
 	len = strlen(pw->pw_name);
 	memcpy(realemail, pw->pw_name, len);
 	realemail[len] = '@';
Kyle Hayes· Apr 22, 2005, 16:16 UTC · re: Martin Schlemmer · lore

Re: [patch] fixup GECOS handling

On Fri, 2005-04-22 at 16:23 +0200, Martin Schlemmer wrote:
> Hi,
> 
> This still applies - any reason for not doing this?
Seems like this will break on certain kinds of data.  See below.
Show 11 quoted lines
>         if (!pw)
>                 die("You don't exist. Go away!");
>         realgecos = pw->pw_gecos;
> +       /* The name is seperated from the room no., tel no, etc via [,;] */
> +       if (strchr(realgecos, ','))
> +               *strchr(realgecos, ',') = 0;
> +       else if (strchr(realgecos, ';'))
> +               *strchr(realgecos, ';') = 0;
>         len = strlen(pw->pw_name);
>         memcpy(realemail, pw->pw_name, len);
>         realemail[len] = '@';
Suppose that the GECOS field is:
Hayes, Kyle; Room 42; 424-424-4242; foo bar baz...

You'll search for the first comma, find it, truncate my name to "Hayes", and continue.

I have seen this kind of GECOS in larger environments where the individual users are not the ones that administrate their machines. Using the LastName, FirstName style of name is not rare.

I think you want something like this (not tested):
char *comma,*semi;

comma = strchr(realgecos,','); semi = strchr(realgecos,';');

if(comma)
	if(semi)
		/* lastname, firstname; room #; phone # format */
		*semi  = 0;
	else
		*comma = 0;
else if(semi)
	*semi = 0;
(hopefully Evolution won't trash the indentation...)

Best, Kyle

-- 
Kyle Hayes <kyle@marchex.com>
Marchex Inc.
Martin Schlemmer· Apr 22, 2005, 16:58 UTC · re: Kyle Hayes · lore

Re: [patch] fixup GECOS handling

On Fri, 2005-04-22 at 09:16 -0700, Kyle Hayes wrote:
Show 30 quoted lines
> On Fri, 2005-04-22 at 16:23 +0200, Martin Schlemmer wrote:
> > Hi,
> > 
> > This still applies - any reason for not doing this?
> 
> Seems like this will break on certain kinds of data.  See below.
> 
> >         if (!pw)
> >                 die("You don't exist. Go away!");
> >         realgecos = pw->pw_gecos;
> > +       /* The name is seperated from the room no., tel no, etc via [,;] */
> > +       if (strchr(realgecos, ','))
> > +               *strchr(realgecos, ',') = 0;
> > +       else if (strchr(realgecos, ';'))
> > +               *strchr(realgecos, ';') = 0;
> >         len = strlen(pw->pw_name);
> >         memcpy(realemail, pw->pw_name, len);
> >         realemail[len] = '@';
> 
> Suppose that the GECOS field is:
> 
> Hayes, Kyle; Room 42; 424-424-4242; foo bar baz...
> 
> You'll search for the first comma, find it, truncate my name to "Hayes",
> and continue.
> 
> I have seen this kind of GECOS in larger environments where the
> individual users are not the ones that administrate their machines.
> Using the LastName, FirstName style of name is not rare. 
> 
What OS?  With Linux at least, this is what chfn's manpage say:
----
       The only restriction placed on the contents of the fields is that no control characters may  be  present,
       nor  any  of  comma, colon, or equal sign. The other field does not have this restriction, and is used to
       store accounting information used by other applications.
----

Meaning, if they use a ',' in one of the fields (and it is a linux system with the chfn most probably from the shadow package), then they are looking for trouble. The only reason I added the ';' was because somebody said whatever OS used it instead of a ','.

Thanks,
-- 
Martin Schlemmer
Petr Baudis· Apr 22, 2005, 17:18 UTC · re: Martin Schlemmer · lore

Re: [patch] fixup GECOS handling

Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter where Martin Schlemmer <azarah@nosferatu.za.org> told me that...

> Meaning, if they use a ',' in one of the fields (and it is a linux
> system with the chfn most probably from the shadow package), then they
> are looking for trouble.  The only reason I added the ';' was because
> somebody said whatever OS used it instead of a ','.

What about just swapping the two tests so that ; is cut off and , only when no ; is around?

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Martin Schlemmer· Apr 22, 2005, 17:25 UTC · re: Petr Baudis · lore

Re: [patch] fixup GECOS handling

On Fri, 2005-04-22 at 19:18 +0200, Petr Baudis wrote:
Show 10 quoted lines
> Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > Meaning, if they use a ',' in one of the fields (and it is a linux
> > system with the chfn most probably from the shadow package), then they
> > are looking for trouble.  The only reason I added the ';' was because
> > somebody said whatever OS used it instead of a ','.
> 
> What about just swapping the two tests so that ; is cut off and , only
> when no ; is around?
> 

Actually, maybe just leave it. Its not a train smash, and in theory on linux ';' is a valid char in the gecos.

-- 
Martin Schlemmer
Kyle Hayes· Apr 22, 2005, 17:58 UTC · re: Petr Baudis · lore

Re: [patch] fixup GECOS handling

On Fri, 2005-04-22 at 19:18 +0200, Petr Baudis wrote:
Show 9 quoted lines
> Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > Meaning, if they use a ',' in one of the fields (and it is a linux
> > system with the chfn most probably from the shadow package), then they
> > are looking for trouble.  The only reason I added the ';' was because
> > somebody said whatever OS used it instead of a ','.
> 
> What about just swapping the two tests so that ; is cut off and , only
> when no ; is around?
Even nicer.  I like it.  Very clean!

Best, Kyle

-- 
Kyle Hayes <kyle@marchex.com>
Marchex Inc.
Martin Schlemmer· Apr 22, 2005, 19:06 UTC · re: Kyle Hayes · lore

Re: [patch] fixup GECOS handling

On Fri, 2005-04-22 at 10:58 -0700, Kyle Hayes wrote:
Show 13 quoted lines
> On Fri, 2005-04-22 at 19:18 +0200, Petr Baudis wrote:
> > Dear diary, on Fri, Apr 22, 2005 at 06:58:25PM CEST, I got a letter
> > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > > Meaning, if they use a ',' in one of the fields (and it is a linux
> > > system with the chfn most probably from the shadow package), then they
> > > are looking for trouble.  The only reason I added the ';' was because
> > > somebody said whatever OS used it instead of a ','.
> > 
> > What about just swapping the two tests so that ; is cut off and , only
> > when no ; is around?
> 
> Even nicer.  I like it.  Very clean!
> 

Right, but ';' is not cutoff on linux for one, and from what you said freebsd as well. How about this rather (note that I assumed that the use of ';' as delimiter will be in the minority, but we can switch things around if it turns out the other way):

---- (not signed off, etc, as just for comments)

Show changes to diff +11 −15
Index: commit-tree.c
===================================================================
--- 5f61aecb06c2f2579bbb5951b1b53e0dedc434eb/commit-tree.c  (mode:100644 sha1:c0b07f89286c3f6cceae8122b4c3142c8efaf8e1)
+++ uncommitted/commit-tree.c  (mode:100644)
@@ -96,21 +96,6 @@
                if (!c)
                        break;
        }
-
-       /*
-        * Go back, and remove crud from the end: some people
-        * have commas etc in their gecos field
-        */
-       dst--;
-       while (--dst >= p) {
-               unsigned char c = *dst;
-               switch (c) {
-               case ',': case ';': case '.':
-                       *dst = 0;
-                       continue;
-               }
-               break;
-       }
 }

 static const char *month_names[] = {
@@ -311,6 +296,17 @@
        if (!pw)
                die("You don't exist. Go away!");
        realgecos = pw->pw_gecos;
+       /*
+        * The GECOS fields are seperated via ',' on Linux, FreeBSD, etc,
+        * and ';' on AIX.
+        */
+#if defined(__aix__)
+       if (strchr(realgecos, ';'))
+               *strchr(realgecos, ';') = 0;
+#else
+       if (strchr(realgecos, ','))
+               *strchr(realgecos, ',') = 0;
+#endif
        len = strlen(pw->pw_name);
        memcpy(realemail, pw->pw_name, len);
        realemail[len] = '@';
-- 
Martin Schlemmer
Kyle Hayes· Apr 22, 2005, 20:46 UTC · re: Martin Schlemmer · lore

Re: [patch] fixup GECOS handling

On Fri, 2005-04-22 at 21:06 +0200, Martin Schlemmer wrote:
> Right, but ';' is not cutoff on linux for one, and from what you said
> freebsd as well.  How about this rather (note that I assumed that the
> use of ';' as delimiter will be in the minority, but we can switch
> things around if it turns out the other way):

I'm not sure that __aix__ is defined, but it is close enough. Someone with an AIX compiler can correct it if needed. Anyone know about HP-UX and Tru64 and all those other ones?

Note that the original code also cuts on '.'. Is that used by some *nix in GECOS?

Best, Kyle

Show 49 quoted lines
> ----
> (not signed off, etc, as just for comments)
> 
> Index: commit-tree.c
> ===================================================================
> --- 5f61aecb06c2f2579bbb5951b1b53e0dedc434eb/commit-tree.c  (mode:100644 sha1:c0b07f89286c3f6cceae8122b4c3142c8efaf8e1)
> +++ uncommitted/commit-tree.c  (mode:100644)
> @@ -96,21 +96,6 @@
>                 if (!c)
>                         break;
>         }
> -
> -       /*
> -        * Go back, and remove crud from the end: some people
> -        * have commas etc in their gecos field
> -        */
> -       dst--;
> -       while (--dst >= p) {
> -               unsigned char c = *dst;
> -               switch (c) {
> -               case ',': case ';': case '.':
> -                       *dst = 0;
> -                       continue;
> -               }
> -               break;
> -       }
>  }
> 
>  static const char *month_names[] = {
> @@ -311,6 +296,17 @@
>         if (!pw)
>                 die("You don't exist. Go away!");
>         realgecos = pw->pw_gecos;
> +       /*
> +        * The GECOS fields are seperated via ',' on Linux, FreeBSD, etc,
> +        * and ';' on AIX.
> +        */
> +#if defined(__aix__)
> +       if (strchr(realgecos, ';'))
> +               *strchr(realgecos, ';') = 0;
> +#else
> +       if (strchr(realgecos, ','))
> +               *strchr(realgecos, ',') = 0;
> +#endif
>         len = strlen(pw->pw_name);
>         memcpy(realemail, pw->pw_name, len);
>         realemail[len] = '@';
> 
> 
-- 
Kyle Hayes <kyle@marchex.com>
Marchex Inc.
Petr Baudis· Apr 23, 2005, 23:38 UTC · re: Martin Schlemmer · lore

Re: [patch] fixup GECOS handling

Dear diary, on Fri, Apr 22, 2005 at 09:06:43PM CEST, I got a letter where Martin Schlemmer <azarah@nosferatu.za.org> told me that...

Show 18 quoted lines
> @@ -311,6 +296,17 @@
>         if (!pw)
>                 die("You don't exist. Go away!");
>         realgecos = pw->pw_gecos;
> +       /*
> +        * The GECOS fields are seperated via ',' on Linux, FreeBSD, etc,
> +        * and ';' on AIX.
> +        */
> +#if defined(__aix__)
> +       if (strchr(realgecos, ';'))
> +               *strchr(realgecos, ';') = 0;
> +#else
> +       if (strchr(realgecos, ','))
> +               *strchr(realgecos, ',') = 0;
> +#endif
>         len = strlen(pw->pw_name);
>         memcpy(realemail, pw->pw_name, len);
>         realemail[len] = '@';

I'm confused, what does this has to do with AIX? Do we even have / can expect to have any major AIX users?

I'm not too happy with this, I have to say. It seems it won't do always the right thing anyway. I would still favour the approach when you cut off everything after ';', and everything after ',' if no ';' is found. Seems simplest, safest, etc.

Tell me about anyone who has a semicolon in his realname.
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Martin Schlemmer· Apr 23, 2005, 23:49 UTC · re: Petr Baudis · lore

Re: [patch] fixup GECOS handling

On Sun, 2005-04-24 at 01:38 +0200, Petr Baudis wrote:
Show 24 quoted lines
> Dear diary, on Fri, Apr 22, 2005 at 09:06:43PM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > @@ -311,6 +296,17 @@
> >         if (!pw)
> >                 die("You don't exist. Go away!");
> >         realgecos = pw->pw_gecos;
> > +       /*
> > +        * The GECOS fields are seperated via ',' on Linux, FreeBSD, etc,
> > +        * and ';' on AIX.
> > +        */
> > +#if defined(__aix__)
> > +       if (strchr(realgecos, ';'))
> > +               *strchr(realgecos, ';') = 0;
> > +#else
> > +       if (strchr(realgecos, ','))
> > +               *strchr(realgecos, ',') = 0;
> > +#endif
> >         len = strlen(pw->pw_name);
> >         memcpy(realemail, pw->pw_name, len);
> >         realemail[len] = '@';
> 
> I'm confused, what does this has to do with AIX? Do we even have / can
> expect to have any major AIX users?
> 
Given.
Show 7 quoted lines
> I'm not too happy with this, I have to say. It seems it won't do always
> the right thing anyway. I would still favour the approach when you cut
> off everything after ';', and everything after ',' if no ';' is found.
> Seems simplest, safest, etc.
> 
> Tell me about anyone who has a semicolon in his realname.
> 

Point I guess is still that the only valid delimiter on linux is ',', and the only reason for the ';' was because of some aix/whatever user saying that is a delimiter as well. But like I said: cat $this

> /dev/null ... This is basically the same type of discussion as the
hash collision one, and I'm sure we all have better things to do.
Thanks,
-- 
Martin Schlemmer
Kyle Hayes· Apr 22, 2005, 17:43 UTC · re: Martin Schlemmer · lore

Re: [patch] fixup GECOS handling

On Fri, 2005-04-22 at 18:58 +0200, Martin Schlemmer wrote:
Show 14 quoted lines
> On Fri, 2005-04-22 at 09:16 -0700, Kyle Hayes wrote:
> > Suppose that the GECOS field is:
> > 
> > Hayes, Kyle; Room 42; 424-424-4242; foo bar baz...
> > 
> > You'll search for the first comma, find it, truncate my name to "Hayes",
> > and continue.
> > 
> > I have seen this kind of GECOS in larger environments where the
> > individual users are not the ones that administrate their machines.
> > Using the LastName, FirstName style of name is not rare. 
> > 
> 
> What OS?  With Linux at least, this is what chfn's manpage say:

Can't remember, it's been a while (years). We had AIX, Solaris, Linux and BSD machines at the time. Might have been AIX, I think. The memory of which OS is vague, but not the annoyance of finding the problem :-(

Show 10 quoted lines
> ----
>        The only restriction placed on the contents of the fields is that no control characters may  be  present,
>        nor  any  of  comma, colon, or equal sign. The other field does not have this restriction, and is used to
>        store accounting information used by other applications.
> ----
> 
> Meaning, if they use a ',' in one of the fields (and it is a linux
> system with the chfn most probably from the shadow package), then they
> are looking for trouble.  The only reason I added the ';' was because
> somebody said whatever OS used it instead of a ','.
>From the AIX version of chfn:

---- You can use any printable characters in the gecos information string except a : (colon), which is an attribute delimiter. ----

The AIX examples show use of semicolon as a separator.

So, at least on AIX, it is appears valid to use the style I showed above. I don't have access to Solaris machines right now. The BSD (FreeBSD 4.11) version of man 5 passwd:

---- The gecos field normally contains comma (`,') separated subfields as follows:... ----

Best, Kyle

-- 
Kyle Hayes <kyle@marchex.com>
Marchex Inc.
Andy Isaacson· Apr 22, 2005, 23:30 UTC · re: Kyle Hayes · lore

Re: [patch] fixup GECOS handling

On Fri, Apr 22, 2005 at 09:16:39AM -0700, Kyle Hayes wrote:
Show 8 quoted lines
> if(comma)
> 	if(semi)
> 		/* lastname, firstname; room #; phone # format */
> 		*semi  = 0;
> 	else
> 		*comma = 0;
> else if(semi)
> 	*semi = 0;
That's a really complicated way of writing

if(semi) *semi = 0; else if(comma) *comma = 0;

(The two code fragments are precisely identical. Mmmm, strength reduction.)

-andy
Kyle Hayes· Apr 25, 2005, 17:02 UTC · re: Andy Isaacson · lore

Re: [patch] fixup GECOS handling

On Fri, 2005-04-22 at 16:30 -0700, Andy Isaacson wrote:
Show 17 quoted lines
> On Fri, Apr 22, 2005 at 09:16:39AM -0700, Kyle Hayes wrote:
> > if(comma)
> > 	if(semi)
> > 		/* lastname, firstname; room #; phone # format */
> > 		*semi  = 0;
> > 	else
> > 		*comma = 0;
> > else if(semi)
> > 	*semi = 0;
> 
> That's a really complicated way of writing
> 
> if(semi) *semi = 0;
> else if(comma) *comma = 0;
> 
> (The two code fragments are precisely identical.  Mmmm, strength
> reduction.)
Indeed :-)

As someone else noted, this was too complex. As another person noted, this (like the SHA1 thread) has been thrashed around more than enough.

Best, Kyle

-- 
Kyle Hayes <kyle@marchex.com>
Marchex Inc.

← back to recent threads