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).
This commit is contained in:
David Nugent 1996-12-19 15:22:45 +00:00
parent 78f64bccfd
commit d9b711b719
4 changed files with 37 additions and 16 deletions

View File

@ -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

View File

@ -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 <stdio.h>
@ -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);

View File

@ -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 <unistd.h>
@ -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;

View File

@ -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 <unistd.h>
@ -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;
}