Date: Wed, 27 Nov 2002 13:45:31 -0800 From: Terry Lambert <tlambert2@mindspring.com> To: Garance A Drosihn <drosih@rpi.edu>, "David W. Chapman Jr." <dwcjr@inethouston.net>, current@FreeBSD.ORG Subject: Re: pw_user.c change for samba Message-ID: <3DE53CFB.F38F9361@mindspring.com> References: <20021127192126.GA31706@leviathan.inethouston.net> <3DE52B70.44402B98@mindspring.com> <20021127203401.GA35573@leviathan.inethouston.net> <p05200f19ba0ae54093d6@[128.113.24.47]> <3DE53BEE.A71BCCE1@mindspring.com>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------9C7626749B1700555DC1AF22 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Oops. Better patch attached (damn Makefile dependencies are broken unless you manually build them via "make depend"). -- Terry --------------9C7626749B1700555DC1AF22 Content-Type: text/plain; charset=us-ascii; name="pwcheck.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pwcheck.diff" Index: pw.h =================================================================== RCS file: /cvs/src/usr.sbin/pw/pw.h,v retrieving revision 1.13 diff -c -r1.13 pw.h *** pw.h 5 Jul 2001 08:01:15 -0000 1.13 --- pw.h 27 Nov 2002 17:21:03 -0000 *************** *** 62,67 **** --- 62,74 ---- W_NUM }; + enum _checktype + { + PWC_DEFAULT, + PWC_GECOS, + PWC_LOGIN + }; + struct carg { int ch; *************** *** 105,111 **** 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); int addpwent(struct passwd * pwd); int delpwent(struct passwd * pwd); --- 112,118 ---- 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, enum _checktype checktype); int addpwent(struct passwd * pwd); int delpwent(struct passwd * pwd); Index: pw_group.c =================================================================== RCS file: /cvs/src/usr.sbin/pw/pw_group.c,v retrieving revision 1.13 diff -c -r1.13 pw_group.c *** pw_group.c 22 Jun 2000 16:48:41 -0000 1.13 --- pw_group.c 27 Nov 2002 17:44:10 -0000 *************** *** 135,141 **** 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); } else { if (a_name == NULL) /* Required */ errx(EX_DATAERR, "group name required"); --- 135,141 ---- grp->gr_gid = (gid_t) atoi(a_gid->val); if ((arg = getarg(args, 'l')) != NULL) ! grp->gr_name = pw_checkname((u_char *)arg->val, PWC_DEFAULT); } else { if (a_name == NULL) /* Required */ errx(EX_DATAERR, "group name required"); *************** *** 145,151 **** extendarray(&members, &grmembers, 200); members[0] = NULL; grp = &fakegroup; ! grp->gr_name = pw_checkname((u_char *)a_name->val, 0); grp->gr_passwd = "*"; grp->gr_gid = gr_gidpolicy(cnf, args); grp->gr_mem = members; --- 145,151 ---- extendarray(&members, &grmembers, 200); members[0] = NULL; grp = &fakegroup; ! grp->gr_name = pw_checkname((u_char *)a_name->val, PWC_DEFAULT); grp->gr_passwd = "*"; grp->gr_gid = gr_gidpolicy(cnf, args); grp->gr_mem = members; Index: pw_user.c =================================================================== RCS file: /cvs/src/usr.sbin/pw/pw_user.c,v retrieving revision 1.51 diff -c -r1.51 pw_user.c *** pw_user.c 24 Jun 2002 11:33:17 -0000 1.51 --- pw_user.c 27 Nov 2002 17:30:43 -0000 *************** *** 231,237 **** } } if ((arg = getarg(args, 'L')) != NULL) ! cnf->default_class = pw_checkname((u_char *)arg->val, 0); if ((arg = getarg(args, 'G')) != NULL && arg->val) { int i = 0; --- 231,237 ---- } } if ((arg = getarg(args, 'L')) != NULL) ! cnf->default_class = pw_checkname((u_char *)arg->val, PWC_DEFAULT); if ((arg = getarg(args, 'G')) != NULL && arg->val) { int i = 0; *************** *** 293,299 **** } if ((a_name = getarg(args, 'n')) != NULL) ! pwd = GETPWNAM(pw_checkname((u_char *)a_name->val, 0)); a_uid = getarg(args, 'u'); if (a_uid == NULL) { --- 293,299 ---- } if ((a_name = getarg(args, 'n')) != NULL) ! pwd = GETPWNAM(pw_checkname((u_char *)a_name->val, PWC_LOGIN)); a_uid = getarg(args, 'u'); if (a_uid == NULL) { *************** *** 455,461 **** 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); edited = 1; } --- 455,461 ---- 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, PWC_LOGIN); edited = 1; } *************** *** 595,601 **** * Shared add/edit code */ if ((arg = getarg(args, 'c')) != NULL) { ! char *gecos = pw_checkname((u_char *)arg->val, 1); if (strcmp(pwd->pw_gecos, gecos) != 0) { pwd->pw_gecos = gecos; edited = 1; --- 595,601 ---- * Shared add/edit code */ if ((arg = getarg(args, 'c')) != NULL) { ! char *gecos = pw_checkname((u_char *)arg->val, PWC_GECOS); if (strcmp(pwd->pw_gecos, gecos) != 0) { pwd->pw_gecos = gecos; edited = 1; *************** *** 1192,1201 **** } char * ! pw_checkname(u_char *name, int gecos) { int l = 0; ! char const *notch = gecos ? ":!@" : " ,\t:+&#%$^()!@~*?<>=|\\/\""; while (name[l]) { if (strchr(notch, name[l]) != NULL || name[l] < ' ' || name[l] == 127 || --- 1192,1217 ---- } char * ! pw_checkname(u_char *name, enum _checktype checktype) { int l = 0; ! 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 || --------------9C7626749B1700555DC1AF22-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3DE53CFB.F38F9361>