[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: another kpasswdd issue



On 18 Jul 2000, Johan Danielsson wrote:

> Derrick J Brashear <shadow@dementia.org> writes:
> 
> > like my previous 2 issues i know how i can fix it but i'm hoping for
> > some guidance from the people who actually can commit code so i
> > don't implement a conflicting solution
> 
> Set the key, but don't bump the kvno? Don't know if there's an easier
> way.

I don't see a way to do it other than this:
*** /usr/tmp/heimdal/sandbox/heimdal/heimdal/kpasswd/kpasswdd.c	Fri May 12 07:42:49 2000
--- ./kpasswdd.c	Wed Jul 19 16:53:34 2000
***************
*** 34,40 ****
--- 34,45 ----
  #include "kpasswd_locl.h"
  RCSID("$Id: kpasswdd.c,v 1.42 2000/05/12 11:42:49 assar Exp $");
  
+ #include <hdb.h>
+ #ifdef HAVE_SYS_UN_H
+ #include <sys/un.h>
+ #endif
  #include <kadm5/admin.h>
+ #include <kadm5/private.h>
  #ifdef HAVE_DLFCN_H
  #include <dlfcn.h>
  #endif
***************
*** 214,219 ****
--- 219,225 ----
      int unchanged;
      kadm5_config_params conf;
      void *kadm5_handle;
+     char *tmp;
  
      memset (&conf, 0, sizeof(conf));
      
***************
*** 283,315 ****
  
      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");
  out:
      kadm5_free_principal_ent (kadm5_handle, &ent);
--- 289,344 ----
  
      krb5_free_keyblock_contents (context, &new_keyblock);
  
+     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';
+ 
      if (unchanged) {
! 	/* Update the keys, then decrement the kvno. */
! 	kadm5_server_context *context = kadm5_handle;
! 	hdb_entry ent;
! 
! 	ent.principal = principal;
! 	ret = context->db->open(context->context, context->db, O_RDWR, 0);
! 	if(ret)
! 	    goto out1;
! 	ret = context->db->fetch(context->context, context->db, 
! 				 0, &ent);
! 	if(ret == HDB_ERR_NOENTRY)
! 	    goto out2;
! 	ret = _kadm5_set_keys(context, &ent, tmp);
! 	if(ret)
! 	    goto out3;
! 	ent.kvno--;
! 	hdb_seal_keys(context->context, context->db, &ent);
! 	ret = context->db->store(context->context, context->db, 
! 				 HDB_F_REPLACE, &ent);
!     out3:
! 	hdb_free_entry(context->context, &ent);
!     out2:
! 	context->db->close(context->context, context->db);
!     out1:
      } else {
  	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");
  out:
      kadm5_free_principal_ent (kadm5_handle, &ent);