diff options
author | Andreas Schneider <asn@samba.org> | 2016-08-26 17:08:57 +0200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2016-08-31 20:59:18 +0200 |
commit | e01587c948ecb064002e89e961bbbec4d625d9dd (patch) | |
tree | d384bc871cca2bec7e74fa1e241f8e95289273ac /source3/libads/krb5_setpw.c | |
parent | 9d4f1b4d3119f0c655eff3619e675423ad8c21d8 (diff) | |
download | samba-e01587c948ecb064002e89e961bbbec4d625d9dd.tar.gz |
s3-libads: Do not use deprecated krb5_get_init_creds_opt_init()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3/libads/krb5_setpw.c')
-rw-r--r-- | source3/libads/krb5_setpw.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/source3/libads/krb5_setpw.c b/source3/libads/krb5_setpw.c index 446278a580a..2aed322f9b7 100644 --- a/source3/libads/krb5_setpw.c +++ b/source3/libads/krb5_setpw.c @@ -168,7 +168,7 @@ static ADS_STATUS ads_krb5_chg_password(const char *kdc_host, krb5_error_code ret; krb5_context context = NULL; krb5_principal princ; - krb5_get_init_creds_opt opts; + krb5_get_init_creds_opt *opts = NULL; krb5_creds creds; char *chpw_princ = NULL, *password; char *realm = NULL; @@ -191,12 +191,18 @@ static ADS_STATUS ads_krb5_chg_password(const char *kdc_host, return ADS_ERROR_KRB5(ret); } - krb5_get_init_creds_opt_init(&opts); + ret = krb5_get_init_creds_opt_alloc(context, &opts); + if (ret != 0) { + krb5_free_context(context); + DBG_WARNING("krb5_get_init_creds_opt_alloc failed: %s\n", + error_message(ret)); + return ADS_ERROR_KRB5(ret); + } - krb5_get_init_creds_opt_set_tkt_life(&opts, 5*60); - krb5_get_init_creds_opt_set_renew_life(&opts, 0); - krb5_get_init_creds_opt_set_forwardable(&opts, 0); - krb5_get_init_creds_opt_set_proxiable(&opts, 0); + krb5_get_init_creds_opt_set_tkt_life(opts, 5*60); + krb5_get_init_creds_opt_set_renew_life(opts, 0); + krb5_get_init_creds_opt_set_forwardable(opts, 0); + krb5_get_init_creds_opt_set_proxiable(opts, 0); /* note that heimdal will fill in the local addresses if the addresses * in the creds_init_opt are all empty and then later fail with invalid @@ -205,15 +211,17 @@ static ADS_STATUS ads_krb5_chg_password(const char *kdc_host, ret = smb_krb5_gen_netbios_krb5_address(&addr, lp_netbios_name()); if (ret) { krb5_free_principal(context, princ); + krb5_get_init_creds_opt_free(context, opts); krb5_free_context(context); return ADS_ERROR_KRB5(ret); } - krb5_get_init_creds_opt_set_address_list(&opts, addr->addrs); + krb5_get_init_creds_opt_set_address_list(opts, addr->addrs); realm = smb_krb5_principal_get_realm(context, princ); /* We have to obtain an INITIAL changepw ticket for changing password */ if (asprintf(&chpw_princ, "kadmin/changepw@%s", realm) == -1) { + krb5_get_init_creds_opt_free(context, opts); krb5_free_context(context); free(realm); DEBUG(1,("ads_krb5_chg_password: asprintf fail\n")); @@ -224,7 +232,8 @@ static ADS_STATUS ads_krb5_chg_password(const char *kdc_host, password = SMB_STRDUP(oldpw); ret = krb5_get_init_creds_password(context, &creds, princ, password, kerb_prompter, NULL, - 0, chpw_princ, &opts); + 0, chpw_princ, opts); + krb5_get_init_creds_opt_free(context, opts); SAFE_FREE(chpw_princ); SAFE_FREE(password); |