/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
*/
/*
* Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved.
*/
/*
* 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
*
*/
#include <stdio.h>
#include "autoconf.h"
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#include <time.h>
#include <string.h>
/* Solaris Kerberos */
#include <locale.h>
#include "admin_internal.h"
#include <krb5.h>
/* Solaris Kerberos */
/*
* Function: kadm5_chpass_principal_util
*
* Purpose: Wrapper around chpass_principal. We can read new pw, change pw and return useful messages
*
* Arguments:
*
* princ (input) a krb5b_principal structure for the
* principal whose password we should change.
*
* new_password (input) NULL or a null terminated string with the
* the principal's desired new password. If new_password
* is NULL then this routine will read a new password.
*
* pw_ret (output) if non-NULL, points to a static buffer
* containing the new password (if password is prompted
* internally), or to the new_password argument (if
* that is non-NULL). If the former, then the buffer
* is only valid until the next call to the function,
* and the caller should be sure to zero it when
* it is no longer needed.
*
* msg_ret (output) a useful message is copied here.
*
* <return value> exit status of 0 for success, else the com err code
* for the last significant routine called.
*
* Requires:
*
* A msg_ret should point to a buffer large enough for the messasge.
*
* Effects:
*
* Modifies:
*
*
*/
void *lhandle,
char *new_pw,
char **ret_pw,
char *msg_ret,
unsigned int msg_len)
{
unsigned int pwsize;
char *new_password;
/* Solaris Kerberos */
if (ret_pw)
} else { /* read the password */
}
if (code == 0)
else {
#ifdef ZEROPASSWD
#endif
if (code == KRB5_LIBOS_BADPWDMATCH) {
msg_len - 1);
return(code);
} else {
msg_len - 1);
msg_len - 1);
return(code);
}
}
if (pwsize == 0) {
#ifdef ZEROPASSWD
#endif
return(KRB5_LIBOS_CANTREADPWD); /* could do better */
}
}
if (ret_pw)
*ret_pw = new_password;
/* Solaris Kerberos */
if (passwd_protocol == KRB5_CHGPWD_CHANGEPW_V2) {
&srvr_msg);
if (srvr_rsp_code) {
return (srvr_rsp_code);
}
return (code);
} else if (passwd_protocol == KRB5_CHGPWD_RPCSEC) {
#ifdef ZEROPASSWD
if (!ret_pw)
#endif
return(0);
}
if ((code != KADM5_PASS_Q_TOOSHORT) &&
/* Can't get more info for other errors */
buffer);
return(code);
}
/* Ok, we have a password quality error. Return a good message */
if (code == KADM5_PASS_REUSE) {
return(code);
}
if (code == KADM5_PASS_Q_DICT) {
msg_len - 1);
return(code);
}
/* Look up policy for the remaining messages */
if (code2 != 0) {
return(code);
}
return(code);
}
&policy_ent);
if (code2 != 0) {
return(code);
}
if (code == KADM5_PASS_Q_TOOSHORT) {
return(code);
}
/* Can't get more info for other errors */
if (code == KADM5_PASS_Q_CLASS) {
return(code);
}
if (code == KADM5_PASS_TOOSOON) {
*ptr = '\0';
return(code);
/* Solaris Kerberos */
} else {
/* We should never get here, but just in case ... */
buffer);
return(code);
}
} else {
"Password protocol in krb5.conf is not supported\n");
return (-1);
}
}
/*
* Solaris Kerberos
* krb5_chpw_result_code_string
*
* convert the return code received from the password server
* to a human-readable string.
*/
const char *
{
switch (result_code) {
case KRB5_KPASSWD_MALFORMED:
case KRB5_KPASSWD_HARDERROR:
case KRB5_KPASSWD_AUTHERROR:
case KRB5_KPASSWD_SOFTERROR:
return (dgettext(TEXT_DOMAIN,
"Not authorized to change password"));
case KRB5_KPASSWD_BAD_VERSION:
return (dgettext(TEXT_DOMAIN,
"initial flag required in changepw request"));
return (dgettext(TEXT_DOMAIN,
"target principal does not exist for "
"changepw request"));
return (dgettext(TEXT_DOMAIN,
"changepw request key sequence has an "
"unsupported Etype"));
default:
}
}