17c478bd9Sstevel@tonic-gate /*
2*56a424ccSmp153739 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
37c478bd9Sstevel@tonic-gate * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate */
57c478bd9Sstevel@tonic-gate
67c478bd9Sstevel@tonic-gate /*
77c478bd9Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * Openvision retains the copyright to derivative works of
107c478bd9Sstevel@tonic-gate * this source code. Do *NOT* create a derivative of this
117c478bd9Sstevel@tonic-gate * source code before consulting with your legal department.
127c478bd9Sstevel@tonic-gate * Do *NOT* integrate *ANY* of this source code into another
137c478bd9Sstevel@tonic-gate * product before consulting with your legal department.
147c478bd9Sstevel@tonic-gate *
157c478bd9Sstevel@tonic-gate * For further information, read the top-level Openvision
167c478bd9Sstevel@tonic-gate * copyright which is contained in the top-level MIT Kerberos
177c478bd9Sstevel@tonic-gate * copyright.
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
207c478bd9Sstevel@tonic-gate *
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate
237c478bd9Sstevel@tonic-gate
247c478bd9Sstevel@tonic-gate /*
257c478bd9Sstevel@tonic-gate * Copyright 1993-1994 OpenVision Technologies, Inc., All Rights Reserved.
267c478bd9Sstevel@tonic-gate *
27*56a424ccSmp153739 * $Header: /cvs/krbdev/krb5/src/kadmin/passwd/tty_kpasswd.c,v 1.9 2001/02/26 18:22:08 epeisach Exp $
287c478bd9Sstevel@tonic-gate *
297c478bd9Sstevel@tonic-gate *
307c478bd9Sstevel@tonic-gate */
317c478bd9Sstevel@tonic-gate
32*56a424ccSmp153739 static char rcsid[] = "$Id: tty_kpasswd.c,v 1.9 2001/02/26 18:22:08 epeisach Exp $";
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gate #include <kadm5/admin.h>
357c478bd9Sstevel@tonic-gate #include <krb5.h>
367c478bd9Sstevel@tonic-gate
377c478bd9Sstevel@tonic-gate #include "kpasswd_strings.h"
387c478bd9Sstevel@tonic-gate #define string_text error_message
397c478bd9Sstevel@tonic-gate
40*56a424ccSmp153739 #include "kpasswd.h"
417c478bd9Sstevel@tonic-gate #include <stdio.h>
427c478bd9Sstevel@tonic-gate #include <pwd.h>
437c478bd9Sstevel@tonic-gate #include <string.h>
447c478bd9Sstevel@tonic-gate #include <libintl.h>
457c478bd9Sstevel@tonic-gate #include <locale.h>
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate char *whoami;
487c478bd9Sstevel@tonic-gate
display_intro_message(fmt_string,arg_string)49*56a424ccSmp153739 void display_intro_message(fmt_string, arg_string)
50*56a424ccSmp153739 const char *fmt_string;
51*56a424ccSmp153739 const char *arg_string;
527c478bd9Sstevel@tonic-gate {
537c478bd9Sstevel@tonic-gate com_err(whoami, 0, fmt_string, arg_string);
547c478bd9Sstevel@tonic-gate }
557c478bd9Sstevel@tonic-gate
read_old_password(context,password,pwsize)56*56a424ccSmp153739 long read_old_password(context, password, pwsize)
577c478bd9Sstevel@tonic-gate krb5_context context;
587c478bd9Sstevel@tonic-gate char *password;
597c478bd9Sstevel@tonic-gate unsigned int *pwsize;
607c478bd9Sstevel@tonic-gate {
617c478bd9Sstevel@tonic-gate long code = krb5_read_password(context,
627c478bd9Sstevel@tonic-gate (char *) string_text(KPW_STR_OLD_PASSWORD_PROMPT),
637c478bd9Sstevel@tonic-gate 0, password, pwsize);
64*56a424ccSmp153739 return code;
657c478bd9Sstevel@tonic-gate }
667c478bd9Sstevel@tonic-gate
read_new_password(server_handle,password,pwsize,msg_ret,msg_len,princ)67*56a424ccSmp153739 long read_new_password(server_handle, password, pwsize, msg_ret, msg_len, princ)
687c478bd9Sstevel@tonic-gate void *server_handle;
697c478bd9Sstevel@tonic-gate char *password;
70*56a424ccSmp153739 unsigned int *pwsize;
717c478bd9Sstevel@tonic-gate char *msg_ret;
727c478bd9Sstevel@tonic-gate int msg_len;
737c478bd9Sstevel@tonic-gate krb5_principal princ;
747c478bd9Sstevel@tonic-gate {
757c478bd9Sstevel@tonic-gate return (kadm5_chpass_principal_util(server_handle, princ, NULL,
767c478bd9Sstevel@tonic-gate NULL /* don't need new pw back */,
777c478bd9Sstevel@tonic-gate msg_ret, msg_len));
787c478bd9Sstevel@tonic-gate }
797c478bd9Sstevel@tonic-gate
807c478bd9Sstevel@tonic-gate
817c478bd9Sstevel@tonic-gate /*
827c478bd9Sstevel@tonic-gate * main() for tty version of kpasswd.c
837c478bd9Sstevel@tonic-gate */
847c478bd9Sstevel@tonic-gate int
main(argc,argv)857c478bd9Sstevel@tonic-gate main(argc, argv)
867c478bd9Sstevel@tonic-gate int argc;
877c478bd9Sstevel@tonic-gate char *argv[];
887c478bd9Sstevel@tonic-gate {
897c478bd9Sstevel@tonic-gate krb5_context context;
907c478bd9Sstevel@tonic-gate int retval;
917c478bd9Sstevel@tonic-gate
927c478bd9Sstevel@tonic-gate whoami = (whoami = strrchr(argv[0], '/')) ? whoami + 1 : argv[0];
937c478bd9Sstevel@tonic-gate
947c478bd9Sstevel@tonic-gate (void) setlocale(LC_ALL, "");
957c478bd9Sstevel@tonic-gate
967c478bd9Sstevel@tonic-gate #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
977c478bd9Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */
987c478bd9Sstevel@tonic-gate #endif
997c478bd9Sstevel@tonic-gate
1007c478bd9Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN);
1017c478bd9Sstevel@tonic-gate
102*56a424ccSmp153739 retval = krb5_init_context(&context);
103*56a424ccSmp153739 if (retval) {
1047c478bd9Sstevel@tonic-gate com_err(whoami, retval, gettext("initializing krb5 context"));
1057c478bd9Sstevel@tonic-gate exit(retval);
1067c478bd9Sstevel@tonic-gate }
1077c478bd9Sstevel@tonic-gate /* initialize_kpws_error_table(); SUNWresync121 */
108*56a424ccSmp153739
1097c478bd9Sstevel@tonic-gate retval = kpasswd(context, argc, argv);
1107c478bd9Sstevel@tonic-gate
1117c478bd9Sstevel@tonic-gate if (!retval)
1127c478bd9Sstevel@tonic-gate printf(string_text(KPW_STR_PASSWORD_CHANGED));
1137c478bd9Sstevel@tonic-gate
1147c478bd9Sstevel@tonic-gate exit(retval);
1157c478bd9Sstevel@tonic-gate }
116