From fb318265f4aee122f20f5750cea5238f9baddffc Mon Sep 17 00:00:00 2001 From: David Nugent Date: Thu, 19 Dec 1996 15:22:45 +0000 Subject: Allow 8-bit characters in the passwd gecos field, and adds a paragraph to the mangpage explaining the consequences (to be updated at a later date after login class conf support is added). --- pw/pw.8 | 22 +++++++++++++++++++++- pw/pw.h | 3 ++- pw/pw_group.c | 6 +++--- pw/pw_user.c | 22 +++++++++++----------- 4 files changed, 37 insertions(+), 16 deletions(-) (limited to 'pw') diff --git a/pw/pw.8 b/pw/pw.8 index 31e19d8..f0aa9f7 100644 --- a/pw/pw.8 +++ b/pw/pw.8 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: pw.8,v 1.3 1996/12/10 00:21:28 joerg Exp $ +.\" $Id: pw.8,v 1.4 1996/12/11 00:07:19 joerg Exp $ .\" .Dd December 9, 1996 .Dt PW 8 @@ -760,6 +760,26 @@ For a summary of options available with each command, you can use For example, .Dl pw useradd help lists all available options for the useradd operation. +.Pp +.Nm pw +allows 8-bit characters in the passwd gecos field (user's full name, +office, work and home phone number subfields), but disallows them in +user login and group names. +Use 8-bit characters with caution, as connection to the internet will +require that your mail transport program supports 8BITMIME, and will +convert headers containing 8-bit characters to 7-bit quoted-printable +format. +.Xr sendmail 8 +does support this. +Use of 8-bit characters in the gecos field should be used in +conjunction with the user's default locale and character set +and should not be implemented without their use. +Using 8-bit characters may also affect other +programs that transmit the contents of the gecos field over the +internet, such as +.Xr fingerd 8 , +and a small number of tcpip clients, such as irc, where fullnames +specified in the passwd file may be used by default. .Sh FILES .Bl -tag -width /etc/master.passwd.new -compact .It Pa /etc/master.passwd diff --git a/pw/pw.h b/pw/pw.h index c98f795..57c9bce 100644 --- a/pw/pw.h +++ b/pw/pw.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pw.h,v 1.1.1.2 1996/12/09 23:55:23 joerg Exp $ + * $Id: pw.h,v 1.1.1.3 1996/12/10 23:58:59 joerg Exp $ */ #include @@ -101,6 +101,7 @@ void cmderr(int ec, char const * fmt,...); 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); diff --git a/pw/pw_group.c b/pw/pw_group.c index 7bd99a1..8097297 100644 --- a/pw/pw_group.c +++ b/pw/pw_group.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pw_group.c,v 1.1.1.2 1996/12/09 23:55:25 joerg Exp $ + * $Id: pw_group.c,v 1.1.1.3 1996/12/10 23:59:01 joerg Exp $ */ #include @@ -119,7 +119,7 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args) grp->gr_gid = (gid_t) atoi(a_gid->val); if ((arg = getarg(args, 'l')) != NULL) - grp->gr_name = arg->val; + grp->gr_name = pw_checkname((u_char *)arg->val, 0); } else { if (a_name == NULL) /* Required */ cmderr(EX_DATAERR, "group name required\n"); @@ -128,7 +128,7 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args) memset(members, 0, sizeof members); grp = &fakegroup; - grp->gr_name = a_name->val; + 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; diff --git a/pw/pw_user.c b/pw/pw_user.c index 2967190..dabf795 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pw_user.c,v 1.4 1996/12/17 01:43:30 davidn Exp $ + * $Id: pw_user.c,v 1.5 1996/12/17 14:15:35 davidn Exp $ */ #include @@ -49,7 +49,6 @@ static time_t pw_exppolicy(struct userconf * cnf, struct cargs * args); static char *pw_homepolicy(struct userconf * cnf, struct cargs * args, char const * user); static char *pw_shellpolicy(struct userconf * cnf, struct cargs * args, char *newshell); static char *pw_password(struct userconf * cnf, struct cargs * args, char const * user); -static char *pw_checkname(char *name, int gecos); static char *shell_path(char const * path, char *shells[], char *sh); static void rmat(uid_t uid); @@ -148,7 +147,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) cnf->default_group = newstr(grp->gr_name); } if ((arg = getarg(args, 'L')) != NULL) - cnf->default_class = pw_checkname(arg->val, 0); + cnf->default_class = pw_checkname((u_char *)arg->val, 0); if ((arg = getarg(args, 'G')) != NULL && arg->val) { int i = 0; @@ -204,7 +203,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) return EXIT_SUCCESS; } if ((a_name = getarg(args, 'n')) != NULL) - pwd = getpwnam(pw_checkname(a_name->val, 0)); + pwd = getpwnam(pw_checkname((u_char *)a_name->val, 0)); a_uid = getarg(args, 'u'); if (a_uid == NULL) { @@ -306,7 +305,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) if ((arg = getarg(args, 'l')) != NULL) { if (strcmp(pwd->pw_name, "root") == 0) cmderr(EX_DATAERR, "can't rename `root' account\n"); - pwd->pw_name = pw_checkname(arg->val, 0); + pwd->pw_name = pw_checkname((u_char *)arg->val, 0); } if ((arg = getarg(args, 'u')) != NULL && isdigit(*arg->val)) { pwd->pw_uid = (uid_t) atol(arg->val); @@ -379,7 +378,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) * Shared add/edit code */ if ((arg = getarg(args, 'c')) != NULL) - pwd->pw_gecos = pw_checkname(arg->val, 1); + pwd->pw_gecos = pw_checkname((u_char *)arg->val, 1); if ((arg = getarg(args, 'h')) != NULL) { if (strcmp(arg->val, "-") == 0) @@ -933,15 +932,16 @@ print_user(struct passwd * pwd, int pretty) return EXIT_SUCCESS; } -static char * -pw_checkname(char *name, int gecos) +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] > 126) - cmderr(EX_DATAERR, (name[l]<' ' || (unsigned char)name[l] > 126) + if (strchr(notch, name[l]) != NULL || name[l] < ' ' || + name[l] == 127 || (!gecos && name[l] & 0x80)) /* 8-bit */ + cmderr(EX_DATAERR, (name[l]<' ' || name[l] > 126) ? "invalid character `%c' in field\n" : "invalid character 0x$02x in field\n", name[l]); @@ -949,7 +949,7 @@ pw_checkname(char *name, int gecos) } if (!gecos && l > MAXLOGNAME) cmderr(EX_DATAERR, "name too long `%s'\n", name); - return name; + return (char *)name; } -- cgit v1.2.3-56-ge451