DragonFly BSD
DragonFly submit List (threaded) for 2005-05
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

[patch] libexec/rlogind cleanup


From: Peter Schuller <peter.schuller@xxxxxxxxxxxx>
Date: Sat, 14 May 2005 00:33:53 +0200

* WARNS=6
* Makes functions static
* Style fixes w.r.t. function arguments
* Constification
* A couple of renames of local vars that were previously shadowing eachother
* The 'kerberos' support mentioned in the man-page seems non-existent, apart
  from the do_krb_login() function being declared (but not implemented).
  The patch removes the function declaration and removes the reference to
  kerberos in the manpage. I'm not sure what people think about this; I
  presume the rlogind cmdline params might be considered 'standard'. Would
  it perhaps be better to keep the manpage as is, but add a note that it is
  currently not implemented?
* The code depending on CRYPT (and which implements -x documented in the manpage)
  is there, but I cannot find any place where CRYPT is defined. In other words,
  unless I am missing something, -x is effectively unsupported from a user
  stand-point. The patch doesn't touch this however (opinions?).

-- 
/ Peter Schuller, InfiDyne Technologies HB

PGP userID: 0xE9758B7D or 'Peter Schuller <peter.schuller@xxxxxxxxxxxx>'
Key retrieval: Send an E-Mail to getpgpkey@xxxxxxxxx
E-Mail: peter.schuller@xxxxxxxxxxxx Web: http://www.scode.org

--- libexec/rlogind/Makefile.orig	2005-05-13 14:25:34.000000000 +0000
+++ libexec/rlogind/Makefile	2005-05-13 14:25:48.000000000 +0000
@@ -8,5 +8,6 @@
 DPADD=	${LIBUTIL}
 LDADD=	-lutil
 CFLAGS+= -Wall -DINET6
+WARNS?= 6
 
 .include <bsd.prog.mk>
--- libexec/rlogind/rlogind.8.orig	2005-05-13 15:10:02.000000000 +0000
+++ libexec/rlogind/rlogind.8	2005-05-13 15:15:47.000000000 +0000
@@ -65,12 +65,8 @@
 Disable keep-alive messages.
 .El
 .Pp
-The following options are valid only if Kerberos is in use:
+The following options are valid only if encryption is enabled:
 .Bl -tag -width indent
-.It Fl k
-Enable Kerberos authentication.
-.It Fl v
-Enable vacuous mode.
 .It Fl x
 Enable
 .Tn DES
--- libexec/rlogind/rlogind.c.orig	2005-05-13 14:25:39.000000000 +0000
+++ libexec/rlogind/rlogind.c	2005-05-13 15:08:38.000000000 +0000
@@ -83,6 +83,8 @@
 #define	NI_WITHSCOPEID	0
 #endif
 
+extern int __check_rhosts_file;
+
 char	*env[2];
 #define	NMAX 30
 char	lusername[NMAX+1], rusername[NMAX+1];
@@ -107,24 +109,21 @@
 #define su_family	su_si.si_family
 #define su_port		su_si.si_port
 
-void	doit (int, union sockunion *);
-int	control (int, char *, int);
-void	protocol (int, int);
-void	cleanup (int);
-void	fatal (int, char *, int);
-int	do_rlogin (union sockunion *);
-void	getstr (char *, int, char *);
-void	setup_term (int);
-int	do_krb_login (struct sockaddr_in *);
-void	usage (void);
-
+static void   doit (int, union sockunion *);
+static int    control (int, char *, int);
+static void   protocol (int, int);
+static void   cleanup (int);
+static void   fatal (int, const char *, int);
+static int    do_rlogin (union sockunion *);
+static void   getstr (char *, int, const char *);
+static void   setup_term (int);
+static void   usage (void);
 
 int
 main(argc, argv)
 	int argc;
 	char *argv[];
 {
-	extern int __check_rhosts_file;
 	union sockunion from;
 	int ch, fromlen, on;
 
@@ -189,10 +188,8 @@
 struct winsize win = { 0, 0, 0, 0 };
 
 
-void
-doit(f, fromp)
-	int f;
-	union sockunion *fromp;
+static void
+doit(int f, union sockunion *fromp)
 {
 	int master, pid, on = 1;
 	int authenticated = 0;
@@ -245,17 +242,17 @@
 		if (getsockopt(0, ipproto, IP_OPTIONS, (char *)optbuf,
 		    &optsize) == 0 && optsize != 0) {
 			for (i = 0; i < optsize; ) {
-				u_char c = optbuf[i];
-				if (c == IPOPT_LSRR || c == IPOPT_SSRR) {
+				u_char optc = optbuf[i];
+				if (optc == IPOPT_LSRR || optc == IPOPT_SSRR) {
 					syslog(LOG_NOTICE,
 						"Connection refused from %s with IP option %s",
 						inet_ntoa(fromp->su_sin.sin_addr),
-						c == IPOPT_LSRR ? "LSRR" : "SSRR");
+						optc == IPOPT_LSRR ? "LSRR" : "SSRR");
 					exit(1);
 				}
-				if (c == IPOPT_EOL)
+				if (optc == IPOPT_EOL)
 					break;
-				i += (c == IPOPT_NOP) ? 1 : optbuf[i+1];
+				i += (optc == IPOPT_NOP) ? 1 : optbuf[i+1];
 			}
 		}
 	      }
@@ -326,15 +323,12 @@
  * in the data stream.  For now, we are only willing to handle
  * window size changes.
  */
-int
-control(pty, cp, n)
-	int pty;
-	char *cp;
-	int n;
+static int
+control(int pty, char *cp, int n)
 {
 	struct winsize w;
 
-	if (n < 4+sizeof (w) || cp[2] != 's' || cp[3] != 's')
+	if (n < 4+(int)(sizeof (w)) || cp[2] != 's' || cp[3] != 's')
 		return (0);
 	oobdata[0] &= ~TIOCPKT_WINDOW;	/* we know he heard */
 	bcopy(cp+4, (char *)&w, sizeof(w));
@@ -349,9 +343,8 @@
 /*
  * rlogin "protocol" machine.
  */
-void
-protocol(f, p)
-	register int f, p;
+static void
+protocol(register int f, int p)
 {
 	char pibuf[1024+1], fibuf[1024], *pbp = NULL, *fbp = NULL;
 	int pcc = 0, fcc = 0;
@@ -427,7 +420,7 @@
 				fcc = 0;
 			else {
 				register char *cp;
-				int left, n;
+				int left, count;
 
 				if (fcc <= 0)
 					break;
@@ -438,12 +431,12 @@
 					if (cp[0] == magic[0] &&
 					    cp[1] == magic[1]) {
 						left = fcc - (cp-fibuf);
-						n = control(p, cp, left);
-						if (n) {
-							left -= n;
+						count = control(p, cp, left);
+						if (count > 0) {
+							left -= count;
 							if (left > 0)
-								bcopy(cp+n, cp, left);
-							fcc -= n;
+								bcopy(cp+count, cp, left);
+							fcc -= count;
 							goto top; /* n^2 */
 						}
 					}
@@ -506,9 +499,8 @@
 	}
 }
 
-void
-cleanup(signo)
-	int signo;
+static void
+cleanup(__unused int signo)
 {
 	char *p;
 
@@ -526,11 +518,8 @@
 	exit(1);
 }
 
-void
-fatal(f, msg, syserr)
-	int f;
-	char *msg;
-	int syserr;
+static void
+fatal(int f, const char *msg, int syserr)
 {
 	int len;
 	char buf[BUFSIZ], *bp = buf;
@@ -550,9 +539,8 @@
 	exit(1);
 }
 
-int
-do_rlogin(dest)
-	union sockunion *dest;
+static int
+do_rlogin(union sockunion *dest)
 {
 
 	getstr(rusername, sizeof(rusername), "remuser too long");
@@ -568,11 +556,8 @@
 			    lusername));
 }
 
-void
-getstr(buf, cnt, errmsg)
-	char *buf;
-	int cnt;
-	char *errmsg;
+static void
+getstr(char *buf, int cnt, const char *errmsg)
 {
 	char c;
 
@@ -587,9 +572,8 @@
 
 extern	char **environ;
 
-void
-setup_term(fd)
-	int fd;
+static void
+setup_term(int fd)
 {
 	register char *cp = index(term+ENVSIZE, '/');
 	char *speed;
@@ -628,7 +612,7 @@
 	environ = env;
 }
 
-void
+static void
 usage()
 {
 	syslog(LOG_ERR, "usage: rlogind [-" ARGSTR "]");


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]