Add usage(), use err(3).
Rewrote man page in mdoc format.
This commit is contained in:
parent
5d422d6aa7
commit
f2abddceac
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=27754
@ -28,14 +28,19 @@
|
|||||||
* Mountain View, California 94043
|
* Mountain View, California 94043
|
||||||
*/
|
*/
|
||||||
#if !defined(lint) && defined(SCCSIDS)
|
#if !defined(lint) && defined(SCCSIDS)
|
||||||
|
#if 0
|
||||||
static char sccsid[] = "@(#)generic.c 1.2 91/03/11 Copyr 1986 Sun Micro";
|
static char sccsid[] = "@(#)generic.c 1.2 91/03/11 Copyr 1986 Sun Micro";
|
||||||
#endif
|
#endif
|
||||||
|
static const char rcsid[] =
|
||||||
|
"$Id$";
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 1986, Sun Microsystems, Inc.
|
* Copyright (C) 1986, Sun Microsystems, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <rpc/rpc.h>
|
#include <rpc/rpc.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <mp.h>
|
#include <mp.h>
|
||||||
|
@ -1,54 +1,53 @@
|
|||||||
.\" @(#)newkey.8 1.3 91/03/11 TIRPC 1.0; from 1.12 90/02/03 SMI;
|
.\" @(#)newkey.8 1.3 91/03/11 TIRPC 1.0; from 1.12 90/02/03 SMI;
|
||||||
.TH NEWKEY 8 "12 October 1987"
|
.Dd October 12, 1987
|
||||||
.SH NAME
|
.Dt NEWKEY 8
|
||||||
newkey \- create a new key in the publickey database
|
.Os
|
||||||
.SH SYNOPSIS
|
.Sh NAME
|
||||||
.B "newkey \-h"
|
.Nm newkey
|
||||||
.I hostname
|
.Nd create a new key in the publickey database
|
||||||
.br
|
.Sh SYNOPSIS
|
||||||
.B "newkey \-u"
|
.Nm newkey
|
||||||
.I username
|
.Fl h Ar hostname
|
||||||
.SH DESCRIPTION
|
.Nm newkey
|
||||||
.IX "newkey command" "" "\fLnewkey\fP command"
|
.Fl u Ar username
|
||||||
.LP
|
.Sh DESCRIPTION
|
||||||
.B newkey
|
.Nm Newkey
|
||||||
is normally run by the network administrator on the
|
is normally run by the network administrator on the
|
||||||
Network Interface Service
|
Network Interface Service
|
||||||
(\s-1NIS\s0)
|
(\s-1NIS\s0)
|
||||||
master machine in order to establish public keys for
|
master machine in order to establish public keys for
|
||||||
users and super-users on the network.
|
users and super-users on the network.
|
||||||
These keys are needed for using secure
|
These keys are needed for using secure
|
||||||
.SM RPC
|
RPC
|
||||||
or secure
|
or secure
|
||||||
.SM NFS\s0.
|
NFS\s0.
|
||||||
.LP
|
.Pp
|
||||||
.B newkey
|
.Nm Newkey
|
||||||
will prompt for the login password of the given username and then
|
will prompt for the login password of the given username and then
|
||||||
create a new public/secret key pair in
|
create a new public/secret key pair in
|
||||||
.B /etc/publickey
|
.Pa /etc/publickey
|
||||||
encrypted with the login password of the given user.
|
encrypted with the login password of the given user.
|
||||||
.LP
|
.Pp
|
||||||
Use of this program is
|
Use of this program is
|
||||||
not required: users may create their own keys using
|
not required: users may create their own keys using
|
||||||
.BR chkey (1).
|
.Xr chkey 1 .
|
||||||
.SH OPTIONS
|
.Sh OPTIONS
|
||||||
.TP 12
|
.Bl -tag -width indent
|
||||||
.BI \-h " hostname"
|
.It Fl h Ar hostname
|
||||||
Create a new public key for the super-user at the given hostname.
|
Create a new public key for the super-user at the given hostname.
|
||||||
Prompts for the root password of the given hostname.
|
Prompts for the root password of the given hostname.
|
||||||
.TP
|
.It Fl u Ar username
|
||||||
.BI \-u " username"
|
|
||||||
Create a new public key for the given username.
|
Create a new public key for the given username.
|
||||||
Prompts for the
|
Prompts for the
|
||||||
.SM NIS
|
NIS
|
||||||
password of the given username.
|
password of the given username.
|
||||||
.SH "SEE ALSO"
|
.El
|
||||||
.BR chkey (1),
|
.Sh SEE ALSO
|
||||||
.BR keylogin (1),
|
.Xr chkey 1 ,
|
||||||
.BR publickey (5),
|
.Xr keylogin 1 ,
|
||||||
.BR keyserv (8C)
|
.Xr publickey 5 ,
|
||||||
.SH NOTES
|
.Xr keyserv 8
|
||||||
.LP
|
.Sh NOTES
|
||||||
The Network Information Service
|
The Network Information Service
|
||||||
(\s-1NIS\s0)
|
(\s-1NIS\s0)
|
||||||
was formerly known as Sun Yellow Pages
|
was formerly known as Sun Yellow Pages
|
||||||
|
@ -28,8 +28,12 @@
|
|||||||
* Mountain View, California 94043
|
* Mountain View, California 94043
|
||||||
*/
|
*/
|
||||||
#if !defined(lint) && defined(SCCSIDS)
|
#if !defined(lint) && defined(SCCSIDS)
|
||||||
|
#if 0
|
||||||
static char sccsid[] = "@(#)newkey.c 1.8 91/03/11 Copyr 1986 Sun Micro";
|
static char sccsid[] = "@(#)newkey.c 1.8 91/03/11 Copyr 1986 Sun Micro";
|
||||||
#endif
|
#endif
|
||||||
|
static const char rcsid[] =
|
||||||
|
"$Id$";
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 1986, Sun Microsystems, Inc.
|
* Copyright (C) 1986, Sun Microsystems, Inc.
|
||||||
@ -38,6 +42,7 @@ static char sccsid[] = "@(#)newkey.c 1.8 91/03/11 Copyr 1986 Sun Micro";
|
|||||||
/*
|
/*
|
||||||
* Administrative tool to add a new user to the publickey database
|
* Administrative tool to add a new user to the publickey database
|
||||||
*/
|
*/
|
||||||
|
#include <err.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <rpc/rpc.h>
|
#include <rpc/rpc.h>
|
||||||
#include <rpc/key_prot.h>
|
#include <rpc/key_prot.h>
|
||||||
@ -49,6 +54,7 @@ static char sccsid[] = "@(#)newkey.c 1.8 91/03/11 Copyr 1986 Sun Micro";
|
|||||||
#endif /* YP */
|
#endif /* YP */
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
|
||||||
#ifdef YP
|
#ifdef YP
|
||||||
@ -66,9 +72,6 @@ static char sccsid[] = "@(#)newkey.c 1.8 91/03/11 Copyr 1986 Sun Micro";
|
|||||||
#define ERR_KEY 6
|
#define ERR_KEY 6
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern char *getpass();
|
|
||||||
extern char *malloc();
|
|
||||||
|
|
||||||
#ifdef YP
|
#ifdef YP
|
||||||
static char *basename();
|
static char *basename();
|
||||||
static char SHELL[] = "/bin/sh";
|
static char SHELL[] = "/bin/sh";
|
||||||
@ -80,6 +83,9 @@ static char PKFILE[] = "/etc/publickey";
|
|||||||
static char *err_string();
|
static char *err_string();
|
||||||
#endif /* YP */
|
#endif /* YP */
|
||||||
|
|
||||||
|
static void usage __P((void));
|
||||||
|
|
||||||
|
int
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char *argv[];
|
char *argv[];
|
||||||
@ -98,37 +104,25 @@ main(argc, argv)
|
|||||||
|
|
||||||
if (argc != 3 || !(strcmp(argv[1], "-u") == 0 ||
|
if (argc != 3 || !(strcmp(argv[1], "-u") == 0 ||
|
||||||
strcmp(argv[1], "-h") == 0)) {
|
strcmp(argv[1], "-h") == 0)) {
|
||||||
(void)fprintf(stderr, "usage: %s [-u username]\n",
|
usage();
|
||||||
argv[0]);
|
|
||||||
(void)fprintf(stderr, "usage: %s [-h hostname]\n",
|
|
||||||
argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (geteuid() != 0) {
|
|
||||||
(void)fprintf(stderr, "must be superuser to run %s\n", argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
if (geteuid() != 0)
|
||||||
|
errx(1, "must be superuser");
|
||||||
|
|
||||||
#ifdef YP
|
#ifdef YP
|
||||||
if (chdir(YPDBPATH) < 0) {
|
if (chdir(YPDBPATH) < 0)
|
||||||
(void)fprintf(stderr, "cannot chdir to ");
|
warn("cannot chdir to %s", YPDBPATH);
|
||||||
perror(YPDBPATH);
|
|
||||||
}
|
|
||||||
#endif /* YP */
|
#endif /* YP */
|
||||||
if (strcmp(argv[1], "-u") == 0) {
|
if (strcmp(argv[1], "-u") == 0) {
|
||||||
pw = getpwnam(argv[2]);
|
pw = getpwnam(argv[2]);
|
||||||
if (pw == NULL) {
|
if (pw == NULL)
|
||||||
(void)fprintf(stderr, "unknown user: %s\n", argv[2]);
|
errx(1, "unknown user: %s", argv[2]);
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
(void)user2netname(name, (int)pw->pw_uid, (char *)NULL);
|
(void)user2netname(name, (int)pw->pw_uid, (char *)NULL);
|
||||||
} else {
|
} else {
|
||||||
#ifdef undef
|
#ifdef undef
|
||||||
h = gethostbyname(argv[2]);
|
h = gethostbyname(argv[2]);
|
||||||
if (h == NULL) {
|
if (h == NULL)
|
||||||
(void)fprintf(stderr, "unknown host: %s\n", argv[1]);
|
errx(1, "unknown host: %s", argv[1]);
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
(void)host2netname(name, h->h_name, (char *)NULL);
|
(void)host2netname(name, h->h_name, (char *)NULL);
|
||||||
#else
|
#else
|
||||||
(void)host2netname(name, argv[2], (char *)NULL);
|
(void)host2netname(name, argv[2], (char *)NULL);
|
||||||
@ -147,31 +141,35 @@ main(argc, argv)
|
|||||||
memcpy(crypt2, crypt1, HEXKEYBYTES + KEYCHECKSUMSIZE + 1);
|
memcpy(crypt2, crypt1, HEXKEYBYTES + KEYCHECKSUMSIZE + 1);
|
||||||
xdecrypt(crypt2, getpass("Retype password:"));
|
xdecrypt(crypt2, getpass("Retype password:"));
|
||||||
if (memcmp(crypt2, crypt2 + HEXKEYBYTES, KEYCHECKSUMSIZE) != 0 ||
|
if (memcmp(crypt2, crypt2 + HEXKEYBYTES, KEYCHECKSUMSIZE) != 0 ||
|
||||||
memcmp(crypt2, secret, HEXKEYBYTES) != 0) {
|
memcmp(crypt2, secret, HEXKEYBYTES) != 0)
|
||||||
(void)fprintf(stderr, "Password incorrect.\n");
|
errx(1, "password incorrect");
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef YP
|
#ifdef YP
|
||||||
(void)printf("Please wait for the database to get updated...\n");
|
(void)printf("Please wait for the database to get updated...\n");
|
||||||
#endif
|
#endif
|
||||||
if (status = setpublicmap(name, public, crypt1)) {
|
if ((status = setpublicmap(name, public, crypt1))) {
|
||||||
#ifdef YP
|
#ifdef YP
|
||||||
(void)fprintf(stderr,
|
errx(1, "unable to update NIS database (%u): %s",
|
||||||
"%s: unable to update NIS database (%u): %s\n",
|
status, yperr_string(status));
|
||||||
argv[0], status, yperr_string(status));
|
|
||||||
#else
|
#else
|
||||||
(void)fprintf(stderr,
|
errx(1, "unable to update publickey database (%u): %s",
|
||||||
"%s: unable to update publickey database (%u): %s\n",
|
status, err_string(status));
|
||||||
argv[0], status, err_string(status));
|
|
||||||
#endif
|
#endif
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
(void)printf("Your new key has been successfully stored away.\n");
|
(void)printf("Your new key has been successfully stored away.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
(void)fprintf(stderr, "%s\n%s\n",
|
||||||
|
"usage: newkey [-u username]",
|
||||||
|
" newkey [-h hostname]");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the entry in the public key file
|
* Set the entry in the public key file
|
||||||
*/
|
*/
|
||||||
|
@ -28,8 +28,12 @@
|
|||||||
* Mountain View, California 94043
|
* Mountain View, California 94043
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
static char sccsid[] = "@(#)update.c 1.2 91/03/11 Copyr 1986 Sun Micro";
|
static char sccsid[] = "@(#)update.c 1.2 91/03/11 Copyr 1986 Sun Micro";
|
||||||
#endif
|
#endif
|
||||||
|
static const char rcsid[] =
|
||||||
|
"$Id$";
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 1986, 1989, Sun Microsystems, Inc.
|
* Copyright (C) 1986, 1989, Sun Microsystems, Inc.
|
||||||
@ -49,6 +53,7 @@ static char sccsid[] = "@(#)update.c 1.2 91/03/11 Copyr 1986 Sun Micro";
|
|||||||
#endif /* YP */
|
#endif /* YP */
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
|
||||||
#ifdef YP
|
#ifdef YP
|
||||||
@ -60,9 +65,6 @@ static char sccsid[] = "@(#)update.c 1.2 91/03/11 Copyr 1986 Sun Micro";
|
|||||||
#define YPOP_STORE 4 /* add, or change */
|
#define YPOP_STORE 4 /* add, or change */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern char *getpass();
|
|
||||||
extern char *malloc();
|
|
||||||
|
|
||||||
#ifdef YP
|
#ifdef YP
|
||||||
static char *basename();
|
static char *basename();
|
||||||
static char SHELL[] = "/bin/sh";
|
static char SHELL[] = "/bin/sh";
|
||||||
|
Loading…
Reference in New Issue
Block a user