(kadm5_s_chpass_principal_cond): new function

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8763 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
2000-07-22 05:50:13 +00:00
parent b881967248
commit ff33a64774

View File

@@ -35,18 +35,19 @@
RCSID("$Id$"); RCSID("$Id$");
/* static kadm5_ret_t
* change the password of `princ' to `password' change(void *server_handle,
*/ krb5_principal princ,
char *password,
kadm5_ret_t int cond)
kadm5_s_chpass_principal(void *server_handle,
krb5_principal princ,
char *password)
{ {
kadm5_server_context *context = server_handle; kadm5_server_context *context = server_handle;
hdb_entry ent; hdb_entry ent;
kadm5_ret_t ret; kadm5_ret_t ret;
Key *keys;
size_t num_keys;
int cmp = 1;
ent.principal = princ; ent.principal = princ;
ret = context->db->open(context->context, context->db, O_RDWR, 0); ret = context->db->open(context->context, context->db, O_RDWR, 0);
if(ret) if(ret)
@@ -55,9 +56,26 @@ kadm5_s_chpass_principal(void *server_handle,
0, &ent); 0, &ent);
if(ret == HDB_ERR_NOENTRY) if(ret == HDB_ERR_NOENTRY)
goto out; goto out;
num_keys = ent.keys.len;
keys = ent.keys.val;
ent.keys.len = 0;
ent.keys.val = NULL;
ret = _kadm5_set_keys(context, &ent, password); ret = _kadm5_set_keys(context, &ent, password);
if(ret) if(ret) {
_kadm5_free_keys (server_handle, num_keys, keys);
goto out2; goto out2;
}
if (cond)
cmp = _kadm5_cmp_keys (ent.keys.val, ent.keys.len,
keys, num_keys);
_kadm5_free_keys (server_handle, num_keys, keys);
if (cmp == 0)
goto out2;
ret = _kadm5_set_modifier(context, &ent); ret = _kadm5_set_modifier(context, &ent);
if(ret) if(ret)
goto out2; goto out2;
@@ -78,6 +96,32 @@ out:
return _kadm5_error_code(ret); return _kadm5_error_code(ret);
} }
/*
* change the password of `princ' to `password' if it's not already that.
*/
kadm5_ret_t
kadm5_s_chpass_principal_cond(void *server_handle,
krb5_principal princ,
char *password)
{
return change (server_handle, princ, password, 1);
}
/*
* change the password of `princ' to `password'
*/
kadm5_ret_t
kadm5_s_chpass_principal(void *server_handle,
krb5_principal princ,
char *password)
{
return change (server_handle, princ, password, 0);
}
/* /*
* change keys for `princ' to `keys' * change keys for `princ' to `keys'
*/ */