[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: smbk5pwd crash for missing symbol



Love Hörnquist Åstrand a écrit :

27 maj 2008 kl. 02.18 skrev Guillaume Rousse:

I tried this approach (patch attached).

Converting _kadm5_free_keys to hdb_free_keys is trivial, as the former is just a wrapper over the second.

However, converting _kadm5_set_keys to hdb_generate_key_set_password is much more difficult. I first tried to inline all code from _kadm5_set_keys in smbk5pwd.c. However, gcc complains about "request for member ‘context’ in something not a structure or union" because it doesn't have any clue about the nature of kadm_context, which is a void ponter for smbk5pwd. Trying to cast it as a kadm5_server_context pointer fails, as this seems also to be a private heimdal structure...

Given my lack of C knowledge, I'm a bit stuck there.

You can use the krb5_contex that is global in the module, just change the code to use context instead of kadm5_context.
Slightly better but I still can't access its members:
smbk5pwd.c:416: error: dereferencing pointer to incomplete type

According to my understanding, kadm_context type is a pointer to an internally-defined krb5_context_data structure.

Inlining private function is not straightforward, especially for dumb C programmers :)

Updated patch attached.
--
Guillaume Rousse
Moyens Informatiques - INRIA Futurs
Tel: 01 69 35 69 62
--- smbk5pwd.c~	2008-02-12 00:34:15.000000000 +0100
+++ smbk5pwd.c	2008-05-28 11:05:18.000000000 +0200
@@ -368,6 +368,8 @@
 		struct berval *keys;
 		int kvno, i;
 		Attribute *a;
+		Key *local_keys;
+		size_t local_num_keys;
 
 		if ( !SMBK5PWD_DO_KRB5( pi ) ) break;
 
@@ -396,7 +398,26 @@
 				op->o_log_prefix, e->e_name.bv_val, 0 );
 		}
 
-		ret = _kadm5_set_keys(kadm_context, &ent, qpw->rs_new.bv_val);
+		/* _kadm5_set_keys is a private function, inline its code here */
+		ret = hdb_generate_key_set_password(context, ent.principal,
+                qpw->rs_new.bv_val, &local_keys, &local_num_keys);
+		if (ret != 0)
+			break;
+
+		hdb_free_keys(context, ent.keys.len, ent.keys.val);
+		ent.keys.val = local_keys;
+		ent.keys.len = local_num_keys;
+
+		hdb_entry_set_pw_change_time(context, &ent, 0);
+
+		if (krb5_config_get_bool_default(context, NULL, FALSE,
+			"kadmin", "save-password", NULL)) {
+			ret = hdb_entry_set_password(context,
+				context->db, &ent, qpw->rs_new.bv_val);
+			if (ret != 0)
+				break;
+		}
+
 		hdb_seal_keys(context, db, &ent);
 		krb5_free_principal( context, ent.principal );
 
@@ -415,7 +436,7 @@
 		}
 		BER_BVZERO( &keys[i] );
 
-		_kadm5_free_keys(kadm_context, ent.keys.len, ent.keys.val);
+		hdb_free_keys(context, ent.keys.len, ent.keys.val);
 
 		if ( i != ent.keys.len ) {
 			ber_bvarray_free( keys );