+2001-07-05 Ezra Peisach <epeisach@mit.edu>
+
+ * Makefile.in: Link krshd with KRSHDLIBS instead of LOGINLIBS.
+
+ * configure.in: Creare a new variable KRSHDLIBS which differs from
+ LOGINLIBS by not including libkrb524.a. Test for getenv.
+
+ * krcp.c: Prototype lostconn().
+
+ * krlogind.c: Provide prototype for signal handler cleanup. Implied
+ need to add extra argument to function - ensure consistant
+ calling.
+
+ * krsh.c: Provide prototype for signal handler sendsig.
+
+ * krshd.c: Rewrite error() to use stdargs/varargs.
+ (doit): When creating a tty name using getpid. Ensure that does
+ not overflow tty string buffer.
+
+ * login.c: Provide prototype for signal handler timedout.
+
+ * setenv.c: Do not define getenv() unless needed.
+
+ * v4rcp.c: Rewrite error() to use stdargs/varargs. Add signal
+ number argument to lostconn(), include prototype, and ensure
+ called consistantly.
+
2001-07-03 Ezra Peisach <epeisach@mit.edu>
* v4rcp.c, login.c: Fill in prototypes, declare many functions static.
SETENVSRC=@SETENVSRC@
SETENVOBJ=@SETENVOBJ@
-LOGINLIBS =@LOGINLIBS@
+LOGINLIBS=@LOGINLIBS@
LIBOBJS=@LIBOBJS@
V4RCP=@V4RCP@
V4RCPO=@V4RCPO@
+KRSHDLIBS=@KRSHDLIBS@
SRCS= krcp.c krlogin.c krsh.c kcmd.c forward.c $(SETENVSRC) \
login.c krshd.c krlogind.c v4rcp.c
fi
kshd: krshd.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(PTY_DEPLIB) $(UTIL_DEPLIB) $(KRB4COMPAT_DEPLIBS)
- $(CC_LINK) -o kshd krshd.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(LOGINLIBS) $(PTY_LIB) $(UTIL_LIB) $(KRB4COMPAT_LIBS)
+ $(CC_LINK) -o kshd krshd.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(KRSHDLIBS) $(PTY_LIB) $(UTIL_LIB) $(KRB4COMPAT_LIBS)
klogind: krlogind.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(PTY_DEPLIB) $(UTIL_DEPLIB) $(KRB4COMPAT_DEPLIBS)
$(CC_LINK) -o klogind krlogind.o kcmd.o forward.o $(SETENVOBJ) $(LIBOBJS) $(PTY_LIB) $(UTIL_LIB) $(KRB4COMPAT_LIBS)
ac_cv_header_termios_h=no
;;
esac
+dnl
+dnl krshd does not use krb524...
+dnl
+KRSHDLIBS="$LOGINLIBS"
dnl
dnl After beta6 this functionality will be integrated with aclocal.m4
AC_ARG_WITH([krb4],
fi
dnl
dnl
+AC_SUBST(KRSHDLIBS)
AC_SUBST(LOGINLIBS)
AC_SUBST(V4RCP)
AC_SUBST(V4RCPO)
dnl
AC_FUNC_VFORK
AC_TYPE_MODE_T
-AC_CHECK_FUNCS(isatty inet_aton gettosbyname killpg initgroups setpriority setreuid setresuid waitpid setsid ptsname setlogin tcgetpgrp tcsetpgrp setpgid strsave utimes rmufile)
+AC_CHECK_FUNCS(isatty inet_aton getenv gettosbyname killpg initgroups setpriority setreuid setresuid waitpid setsid ptsname setlogin tcgetpgrp tcsetpgrp setpgid strsave utimes rmufile)
AC_CHECK_HEADERS(unistd.h stdlib.h string.h sys/filio.h sys/sockio.h sys/label.h sys/tty.h ttyent.h lastlog.h sys/select.h sys/ptyvar.h utmp.h sys/time.h krb4-proto.h sys/ioctl_compat.h paths.h arpa/nameser.h)
AC_HEADER_STDARG
AC_REPLACE_FUNCS(getdtablesize)
int rem;
char *colon(char *);
int errs;
-krb5_sigtype lostconn();
+krb5_sigtype lostconn(int);
int iamremote, targetshouldbedirectory;
int iamrecursive;
int pflag;
{
char resp, c, rbuf[RCP_BUFSIZ], *cp = rbuf;
if (rcmd_stream_read(rem, &resp, 1, 0) != 1)
- lostconn();
+ lostconn(0);
switch (resp) {
case 0: /* ok */
case 2: /* fatal error, "" */
do {
if (rcmd_stream_read(rem, &c, 1, 0) != 1)
- lostconn();
+ lostconn(0);
*cp++ = c;
} while (cp < &rbuf[RCP_BUFSIZ] && c != '\n');
if (iamremote == 0)
krb5_sigtype
- lostconn()
+ lostconn(signumber)
+ int signumber;
{
if (iamremote == 0)
fprintf(stderr, "rcp: lost connection\n");
void fatal(int, const char *), fatalperror(int, const char *), doit(int, struct sockaddr_in *), usage(void), do_krb_login(char *, char *), getstr(int, char *, int, char *);
void protocol(int, int);
int princ_maps_to_lname(krb5_principal, char *), default_realm(krb5_principal);
-krb5_sigtype cleanup();
+krb5_sigtype cleanup(int);
krb5_error_code recvauth(int *);
/* There are two authentication related masks:
#endif
protocol(f, p);
signal(SIGCHLD, SIG_IGN);
- cleanup();
+ cleanup(0);
}
unsigned char magic[2] = { 0377, 0377 };
-krb5_sigtype cleanup()
+krb5_sigtype cleanup(signumber)
+ int signumber;
{
pty_cleanup (line, pid, 1);
shutdown(netf, 2);
#else
(void) ioctl(f, TCFLSH, out);
#endif
- cleanup();
+ cleanup(0);
}
exit(1);
}
int options;
int rfd2;
int nflag;
-krb5_sigtype sendsig();
+krb5_sigtype sendsig(int);
#ifdef KERBEROS
#include <sys/audit.h>
#include <pwdadj.h>
#endif
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
#include <signal.h>
#if !defined(KERBEROS) || !defined(KRB5_KRB4_COMPAT)
extern
#endif /* CRAY */
-/*VARARGS1*/
-void error();
+void error (char *fmt, ...)
+#if !defined (__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
+ __attribute__ ((__format__ (__printf__, 1, 2)))
+#endif
+ ;
void usage(void), getstr(int, char *, int, char *),
doit(int, struct sockaddr_in *);
#define KRB5_RECVAUTH_V4 4
#define KRB5_RECVAUTH_V5 5
-krb5_sigtype
+static krb5_sigtype
cleanup(signumber)
int signumber;
{
privileges. */
if (port) {
/* Place entry into wtmp */
- sprintf(ttyn,"krsh%1d",getpid());
+ sprintf(ttyn,"krsh%ld",(long) (getpid() % 9999999));
pty_logwtmp(ttyn,locuser,sane_host);
}
/* We are simply execing a program over rshd : log entry into wtmp,
+void
+#ifdef HAVE_STDARG_H
+error(char *fmt, ...)
+#else
/*VARARGS1*/
-void error(fmt, a1, a2, a3)
+error(fmt, va_alist)
char *fmt;
- char *a1, *a2, *a3;
+ va_dcl
+#endif
{
- char buf[RCMD_BUFSIZ];
+ va_list ap;
+ char buf[RCMD_BUFSIZ], *cp = buf;
- buf[0] = 1;
- (void) sprintf(buf+1, "%s: ", progname);
- (void) sprintf(buf+strlen(buf), fmt, a1, a2, a3);
+#ifdef HAVE_STDARG_H
+ va_start(ap, fmt);
+#else
+ va_start(ap);
+#endif
+
+ *cp++ = 1;
+ (void) sprintf(cp, "%s: ", progname);
+ (void) vsprintf(buf+strlen(buf), fmt, ap);
+ va_end(ap);
(void) write(2, buf, strlen(buf));
syslog(LOG_ERR ,"%s",buf+1);
}
typedef krb5_sigtype sigtype;
+sigtype timedout(int);
+
#ifndef HAVE_INITGROUPS
static int initgroups(char* name, gid_t basegid) {
int fflag, hflag, pflag, rflag, cnt;
int kflag, Kflag, eflag;
int quietlog, passwd_req, ioctlval;
- sigtype timedout();
char *domain, **envinit, *ttyn, *tty;
char tbuf[MAXPATHLEN + 2];
char *ttyname(), *crypt(), *getpass();
}
sigtype
-timedout()
+timedout(signumber)
+ int signumber;
{
fprintf(stderr, "Login timed out after %d seconds\n", timeout);
exit(0);
#include <sys/types.h>
#include <stdio.h>
+#ifdef NEED_SETENV
+extern int setenv(char *, char *, int);
+extern void unsetenv(char *);
+#endif
+
+static char *_findenv(char *, int*);
/*
* setenv --
* Set the value of the environmental variable "name" to be
static int alloced; /* if allocated space before */
register char *C;
int l_value, offset;
- char *malloc(), *realloc(), *_findenv();
+ char *malloc(), *realloc();
if (*value == '=') /* no `=' in value */
++value;
extern char **environ;
register char **P;
int offset;
- char *_findenv();
while (_findenv(name, &offset)) /* if set multiple times */
for (P = &environ[offset];; ++P)
/* based on @(#)getenv.c 5.5 (Berkeley) 6/27/88 */
+#ifndef HAVE_GETENV
/*
* getenv --
* Returns ptr to value associated with name, if any, else NULL.
char *name;
{
int offset;
- char *_findenv();
return(_findenv(name, &offset));
}
+#endif
/*
* _findenv --
*
* This routine *should* be a static; don't use it.
*/
-char *
+static char *
_findenv(name, offset)
register char *name;
int *offset;
#include <netdb.h>
#endif
#include <errno.h>
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
#ifdef KERBEROS
#include <krb.h>
#include <krbports.h>
void sink(int, char **), source(int, char **),
rsource(char *, struct stat *), usage(void);
/*VARARGS*/
-void error();
+void error (char *fmt, ...)
+#if !defined (__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
+ __attribute__ ((__format__ (__printf__, 1, 2)))
+#endif
+ ;
int response(void);
#if !defined(HAVE_UTIMES)
int utimes();
kstream krem;
int errs;
-krb5_sigtype lostconn();
+krb5_sigtype lostconn(int);
int iamremote, targetshouldbedirectory;
int iamrecursive;
int pflag;
char resp, c, rbuf[BUFSIZ], *cp = rbuf;
if (kstream_read (krem, &resp, 1) != 1)
- lostconn();
+ lostconn(0);
switch (resp) {
case 0: /* ok */
case 2: /* fatal error, "" */
do {
if (kstream_read (krem, &c, 1) != 1)
- lostconn();
+ lostconn(0);
*cp++ = c;
} while (cp < &rbuf[BUFSIZ] && c != '\n');
if (iamremote == 0)
return -1;
}
-krb5_sigtype lostconn()
+krb5_sigtype lostconn(signum)
+ int signum;
{
if (iamremote == 0)
return (bp);
}
+void
+#ifdef HAVE_STDARG_H
+error(char *fmt, ...)
+#else
/*VARARGS1*/
-void error(fmt, a1, a2, a3, a4, a5)
- char *fmt;
- int a1, a2, a3, a4, a5;
+error(fmt, va_alist)
+ char *fmt;
+ va_dcl
+#endif
{
- char buf[BUFSIZ], *cp = buf;
+ va_list ap;
+ char buf[BUFSIZ], *cp = buf;
+
+#ifdef HAVE_STDARG_H
+ va_start(ap, fmt);
+#else
+ va_start(ap);
+#endif
- errs++;
- *cp++ = 1;
- (void) sprintf(cp, fmt, a1, a2, a3, a4, a5);
- if (krem)
- (void) kstream_write(krem, buf, strlen(buf));
- if (iamremote == 0)
- (void) write(2, buf+1, strlen(buf+1));
+ errs++;
+ *cp++ = 1;
+ (void) vsprintf(cp, fmt, ap);
+ va_end(ap);
+
+ if (krem)
+ (void) kstream_write(krem, buf, strlen(buf));
+ if (iamremote == 0)
+ (void) write(2, buf+1, strlen(buf+1));
}
void usage()