+Mon Feb 26 13:13:21 2001 Ezra Peisach <epeisach@mit.edu>
+
+ * 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 <epeisach@mit.edu>
* tty_kpasswd.c (read_old_password): Argument pwsize changed to
#include "kpasswd_strings.h"
#define string_text error_message
+#include "kpasswd.h"
+
#include <stdio.h>
#include <pwd.h>
#include <string.h>
extern char *whoami;
-extern void display_intro_message();
-extern long read_old_password();
-extern long read_new_password();
#define MISC_EXIT_STATUS 6
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;
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);
(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));
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));
--- /dev/null
+/*
+ * 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__ */
+
+
#include "kpasswd_strings.h"
#define string_text error_message
+#include "kpasswd.h"
#include <stdio.h>
#include <pwd.h>
#include <string.h>
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);
}
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;
}
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;
{
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);
}
*/
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];
read_old_password(context, password, pwsize)
krb5_context context;
char *password;
- int *pwsize;
+ unsigned int *pwsize;
{
long code;
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;
{