summaryrefslogtreecommitdiff
path: root/usr/src/cmd/krb5/kadmin/kpasswd/tty_kpasswd.c
blob: ec1618155e7bca8926073d7f1ff83efad7257e6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#pragma ident	"%Z%%M%	%I%	%E% SMI"

/*
 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
 *
 *	Openvision retains the copyright to derivative works of
 *	this source code.  Do *NOT* create a derivative of this
 *	source code before consulting with your legal department.
 *	Do *NOT* integrate *ANY* of this source code into another
 *	product before consulting with your legal department.
 *
 *	For further information, read the top-level Openvision
 *	copyright which is contained in the top-level MIT Kerberos
 *	copyright.
 *
 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
 *
 */


/*
 * Copyright 1993-1994 OpenVision Technologies, Inc., All Rights Reserved.
 *
 * $Header: /cvs/krbdev/krb5/src/kadmin/passwd/tty_kpasswd.c,v 1.7\
 * 1997/02/20 06:13:01 probe Exp $
 *
 *
 */

static char rcsid[] = "$Id: tty_kpasswd.c,v 1.7 " 
                      "1997/02/20 06:13:01 probe Exp $";

#include <kadm5/admin.h>
#include <krb5.h>

#include "kpasswd_strings.h"
#define	string_text error_message

#include <stdio.h>
#include <pwd.h>
#include <string.h>
#include <libintl.h>
#include <locale.h>

char *whoami;

void
display_intro_message(fmt_string, arg_string)
char *fmt_string;
char *arg_string;
{
	com_err(whoami, 0, fmt_string, arg_string);
}

long
read_old_password(context, password, pwsize)
krb5_context context;
char *password;
unsigned int *pwsize;
{
	long code = krb5_read_password(context,
	    (char *) string_text(KPW_STR_OLD_PASSWORD_PROMPT),
	    0, password, pwsize);

	return (code);
}

long
read_new_password(server_handle, password, pwsize,
                 msg_ret, msg_len, princ)
void *server_handle;
char *password;
int *pwsize;
char *msg_ret;
int msg_len;
krb5_principal princ;
{
	return (kadm5_chpass_principal_util(server_handle, princ, NULL,
		NULL /* don't need new pw back */,
		msg_ret, msg_len));
}


/*
 * main() for tty version of kpasswd.c
 */
int
main(argc, argv)
int argc;
char *argv[];
{
	krb5_context context;
	int retval;

	whoami = (whoami = strrchr(argv[0], '/')) ? whoami + 1 : argv[0];

	(void) setlocale(LC_ALL, "");

#if !defined(TEXT_DOMAIN)  /* Should be defined by cc -D */
#define	TEXT_DOMAIN	"SYS_TEST"	/* Use this only if it weren't */
#endif

	(void) textdomain(TEXT_DOMAIN);

	if (retval = krb5_init_context(&context)) {
		com_err(whoami, retval, gettext("initializing krb5 context"));
		exit(retval);
	}
	/* initialize_kpws_error_table(); SUNWresync121 */
	retval = kpasswd(context, argc, argv);

	if (!retval)
		printf(string_text(KPW_STR_PASSWORD_CHANGED));

	exit(retval);
}