use kadm5_s_chpass_principal_cond instead of mis-doing it here
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8769 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -206,14 +206,10 @@ change (krb5_auth_context auth_context,
|
|||||||
{
|
{
|
||||||
krb5_error_code ret;
|
krb5_error_code ret;
|
||||||
char *client;
|
char *client;
|
||||||
kadm5_principal_ent_rec ent;
|
|
||||||
krb5_key_data *kd;
|
|
||||||
krb5_salt salt;
|
|
||||||
krb5_keyblock new_keyblock;
|
|
||||||
const char *pwd_reason;
|
const char *pwd_reason;
|
||||||
int unchanged;
|
|
||||||
kadm5_config_params conf;
|
kadm5_config_params conf;
|
||||||
void *kadm5_handle;
|
void *kadm5_handle;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
memset (&conf, 0, sizeof(conf));
|
memset (&conf, 0, sizeof(conf));
|
||||||
|
|
||||||
@@ -244,75 +240,27 @@ change (krb5_auth_context auth_context,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = kadm5_get_principal (kadm5_handle,
|
tmp = malloc (pwd_data->length + 1);
|
||||||
principal,
|
if (tmp == NULL) {
|
||||||
&ent,
|
krb5_warnx (context, "malloc: out of memory");
|
||||||
KADM5_KEY_DATA);
|
|
||||||
if (ret) {
|
|
||||||
krb5_warn (context, ret, "kadm5_get_principal");
|
|
||||||
reply_priv (auth_context, s, sa, sa_size, 2,
|
reply_priv (auth_context, s, sa, sa_size, 2,
|
||||||
"Internal error");
|
"Internal error");
|
||||||
kadm5_destroy (kadm5_handle);
|
goto out;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
memcpy (tmp, pwd_data->data, pwd_data->length);
|
||||||
|
tmp[pwd_data->length] = '\0';
|
||||||
|
|
||||||
/*
|
ret = kadm5_s_chpass_principal_cond (kadm5_handle, principal, tmp);
|
||||||
* Compare with the first key to see if it already has been
|
memset (tmp, 0, pwd_data->length);
|
||||||
* changed. If it hasn't, store the new key in the database and
|
free (tmp);
|
||||||
* string2key all the rest of them.
|
if (ret) {
|
||||||
*/
|
krb5_warn (context, ret, "kadm5_s_chpass_principal_cond");
|
||||||
|
reply_priv (auth_context, s, sa, sa_size, 2,
|
||||||
kd = &ent.key_data[0];
|
"Internal error");
|
||||||
|
goto out;
|
||||||
salt.salttype = kd->key_data_type[1];
|
|
||||||
salt.saltvalue.length = kd->key_data_length[1];
|
|
||||||
salt.saltvalue.data = kd->key_data_contents[1];
|
|
||||||
|
|
||||||
memset (&new_keyblock, 0, sizeof(new_keyblock));
|
|
||||||
krb5_string_to_key_data_salt (context,
|
|
||||||
kd->key_data_type[0],
|
|
||||||
*pwd_data,
|
|
||||||
salt,
|
|
||||||
&new_keyblock);
|
|
||||||
|
|
||||||
unchanged = new_keyblock.keytype == kd->key_data_type[0]
|
|
||||||
&& new_keyblock.keyvalue.length == kd->key_data_length[0]
|
|
||||||
&& memcmp(new_keyblock.keyvalue.data,
|
|
||||||
kd->key_data_contents[0],
|
|
||||||
new_keyblock.keyvalue.length) == 0;
|
|
||||||
|
|
||||||
krb5_free_keyblock_contents (context, &new_keyblock);
|
|
||||||
|
|
||||||
if (unchanged) {
|
|
||||||
ret = 0;
|
|
||||||
} else {
|
|
||||||
char *tmp;
|
|
||||||
|
|
||||||
tmp = malloc (pwd_data->length + 1);
|
|
||||||
if (tmp == NULL) {
|
|
||||||
krb5_warnx (context, "malloc: out of memory");
|
|
||||||
reply_priv (auth_context, s, sa, sa_size, 2,
|
|
||||||
"Internal error");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
memcpy (tmp, pwd_data->data, pwd_data->length);
|
|
||||||
tmp[pwd_data->length] = '\0';
|
|
||||||
|
|
||||||
ret = kadm5_chpass_principal (kadm5_handle,
|
|
||||||
principal,
|
|
||||||
tmp);
|
|
||||||
memset (tmp, 0, pwd_data->length);
|
|
||||||
free (tmp);
|
|
||||||
if (ret) {
|
|
||||||
krb5_warn (context, ret, "kadm5_s_chpass_principal");
|
|
||||||
reply_priv (auth_context, s, sa, sa_size, 2,
|
|
||||||
"Internal error");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
reply_priv (auth_context, s, sa, sa_size, 0, "Password changed");
|
reply_priv (auth_context, s, sa, sa_size, 0, "Password changed");
|
||||||
out:
|
out:
|
||||||
kadm5_free_principal_ent (kadm5_handle, &ent);
|
|
||||||
kadm5_destroy (kadm5_handle);
|
kadm5_destroy (kadm5_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,6 +392,7 @@ process (krb5_principal server,
|
|||||||
s,
|
s,
|
||||||
sa, sa_size,
|
sa, sa_size,
|
||||||
&out_data);
|
&out_data);
|
||||||
|
memset (out_data.data, 0, out_data.length);
|
||||||
krb5_free_ticket (context, ticket);
|
krb5_free_ticket (context, ticket);
|
||||||
free (ticket);
|
free (ticket);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user