head	1.3;
access;
symbols
	RELEASE_8_3_0:1.3
	RELEASE_9_0_0:1.3
	RELEASE_7_4_0:1.3
	RELEASE_8_2_0:1.3
	RELEASE_6_EOL:1.3
	RELEASE_8_1_0:1.3
	RELEASE_7_3_0:1.3
	RELEASE_8_0_0:1.2
	RELEASE_7_2_0:1.2
	RELEASE_7_1_0:1.2
	RELEASE_6_4_0:1.2
	RELEASE_5_EOL:1.2
	RELEASE_7_0_0:1.2
	RELEASE_6_3_0:1.2
	PRE_XORG_7:1.2
	RELEASE_4_EOL:1.2
	RELEASE_6_2_0:1.2
	RELEASE_6_1_0:1.2
	RELEASE_5_5_0:1.2
	RELEASE_6_0_0:1.2
	RELEASE_5_4_0:1.2
	RELEASE_4_11_0:1.2
	RELEASE_5_3_0:1.2
	RELEASE_4_10_0:1.2
	RELEASE_5_2_1:1.2
	RELEASE_5_2_0:1.2
	RELEASE_4_9_0:1.1.1.1
	RELEASE_5_1_0:1.1.1.1
	RELEASE_4_8_0:1.1.1.1
	RELEASE_5_0_0:1.1.1.1
	RELEASE_4_7_0:1.1.1.1
	RELEASE_4_6_2:1.1.1.1
	RELEASE_4_6_1:1.1.1.1
	RELEASE_4_6_0:1.1.1.1
	RELEASE_5_0_DP1:1.1.1.1
	RELEASE_4_5_0:1.1.1.1
	RELEASE_4_4_0:1.1.1.1
	RELEASE_4_3_0:1.1.1.1
	RELEASE_4_2_0:1.1.1.1
	RELEASE_4_1_1:1.1.1.1
	RELEASE_4_1_0:1.1.1.1
	RELEASE_3_5_0:1.1.1.1
	RELEASE_4_0_0:1.1.1.1
	RELEASE_3_4_0:1.1.1.1
	RELEASE_3_3_0:1.1.1.1
	RELEASE_3_2_0:1.1.1.1
	v0_1_0:1.1.1.1
	SHIPLEY:1.1.1;
locks; strict;
comment	@# @;


1.3
date	2010.01.20.15.53.24;	author ed;	state Exp;
branches;
next	1.2;

1.2
date	2003.10.27.14.11.12;	author krion;	state Exp;
branches;
next	1.1;

1.1
date	99.05.09.17.50.07;	author steve;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	99.05.09.17.50.07;	author steve;	state Exp;
branches;
next	;


desc
@@


1.3
log
@Make slush build when using utmpx.

Approved by:	miwi (portmgr, implicit)
@
text
@--- slushd.c
+++ slushd.c
@@@@ -40,11 +40,19 @@@@
 #include <ctype.h>
 #include <stdlib.h>
 #include <netdb.h>
+#include <sys/param.h>
+#if __FreeBSD_version >= 500000
 #include <getopt.h>
+#endif
 #include <pwd.h>
 #include <grp.h>
 #include <fcntl.h>
+#if __FreeBSD_version >= 900007
+#include <utmpx.h>
+#else
 #include <utmp.h>
+#include <libutil.h>
+#endif
 #include <limits.h>
 #include <paths.h>
 #include <sys/types.h>
@@@@ -653,59 +661,42 @@@@
 /* exits on error */
 void log_uwtmp(struct passwd *pw, struct in_addr *i, char *tty, int is_logout)
 {
-	struct utmp ut;
-	int wtmp;
-	int lock;
-	
-	tty = strrchr(tty, '/');
-	if (tty == NULL)
-	{
-		syslog(LOG_ERR, "Can't determine basename of tty");
-		exit(3);
-	}
-	tty++;
-	
-	utmpname(_PATH_UTMP);
-	setutent();
-	memset(&ut, 0, sizeof(ut));
+#if __FreeBSD_version >= 900007
+	struct utmpx ut;
 
-	if (ut.ut_id[0] == 0)
-		strncpy(ut.ut_id, tty + 3, sizeof(ut.ut_id));
+	if (strncmp(tty, "/dev/", 5) == 0)
+		tty += 5;
 
-	if (!is_logout)
-		strncpy(ut.ut_user, pw->pw_name, sizeof(ut.ut_user));
-	
-	strncpy(ut.ut_line, tty, sizeof(ut.ut_line) - 1);
-	ut.ut_line[sizeof(ut.ut_line) - 1] = 0;
-	
-	ut.ut_time = time(NULL);
-	ut.ut_type = is_logout?DEAD_PROCESS:USER_PROCESS;
-	ut.ut_pid = getpid();
-
-	strncpy(ut.ut_host, hostname, sizeof(ut.ut_host) - 1);
-	ut.ut_host[sizeof(ut.ut_host) - 1] = 0;
-	
-	memcpy(&ut.ut_addr, i, sizeof(ut.ut_addr));
+	memset(&ut, 0, sizeof ut);
+	gettimeofday(&ut.ut_tv, NULL);
+	strncpy(ut.ut_id, tty, sizeof ut.ut_id);
+
+	if (is_logout) {
+		ut.ut_type = DEAD_PROCESS;
+	} else {
+		ut.ut_type = USER_PROCESS;
+		strncpy(ut.ut_line, tty, sizeof ut.ut_line);
+		strncpy(ut.ut_user, pw->pw_name, sizeof ut.ut_user);
+		strncpy(ut.ut_host, inet_ntoa(*i), sizeof ut.ut_host);
+	}
+	pututxline(&ut);
+#else
+	struct utmp ut;
 
-	pututline(&ut);
-	endutent();
+	if (strncmp(tty, "/dev/", 5) == 0)
+		tty += 5;
 
-	lock = open(_PATH_WTMPLOCK, O_CREAT|O_WRONLY, 0660);
-	if (lock == -1)
-		ioerror("open");
-		
-	if (flock(lock, LOCK_EX) == -1)
-		ioerror("flock");
-		
-	wtmp = open(_PATH_WTMP, O_APPEND|O_WRONLY);
-	if (wtmp == -1)
-		ioerror("open");
-		
-	write(wtmp, (char *)&ut, sizeof(ut));
-	close(wtmp);
+	if (is_logout) {
+		logout(tty);
+		return;
+	}
 
-	flock(lock, LOCK_UN);
-	close(lock);
+	strncpy(ut.ut_line, tty, sizeof ut.ut_line);
+	strncpy(ut.ut_name, pw->pw_name, sizeof ut.ut_name);
+	strncpy(ut.ut_host, inet_ntoa(*i), sizeof ut.ut_host);
+	ut.ut_time = time(0);
+	login(&ut);
+#endif
 }
 
 /* Retrieve client X509 certificate and test authentication */
@


1.2
log
@- Fix build on -current
- Fixes for portlint (DOCSDIR)

PR:		58582
Submitted by:	elvis@@sslab.cs.ccu.edu.tw
@
text
@d1 113
a113 117
*** slushd.c-	Mon Oct 27 06:19:54 2003
--- slushd.c	Mon Oct 27 06:22:02 2003
***************
*** 40,46 ****
--- 40,50 ----
  #include <ctype.h>
  #include <stdlib.h>
  #include <netdb.h>
+ #include <sys/param.h>
+ #if __FreeBSD_version >= 500000
  #include <getopt.h>
+ #endif
+ #include <libutil.h>
  #include <pwd.h>
  #include <grp.h>
  #include <fcntl.h>
***************
*** 51,56 ****
--- 55,61 ----
  #include <sys/stat.h>
  #include <sys/ioctl.h>
  #include <sys/file.h>
+ 
  #ifdef HAVE_UNISTD_H
  #include <unistd.h>	  /* fork, execvp, exit */
  #endif
***************
*** 654,711 ****
  void log_uwtmp(struct passwd *pw, struct in_addr *i, char *tty, int is_logout)
  {
  	struct utmp ut;
- 	int wtmp;
- 	int lock;
  	
  	tty = strrchr(tty, '/');
  	if (tty == NULL)
  	{
  		syslog(LOG_ERR, "Can't determine basename of tty");
! 		exit(3);
  	}
  	tty++;
  	
- 	utmpname(_PATH_UTMP);
- 	setutent();
- 	memset(&ut, 0, sizeof(ut));
  
! 	if (ut.ut_id[0] == 0)
! 		strncpy(ut.ut_id, tty + 3, sizeof(ut.ut_id));
  
- 	if (!is_logout)
- 		strncpy(ut.ut_user, pw->pw_name, sizeof(ut.ut_user));
- 	
  	strncpy(ut.ut_line, tty, sizeof(ut.ut_line) - 1);
! 	ut.ut_line[sizeof(ut.ut_line) - 1] = 0;
! 	
! 	ut.ut_time = time(NULL);
! 	ut.ut_type = is_logout?DEAD_PROCESS:USER_PROCESS;
! 	ut.ut_pid = getpid();
  
- 	strncpy(ut.ut_host, hostname, sizeof(ut.ut_host) - 1);
- 	ut.ut_host[sizeof(ut.ut_host) - 1] = 0;
  	
! 	memcpy(&ut.ut_addr, i, sizeof(ut.ut_addr));
! 
! 	pututline(&ut);
! 	endutent();
! 
! 	lock = open(_PATH_WTMPLOCK, O_CREAT|O_WRONLY, 0660);
! 	if (lock == -1)
! 		ioerror("open");
! 		
! 	if (flock(lock, LOCK_EX) == -1)
! 		ioerror("flock");
! 		
! 	wtmp = open(_PATH_WTMP, O_APPEND|O_WRONLY);
! 	if (wtmp == -1)
! 		ioerror("open");
! 		
! 	write(wtmp, (char *)&ut, sizeof(ut));
! 	close(wtmp);
! 
! 	flock(lock, LOCK_UN);
! 	close(lock);
  }
  
  /* Retrieve client X509 certificate and test authentication */
--- 659,688 ----
  void log_uwtmp(struct passwd *pw, struct in_addr *i, char *tty, int is_logout)
  {
  	struct utmp ut;
  	
  	tty = strrchr(tty, '/');
  	if (tty == NULL)
  	{
  		syslog(LOG_ERR, "Can't determine basename of tty");
! 		return;
  	}
  	tty++;
+ 
  	
  
! 	if(is_logout) {
! 		logout(tty);
! 		return;
! 	}
  
  	strncpy(ut.ut_line, tty, sizeof(ut.ut_line) - 1);
! 	strncpy(ut.ut_name, pw->pw_name, sizeof(ut.ut_name)-1);
! 	strncpy(ut.ut_host, inet_ntoa(*i), sizeof(ut.ut_host) - 1);
! 	ut.ut_time = time(0);
! 	login(&ut);
  
  	
! 	return;
  }
  
  /* Retrieve client X509 certificate and test authentication */
@


1.1
log
@Initial revision
@
text
@d1 2
a2 2
*** slushd.c.orig	Tue Apr  6 05:14:04 1999
--- slushd.c	Sat May  8 23:53:40 1999
d5 1
d9 5
a13 9
! #include <getopt.h>
  #include <pwd.h>
  #include <grp.h>
  #include <fcntl.h>
--- 40,46 ----
  #include <ctype.h>
  #include <stdlib.h>
  #include <netdb.h>
! #include <libutil.h>
d19 1
a19 1
--- 51,57 ----
d87 1
a87 1
--- 655,684 ----
@


1.1.1.1
log
@Initial import of slush version 0.1.0.
A telnet-like application which uses a secure SSL channel.

PR:		11557
Submitted by:	Peter Shipley <shipley@@dis.org>
@
text
@@
