Re: [patch] fixup GECOS handling

From: Martin Schlemmer <azarah@nosferatu.za.org>
Date: 2005-04-23 05:06:43
On Fri, 2005-04-22 at 10:58 -0700, Kyle Hayes wrote:
> 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)

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



-
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 05:02:57 2005

This archive was generated by hypermail 2.1.8 : 2005-04-23 05:02:57 EST