Date: Sun, 7 Jun 2015 10:57:03 +0000 (UTC) From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r284110 - head/usr.sbin/pw Message-ID: <201506071057.t57Av319071267@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bapt Date: Sun Jun 7 10:57:02 2015 New Revision: 284110 URL: https://svnweb.freebsd.org/changeset/base/284110 Log: Instead of always casting the pw_checkname input to u_char * and casting it back to char *, change pw_checkname to directly take char * in input Modified: head/usr.sbin/pw/pw.h head/usr.sbin/pw/pw_group.c head/usr.sbin/pw/pw_user.c Modified: head/usr.sbin/pw/pw.h ============================================================================== --- head/usr.sbin/pw/pw.h Sun Jun 7 10:50:15 2015 (r284109) +++ head/usr.sbin/pw/pw.h Sun Jun 7 10:57:02 2015 (r284110) @@ -108,7 +108,7 @@ struct carg *getarg(struct cargs * _args 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(char *name, int gecos); int addnispwent(const char *path, struct passwd *pwd); int delnispwent(const char *path, const char *login); Modified: head/usr.sbin/pw/pw_group.c ============================================================================== --- head/usr.sbin/pw/pw_group.c Sun Jun 7 10:50:15 2015 (r284109) +++ head/usr.sbin/pw/pw_group.c Sun Jun 7 10:57:02 2015 (r284110) @@ -146,7 +146,7 @@ pw_group(struct userconf * cnf, int mode grp->gr_gid = (gid_t) atoi(a_gid->val); if (a_newname != NULL) - grp->gr_name = pw_checkname((u_char *)a_newname->val, 0); + grp->gr_name = pw_checkname(a_newname->val, 0); } else { if (a_name == NULL) /* Required */ errx(EX_DATAERR, "group name required"); @@ -156,7 +156,7 @@ pw_group(struct userconf * cnf, int mode 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(a_name->val, 0); grp->gr_passwd = "*"; grp->gr_gid = gr_gidpolicy(cnf, args); grp->gr_mem = members; Modified: head/usr.sbin/pw/pw_user.c ============================================================================== --- head/usr.sbin/pw/pw_user.c Sun Jun 7 10:50:15 2015 (r284109) +++ head/usr.sbin/pw/pw_user.c Sun Jun 7 10:57:02 2015 (r284110) @@ -263,7 +263,7 @@ pw_user(struct userconf * cnf, int mode, } } if ((arg = getarg(args, 'L')) != NULL) - cnf->default_class = pw_checkname((u_char *)arg->val, 0); + cnf->default_class = pw_checkname(arg->val, 0); if ((arg = getarg(args, 'G')) != NULL && arg->val) { int i = 0; @@ -323,7 +323,7 @@ pw_user(struct userconf * cnf, int mode, } if ((a_name = getarg(args, 'n')) != NULL) - pwd = GETPWNAM(pw_checkname((u_char *)a_name->val, 0)); + pwd = GETPWNAM(pw_checkname(a_name->val, 0)); a_uid = getarg(args, 'u'); if (a_uid == NULL) { @@ -510,7 +510,7 @@ pw_user(struct userconf * cnf, int mode, 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(arg->val, 0); edited = 1; } @@ -648,7 +648,7 @@ pw_user(struct userconf * cnf, int mode, * Shared add/edit code */ if ((arg = getarg(args, 'c')) != NULL) { - char *gecos = pw_checkname((u_char *)arg->val, 1); + char *gecos = pw_checkname(arg->val, 1); if (strcmp(pwd->pw_gecos, gecos) != 0) { pwd->pw_gecos = gecos; edited = 1; @@ -1239,11 +1239,11 @@ print_user(struct passwd * pwd, int pret return EXIT_SUCCESS; } -char * -pw_checkname(u_char *name, int gecos) +char * +pw_checkname(char *name, int gecos) { char showch[8]; - u_char const *badchars, *ch, *showtype; + const char *badchars, *ch, *showtype; int reject; ch = name; @@ -1294,7 +1294,8 @@ pw_checkname(u_char *name, int gecos) if (!gecos && (ch - name) > LOGNAMESIZE) errx(EX_DATAERR, "name too long `%s' (max is %d)", name, LOGNAMESIZE); - return (char *)name; + + return (name); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201506071057.t57Av319071267>