Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Jan 2003 10:02:32 -0300 (ART)
From:      Fernando Schapachnik <fernando@mecon.gov.ar>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/46890: [PATCH] pw doesn't accept characters like $ although it should according to passwd(5)
Message-ID:  <200301091302.h09D2WPE000736@bal740r0.mecon.gov.ar>

next in thread | raw e-mail | index | archive | help

>Number:         46890
>Category:       bin
>Synopsis:       [PATCH] pw doesn't accept characters like $ although it should according to passwd(5)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 09 05:10:02 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Fernando Schapachnik
>Release:        FreeBSD 4.7-RELEASE-p3 i386
>Organization:
>Environment:
System: FreeBSD bal740r0.mecon.gov.ar 4.7-RELEASE-p3 FreeBSD 4.7-RELEASE-p3 #2: Mon Jan 6 15:33:54 ART 2003 root@bal740r0.mecon.gov.ar:/usr/obj/usr/src/sys/BAL740R0 i386



>Description:

passwd(5) puts very 'soft' restrictions on the user name:

     The login name must never begin with a hyphen (`-'); also, it is strongly
     suggested that neither upper-case characters nor dots (`.') be part of
     the name, as this tends to confuse mailers.

So it should be safe to pw user add user$, although you get:

     pw: invalid character `$' in field

Usernames ending in $ are needed in some SAMBA setups (machine names).

>How-To-Repeat:

	pw user add user$

>Fix:



	Really simple, just change the right flag in a few places.

--- pw_user.c	Tue Dec  3 09:12:12 2002
+++ /tmp/pw/pw_user.c	Thu Jan  9 09:57:16 2003
@@ -293,7 +293,7 @@
 	}
 
 	if ((a_name = getarg(args, 'n')) != NULL)
-		pwd = GETPWNAM(pw_checkname((u_char *)a_name->val, 0));
+		pwd = GETPWNAM(pw_checkname((u_char *)a_name->val, 1));
 	a_uid = getarg(args, 'u');
 
 	if (a_uid == NULL) {
@@ -455,7 +455,7 @@
 		if ((arg = getarg(args, 'l')) != NULL) {
 			if (strcmp(pwd->pw_name, "root") == 0)
 				errx(EX_DATAERR, "can't rename `root' account");
-			pwd->pw_name = pw_checkname((u_char *)arg->val, 0);
+			pwd->pw_name = pw_checkname((u_char *)arg->val, 1);
 			edited = 1;
 		}
 
--- pw_group.c	Wed Jun 28 16:19:04 2000
+++ /tmp/pw/pw_group.c	Thu Jan  9 09:56:35 2003
@@ -135,7 +135,7 @@
 			grp->gr_gid = (gid_t) atoi(a_gid->val);
 
 		if ((arg = getarg(args, 'l')) != NULL)
-			grp->gr_name = pw_checkname((u_char *)arg->val, 0);
+			grp->gr_name = pw_checkname((u_char *)arg->val, 1);
 	} else {
 		if (a_name == NULL)	/* Required */
 			errx(EX_DATAERR, "group name required");
@@ -145,7 +145,7 @@
 		extendarray(&members, &grmembers, 200);
 		members[0] = NULL;
 		grp = &fakegroup;
-		grp->gr_name = pw_checkname((u_char *)a_name->val, 0);
+		grp->gr_name = pw_checkname((u_char *)a_name->val, 1);
 		grp->gr_passwd = "*";
 		grp->gr_gid = gr_gidpolicy(cnf, args);
 		grp->gr_mem = members;


>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200301091302.h09D2WPE000736>