From owner-freebsd-current Thu Jan 23 20:27:44 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D72BD37B401 for ; Thu, 23 Jan 2003 20:27:39 -0800 (PST) Received: from out001.verizon.net (out001pub.verizon.net [206.46.170.140]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1E7CE43EB2 for ; Thu, 23 Jan 2003 20:27:39 -0800 (PST) (envelope-from mtm@identd.net) Received: from kokeb.ambesa.net ([138.88.50.143]) by out001.verizon.net (InterMail vM.5.01.05.20 201-253-122-126-120-20021101) with ESMTP id <20030124042738.RNFU23484.out001.verizon.net@kokeb.ambesa.net>; Thu, 23 Jan 2003 22:27:38 -0600 Date: Thu, 23 Jan 2003 23:27:34 -0500 From: Mike Makonnen To: Max Khon Cc: rodrigc@attbi.com, freebsd-current@FreeBSD.org Subject: Re: pw In-Reply-To: <20030124030942.A37794@iclub.nsu.ru> References: <20030124022538.C36624@iclub.nsu.ru> <20030123205418.GA41199@attbi.com> <20030124030942.A37794@iclub.nsu.ru> X-Mailer: Sylpheed version 0.8.6 (GTK+ 1.2.10; i386-portbld-freebsd5.0) Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="Ydkc,)x78G(=.n)g" X-Authentication-Info: Submitted using SMTP AUTH at out001.verizon.net from [138.88.50.143] at Thu, 23 Jan 2003 22:27:34 -0600 Message-Id: <20030124042738.RNFU23484.out001.verizon.net@kokeb.ambesa.net> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --Ydkc,)x78G(=.n)g Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Attached is Terry's patch modified to include $ in group names as well. I have tested it. Both adduser(8) and rmuser(8) work as expected. Please give -audit a chance to object and then commit it. Also, please close PR: bin/46890 when you do. We should have had this a long time ago. If -audit doesn't object I say go for it! Cheers. -- Mike Makonnen | GPG-KEY: http://www.identd.net/~mtm/mtm.asc mtm@identd.net | Fingerprint: D228 1A6F C64E 120A A1C9 A3AA DAE1 E2AF DBCC 68B9 Index: usr.sbin/pw/pw.h =================================================================== RCS file: /home/ncvs/src/usr.sbin/pw/pw.h,v retrieving revision 1.13 diff -u -r1.13 pw.h --- usr.sbin/pw/pw.h 5 Jul 2001 08:01:15 -0000 1.13 +++ usr.sbin/pw/pw.h 24 Jan 2003 03:16:41 -0000 @@ -62,6 +62,13 @@ W_NUM }; +enum _checktype +{ + PWC_DEFAULT, + PWC_GECOS, + PWC_LOGIN +}; + struct carg { int ch; @@ -105,7 +112,7 @@ int pw_user(struct userconf * cnf, int mode, struct cargs * _args); int pw_group(struct userconf * cnf, int mode, struct cargs * _args); -char *pw_checkname(u_char *name, int gecos); +char *pw_checkname(u_char *name, enum _checktype checktype); int addpwent(struct passwd * pwd); int delpwent(struct passwd * pwd); Index: usr.sbin/pw/pw_group.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/pw/pw_group.c,v retrieving revision 1.13 diff -u -r1.13 pw_group.c --- usr.sbin/pw/pw_group.c 22 Jun 2000 16:48:41 -0000 1.13 +++ usr.sbin/pw/pw_group.c 24 Jan 2003 03:59:07 -0000 @@ -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, PWC_LOGIN); } 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, PWC_LOGIN); grp->gr_passwd = "*"; grp->gr_gid = gr_gidpolicy(cnf, args); grp->gr_mem = members; Index: usr.sbin/pw/pw_user.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/pw/pw_user.c,v retrieving revision 1.51 diff -u -r1.51 pw_user.c --- usr.sbin/pw/pw_user.c 24 Jun 2002 11:33:17 -0000 1.51 +++ usr.sbin/pw/pw_user.c 24 Jan 2003 03:48:44 -0000 @@ -231,7 +231,7 @@ } } if ((arg = getarg(args, 'L')) != NULL) - cnf->default_class = pw_checkname((u_char *)arg->val, 0); + cnf->default_class = pw_checkname((u_char *)arg->val, PWC_DEFAULT); if ((arg = getarg(args, 'G')) != NULL && arg->val) { int i = 0; @@ -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, PWC_LOGIN)); 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, PWC_LOGIN); edited = 1; } @@ -595,7 +595,7 @@ * Shared add/edit code */ if ((arg = getarg(args, 'c')) != NULL) { - char *gecos = pw_checkname((u_char *)arg->val, 1); + char *gecos = pw_checkname((u_char *)arg->val, PWC_GECOS); if (strcmp(pwd->pw_gecos, gecos) != 0) { pwd->pw_gecos = gecos; edited = 1; @@ -1192,10 +1192,26 @@ } char * -pw_checkname(u_char *name, int gecos) +pw_checkname(u_char *name, enum _checktype checktype) { int l = 0; - char const *notch = gecos ? ":!@" : " ,\t:+&#%$^()!@~*?<>=|\\/\""; + char const *notch; + int gecos = (checktype == PWC_GECOS); + + switch (checktype) { + case PWC_GECOS: + notch = ":!@"; + break; + + case PWC_LOGIN: + notch = " ,\t:+&#%^()!@~*?<>=|\\/\""; + break; + + case PWC_DEFAULT: + default: + notch = " ,\t:+&#%$^()!@~*?<>=|\\/\""; + break; + } while (name[l]) { if (strchr(notch, name[l]) != NULL || name[l] < ' ' || name[l] == 127 || --Ydkc,)x78G(=.n)g Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE+MMC22uHir9vMaLkRAoDUAJ0SdD4eMVOLSKDYGJrUPQFLFl4TlwCg6y5l 223zkEsVC5MsuSyKL6fUlG0= =nE2y -----END PGP SIGNATURE----- --Ydkc,)x78G(=.n)g-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message