+2001-06-01 Ezra Peisach <epeisach@mit.edu>
+
+ * login.c: Add braces around initializers. Cleanup assignments in
+ conditionals. Include krb524.h if KRB4_CONVERT defined.
+
+ * krlogind.c (main): Cleanup unused variables.
+ (protocol): Cleanup ambiguous if-if-else warning.
+
+ * krshd.c (main): Cleanup unused variables.
+
+ * krlogin.c (setsignal): Declare as void.
+ (server_message): Cleanup unused variables.
+
+ * setenv.c (setenv): Declare as returning int and clean up
+ assignments in conditionals.
+
+ * kcmd.c (kcmd, rcmd_stream_init_krb5, v5_des_read): Clean up
+ unused variables and assignments in conditionals.
+ * forward.c (rd_and_store_for_creds): Likewise.
+ * krcp.c (rsource): Likewise.
+ * v4rcp.c (answer_auth): Likewise.
+
+ * krsh.c (main): Declare as retuning int.
+
2001-05-25 Tom Yu <tlyu@mit.edu>
* krlogind.c (protocol): Don't do TIOCPKT on systems with STREAMS
*ccache = NULL;
- if (retval = krb5_rd_cred(context, auth_context, inbuf, &creds, NULL))
+ retval = krb5_rd_cred(context, auth_context, inbuf, &creds, NULL);
+ if (retval)
return(retval);
/* Set the KRB5CCNAME ENV variable to keep sessions
sprintf(ccname, "FILE:/tmp/krb5cc_p%d", getpid());
setenv("KRB5CCNAME", ccname, 1);
- if (retval = krb5_cc_resolve(context, ccname, ccache))
+ retval = krb5_cc_resolve(context, ccname, ccache);
+ if (retval)
goto cleanup;
- if (retval = krb5_cc_initialize(context, *ccache, ticket->enc_part2->client))
+ retval = krb5_cc_initialize(context, *ccache, ticket->enc_part2->client);
+ if (retval)
goto cleanup;
- if (retval = krb5_cc_store_cred(context, *ccache, *creds))
+ retval = krb5_cc_store_cred(context, *ccache, *creds);
+ if (retval)
goto cleanup;
cleanup:
goto bad2;
}
- if (status = krb5_cc_default(bsd_context, &cc))
+ status = krb5_cc_default(bsd_context, &cc);
+ if (status)
goto bad2;
- if (status = krb5_cc_get_principal(bsd_context, cc, &get_cred->client)) {
+ status = krb5_cc_get_principal(bsd_context, cc, &get_cred->client);
+ if (status) {
(void) krb5_cc_close(bsd_context, cc);
goto bad2;
}
goto bad2;
/* Only need local address for mk_cred() to send to krlogind */
- if (status = krb5_auth_con_genaddrs(bsd_context, auth_context, s,
- KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR))
+ status = krb5_auth_con_genaddrs(bsd_context, auth_context, s,
+ KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR);
+ if (status)
goto bad2;
if (protonum == KCMD_PROTOCOL_COMPAT_HACK) {
(void) write(s, locuser, strlen(locuser)+1);
if (options & OPTS_FORWARD_CREDS) { /* Forward credentials */
- if (status = krb5_fwd_tgt_creds(bsd_context, auth_context,
- host_save,
- ret_cred->client, ret_cred->server,
- 0, options & OPTS_FORWARDABLE_CREDS,
- &outbuf)) {
+ status = krb5_fwd_tgt_creds(bsd_context, auth_context,
+ host_save,
+ ret_cred->client, ret_cred->server,
+ 0, options & OPTS_FORWARDABLE_CREDS,
+ &outbuf);
+ if (status) {
fprintf(stderr, "kcmd: Error getting forwarded creds\n");
goto bad2;
}
/* Send forwarded credentials */
- if (status = krb5_write_message(bsd_context, (krb5_pointer)&s, &outbuf))
+ status = krb5_write_message(bsd_context, (krb5_pointer)&s, &outbuf);
+ if (status)
goto bad2;
}
else { /* Dummy write to signal no forwarding */
outbuf.length = 0;
- if (status = krb5_write_message(bsd_context, (krb5_pointer)&s, &outbuf))
+ status = krb5_write_message(bsd_context, (krb5_pointer)&s, &outbuf);
+ if (status)
goto bad2;
}
{
krb5_error_code status;
size_t blocksize;
- krb5_boolean similar;
if (!encrypt_flag) {
rcmd_stream_init_normal();
use_ivecs = 1;
- if (status = krb5_c_block_size(bsd_context, keyblock->enctype,
- &blocksize)) {
+ status = krb5_c_block_size(bsd_context, keyblock->enctype,
+ &blocksize);
+ if (status) {
/* XXX what do I do? */
abort();
}
if ((cc = krb5_net_read(bsd_context, fd, &c, 1)) != 1) return 0;
rd_len = (rd_len << 8) | c;
- if (ret = krb5_c_encrypt_length(bsd_context, keyblock->enctype,
- use_ivecs ? rd_len + 4 : rd_len,
- &net_len)) {
+ ret = krb5_c_encrypt_length(bsd_context, keyblock->enctype,
+ use_ivecs ? rd_len + 4 : rd_len,
+ &net_len);
+ if (ret) {
errno = ret;
return(-1);
}
plain.data = storage;
/* decrypt info */
- if (ret = krb5_c_decrypt(bsd_context, keyblock, KCMD_KEYUSAGE,
- use_ivecs ? encivec_i + secondary : 0,
- &cipher, &plain)) {
+ ret = krb5_c_decrypt(bsd_context, keyblock, KCMD_KEYUSAGE,
+ use_ivecs ? encivec_i + secondary : 0,
+ &cipher, &plain);
+ if (ret) {
/* probably out of sync */
errno = EIO;
return(-1);
krb5_boolean similar;
krb5_keyblock *key = &cred->keyblock;
- if (status = krb5_c_enctype_compare(bsd_context,
- ENCTYPE_DES_CBC_CRC,
- cred->keyblock.enctype,
- &similar))
+ status = krb5_c_enctype_compare(bsd_context,
+ ENCTYPE_DES_CBC_CRC,
+ cred->keyblock.enctype,
+ &similar);
+ if (status)
try_normal(orig_argv); /* doesn't return */
if (!similar) {
closedir(d);
return;
}
- while (dp = readdir(d)) {
+ while ((dp = readdir(d)) != NULL) {
if (dp->d_ino == 0)
continue;
if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
void oob KRB5_PROTOTYPE((void));
krb5_sigtype lostpeer KRB5_PROTOTYPE((int));
#if __STDC__
-int setsignal(int sig, krb5_sigtype (*act)());
+void setsignal(int sig, krb5_sigtype (*act)());
#endif
static int read_wrapper(int fd, char *buf, int size, int *got_esc);
void try_normal(char **);
/*
* Trap a signal, unless it is being ignored.
*/
+void
setsignal(sig, act)
int sig;
krb5_sigtype (*act)();
#ifndef POSIX_TERMIOS
int out = FWRITE;
#endif
- int n;
- int rcvd = 0;
#ifdef POSIX_TERMIOS
struct termios tty;
#else
int oldmask;
#endif
{
-#if (defined(BSD) && BSD+0 >= 43) || defined(ultrix)
- int pid = getpid();
-#else
- int pid = -getpid();
-#endif
-fd_set readset, excset, writeset;
+ fd_set readset, excset, writeset;
int n, remaining, left;
char *bufp = rcvbuf;
char *cp;
{
register char *nhost;
#ifdef POSIX_SIGNALS
- struct sigaction sa;
sigset_t mask;
#endif
{
extern int opterr, optind;
extern char * optarg;
- int on = 1, fromlen, ch, i;
+ int on = 1, fromlen, ch;
struct sockaddr_in from;
- char *options;
int debug_port = 0;
int fd;
int do_fork = 0;
int f, p;
{
unsigned char pibuf[BUFSIZ], qpibuf[BUFSIZ*2], fibuf[BUFSIZ], *pbp, *fbp;
- register pcc = 0, fcc = 0;
+ register int pcc = 0, fcc = 0;
int cc;
- char cntl;
#ifdef POSIX_SIGNALS
struct sigaction sa;
#endif
#ifdef TIOCPKT
- register tiocpkt_on = 0;
+ register int tiocpkt_on = 0;
int on = 1;
#endif
FD_SET(p, &obits);
else
FD_SET(f, &ibits);
- if (pcc >= 0)
- if (pcc)
+ if (pcc >= 0) {
+ if (pcc) {
FD_SET(f, &obits);
- else
+ } else {
FD_SET(p, &ibits);
-
+ }
+ }
+
if (select(8*sizeof(ibits), &ibits, &obits, &ebits, 0) < 0) {
if (errno == EINTR)
continue;
char *host_addr, *hostname;
{
krb5_error_code status;
- struct passwd *pwd;
char *msg_fail = NULL;
int valid_checksum;
#define mask(s) (1 << ((s) - 1))
#endif /* POSIX_SIGNALS */
+int
main(argc, argv0)
int argc;
char **argv0;
krb5_keytab keytab = NULL;
krb5_ccache ccache = NULL;
int default_realm(krb5_principal principal);
+#if defined(KERBEROS) && defined(LOG_OTHER_USERS) && !defined(LOG_ALL_LOGINS)
static int princ_maps_to_lname(krb5_principal principal, char *luser);
+#endif
void fatal(int, const char *);
struct sockaddr_in from;
extern int opterr, optind;
extern char *optarg;
- char *options;
int ch;
+#if 0
int i;
+#endif
int fd;
int debug_port = 0;
#ifdef KERBEROS
+#if defined(KERBEROS) && defined(LOG_OTHER_USERS) && !defined(LOG_ALL_LOGINS)
static int princ_maps_to_lname(principal, luser)
krb5_principal principal;
char *luser;
}
return 0;
}
+#endif
int default_realm(principal)
krb5_auth_context auth_context = NULL;
krb5_error_code status;
struct sockaddr_in laddr;
- char krb_vers[KRB_SENDAUTH_VLEN + 1];
int len;
krb5_data inbuf;
#ifdef KRB5_KRB4_COMPAT
strcpy(v4_instance, "*");
#endif
- if (status = krb5_auth_con_init(bsd_context, &auth_context))
+ status = krb5_auth_con_init(bsd_context, &auth_context);
+ if (status)
return status;
- if (status = krb5_auth_con_genaddrs(bsd_context, auth_context, netfd,
- KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR))
+ status = krb5_auth_con_genaddrs(bsd_context, auth_context, netfd,
+ KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR);
+ if (status)
return status;
status = krb5_auth_con_getrcache(bsd_context, auth_context, &rcache);
#include <arpa/resolv.h>
#endif /* BIND_HACK */
+#ifdef KRB4_CONVERT
+#include <krb524.h>
+#endif
+
/* Hacks to maintain compatability with Athena libkrb*/
#ifndef HAVE_KRB_SAVE_CREDENTIALS
#define krb_save_credentials save_credentials
char *getenv();
void dofork();
+
+
+
+void term_init();
int doremotelogin(), do_krb_login(), rootterm();
void lgetstr(), getloginname(), checknologin(), sleepexit();
void dolastlog(), motd(), check_mail();
int *flag;
} login_conf_set[] = {
#ifdef KRB5_GET_TICKETS
- "krb5_get_tickets", &login_krb5_get_tickets,
+ {"krb5_get_tickets", &login_krb5_get_tickets},
#endif
#ifdef KRB5_KRB4_COMPAT
- "krb4_get_tickets", &login_krb4_get_tickets,
- "krb4_convert", &login_krb4_convert,
- "krb4_run_aklog", &login_krb_run_aklog,
+ {"krb4_get_tickets", &login_krb4_get_tickets},
+ {"krb4_convert", &login_krb4_convert},
+ {"krb4_run_aklog", &login_krb_run_aklog},
#endif /* KRB5_KRB4_COMPAT */
};
krb5_error_code code;
krb5_principal me;
- if (code = krb5_parse_name(kcontext, username, &me)) {
+ code = krb5_parse_name(kcontext, username, &me);
+ if (code) {
com_err ("login", code, "when parsing name %s",username);
return 0;
}
*me_p = me;
- if (code = krb5_get_init_creds_password(kcontext, &my_creds, me, pass,
- krb5_prompter_posix, NULL,
- 0, NULL, NULL)) {
+ code = krb5_get_init_creds_password(kcontext, &my_creds, me, pass,
+ krb5_prompter_posix, NULL,
+ 0, NULL, NULL);
+ if (code) {
if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY)
fprintf (stderr,
"%s: Kerberos password incorrect\n",
#endif /* KRB5_GET_TICKETS */
#ifdef KRB4_CONVERT
+int
try_convert524(kcontext, me, use_ccache)
krb5_context kcontext;
krb5_principal me;
#endif
#ifdef KRB4_GET_TICKETS
+int
try_krb4 (me, user_pwstring)
krb5_principal me;
char *user_pwstring;
AUTH_DAT authdata;
unsigned long addr;
static /*const*/ char rcmd[] = "rcmd";
+#if 0
char key[8];
+#endif
int krbval, retval, have_keys;
if (gethostname(hostname, sizeof(hostname)) == -1) {
{
#ifdef KRB5_GET_TICKETS
krb5_ccache cache;
- krb5_error_code retval;
if (login_krb5_get_tickets) {
if(!krb5_cc_default(kcontext, &cache))
break;
if (got_v5_tickets) {
- if (retval = krb5_verify_init_creds(kcontext, &my_creds, NULL,
- NULL, &xtra_creds,
- NULL)) {
+ retval = krb5_verify_init_creds(kcontext, &my_creds, NULL,
+ NULL, &xtra_creds,
+ NULL);
+ if (retval) {
com_err("login", retval, "while verifying initial ticket");
#ifndef SYSLOG42
syslog(LOG_NOTICE|LOG_AUTH,
} else {
mcreds.ticket_flags = 0;
- if (retval = krb5_cc_retrieve_cred(kcontext, ccache, 0,
- &mcreds, &save_v5creds)) {
+ retval = krb5_cc_retrieve_cred(kcontext, ccache, 0,
+ &mcreds, &save_v5creds);
+ if (retval) {
syslog(LOG_ERR,
"%s while retrieiving V5 initial ticket for copy",
error_message(retval));
/* set up credential cache -- obeying KRB5_ENV_CCNAME
set earlier */
/* (KRB5_ENV_CCNAME == "KRB5CCNAME" via osconf.h) */
- if (retval = krb5_cc_default(kcontext, &ccache)) {
+ if ((retval = krb5_cc_default(kcontext, &ccache))) {
com_err(argv[0], retval, "while getting default ccache");
- } else if (retval = krb5_cc_initialize(kcontext, ccache, me)) {
+ } else if ((retval = krb5_cc_initialize(kcontext, ccache, me))) {
com_err(argv[0], retval, "when initializing cache");
- } else if (retval = krb5_cc_store_cred(kcontext, ccache, &my_creds)) {
+ } else if ((retval = krb5_cc_store_cred(kcontext, ccache,
+ &my_creds))) {
com_err(argv[0], retval, "while storing credentials");
} else if (xtra_creds &&
(retval = krb5_cc_copy_creds(kcontext, xtra_creds,
syslog(LOG_ERR,
"%s while re-initializing V5 ccache as user",
error_message(retval));
- } else if (retval = krb5_cc_store_cred(kcontext, ccache,
- &save_v5creds)) {
+ } else if ((retval = krb5_cc_store_cred(kcontext, ccache,
+ &save_v5creds))) {
syslog(LOG_ERR,
"%s while re-storing V5 credentials as user",
error_message(retval));
};
#endif
+void
term_init (do_rlogin)
{
int line_speed = -1;
if (p < nbuf + UT_NAMESIZE)
*p++ = ch;
}
- if (p > nbuf)
+ if (p > nbuf) {
if (nbuf[0] == '-')
fprintf(stderr,
"login names may not start with '-'.\n");
username = nbuf;
break;
}
+ }
}
}
* Set the value of the environmental variable "name" to be
* "value". If rewrite is set, replace any current value.
*/
+int
setenv(name, value, rewrite)
register char *name, *value;
int rewrite;
if (!rewrite)
return(0);
if (strlen(C) >= l_value) { /* old larger; copy over */
- while (*C++ = *value++);
+ while ((*C++ = *value++));
return(0);
}
}
malloc((u_int)((int)(C - name) + l_value + 2))))
return(-1);
for (C = environ[offset]; (*C = *name++) &&( *C != '='); ++C);
- for (*C++ = '='; *C++ = *value++;);
+ for (*C++ = '='; (*C++ = *value++););
return(0);
}
local.sin_addr.s_addr = inet_addr(envaddr);
#endif
local.sin_family = AF_INET;
- if (envaddr = getenv("KRB5LOCALPORT"))
+ envaddr = getenv("KRB5LOCALPORT");
+ if (envaddr)
local.sin_port = htons(atoi(envaddr));
else
local.sin_port = 0;
foreign.sin_addr.s_addr = inet_addr(envaddr);
#endif
foreign.sin_family = AF_INET;
- if (envaddr = getenv("KRB5REMOTEPORT"))
+ envaddr = getenv("KRB5REMOTEPORT");
+ if (envaddr)
foreign.sin_port = htons(atoi(envaddr));
else
foreign.sin_port = 0;