aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-kerberos.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2009-10-07 07:03:33 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2009-10-07 07:03:33 +0000
commitd86f67b925ed4315c754bac3f70d04d21dd493f0 (patch)
tree6b5538e9e07e7027b19d5df7636cd6b7d3952cfc /epan/dissectors/packet-kerberos.c
parentc177dd5a0ffc6541f2eede06abd33c0e490a160e (diff)
add a new function read_keytab_file_from_preferences(void)
that can be called by dissectoirs using kerberos keytab files. This function will load a new keytab file on demand, if it is changed in the preferences. The previous code had you save the preferences and then restart wireshark which is suboptimal from a user friendly perspective svn path=/trunk/; revision=30384
Diffstat (limited to 'epan/dissectors/packet-kerberos.c')
-rw-r--r--epan/dissectors/packet-kerberos.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/epan/dissectors/packet-kerberos.c b/epan/dissectors/packet-kerberos.c
index 20335839d0..b4f527682d 100644
--- a/epan/dissectors/packet-kerberos.c
+++ b/epan/dissectors/packet-kerberos.c
@@ -387,6 +387,34 @@ gboolean krb_decrypt = FALSE;
/* keytab filename */
static const char *keytab_filename = "insert filename here";
+void read_keytab_file(const char *);
+
+void
+read_keytab_file_from_preferences(void)
+{
+ static char *last_keytab = NULL;
+
+ if (!krb_decrypt) {
+ return;
+ }
+
+ if (keytab_filename == NULL) {
+ return;
+ }
+
+ if (last_keytab && !strcmp(last_keytab, keytab_filename)) {
+ return;
+ }
+
+ if (last_keytab != NULL) {
+ g_free(last_keytab);
+ last_keytab = NULL;
+ }
+ last_keytab = g_strdup(keytab_filename);
+
+ read_keytab_file(last_keytab);
+}
+
#endif
#if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS)
@@ -505,7 +533,6 @@ decrypt_krb5_data(proto_tree *tree, packet_info *pinfo,
int keytype,
int *datalen)
{
- static gboolean first_time=TRUE;
krb5_error_code ret;
enc_key_t *ek;
static krb5_data data = {0,0,NULL};
@@ -523,14 +550,7 @@ decrypt_krb5_data(proto_tree *tree, packet_info *pinfo,
return NULL;
}
- /* XXX we should only do this for first time, then store somewhere */
- /* XXX We also need to re-read the keytab when the preference changes */
-
- /* should this have a destroy context ? MIT people would know */
- if(first_time){
- first_time=FALSE;
- read_keytab_file(keytab_filename);
- }
+ read_keytab_file_from_preferences();
for(ek=enc_key_list;ek;ek=ek->next){
krb5_enc_data input;
@@ -646,7 +666,6 @@ decrypt_krb5_data(proto_tree *tree, packet_info *pinfo,
int keytype,
int *datalen)
{
- static gboolean first_time=TRUE;
krb5_error_code ret;
krb5_data data;
enc_key_t *ek;
@@ -663,14 +682,7 @@ decrypt_krb5_data(proto_tree *tree, packet_info *pinfo,
return NULL;
}
- /* XXX we should only do this for first time, then store somewhere */
- /* XXX We also need to re-read the keytab when the preference changes */
-
- /* should this have a destroy context ? Heimdal people would know */
- if(first_time){
- first_time=FALSE;
- read_keytab_file(keytab_filename);
- }
+ read_keytab_file_from_preferences();
for(ek=enc_key_list;ek;ek=ek->next){
krb5_keytab_entry key;