changeset 1:c06480deb43d

blah
author Simon Horman <horms@verge.net.au>
date Mon, 13 May 2002 15:48:39 +0900
parents 2fbf657d0af2
children 2517dd7ac6d4
files AUTHORS Makefile.am acconfig.h configure.in pbs/Makefile.am pbs/Makefile.in pbs/pbs.c pbs/pbs_db.c pbs/pbs_db.h pbs/pbs_log.h pbs/pbs_option.c pbs/pbs_option.h pbs/pbs_record.c pbs/pbs_record.h
diffstat 14 files changed, 311 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/AUTHORS	Mon May 13 14:19:35 2002 +0900
+++ b/AUTHORS	Mon May 13 15:48:39 2002 +0900
@@ -2,7 +2,7 @@
 
 perdition-pbs
 Pop Before SMTP Tools
-Copyright (C) 1999-2002  Horms <horms@vergenet.net>
+Copyright (C) 2002  Horms <horms@vergenet.net>
 ----------------------------------------------------------------------
 
 Horms: <horms@vergenet.net>
--- a/Makefile.am	Mon May 13 14:19:35 2002 +0900
+++ b/Makefile.am	Mon May 13 15:48:39 2002 +0900
@@ -1,10 +1,10 @@
 ######################################################################
-# Makefile.am                                            February 2000
+# Makefile.am                                                 May 2002
 # Horms                                             horms@vergenet.net
 #
-# perdition
-# Mail retrieval proxy server
-# Copyright (C) 1999-2002  Horms <horms@vergenet.net>
+# Perdition PBS
+# Pop Before SMTP Tools
+# Copyright (C) 2002 Horms
 # 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -14,14 +14,14 @@
 # This program is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more depbss.
+# General Public License for more details.
 # 
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 # 02111-1307  USA
 #
-######################################################################
+######################################################################/
 
 SUBDIRS = pbs
 
--- a/acconfig.h	Mon May 13 14:19:35 2002 +0900
+++ b/acconfig.h	Mon May 13 15:48:39 2002 +0900
@@ -1,2 +1,27 @@
+/**********************************************************************
+ * acconfig.h                                                  May 2002
+ * Horms                                             horms@vergenet.net
+ *
+ * Perdition PBS
+ * Pop Before SMTP Tools
+ * Copyright (C) 2002 Horms
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307  USA
+ *
+ **********************************************************************/
+
 /* Should we use DMALLOC */
 /* #define WITH_DMALLOC 1 */
--- a/configure.in	Mon May 13 14:19:35 2002 +0900
+++ b/configure.in	Mon May 13 15:48:39 2002 +0900
@@ -1,3 +1,28 @@
+######################################################################
+# configure.in                                                May 2002
+# Horms                                             horms@vergenet.net
+#
+# Perdition PBS
+# Pop Before SMTP Tools
+# Copyright (C) 2002 Horms
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307  USA
+#
+######################################################################/
+
 # Process this file with autoconf to produce a configure script.
 AC_INIT(pbs/pbs_log.h)
 AM_CONFIG_HEADER(config.h)
--- a/pbs/Makefile.am	Mon May 13 14:19:35 2002 +0900
+++ b/pbs/Makefile.am	Mon May 13 15:48:39 2002 +0900
@@ -1,10 +1,10 @@
 ######################################################################
-# Makefile.am                                            February 2000
+# Makefile.am                                                 May 2002
 # Horms                                             horms@vergenet.net
 #
-# perdition
-# Mail retrieval proxy server
-# Copyright (C) 1999-2002  Horms
+# Perdition PBS
+# Pop Before SMTP Tools
+# Copyright (C) 2002 Horms
 # 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -14,14 +14,15 @@
 # This program is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more depbss.
+# General Public License for more details.
 # 
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 # 02111-1307  USA
 #
-######################################################################
+######################################################################/
+
 
 sbin_PROGRAMS = perdition-pbs
 
--- a/pbs/Makefile.in	Mon May 13 14:19:35 2002 +0900
+++ b/pbs/Makefile.in	Mon May 13 15:48:39 2002 +0900
@@ -11,12 +11,12 @@
 # PARTICULAR PURPOSE.
 
 ######################################################################
-# Makefile.am                                            February 2000
+# Makefile.am                                                 May 2002
 # Horms                                             horms@vergenet.net
 #
-# perdition
-# Mail retrieval proxy server
-# Copyright (C) 1999-2002  Horms
+# Perdition PBS
+# Pop Before SMTP Tools
+# Copyright (C) 2002 Horms
 # 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -26,14 +26,14 @@
 # This program is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# General Public License for more depbss.
+# General Public License for more details.
 # 
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 # 02111-1307  USA
 #
-######################################################################
+######################################################################/
 
 
 SHELL = @SHELL@
--- a/pbs/pbs.c	Mon May 13 14:19:35 2002 +0900
+++ b/pbs/pbs.c	Mon May 13 15:48:39 2002 +0900
@@ -1,3 +1,28 @@
+/**********************************************************************
+ * pbs.c                                                       May 2002
+ * Horms                                             horms@vergenet.net
+ *
+ * Perdition PBS
+ * Pop Before SMTP Tools
+ * Copyright (C) 2002 Horms
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307  USA
+ *
+ **********************************************************************/
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -12,6 +37,7 @@
 #include <signal.h>
 #include <time.h>
 #include <locale.h>
+#include <string.h>
 #include <vanessa_logger.h>
 #include <vanessa_socket.h>
 
@@ -42,7 +68,8 @@
 static int do_mode_remove(pbs_db_t *db, const char **key, const char *prefix,
 		int quiet);
 static int do_mode_purge(pbs_db_t *db, int quiet);
-static int do_mode_setenv(pbs_db_t *db, const char **key);
+static int do_mode_setenv(pbs_db_t *db, int fd, const char *prefix,
+		const char **key);
 
 static int pbs_exit_now = 0;
 static int pbs_reread_now = 0;
@@ -79,9 +106,14 @@
 	}
 
 	/* Update Logger */
-	if(opt->mode == PBS_MODE_DAEMON){
+	if(opt->mode == PBS_MODE_DAEMON || opt->mode == PBS_MODE_SETENV){
   		vanessa_logger_closelog(pbs_vl);
-		vanessa_socket_daemon_process();
+		if(opt->mode == PBS_MODE_DAEMON) {
+			vanessa_socket_daemon_process();
+		}
+		else {
+			vanessa_socket_daemon_inetd_process();
+		}
 		pbs_vl=vanessa_logger_openlog_syslog_byname(
 				opt->log_facility, LOG_IDENT, 
 				opt->log_level, LOG_CONS);
@@ -142,7 +174,7 @@
 	}
 
 	if(opt->mode == PBS_MODE_SETENV) {
-		status = do_mode_setenv(db, opt->leftover);
+		status = do_mode_setenv(db, 1, opt->prefix, opt->leftover);
 		if(status == -2) {
 			PBS_ERR("There must be at least one argument "
 					"to setenv");
@@ -511,9 +543,8 @@
 			PBS_DEBUG("pbs_record_fix_key");
 			return(-1);
 		}
-		pbs_db_get(db, (char *)k_fixed, strlen(k_fixed)+1, 
-				(void **)&time, &len);
-		if(time == NULL || len == 0) {
+		if(pbs_db_get(db, (char *)k_fixed, strlen(k_fixed)+1, 
+				(void **)&time, &len) < 0) {
 			pbs_record_show_str((char *)*k, "Not found", width);
 		}
 		else {
@@ -644,18 +675,59 @@
 }
 
 
-static int do_mode_setenv(pbs_db_t *db, const char **key) {
+static int do_mode_setenv(pbs_db_t *db, const int fd,  const char *prefix,
+		const char **argv) {
 	char value = '\0';
+	struct sockaddr_in peername;
+	socklen_t namelen;
+	char *peername_str;
+	const char *peername_str_fixed;
+	char *buf = NULL;
+	time_t expire;
+	size_t len;
+	size_t buf_len = 0;
 
-	PBS_ERR("You need to check the source IP address!!");
-
-	if(key == NULL) {
-		PBS_DEBUG("no key");
+	if(argv == NULL) {
+		PBS_DEBUG("no arguments");
 		return(-2);
 	}
 
-	setenv("RELAYCLIENT", &value, 0);
-	execv(key[0], (char **const)key);
+	namelen = sizeof(peername);
+	if(getpeername(fd, (struct sockaddr *)&peername, &namelen)) {
+		PBS_DEBUG_ERRNO("getpeername");
+		return(-1);
+	}
+	peername_str = inet_ntoa(peername.sin_addr);
+	if(peername_str == NULL) {
+		PBS_DEBUG_ERRNO("inet_ntoa");
+		return(-1);
+	}
+
+	peername_str_fixed = pbs_record_fix_key(peername_str, prefix, 
+			&buf, &buf_len);
+	if(peername_str_fixed == NULL) {
+		PBS_DEBUG("pbs_record_fix_key");
+		return(-1);
+	}
+
+	if(pbs_db_get(db, (char *)peername_str_fixed, 
+			strlen(peername_str_fixed)+1, 
+			(void **)&expire, &len) < 0) {
+		PBS_INFO_UNSAFE("No (Not in database): %s", peername_str);
+	}
+	else if (time(NULL) > expire) {
+		PBS_INFO_UNSAFE("No (Expired): %s", peername_str);
+	}
+	else {
+		PBS_INFO_UNSAFE("Yes: %s, peername_str");
+		setenv("RELAYCLIENT", &value, 0);
+	}
+
+	if(buf != NULL) {
+		free(buf);
+	}
+
+	execv(argv[0], (char **const)argv);
 	PBS_DEBUG_ERRNO("execl");	
 	return(-1);
 }
--- a/pbs/pbs_db.c	Mon May 13 14:19:35 2002 +0900
+++ b/pbs/pbs_db.c	Mon May 13 15:48:39 2002 +0900
@@ -1,3 +1,28 @@
+/**********************************************************************
+ * pbs_db.c                                                    May 2002
+ * Horms                                             horms@vergenet.net
+ *
+ * Perdition PBS
+ * Pop Before SMTP Tools
+ * Copyright (C) 2002 Horms
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307  USA
+ *
+ **********************************************************************/
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
--- a/pbs/pbs_db.h	Mon May 13 14:19:35 2002 +0900
+++ b/pbs/pbs_db.h	Mon May 13 15:48:39 2002 +0900
@@ -1,3 +1,28 @@
+/**********************************************************************
+ * pbs_db.h                                                    May 2002
+ * Horms                                             horms@vergenet.net
+ *
+ * Perdition PBS
+ * Pop Before SMTP Tools
+ * Copyright (C) 2002 Horms
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307  USA
+ *
+ **********************************************************************/
+
 #ifndef __PBS_DB_H
 #define __PBS_DB_H
 
--- a/pbs/pbs_log.h	Mon May 13 14:19:35 2002 +0900
+++ b/pbs/pbs_log.h	Mon May 13 15:48:39 2002 +0900
@@ -1,12 +1,10 @@
 /**********************************************************************
- * pbs_log.h                                                 September 2000
+ * pbs_log.h                                                   May 2002
  * Horms                                             horms@vergenet.net
  *
- * Defines for logging
- *
- * perdition
- * Mail retrieval proxy server
- * Copyright (C) 1999-2002  Horms
+ * Perdition PBS
+ * Pop Before SMTP Tools
+ * Copyright (C) 2002 Horms
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -16,7 +14,7 @@
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more depbss.
+ * General Public License for more details.
  * 
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
--- a/pbs/pbs_option.c	Mon May 13 14:19:35 2002 +0900
+++ b/pbs/pbs_option.c	Mon May 13 15:48:39 2002 +0900
@@ -1,3 +1,28 @@
+/**********************************************************************
+ * pbs_option.c                                                May 2002
+ * Horms                                             horms@vergenet.net
+ *
+ * Perdition PBS
+ * Pop Before SMTP Tools
+ * Copyright (C) 2002 Horms
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307  USA
+ *
+ **********************************************************************/
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
--- a/pbs/pbs_option.h	Mon May 13 14:19:35 2002 +0900
+++ b/pbs/pbs_option.h	Mon May 13 15:48:39 2002 +0900
@@ -1,3 +1,28 @@
+/**********************************************************************
+ * pbs_option.h                                                May 2002
+ * Horms                                             horms@vergenet.net
+ *
+ * Perdition PBS
+ * Pop Before SMTP Tools
+ * Copyright (C) 2002 Horms
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307  USA
+ *
+ **********************************************************************/
+
 #ifndef __PBS_OPTIONS_H
 #define __PBS_OPTIONS_H
 
--- a/pbs/pbs_record.c	Mon May 13 14:19:35 2002 +0900
+++ b/pbs/pbs_record.c	Mon May 13 15:48:39 2002 +0900
@@ -1,3 +1,28 @@
+/**********************************************************************
+ * pbs_record.c                                                May 2002
+ * Horms                                             horms@vergenet.net
+ *
+ * Perdition PBS
+ * Pop Before SMTP Tools
+ * Copyright (C) 2002 Horms
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307  USA
+ *
+ **********************************************************************/
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
--- a/pbs/pbs_record.h	Mon May 13 14:19:35 2002 +0900
+++ b/pbs/pbs_record.h	Mon May 13 15:48:39 2002 +0900
@@ -1,3 +1,28 @@
+/**********************************************************************
+ * pbs_record.h                                                May 2002
+ * Horms                                             horms@vergenet.net
+ *
+ * Perdition PBS
+ * Pop Before SMTP Tools
+ * Copyright (C) 2002 Horms
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307  USA
+ *
+ **********************************************************************/
+
 #ifndef __PBS_TIME_H
 #define __PBS_TIME_H