krb5_child.c revision 83011d97d17bd00e99ccf1e0302167a6bc0db84e
46b207daf66b64930a59f3615c8b127aac0b8e43Christian Maeder Kerberos 5 Backend Module -- tgt_req and changepw child
46b207daf66b64930a59f3615c8b127aac0b8e43Christian Maeder Sumit Bose <sbose@redhat.com>
46b207daf66b64930a59f3615c8b127aac0b8e43Christian Maeder Copyright (C) 2009-2010 Red Hat
46b207daf66b64930a59f3615c8b127aac0b8e43Christian Maeder This program is free software; you can redistribute it and/or modify
46b207daf66b64930a59f3615c8b127aac0b8e43Christian Maeder it under the terms of the GNU General Public License as published by
46b207daf66b64930a59f3615c8b127aac0b8e43Christian Maeder the Free Software Foundation; either version 3 of the License, or
46b207daf66b64930a59f3615c8b127aac0b8e43Christian Maeder (at your option) any later version.
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maeder This program is distributed in the hope that it will be useful,
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maeder but WITHOUT ANY WARRANTY; without even the implied warranty of
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maeder MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maeder GNU General Public License for more details.
46b207daf66b64930a59f3615c8b127aac0b8e43Christian Maeder You should have received a copy of the GNU General Public License
df0e8744a2befcba003ea6d93214601c743bde74Christian Maeder along with this program. If not, see <http://www.gnu.org/licenses/>.
46b207daf66b64930a59f3615c8b127aac0b8e43Christian Maeder#define SSSD_KRB5_CHANGEPW_PRINCIPAL "kadmin/changepw"
59bbf8aeab565e86d79c8482a4c7bd7a1841ca7bChristian Maeder#define KRB5_CHILD_DEBUG(level, error) KRB5_DEBUG(level, krb5_error_ctx, error)
46b207daf66b64930a59f3615c8b127aac0b8e43Christian Maederstatic krb5_error_code get_changepw_options(krb5_context ctx,
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maeder kerr = sss_krb5_get_init_creds_opt_alloc(ctx, &options);
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maeder KRB5_CHILD_DEBUG(SSSDBG_CRIT_FAILURE, kerr);
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maeder sss_krb5_get_init_creds_opt_set_canonicalize(options, 0);
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maeder krb5_get_init_creds_opt_set_forwardable(options, 0);
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maeder krb5_get_init_creds_opt_set_proxiable(options, 0);
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maeder krb5_get_init_creds_opt_set_renew_life(options, 0);
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maeder krb5_get_init_creds_opt_set_tkt_life(options, 5*60);
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maederstatic errno_t sss_send_pac(krb5_authdata **pac_authdata)
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maeder ret = sss_pac_make_request(SSS_PAC_ADD_PAC_USER, &sss_data,
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maeder if (ret != NSS_STATUS_SUCCESS || errnop != 0) {
b8cd2804f426fd97148615fe31c1f47afac7a683Christian Maeder DEBUG(SSSDBG_OP_FAILURE, ("sss_pac_make_request failed [%d][%d].\n",
863c98ae89e37c21c0c04b9b130b5136688976eeChristian Maederstatic void sss_krb5_expire_callback_func(krb5_context context, void *data,
long exp_time;
if (password_expiration == 0) {
typedef int (*checker)(int c);
switch (format) {
return isdigit;
return isxdigit;
return isalnum;
return NULL;
return ENOTSUP;
return ENOTSUP;
return EPROTO;
return ENOMEM;
return ENOTSUP;
return EMSGSIZE;
return ENOMEM;
return EMSGSIZE;
return EMSGSIZE;
return ENOMEM;
return EBADMSG;
return ret;
goto done;
goto done;
switch (ret) {
case EBADMSG:
case EMSGSIZE:
case ENOTSUP:
case EPROTO:
goto done;
goto done;
goto done;
done:
return ret;
void *data,
return EINVAL;
int ret;
if (num_prompts != 0) {
return KRB5_LIBOS_CANTREADPWD;
return EOK;
return EOK;
return ENOMEM;
if (kerr != 0) {
goto done;
if (kerr != 0) {
goto done;
done:
if (kerr != 0) {
return kerr;
int ret;
int fd;
return EOK;
return ret;
return EOK;
const char *type;
#ifdef HAVE_KRB5_CC_COLLECTION
bool switch_to_cc = false;
if (kerr) {
return ERR_INTERNAL;
#ifdef HAVE_KRB5_CC_COLLECTION
switch_to_cc = true;
#ifdef HAVE_KRB5_CC_COLLECTION
if (switch_to_cc) {
done:
if (kcc) {
return kerr;
size_t p = 0;
if (!buf) {
return ENOMEM;
*_len = p;
return EOK;
int ret;
return ERR_INTERNAL;
return ENOMEM;
return ret;
int ret;
return ret;
errno = 0;
return ret;
return EOK;
return EOK;
int ret;
unsigned int upn_len = 0;
goto done;
if (kerr != 0) {
goto done;
goto done;
done:
return ret;
bool realm_entry_found = false;
if (kerr != 0) {
return kerr;
if (kerr != 0) {
return kerr;
if (kerr != 0) {
goto done;
if (kerr != 0) {
realm_entry_found = true;
if (!realm_entry_found) {
if (kerr != 0) {
goto done;
goto done;
if (kerr != 0) {
goto done;
if (kerr == 0) {
principal));
goto done;
if (kerr != 0) {
kerr = 0;
goto done;
if (kerr != 0) {
kerr = 0;
done:
return kerr;
int canonicalize = 0;
char *tmp_str;
char *ccname)
&options);
if (kerr != 0) {
return kerr;
if (kerr != 0) {
goto done;
kerr = 0;
done:
return kerr;
const char *password)
const char *realm_name;
int realm_length;
char *cc_name;
kr);
if (kerr != 0) {
if (kerr != 0) {
return kerr;
if (kerr != 0) {
return kerr;
if (kerr != 0) {
return kerr;
if (kerr != 0) {
goto done;
if (kerr != 0) {
kerr = 0;
done:
return kerr;
if (kerr != 0) {
switch (kerr) {
return ERR_OK;
case KRB5_LIBOS_CANTREADPWD:
return ERR_NO_CREDS;
case KRB5KRB_AP_ERR_SKEW:
case KRB5_KDC_UNREACH:
case KRB5_REALM_CANT_RESOLVE:
return ERR_NETWORK_IO;
return ERR_ACCOUNT_EXPIRED;
case KRB5KDC_ERR_KEY_EXP:
return ERR_CREDS_EXPIRED;
return ERR_AUTH_FAILED;
case KRB5_PREAUTH_FAILED:
return ERR_CREDS_INVALID;
return ERR_INTERNAL;
int ret;
const char *realm_name;
int realm_length;
return ERR_NO_CREDS;
if (!prelim) {
if (kerr != 0) {
return kerr;
if (kerr != 0) {
msg);
return kerr;
if (prelim) {
return EOK;
return ERR_NO_CREDS;
return ERR_NETWORK_IO;
if (kerr != 0) {
return ERR_CHPASS_FAILED;
if (kerr == 0) {
int ret;
switch (ret) {
case EOK:
case EACCES:
return ERR_INVALID_CRED_TYPE;
return ERR_NO_CREDS;
if (kerr == 0) {
goto done;
if (kerr != 0) {
if (kerr != 0) {
return kerr;
if (kerr == 0) {
done:
return ret;
if (kerr != 0) {
if (access_allowed) {
return EOK;
return ERR_AUTH_DENIED;
const char *ccname;
int ret;
return ERR_INVALID_CRED_TYPE;
if (kerr != 0) {
goto done;
if (kerr != 0) {
goto done;
if (kerr != 0) {
goto done;
if (kerr != 0) {
goto done;
if (kerr != 0) {
goto done;
if (kerr != 0) {
goto done;
if (kerr != 0) {
done:
if (kerr == 0) {
if (kerr != 0) {
return EINVAL;
switch (auth_token_type) {
case SSS_AUTHTOK_TYPE_EMPTY:
case SSS_AUTHTOK_TYPE_CCFILE:
return EINVAL;
*p += auth_token_length;
return ret;
size_t p = 0;
return ENOMEM;
p += len;
p += len;
p += len;
if (ret) {
return ret;
if (ret) {
return ret;
p += len;
return EOK;
return EOK;
if (krberr != 0) {
goto done;
if (krberr != 0) {
krberr = 0;
goto done;
krberr = 0;
done:
return krberr;
const char *primary,
const char *realm,
const char *keytab_name,
char **fast_ccname)
char *ccname;
char *server_name;
return ENOMEM;
goto done;
if (kerr) {
goto done;
if (kerr != 0) {
goto done;
goto done;
if (kerr != 0) {
goto done;
if (kerr == 0) {
goto done;
if (kerr != 0) {
goto done;
kerr = 0;
done:
if (kerr == 0) {
return kerr;
errno = 0;
return ret;
return ret;
char *fast_principal_realm;
char *fast_principal;
char *tmp_str;
if (tmp_str) {
if (kerr) {
return kerr;
&tmp_str);
if (kerr) {
return kerr;
if (!fast_principal) {
return KRB5KRB_ERR_GENERIC;
if (!fast_principal_realm) {
return ENOMEM;
if (kerr != 0) {
return kerr;
if (kerr != 0) {
return kerr;
if (demand) {
if (kerr != 0) {
return kerr;
return EOK;
char *lifetime_str;
char *use_fast_str;
int parse_flags;
if (kerr != 0) {
return kerr;
if (kerr != 0) {
return EIO;
* missing in krb5.conf or to allow SSSD to work with multiple unconnected
if (kerr != 0) {
if (kerr != 0) {
return kerr;
if (kerr != 0) {
return kerr;
return ENOMEM;
if (kerr != 0) {
return kerr;
if (kerr != 0) {
return kerr;
if (kerr != 0) {
lifetime_str));
return kerr;
if (kerr != 0) {
lifetime_str));
return kerr;
if (!offline) {
use_fast_str));
return EINVAL;
return kerr;
int opt;
switch(opt) {
if (!debug_prg_name) {
goto done;
goto done;
goto done;
case SSS_PAM_AUTHENTICATE:
if (offline) {
case SSS_PAM_CHAUTHTOK:
case SSS_PAM_CHAUTHTOK_PRELIM:
case SSS_PAM_ACCT_MGMT:
case SSS_CMD_RENEW:
if (offline) {
goto done;
goto done;
done:
exit(0);