Re: [patch] fixup GECOS handling

2005-04-23 Thread Martin Schlemmer
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 [EMAIL PROTECTED] 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



signature.asc
Description: This is a digitally signed message part


[patch] fixup GECOS handling

2005-04-22 Thread Martin Schlemmer
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 [EMAIL PROTECTED]

commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c 2005-04-18 12:22:18.0 +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 [,;] */
+   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.0 +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] = '@';


signature.asc
Description: This is a digitally signed message part


[patch] fixup GECOS handling

2005-04-18 Thread Martin Schlemmer
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
([EMAIL PROTECTED]).

Signed-off-by: Martin Schlemmer [EMAIL PROTECTED]

commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c 2005-04-18 12:22:18.0 +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 [,;] */
+   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.0 +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] = '@';


signature.asc
Description: This is a digitally signed message part


Re: [patch] fixup GECOS handling

2005-04-18 Thread Martin Schlemmer
On Mon, 2005-04-18 at 22:35 +1000, David Woodhouse wrote:
 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 [EMAIL PROTECTED]

commit-tree.c: ec53a4565ec0033aaf6df2a48d233ccf4823e8b0
--- 1/commit-tree.c
+++ 2/commit-tree.c 2005-04-18 12:22:18.0 +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 [,;] */
+   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.0 +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] = '@';


signature.asc
Description: This is a digitally signed message part