From f1084090738a70aa8804c817c694566d30d291ce Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Mon, 26 Feb 2001 18:22:08 +0000 Subject: [PATCH] * kpasswd.c, tty_kpasswd.c, xm_kpasswd.c: Compiler warning clenups. Use const when apropriate, remove assignments in conditionals, remove unnecessary casts. * kpasswd.h: New file with prototypes of functions used in different files. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13024 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/passwd/ChangeLog | 9 +++++++ src/kadmin/passwd/kpasswd.c | 19 ++++++++------ src/kadmin/passwd/kpasswd.h | 46 +++++++++++++++++++++++++++++++++ src/kadmin/passwd/tty_kpasswd.c | 12 +++++---- src/kadmin/passwd/xm_kpasswd.c | 8 +++--- 5 files changed, 77 insertions(+), 17 deletions(-) create mode 100644 src/kadmin/passwd/kpasswd.h diff --git a/src/kadmin/passwd/ChangeLog b/src/kadmin/passwd/ChangeLog index a638a0a32..da6d425cf 100644 --- a/src/kadmin/passwd/ChangeLog +++ b/src/kadmin/passwd/ChangeLog @@ -1,3 +1,12 @@ +Mon Feb 26 13:13:21 2001 Ezra Peisach + + * kpasswd.c, tty_kpasswd.c, xm_kpasswd.c: Compiler warning + clenups. Use const when apropriate, remove assignments in + conditionals, remove unnecessary casts. + + * kpasswd.h: New file with prototypes of functions used in + different files. + 2000-10-17 Ezra Peisach * tty_kpasswd.c (read_old_password): Argument pwsize changed to diff --git a/src/kadmin/passwd/kpasswd.c b/src/kadmin/passwd/kpasswd.c index b56292e89..912990d2d 100644 --- a/src/kadmin/passwd/kpasswd.c +++ b/src/kadmin/passwd/kpasswd.c @@ -14,15 +14,14 @@ static char rcsid[] = "$Id$"; #include "kpasswd_strings.h" #define string_text error_message +#include "kpasswd.h" + #include #include #include extern char *whoami; -extern void display_intro_message(); -extern long read_old_password(); -extern long read_new_password(); #define MISC_EXIT_STATUS 6 @@ -82,7 +81,7 @@ kpasswd(context, argc, argv) krb5_principal princ = 0; char *princ_str; struct passwd *pw = 0; - int pwsize; + unsigned int pwsize; char password[255]; /* I don't really like 255 but that's what kinit uses */ char msg_ret[1024], admin_realm[1024]; ovsec_kadm_principal_ent_t principal_entry = NULL; @@ -227,7 +226,9 @@ kpasswd(context, argc, argv) com_err(whoami, 0, string_text(KPW_STR_POLICY_EXPLANATION), princ_str, principal_entry->policy, policy_entry->pw_min_length, policy_entry->pw_min_classes); - if (code = ovsec_kadm_free_principal_ent(server_handle, principal_entry)) { + + code = ovsec_kadm_free_principal_ent(server_handle, principal_entry); + if (code) { (void) ovsec_kadm_free_policy_ent(server_handle, policy_entry); krb5_free_principal(context, princ); free(princ_str); @@ -235,7 +236,9 @@ kpasswd(context, argc, argv) (void) ovsec_kadm_destroy(server_handle); return(MISC_EXIT_STATUS); } - if (code = ovsec_kadm_free_policy_ent(server_handle, policy_entry)) { + + code = ovsec_kadm_free_policy_ent(server_handle, policy_entry); + if (code) { krb5_free_principal(context, princ); free(princ_str); com_err(whoami, code, string_text(KPW_STR_WHILE_FREEING_POLICY)); @@ -246,8 +249,8 @@ kpasswd(context, argc, argv) else { /* kpasswd *COULD* output something here to encourage the choice of good passwords, in the absence of an enforced policy. */ - if (code = ovsec_kadm_free_principal_ent(server_handle, - principal_entry)) { + code = ovsec_kadm_free_principal_ent(server_handle, principal_entry); + if (code) { krb5_free_principal(context, princ); free(princ_str); com_err(whoami, code, string_text(KPW_STR_WHILE_FREEING_PRINCIPAL)); diff --git a/src/kadmin/passwd/kpasswd.h b/src/kadmin/passwd/kpasswd.h new file mode 100644 index 000000000..577ab386f --- /dev/null +++ b/src/kadmin/passwd/kpasswd.h @@ -0,0 +1,46 @@ +/* + * kadmin/passwd/kpasswd.h + * + * Copyright 2001 by the Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + * + * + * Prototypes for the kpasswd program callback functions. + */ + +#ifndef __KPASSWD_H__ +#define __KPASSWD_H__ + +int kpasswd(krb5_context context, int argc, char *argv[]); + +long read_old_password(krb5_context context, char *password, + unsigned int *pwsize); + +long read_new_password(void *server_handle, char *password, + unsigned int *pwsize, char *msg_ret, + krb5_principal princ); + +void display_intro_message(const char *fmt_string, const char *arg_string); + +#endif /* __KPASSWD_H__ */ + + diff --git a/src/kadmin/passwd/tty_kpasswd.c b/src/kadmin/passwd/tty_kpasswd.c index 3c61ecd4a..189409140 100644 --- a/src/kadmin/passwd/tty_kpasswd.c +++ b/src/kadmin/passwd/tty_kpasswd.c @@ -14,6 +14,7 @@ static char rcsid[] = "$Id$"; #include "kpasswd_strings.h" #define string_text error_message +#include "kpasswd.h" #include #include #include @@ -21,8 +22,8 @@ static char rcsid[] = "$Id$"; char *whoami; void display_intro_message(fmt_string, arg_string) - char *fmt_string; - char *arg_string; + const char *fmt_string; + const char *arg_string; { com_err(whoami, 0, fmt_string, arg_string); } @@ -33,7 +34,7 @@ long read_old_password(context, password, pwsize) unsigned int *pwsize; { long code = krb5_read_password(context, - (char *)string_text(KPW_STR_OLD_PASSWORD_PROMPT), + string_text(KPW_STR_OLD_PASSWORD_PROMPT), 0, password, pwsize); return code; } @@ -41,7 +42,7 @@ long read_old_password(context, password, pwsize) long read_new_password(server_handle, password, pwsize, msg_ret, princ) void *server_handle; char *password; - int *pwsize; + unsigned int *pwsize; char *msg_ret; krb5_principal princ; { @@ -64,7 +65,8 @@ main(argc, argv) whoami = (whoami = strrchr(argv[0], '/')) ? whoami + 1 : argv[0]; - if (retval = krb5_init_context(&context)) { + retval = krb5_init_context(&context); + if (retval) { com_err(whoami, retval, "initializing krb5 context"); exit(retval); } diff --git a/src/kadmin/passwd/xm_kpasswd.c b/src/kadmin/passwd/xm_kpasswd.c index 4232e3baf..66976208a 100644 --- a/src/kadmin/passwd/xm_kpasswd.c +++ b/src/kadmin/passwd/xm_kpasswd.c @@ -322,8 +322,8 @@ read_password(password, pwsize) */ void display_intro_message(fmt_string, arg_string) - char *fmt_string; - char *arg_string; + const char *fmt_string; + const char *arg_string; { XmString xmstr; char buf[1024]; @@ -341,7 +341,7 @@ long read_old_password(context, password, pwsize) krb5_context context; char *password; - int *pwsize; + unsigned int *pwsize; { long code; @@ -355,7 +355,7 @@ long read_new_password(server_handle, password, pwsize, msg_ret, princ) void *server_handle; char *password; - int *pwsize; + unsigned int *pwsize; char *msg_ret; krb5_principal princ; { -- 2.26.2