Updating usr.bin/passwd
Change-Id: I5512cd44cb9f1684350050d4e3fb5bb4d1c9b6b1
This commit is contained in:
parent
2bc7c627ac
commit
e8235bc09a
6 changed files with 60 additions and 59 deletions
|
@ -129,7 +129,7 @@
|
|||
2009/08/15 20:44:56,usr.bin/mktemp
|
||||
2012/10/17 12:00:00,usr.bin/nbperf
|
||||
2010/05/14 17:28:23,usr.bin/newgrp
|
||||
2012/10/17 12:00:00,usr.bin/passwd/Makefile
|
||||
2012/10/17 12:00:00,usr.bin/passwd
|
||||
2010/02/19 16:35:27,usr.bin/sed
|
||||
2010/05/27 08:40:19,usr.bin/seq
|
||||
2012/10/17 12:00:00,usr.bin/sort
|
||||
|
|
|
@ -3,11 +3,6 @@
|
|||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
.if defined(__MINIX)
|
||||
# LSC Until it compiles cleanly...
|
||||
NOGCCERROR:=yes
|
||||
.endif
|
||||
|
||||
USE_FORT?= yes # setuid
|
||||
PROG= passwd
|
||||
SRCS= local_passwd.c passwd.c
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: extern.h,v 1.13 2006/03/23 23:37:07 wiz Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.14 2011/09/16 15:39:27 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994
|
||||
|
@ -33,7 +33,7 @@
|
|||
|
||||
#ifdef USE_PAM
|
||||
|
||||
void usage(void);
|
||||
__dead void usage(void);
|
||||
|
||||
#ifdef KERBEROS5
|
||||
void pwkrb5_usage(const char *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: krb5_passwd.c,v 1.18 2009/04/18 09:04:34 mlelstv Exp $ */
|
||||
/* $NetBSD: krb5_passwd.c,v 1.20 2012/04/22 23:43:51 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000, 2005 The NetBSD Foundation, Inc.
|
||||
|
@ -45,6 +45,17 @@
|
|||
|
||||
#include "extern.h"
|
||||
|
||||
static void
|
||||
pwkrb5_warn(const char *msg, krb5_context context, krb5_error_code ret)
|
||||
{
|
||||
const char *errtxt = krb5_get_error_message(context, ret);
|
||||
if (errtxt != NULL) {
|
||||
warnx("%s: %s", msg, errtxt);
|
||||
krb5_free_error_message(context, errtxt);
|
||||
} else
|
||||
warnx("%s: %d", msg, ret);
|
||||
}
|
||||
|
||||
#ifdef USE_PAM
|
||||
|
||||
void
|
||||
|
@ -68,7 +79,7 @@ pwkrb5_process(const char *username, int argc, char **argv)
|
|||
{
|
||||
krb5_context context;
|
||||
krb5_error_code ret;
|
||||
krb5_get_init_creds_opt opt;
|
||||
krb5_get_init_creds_opt *opt;
|
||||
krb5_principal principal;
|
||||
krb5_creds cred;
|
||||
int result_code;
|
||||
|
@ -125,21 +136,23 @@ pwkrb5_process(const char *username, int argc, char **argv)
|
|||
if (ret != 0) {
|
||||
if (ret == ENXIO)
|
||||
errx(1, "Kerberos 5 not in use.");
|
||||
warnx("Unable to initialize Kerberos 5: %s",
|
||||
krb5_get_err_text(context, ret));
|
||||
errx(1, "Unable to initialize Kerberos 5: %s", strerror(ret));
|
||||
}
|
||||
|
||||
ret = krb5_get_init_creds_opt_alloc(context, &opt);
|
||||
if (ret) {
|
||||
pwkrb5_warn("failed to allocate opts", context, ret);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
krb5_get_init_creds_opt_init(&opt);
|
||||
|
||||
krb5_get_init_creds_opt_set_tkt_life(&opt, 300L);
|
||||
krb5_get_init_creds_opt_set_forwardable(&opt, FALSE);
|
||||
krb5_get_init_creds_opt_set_proxiable(&opt, FALSE);
|
||||
krb5_get_init_creds_opt_set_tkt_life(opt, 300L);
|
||||
krb5_get_init_creds_opt_set_forwardable(opt, FALSE);
|
||||
krb5_get_init_creds_opt_set_proxiable(opt, FALSE);
|
||||
|
||||
ret = krb5_parse_name(context, username, &principal);
|
||||
if (ret) {
|
||||
warnx("failed to parse principal: %s",
|
||||
krb5_get_err_text(context, ret));
|
||||
krb5_get_init_creds_opt_free(context, opt);
|
||||
pwkrb5_warn("failed to parse principal", context, ret);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
|
@ -151,9 +164,9 @@ pwkrb5_process(const char *username, int argc, char **argv)
|
|||
NULL,
|
||||
0L,
|
||||
"kadmin/changepw",
|
||||
&opt);
|
||||
|
||||
opt);
|
||||
|
||||
krb5_get_init_creds_opt_free(context, opt);
|
||||
switch (ret) {
|
||||
case 0:
|
||||
break;
|
||||
|
@ -168,8 +181,7 @@ pwkrb5_process(const char *username, int argc, char **argv)
|
|||
goto bad;
|
||||
|
||||
default:
|
||||
warnx("failed to get credentials: %s",
|
||||
krb5_get_err_text(context, ret));
|
||||
pwkrb5_warn("failed to get credentials", context, ret);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
|
@ -186,8 +198,7 @@ pwkrb5_process(const char *username, int argc, char **argv)
|
|||
&result_code_string,
|
||||
&result_string);
|
||||
if (ret) {
|
||||
warnx("unable to set password: %s",
|
||||
krb5_get_err_text(context, ret));
|
||||
pwkrb5_warn("unable to set password", context, ret);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
|
@ -259,14 +270,13 @@ krb5_end(void)
|
|||
krb5_free_context(defcontext);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
krb5_chpw(const char *username)
|
||||
{
|
||||
krb5_error_code ret;
|
||||
krb5_context context;
|
||||
krb5_principal principal;
|
||||
krb5_get_init_creds_opt opt;
|
||||
krb5_get_init_creds_opt *opt;
|
||||
krb5_creds cred;
|
||||
int result_code;
|
||||
krb5_data result_code_string, result_string;
|
||||
|
@ -274,22 +284,25 @@ krb5_chpw(const char *username)
|
|||
|
||||
ret = krb5_init_context (&context);
|
||||
if (ret) {
|
||||
warnx("failed kerberos initialisation: %s",
|
||||
krb5_get_err_text(context, ret));
|
||||
pwkrb5_warn("failed kerberos initialisation", context, ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
krb5_get_init_creds_opt_init (&opt);
|
||||
ret = krb5_get_init_creds_opt_alloc (context, &opt);
|
||||
if (ret) {
|
||||
pwkrb5_warn("failed to allocate credential opt", context, ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
krb5_get_init_creds_opt_set_tkt_life (&opt, 300);
|
||||
krb5_get_init_creds_opt_set_forwardable (&opt, FALSE);
|
||||
krb5_get_init_creds_opt_set_proxiable (&opt, FALSE);
|
||||
krb5_get_init_creds_opt_set_tkt_life (opt, 300);
|
||||
krb5_get_init_creds_opt_set_forwardable (opt, FALSE);
|
||||
krb5_get_init_creds_opt_set_proxiable (opt, FALSE);
|
||||
|
||||
if(username != NULL) {
|
||||
ret = krb5_parse_name (context, username, &principal);
|
||||
if (ret) {
|
||||
warnx("failed to parse principal: %s",
|
||||
krb5_get_err_text(context, ret));
|
||||
krb5_get_init_creds_opt_free (context, opt);
|
||||
pwkrb5_warn("failed to parse principal", context, ret);
|
||||
return 1;
|
||||
}
|
||||
} else
|
||||
|
@ -303,8 +316,9 @@ krb5_chpw(const char *username)
|
|||
NULL,
|
||||
0,
|
||||
"kadmin/changepw",
|
||||
&opt);
|
||||
opt);
|
||||
|
||||
krb5_get_init_creds_opt_free (context, opt);
|
||||
switch (ret) {
|
||||
case 0:
|
||||
break;
|
||||
|
@ -317,8 +331,7 @@ krb5_chpw(const char *username)
|
|||
return 1;
|
||||
break;
|
||||
default:
|
||||
warnx("failed to get credentials: %s",
|
||||
krb5_get_err_text(context, ret));
|
||||
pwkrb5_warn("failed to get credentials", context, ret);
|
||||
return 1;
|
||||
}
|
||||
krb5_data_zero (&result_code_string);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: local_passwd.c,v 1.34 2010/03/02 16:19:13 gdt Exp $ */
|
||||
/* $NetBSD: local_passwd.c,v 1.36 2012/03/25 05:55:07 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993, 1994
|
||||
|
@ -34,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "from: @(#)local_passwd.c 8.3 (Berkeley) 4/2/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: local_passwd.c,v 1.34 2010/03/02 16:19:13 gdt Exp $");
|
||||
__RCSID("$NetBSD: local_passwd.c,v 1.36 2012/03/25 05:55:07 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -191,9 +191,7 @@ pwlocal_process(const char *username, int argc, char **argv)
|
|||
login_close(lc);
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
printf("AAA: pw_expiry = %x\n", pw_expiry);
|
||||
#endif
|
||||
|
||||
pw->pw_passwd = getnewpasswd(pw, min_pw_len);
|
||||
old_change = pw->pw_change;
|
||||
pw->pw_change = pw_expiry ? pw_expiry + time(NULL) : 0;
|
||||
|
@ -219,7 +217,7 @@ pwlocal_process(const char *username, int argc, char **argv)
|
|||
pw_copy(pfd, tfd, pw, &old_pw);
|
||||
|
||||
if (pw_mkdb(username, old_change == pw->pw_change) < 0)
|
||||
pw_error((char *)NULL, 0, 1);
|
||||
pw_error(NULL, 0, 1);
|
||||
|
||||
syslog(LOG_AUTH | LOG_INFO,
|
||||
"user %s (UID %lu) successfully changed "
|
||||
|
@ -232,8 +230,7 @@ pwlocal_process(const char *username, int argc, char **argv)
|
|||
static int force_local;
|
||||
|
||||
int
|
||||
local_init(progname)
|
||||
const char *progname;
|
||||
local_init(const char *progname)
|
||||
{
|
||||
force_local = 0;
|
||||
return (0);
|
||||
|
@ -253,7 +250,7 @@ local_arg(char ch, const char *arg)
|
|||
}
|
||||
|
||||
int
|
||||
local_arg_end()
|
||||
local_arg_end(void)
|
||||
{
|
||||
if (force_local)
|
||||
return(PW_USE_FORCE);
|
||||
|
@ -261,14 +258,13 @@ local_arg_end()
|
|||
}
|
||||
|
||||
void
|
||||
local_end()
|
||||
local_end(void)
|
||||
{
|
||||
/* NOOP */
|
||||
}
|
||||
|
||||
int
|
||||
local_chpw(uname)
|
||||
const char *uname;
|
||||
local_chpw(const char *uname)
|
||||
{
|
||||
struct passwd *pw;
|
||||
struct passwd old_pw;
|
||||
|
@ -304,9 +300,7 @@ local_chpw(uname)
|
|||
login_close(lc);
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
printf("pw_expiry = %x, pw->pw_expire = %x\n", pw_expiry, pw->pw_expire);
|
||||
#endif
|
||||
|
||||
pw->pw_passwd = getnewpasswd(pw, min_pw_len);
|
||||
old_change = pw->pw_change;
|
||||
pw->pw_change = pw_expiry ? pw_expiry + time(NULL) : 0;
|
||||
|
@ -332,7 +326,7 @@ local_chpw(uname)
|
|||
pw_copy(pfd, tfd, pw, &old_pw);
|
||||
|
||||
if (pw_mkdb(uname, old_change == pw->pw_change) < 0)
|
||||
pw_error((char *)NULL, 0, 1);
|
||||
pw_error(NULL, 0, 1);
|
||||
|
||||
syslog(LOG_AUTH | LOG_INFO,
|
||||
"user %s (UID %lu) successfully changed "
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: yp_passwd.c,v 1.35 2010/09/08 13:58:46 christos Exp $ */
|
||||
/* $NetBSD: yp_passwd.c,v 1.37 2012/03/25 05:55:07 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1990, 1993, 1994
|
||||
|
@ -34,7 +34,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "from: @(#)local_passwd.c 8.3 (Berkeley) 4/2/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: yp_passwd.c,v 1.35 2010/09/08 13:58:46 christos Exp $");
|
||||
__RCSID("$NetBSD: yp_passwd.c,v 1.37 2012/03/25 05:55:07 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -70,7 +70,7 @@ __RCSID("$NetBSD: yp_passwd.c,v 1.35 2010/09/08 13:58:46 christos Exp $");
|
|||
static uid_t uid;
|
||||
static char *domain;
|
||||
|
||||
static void
|
||||
__dead static void
|
||||
pwerror(const char *name, int show_err, int eval)
|
||||
{
|
||||
|
||||
|
@ -329,8 +329,7 @@ pwyp_process(const char *username, int argc, char **argv)
|
|||
static int yflag;
|
||||
|
||||
int
|
||||
yp_init(progname)
|
||||
const char *progname;
|
||||
yp_init(const char *progname)
|
||||
{
|
||||
int yppwd;
|
||||
|
||||
|
|
Loading…
Reference in a new issue