dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / krb5 / kadmin / kpasswd / tty_kpasswd.c
blob63ee6d37725c37414b6d314c2032e3624fb09a68
1 /*
2 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 #pragma ident "%Z%%M% %I% %E% SMI"
8 /*
9 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
11 * Openvision retains the copyright to derivative works of
12 * this source code. Do *NOT* create a derivative of this
13 * source code before consulting with your legal department.
14 * Do *NOT* integrate *ANY* of this source code into another
15 * product before consulting with your legal department.
17 * For further information, read the top-level Openvision
18 * copyright which is contained in the top-level MIT Kerberos
19 * copyright.
21 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
27 * Copyright 1993-1994 OpenVision Technologies, Inc., All Rights Reserved.
29 * $Header: /cvs/krbdev/krb5/src/kadmin/passwd/tty_kpasswd.c,v 1.9 2001/02/26 18:22:08 epeisach Exp $
34 static char rcsid[] = "$Id: tty_kpasswd.c,v 1.9 2001/02/26 18:22:08 epeisach Exp $";
36 #include <kadm5/admin.h>
37 #include <krb5.h>
39 #include "kpasswd_strings.h"
40 #define string_text error_message
42 #include "kpasswd.h"
43 #include <stdio.h>
44 #include <pwd.h>
45 #include <string.h>
46 #include <libintl.h>
47 #include <locale.h>
49 char *whoami;
51 void display_intro_message(fmt_string, arg_string)
52 const char *fmt_string;
53 const char *arg_string;
55 com_err(whoami, 0, fmt_string, arg_string);
58 long read_old_password(context, password, pwsize)
59 krb5_context context;
60 char *password;
61 unsigned int *pwsize;
63 long code = krb5_read_password(context,
64 (char *) string_text(KPW_STR_OLD_PASSWORD_PROMPT),
65 0, password, pwsize);
66 return code;
69 long read_new_password(server_handle, password, pwsize, msg_ret, msg_len, princ)
70 void *server_handle;
71 char *password;
72 unsigned int *pwsize;
73 char *msg_ret;
74 int msg_len;
75 krb5_principal princ;
77 return (kadm5_chpass_principal_util(server_handle, princ, NULL,
78 NULL /* don't need new pw back */,
79 msg_ret, msg_len));
84 * main() for tty version of kpasswd.c
86 int
87 main(argc, argv)
88 int argc;
89 char *argv[];
91 krb5_context context;
92 int retval;
94 whoami = (whoami = strrchr(argv[0], '/')) ? whoami + 1 : argv[0];
96 (void) setlocale(LC_ALL, "");
98 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
99 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */
100 #endif
102 (void) textdomain(TEXT_DOMAIN);
104 retval = krb5_init_context(&context);
105 if (retval) {
106 com_err(whoami, retval, gettext("initializing krb5 context"));
107 exit(retval);
109 /* initialize_kpws_error_table(); SUNWresync121 */
111 retval = kpasswd(context, argc, argv);
113 if (!retval)
114 printf(string_text(KPW_STR_PASSWORD_CHANGED));
116 exit(retval);