+2001-06-21 Ken Raeburn <raeburn@mit.edu>
+
+ * adm_conn.c, kpasswd.c, srv_net.c: Changed various char string
+ variables into macros, for better format/argument checking under
+ gcc.
+
+ * main.c (pwd_change): Use strncpy instead of sprintf to copy
+ error message text into buffer. Use goto rather than repeated
+ code.
+ (main): Use %lx for params.mask. Make debug_level volatile.
+ Delete unused variables oldnames, rlen.
+
+ * srv_net.c (net_find_slave): Initialize "found".
+ (net_dispatch): Make "kret" volatile, so longjmp won't clobber
+ it.
+ (net_slaves_active): Variable deleted.
+
2001-06-21 Ezra Peisach <epeisach@mit.edu>
* main.c: Add prototype for daemon if needed.
/*
* Strings
*/
-static char *kadm_cache_name_fmt = "FILE:/tmp/tkt_kadm_%d";
+#define kadm_cache_name_fmt "FILE:/tmp/tkt_kadm_%d"
/*
* Prototypes for local functions
/*
* Local data.
*/
-static const char *kpwd_serror_head = "server";
-static const char *kpwd_change_prompt_1 = " Enter new password: ";
-static const char *kpwd_change_prompt_2 = "Re-enter new password: ";
-static const char *kpwd_old_password_prompt = " Enter old password: ";
-static const char *kpwd_old_pwd_name_fmt = "Enter old password for %s: ";
+#define kpwd_serror_head "server"
+#define kpwd_change_prompt_1 " Enter new password: "
+#define kpwd_change_prompt_2 "Re-enter new password: "
+#define kpwd_old_password_prompt " Enter old password: "
+#define kpwd_old_pwd_name_fmt "Enter old password for %s: "
#ifdef LANGUAGES_SUPPORTED
-static const char *kpwd_usage_error_fmt = "%s: usage is %s [-u user] [-l language]\n";
-static const char *kpwd_getoptstring = "l:u:";
+#define kpwd_usage_error_fmt "%s: usage is %s [-u user] [-l language]\n"
+#define kpwd_getoptstring "l:u:"
#else /* LANGUAGES_SUPPORTED */
-static const char *kpwd_usage_error_fmt = "%s: usage is %s [-u user]\n";
-static const char *kpwd_getoptstring = "u:";
+#define kpwd_usage_error_fmt "%s: usage is %s [-u user]\n"
+#define kpwd_getoptstring "u:"
#endif /* LANGUAGES_SUPPORTED */
-static const char *kpwd_extra_args = "extra arguments";
+#define kpwd_extra_args "extra arguments"
#if 0
-static const char *kpwd_bad_option_fmt = "%s: unrecognized option -%c.\n";
+#define kpwd_bad_option_fmt "%s: unrecognized option -%c.\n"
#endif
-static const char *kpwd_no_memory_fmt = "%s: not enough resources to allocate %d bytes for %s.\n";
-static const char *kpwd_bad_client_fmt = "%s: %s%s%s %s not recognized by the server.\n";
-static const char *kpwd_no_server_fmt = "%s: cannot find server for %s.\n";
-static const char *kpwd_incorrect_fmt = "%s: incorrect password\n";
-static const char *kpwd_cant_connect_fmt = "%s: cannot contact server (%s).\n";
-static const char *kpwd_proto_error_fmt = "%s: protocol error during %s request (%s).\n";
-static const char *kpwd_pwproto_unsupp_fmt = "%s: %s request not supported by server.\n";
-static const char *kpwd_pwproto_error = "%s: server error (%s) during %s request.\n";
-static const char *kpwd_pwd_unacceptable = "%s: your new password is unacceptable to the server, %s.\n";
-static const char *kpwd_read_pass_error = "%s: error (%s) reading passwords.\n";
+#define kpwd_no_memory_fmt "%s: not enough resources to allocate %d bytes for %s.\n"
+#define kpwd_bad_client_fmt "%s: %s%s%s %s not recognized by the server.\n"
+#define kpwd_no_server_fmt "%s: cannot find server for %s.\n"
+#define kpwd_incorrect_fmt "%s: incorrect password\n"
+#define kpwd_cant_connect_fmt "%s: cannot contact server (%s).\n"
+#define kpwd_proto_error_fmt "%s: protocol error during %s request (%s).\n"
+#define kpwd_pwproto_unsupp_fmt "%s: %s request not supported by server.\n"
+#define kpwd_pwproto_error "%s: server error (%s) during %s request.\n"
+#define kpwd_pwd_unacceptable "%s: your new password is unacceptable to the server, %s.\n"
+#define kpwd_read_pass_error "%s: error (%s) reading passwords.\n"
static const char *kpwd_password_text = "passwords";
#if 0
int main(int argc, char *argv[])
{
- int ret, nofork;
+ int ret;
+ volatile int nofork;
int timeout = -1;
krb5_error_code code;
- int debug_level = 0;
+ volatile int debug_level = 0;
#if POSIX_SIGNALS
struct sigaction s_action;
#endif /* POSIX_SIGNALS */
ret = krb5_timeofday(kcontext, &now);
if (ret) {
- sprintf(err_str, error_message(ret));
+ /* XXX - The only caller is known to use a 1K buffer. */
+ system_error:
+ strncpy(err_str, error_message(ret), 1024);
return(KRB5_ADM_SYSTEM_ERROR);
}
if((ret = kadm5_get_principal(global_server_handle, principal,
- &princ,
- KADM5_PRINCIPAL_NORMAL_MASK)) !=
- KADM5_OK) {
- sprintf(err_str, error_message(ret));
- return(KRB5_ADM_SYSTEM_ERROR);
+ &princ,
+ KADM5_PRINCIPAL_NORMAL_MASK)) !=
+ KADM5_OK) {
+ goto system_error;
}
if(princ.aux_attributes & KADM5_POLICY) {
if((ret=kadm5_get_policy(global_server_handle,
princ.policy, &pol)) != KADM5_OK) {
(void) kadm5_free_principal_ent(global_server_handle, &princ);
- sprintf(err_str, error_message(ret));
- return(KRB5_ADM_SYSTEM_ERROR);
+ goto system_error;
}
if((now - princ.last_pwd_change) < pol.pw_min_life &&
!(princ.attributes & KRB5_KDB_REQUIRES_PWCHANGE)) {
(void) kadm5_free_policy_ent(global_server_handle, &pol);
(void) kadm5_free_principal_ent(global_server_handle, &princ);
- sprintf(err_str, error_message(ret));
+ /* XXX - The only caller is known to use a 1K buffer. */
+ strncpy(err_str, error_message(ret), 1024);
return(KRB5_ADM_PW_UNACCEPT);
}
ret = kadm5_free_policy_ent(global_server_handle, &pol);
if (ret) {
(void) kadm5_free_principal_ent(global_server_handle, &princ);
- sprintf(err_str, error_message(ret));
- return(KRB5_ADM_SYSTEM_ERROR);
+ goto system_error;
}
}
ret = kadm5_free_principal_ent(global_server_handle, &princ);
if (ret) {
- sprintf(err_str, error_message(ret));
- return(KRB5_ADM_SYSTEM_ERROR);
+ goto system_error;
}
/* ok, it's not too early to change the password. change it. */
/*
* Error messages.
*/
-static const char *net_waiterr_msg = "\004child wait failed - cannot reap children";
+#define net_waiterr_msg "\004child wait failed - cannot reap children"
#if 0
-static const char *net_def_realm_fmt = "%s: cannot get default realm (%s).\n";
+#define net_def_realm_fmt "%s: cannot get default realm (%s).\n"
#endif
-static const char *net_no_mem_fmt = "%s: cannot get memory.\n";
-static const char *net_parse_srv_fmt = "%s: cannot parse server name %s (%s).\n";
-static const char *net_no_hostname_fmt = "%s: cannot get our host name (%s).\n";
-static const char *net_no_hostent_fmt = "%s: cannot get our host entry (%s).\n";
-static const char *net_no_servent_fmt = "%s: cannot get service entry for %s (%s).\n";
-static const char *net_sockerr_fmt = "%s: cannot open network socket (%s).\n";
-static const char *net_soerr_fmt = "%s: cannot set socket options (%s).\n";
-static const char *net_binderr_fmt = "%s: cannot bind to network address (%s).\n";
-
-static const char *net_select_fmt = "\004select failed";
-static const char *net_cl_disp_fmt = "\004client dispatch failed";
-static const char *net_not_ready_fmt = "\004select error - no socket to read";
-static const char *net_dispatch_msg = "network dispatch";
+#define net_no_mem_fmt "%s: cannot get memory.\n"
+#define net_parse_srv_fmt "%s: cannot parse server name %s (%s).\n"
+#define net_no_hostname_fmt "%s: cannot get our host name (%s).\n"
+#define net_no_hostent_fmt "%s: cannot get our host entry (%s).\n"
+#define net_no_servent_fmt "%s: cannot get service entry for %s (%s).\n"
+#define net_sockerr_fmt "%s: cannot open network socket (%s).\n"
+#define net_soerr_fmt "%s: cannot set socket options (%s).\n"
+#define net_binderr_fmt "%s: cannot bind to network address (%s).\n"
+
+#define net_select_fmt "\004select failed"
+#define net_cl_disp_fmt "\004client dispatch failed"
+#define net_not_ready_fmt "\004select error - no socket to read"
+#define net_dispatch_msg "network dispatch"
static int net_debug_level = 0;
net_find_slave(id)
net_slave_type id;
{
- int i, found;
+ int i, found = 0;
for (i=0; i<net_max_slaves; i++) {
if (net_slave_table[i].sl_inuse &&
krb5_context kcontext;
int detached;
{
- krb5_error_code kret;
+ volatile krb5_error_code kret;
fd_set mask, readfds;
int nready;
#if POSIX_SIGNALS