From: Ezra Peisach Date: Fri, 6 Jul 2001 00:18:48 +0000 (+0000) Subject: * Makefile.in: Link krshd with KRSHDLIBS instead of LOGINLIBS X-Git-Tag: krb5-1.3-alpha1~1236 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d63bccc70e56809eee2a7ac0ddbc0f4616ee4282;p=krb5.git * 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. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13567 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/appl/bsd/ChangeLog b/src/appl/bsd/ChangeLog index 0fdd77181..b46a81c25 100644 --- a/src/appl/bsd/ChangeLog +++ b/src/appl/bsd/ChangeLog @@ -1,3 +1,30 @@ +2001-07-05 Ezra Peisach + + * 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 * v4rcp.c, login.c: Fill in prototypes, declare many functions static. diff --git a/src/appl/bsd/Makefile.in b/src/appl/bsd/Makefile.in index d95bfcdbe..7e3258302 100644 --- a/src/appl/bsd/Makefile.in +++ b/src/appl/bsd/Makefile.in @@ -9,10 +9,11 @@ PROG_RPATH=$(KRB5_LIBDIR) 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 @@ -64,7 +65,7 @@ install:: 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) diff --git a/src/appl/bsd/configure.in b/src/appl/bsd/configure.in index 84a898aad..7471d7d45 100644 --- a/src/appl/bsd/configure.in +++ b/src/appl/bsd/configure.in @@ -44,6 +44,10 @@ alpha*-dec-osf*) 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], @@ -65,13 +69,14 @@ else 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) diff --git a/src/appl/bsd/krcp.c b/src/appl/bsd/krcp.c index bf133c2a7..d36d50cd6 100644 --- a/src/appl/bsd/krcp.c +++ b/src/appl/bsd/krcp.c @@ -117,7 +117,7 @@ int encryptflag = 0; int rem; char *colon(char *); int errs; -krb5_sigtype lostconn(); +krb5_sigtype lostconn(int); int iamremote, targetshouldbedirectory; int iamrecursive; int pflag; @@ -918,7 +918,7 @@ int response() { 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 */ @@ -931,7 +931,7 @@ int response() 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) @@ -947,7 +947,8 @@ int response() krb5_sigtype - lostconn() + lostconn(signumber) + int signumber; { if (iamremote == 0) fprintf(stderr, "rcp: lost connection\n"); diff --git a/src/appl/bsd/krlogind.c b/src/appl/bsd/krlogind.c index 2bced2adf..a4b835df8 100644 --- a/src/appl/bsd/krlogind.c +++ b/src/appl/bsd/krlogind.c @@ -325,7 +325,7 @@ extern int daemon(int, int); 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: @@ -897,7 +897,7 @@ void doit(f, fromp) #endif protocol(f, p); signal(SIGCHLD, SIG_IGN); - cleanup(); + cleanup(0); } unsigned char magic[2] = { 0377, 0377 }; @@ -1146,7 +1146,8 @@ void protocol(f, p) -krb5_sigtype cleanup() +krb5_sigtype cleanup(signumber) + int signumber; { pty_cleanup (line, pid, 1); shutdown(netf, 2); @@ -1188,7 +1189,7 @@ void fatal(f, msg) #else (void) ioctl(f, TCFLSH, out); #endif - cleanup(); + cleanup(0); } exit(1); } diff --git a/src/appl/bsd/krsh.c b/src/appl/bsd/krsh.c index 8ec9980bd..bcedf8a00 100644 --- a/src/appl/bsd/krsh.c +++ b/src/appl/bsd/krsh.c @@ -85,7 +85,7 @@ int error(); int options; int rfd2; int nflag; -krb5_sigtype sendsig(); +krb5_sigtype sendsig(int); #ifdef KERBEROS diff --git a/src/appl/bsd/krshd.c b/src/appl/bsd/krshd.c index 1fd63f929..bc0cdc592 100644 --- a/src/appl/bsd/krshd.c +++ b/src/appl/bsd/krshd.c @@ -119,6 +119,11 @@ char copyright[] = #include #include #endif +#ifdef HAVE_STDARG_H +#include +#else +#include +#endif #include #if !defined(KERBEROS) || !defined(KRB5_KRB4_COMPAT) @@ -252,8 +257,11 @@ int secflag; 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 *); @@ -563,7 +571,7 @@ int auth_sys = 0; /* Which version of Kerberos used to authenticate */ #define KRB5_RECVAUTH_V4 4 #define KRB5_RECVAUTH_V5 5 -krb5_sigtype +static krb5_sigtype cleanup(signumber) int signumber; { @@ -935,7 +943,7 @@ void doit(f, fromp) 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, @@ -1531,16 +1539,29 @@ if(port) +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); } diff --git a/src/appl/bsd/login.c b/src/appl/bsd/login.c index 0a8acf666..815492582 100644 --- a/src/appl/bsd/login.c +++ b/src/appl/bsd/login.c @@ -340,6 +340,8 @@ char * strsave(char *); typedef krb5_sigtype sigtype; +sigtype timedout(int); + #ifndef HAVE_INITGROUPS static int initgroups(char* name, gid_t basegid) { @@ -1044,7 +1046,6 @@ int main(argc, argv) 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(); @@ -2051,7 +2052,8 @@ void getloginname() } sigtype -timedout() +timedout(signumber) + int signumber; { fprintf(stderr, "Login timed out after %d seconds\n", timeout); exit(0); diff --git a/src/appl/bsd/setenv.c b/src/appl/bsd/setenv.c index fad8f594e..7316edb54 100644 --- a/src/appl/bsd/setenv.c +++ b/src/appl/bsd/setenv.c @@ -20,6 +20,12 @@ #include #include +#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 @@ -34,7 +40,7 @@ setenv(name, value, rewrite) 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; @@ -90,7 +96,6 @@ unsetenv(name) extern char **environ; register char **P; int offset; - char *_findenv(); while (_findenv(name, &offset)) /* if set multiple times */ for (P = &environ[offset];; ++P) @@ -116,6 +121,7 @@ unsetenv(name) /* 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. @@ -125,10 +131,10 @@ getenv(name) char *name; { int offset; - char *_findenv(); return(_findenv(name, &offset)); } +#endif /* * _findenv -- @@ -139,7 +145,7 @@ getenv(name) * * This routine *should* be a static; don't use it. */ -char * +static char * _findenv(name, offset) register char *name; int *offset; diff --git a/src/appl/bsd/v4rcp.c b/src/appl/bsd/v4rcp.c index 65701b5f0..d27c16c0c 100644 --- a/src/appl/bsd/v4rcp.c +++ b/src/appl/bsd/v4rcp.c @@ -73,6 +73,12 @@ static char sccsid[] = "@(#)rcp.c 5.10 (Berkeley) 9/20/88"; #include #endif #include +#ifdef HAVE_STDARG_H +#include +#else +#include +#endif + #ifdef KERBEROS #include #include @@ -81,7 +87,11 @@ static char sccsid[] = "@(#)rcp.c 5.10 (Berkeley) 9/20/88"; 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(); @@ -321,7 +331,7 @@ int encryptflag = 0; kstream krem; int errs; -krb5_sigtype lostconn(); +krb5_sigtype lostconn(int); int iamremote, targetshouldbedirectory; int iamrecursive; int pflag; @@ -621,7 +631,7 @@ int response() char resp, c, rbuf[BUFSIZ], *cp = rbuf; if (kstream_read (krem, &resp, 1) != 1) - lostconn(); + lostconn(0); switch (resp) { case 0: /* ok */ @@ -634,7 +644,7 @@ int response() 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) @@ -648,7 +658,8 @@ int response() return -1; } -krb5_sigtype lostconn() +krb5_sigtype lostconn(signum) + int signum; { if (iamremote == 0) @@ -921,20 +932,34 @@ allocbuf(bp, fd, blksize) 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()