Re: [patch] fixup GECOS handling

From: Martin Schlemmer <azarah@nosferatu.za.org>
Date: 2005-04-23 02:58:25
On Fri, 2005-04-22 at 09:16 -0700, Kyle Hayes wrote:
> 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



-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Received on Sat Apr 23 02:54:38 2005

This archive was generated by hypermail 2.1.8 : 2005-04-23 02:54:38 EST