From: Ken Raeburn Date: Thu, 16 Nov 2006 00:51:21 +0000 (+0000) Subject: fix some warnings in ldap code X-Git-Tag: krb5-1.7-alpha1~1450 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5a6c2f7a1999a19ee828e0355f4f2dcac9edbfd0;p=krb5.git fix some warnings in ldap code * libkdb_ldap/ldap_realm.c (ignore_duplicates, compare): Unused functions deleted. (krb5_ldap_modify_realm, krb5_ldap_read_realm_params): Conditionalize declarations of automatic variables that are only used for eDirectory. * libkdb_ldap/ldap_service_stash.c (tohex): Use one sprintf call instead of two. (dec_password): Use an unsigned type to fetch values with %x. * libkdb_ldap/ldap_realm.h (ldap_filter_correct): Declare. * libkdb_dlap/ldap_misc.c (my_strndup): Only define if HAVE_LDAP_STR2DN. (populate_krb5_db_entry): Remove unused automatic variable. * ldap_util/kdb5_ldap_util.c (cmd_table): Fix typo in preprocessing conditional. * ldap_util/kdb5_ldap_realm.c (get_ticket_policy): Declarations first, then code. * ldap_util/kdb5_ldap_services.c (kdb5_ldap_stash_service_password): On error, increment exit_status; don't return a value. * ldap_util/kdb5_ldap_services.h (kdb5_ldap_stash_service_password): Update decl. ticket: new target_version: 1.6 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@18813 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_realm.c b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_realm.c index a13bdfacb..d311fdb66 100644 --- a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_realm.c +++ b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_realm.c @@ -144,13 +144,14 @@ static int get_ticket_policy(rparams,i,argv,argc) { time_t date; time_t now; - time(&now); int mask = 0; krb5_error_code retval = 0; krb5_boolean no_msg = FALSE; krb5_boolean print_usage = FALSE; char *me = argv[0]; + + time(&now); if (!strcmp(argv[*i], "-maxtktlife")) { if (++(*i) > argc-1) goto err_usage; diff --git a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_services.c b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_services.c index bd64566f4..80793b7ac 100644 --- a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_services.c +++ b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_services.c @@ -1895,7 +1895,7 @@ cleanup: * Convert the user supplied password into hexadecimal and stash it. Only a * little more secure than storing plain password in the file ... */ -int +void kdb5_ldap_stash_service_password(argc, argv) int argc; char **argv; @@ -2154,7 +2154,8 @@ cleanup: usage(); /* db_usage(STASH_SRV_PW); */ - return ret; + if (ret) + exit_status++; } #endif /* #ifdef HAVE_EDIRECTORY */ diff --git a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_services.h b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_services.h index 86f7457b6..ac4ca8432 100644 --- a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_services.h +++ b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_services.h @@ -67,5 +67,5 @@ extern int kdb5_ldap_set_service_password(int argc, char **argv); extern void kdb5_ldap_set_service_certificate(int argc, char **argv); extern void print_service_params(krb5_ldap_service_params *lserparams, int mask); extern krb5_error_code convert_realm_name2dn_list(char **list, const char *krbcontainer_loc); -extern int kdb5_ldap_stash_service_password(int argc, char **argv); +extern void kdb5_ldap_stash_service_password(int argc, char **argv); diff --git a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c index 38ac03798..9fcc7b79d 100644 --- a/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c +++ b/src/plugins/kdb/ldap/ldap_util/kdb5_ldap_util.c @@ -220,7 +220,8 @@ static struct _cmd_table { {"destroy_service", kdb5_ldap_destroy_service, 1}, {"list_service",kdb5_ldap_list_services,1}, {"setsrvpw", kdb5_ldap_set_service_password, 0}, -#else {"stashsrvpw", kdb5_ldap_stash_service_password, 0}, +#else + {"stashsrvpw", kdb5_ldap_stash_service_password, 0}, #endif {"create_policy", kdb5_ldap_create_policy, 1}, {"modify_policy", kdb5_ldap_modify_policy, 1}, diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c index f76a6e895..19730defa 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c @@ -49,6 +49,7 @@ extern char *strptime (const char *, const char *, struct tm *); But all the world's not Linux. */ #undef strndup #define strndup my_strndup +#ifdef HAVE_LDAP_STR2DN static char *my_strndup (const char *input, size_t limit) { size_t len = strlen(input); @@ -63,6 +64,7 @@ static char *my_strndup (const char *input, size_t limit) } else return strdup(input); } +#endif /* Get integer or string values from the config section, falling back to the default section, then to hard-coded values. */ @@ -1898,11 +1900,11 @@ remove_overlapping_subtrees(char **listin, char **listop, int *subtcount, int ss */ krb5_error_code populate_krb5_db_entry (krb5_context context, - krb5_ldap_context *ldap_context, - LDAP *ld, - LDAPMessage *ent, - krb5_const_principal princ, - krb5_db_entry *entry) + krb5_ldap_context *ldap_context, + LDAP *ld, + LDAPMessage *ent, + krb5_const_principal princ, + krb5_db_entry *entry) { krb5_error_code st = 0; unsigned int mask = 0; @@ -1912,7 +1914,6 @@ populate_krb5_db_entry (krb5_context context, struct berval **bvalues = NULL; krb5_tl_data userinfo_tl_data = {0}; char **link_references = NULL; - krb5_ui_2 entry_len; char *DN = NULL; if (princ == NULL) { diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.c index b5e198ff7..760b7df29 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.c @@ -66,28 +66,6 @@ char *subtreeclass[] = { "Organization", "OrganizationalUnit", "Domain", "kr char *krbContainerRefclass[] = { "krbContainerRefAux", NULL}; - -static void -ignore_duplicates(int_list) - int *int_list; -{ - int i=0, j=0, scount=0; - - for (i=0; int_list[i] != END_OF_LIST; scount=i++) - ; - - for (i=0; i <= scount; ++i) { - if (i > 0 && int_list[i] == int_list[i-1]) { - for (j=i; j<=scount; ++j) - int_list[j-1] = int_list[j]; - int_list[scount] = END_OF_LIST; - --scount; - --i; - continue; - } - } -} - /* * list realms from eDirectory */ @@ -398,16 +376,6 @@ cleanup: return st; } -static int compare (const void *i, const void *j) { - if (*(const krb5_int32 *)i > *(const krb5_int32 *)j) - return 1; - - if (*(const krb5_int32 *)i < *(const krb5_int32 *)j) - return -1; - - return 0; -} - /* * Modify the realm attributes in the Directory. @@ -430,7 +398,10 @@ krb5_ldap_modify_realm(context, rparams, mask) char errbuf[1024]; #endif LDAPMod **mods = NULL; - int i=0, oldmask=0, objectmask=0,k=0; +#ifdef HAVE_EDIRECTORY + int i=0; +#endif + int oldmask=0, objectmask=0,k=0; kdb5_dal_handle *dal_handle=NULL; krb5_ldap_context *ldap_context=NULL; krb5_ldap_server_handle *ldap_server_handle=NULL; @@ -1216,7 +1187,9 @@ krb5_ldap_read_realm_params(context, lrealm, rlparamp, mask) int *mask; { char **values=NULL, *krbcontDN=NULL /*, *curr=NULL */; - unsigned int i=0, /* masklen=4, */ count=0; +#ifdef HAVE_EDIRECTORY + unsigned int count=0; +#endif krb5_error_code st=0, tempst=0; LDAP *ld=NULL; LDAPMessage *result=NULL,*ent=NULL; diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.h b/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.h index 05c2b1432..faff3ffbb 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.h +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.h @@ -93,4 +93,7 @@ krb5_ldap_free_realm_params(krb5_ldap_realm_params *); krb5_error_code krb5_ldap_delete_realm_1(krb5_context, char *, char **); +char * +ldap_filter_correct(unsigned char *, unsigned int); + #endif diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_service_stash.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_service_stash.c index 0deacd9a4..4991e98be 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_service_stash.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_service_stash.c @@ -183,12 +183,12 @@ tohex(in, ret) krb5_data in; krb5_data *ret; { - int i=0, j=0, err = 0; + int i=0, err = 0; ret->length = 0; ret->data = NULL; - ret->data = (unsigned char *)malloc((unsigned int)in.length * 2 + 1 /*Null termination */); + ret->data = malloc((unsigned int)in.length * 2 + 1 /*Null termination */); if (ret->data == NULL) { err = ENOMEM; goto cleanup; @@ -196,10 +196,8 @@ tohex(in, ret) ret->length = in.length * 2; ret->data[ret->length] = 0; - for (i = 0, j = 0; i < in.length; i++, j += 2) { - sprintf((char *)ret->data + j, "%x", in.data[i] >> 4); - sprintf((char *)ret->data + j + 1, "%x", in.data[i] & 0xf); - } + for (i = 0; i < in.length; i++) + sprintf(ret->data + 2 * i, "%02x", in.data[i] & 0xff); cleanup: @@ -255,7 +253,7 @@ int dec_password(struct data pwd, struct data *ret) { ret->len = (pwd.len - strlen("{HEX}")) / 2; ret->value[ret->len] = '\0'; for (i = strlen("{HEX}"), j = 0; i < pwd.len; i += 2, j++) { - int k; + unsigned int k; /* Check if it is a hexadecimal number */ if (isxdigit(pwd.value[i]) == 0 || isxdigit(pwd.value[i + 1]) == 0) { err = ERR_PWD_NOT_HEX;