FreeBSD Bugzilla – Attachment 11649 Details for
Bug 22860
[PATCH] adduser & friends with '$' in usernames
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 4.42 KB, created by
Gerhard Sittig
on 2000-11-15 06:00:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Gerhard Sittig
Created:
2000-11-15 06:00:01 UTC
Size:
4.42 KB
patch
obsolete
>Index: pw.h >=================================================================== >RCS file: /home/ncvs/src/usr.sbin/pw/pw.h,v >retrieving revision 1.10.2.1 >diff -u -r1.10.2.1 pw.h >--- pw.h 2000/06/28 19:19:04 1.10.2.1 >+++ pw.h 2000/11/13 08:36:09 >@@ -62,6 +62,15 @@ > W_NUM > }; > >+enum _gecos >+{ /* pw_checkname() classes (plausi test) */ >+ GEC_PWNAME, /* user name field */ >+ GEC_GROUP, /* user group field */ >+ GEC_CLASS, /* default login class */ >+ GEC_COMMENT, /* gecos comment field */ >+ GEC_MAXDIM /* allowed patterns table dimensioning */ >+}; >+ > struct carg > { > int ch; >@@ -105,7 +114,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 _gecos gecos); > > int addpwent(struct passwd * pwd); > int delpwent(struct passwd * pwd); >Index: pw_group.c >=================================================================== >RCS file: /home/ncvs/src/usr.sbin/pw/pw_group.c,v >retrieving revision 1.12.2.1 >diff -u -r1.12.2.1 pw_group.c >--- pw_group.c 2000/06/28 19:19:04 1.12.2.1 >+++ pw_group.c 2000/11/13 08:36:58 >@@ -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, GEC_GROUP); > } 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, GEC_GROUP); > grp->gr_passwd = "*"; > grp->gr_gid = gr_gidpolicy(cnf, args); > grp->gr_mem = members; >Index: pw_user.c >=================================================================== >RCS file: /home/ncvs/src/usr.sbin/pw/pw_user.c,v >retrieving revision 1.34.2.7 >diff -u -r1.34.2.7 pw_user.c >--- pw_user.c 2000/09/20 11:19:55 1.34.2.7 >+++ pw_user.c 2000/11/13 09:16:54 >@@ -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, GEC_CLASS); > > 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, GEC_PWNAME)); > 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, GEC_PWNAME); > 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, GEC_COMMENT); > if (strcmp(pwd->pw_gecos, gecos) != 0) { > pwd->pw_gecos = gecos; > edited = 1; >@@ -1208,22 +1208,29 @@ > } > > char * >-pw_checkname(u_char *name, int gecos) >+pw_checkname(u_char *name, enum _gecos gecos) > { > int l = 0; >- char const *notch = gecos ? ":!@" : " ,\t:+&#%$^()!@~*?<>=|\\/\""; >+ static const char *notchtab[GEC_MAXDIM] = { >+ " ,\t:+&#%^()!@~*?<>=|\\/\"" , /* GEC_PWNAME */ >+ " ,\t:+&#%$^()!@~*?<>=|\\/\"", /* GEC_GROUP */ >+ " ,\t:+&#%$^()!@~*?<>=|\\/\"", /* GEC_CLASS */ >+ ":!@" , /* GEC_COMMENT */ >+ }; >+ char const *notch = notchtab[gecos]; > > while (name[l]) { > if (strchr(notch, name[l]) != NULL || name[l] < ' ' || name[l] == 127 || >- (!gecos && l==0 && name[l] == '-') || /* leading '-' */ >- (!gecos && name[l] & 0x80)) /* 8-bit */ >+ (gecos != GEC_COMMENT && l==0 && name[l] == '-') || /* leading '-' */ >+ (gecos != GEC_COMMENT && name[l] == '$' && name[l+1]) || /* not a trailing '$' */ >+ (gecos != GEC_COMMENT && name[l] & 0x80)) /* 8-bit */ > errx(EX_DATAERR, (name[l] >= ' ' && name[l] < 127) > ? "invalid character `%c' in field" > : "invalid character 0x%02x in field", > name[l]); > ++l; > } >- if (!gecos && l > LOGNAMESIZE) >+ if (gecos != GEC_COMMENT && l > LOGNAMESIZE) > errx(EX_DATAERR, "name too long `%s'", name); > return (char *)name; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 22860
: 11649