Репозиторий ALT Linux backports/2.4
Последнее обновление: 9 июля 2008 | Пакетов: 497 | Посещений: 1574395
 поиск   регистрация   авторизация 
 
Группа :: Система/Серверы
Пакет: pdnsd

 Главная   Изменения   Спек   Патчи   Загрузить   Bugs and FR 

Патч: pdnsd-1.2.5-alt-sock_path.patch


--- pdnsd-1.2.5/configure.in.orig	2006-12-09 20:36:07 +0500
+++ pdnsd-1.2.5/configure.in	2006-12-09 20:36:08 +0500
@@ -12,6 +12,7 @@
 distribution="Generic"
 target="autodetect"
 cachedir="/var/cache/$PACKAGE"
+sockpath="/var/run/$PACKAGE/socket"
 ipv4_default=1
 have_ipv4="yes"
 newrr="yes"
@@ -63,6 +64,11 @@
     ;;
 esac
 
+AC_ARG_WITH(sockpath,
+[  --with-sockpath=file        Default path for pdnsd control socket
+                              (default=$sockpath)],
+  sockpath=$withval)
+AC_DEFINE_UNQUOTED(SOCKPATH, "$sockpath")
 AC_ARG_WITH(cachedir,
 [  --with-cachedir=dir         Default directory for pdnsd cache 
                               (default=/var/cache/pdnsd)],
--- pdnsd-1.2.5/acconfig.h.orig	2006-12-09 20:36:07 +0500
+++ pdnsd-1.2.5/acconfig.h	2006-12-09 20:36:08 +0500
@@ -119,6 +119,7 @@
 #define CACHE_DBM DBM_NATIVE
 
 #define CACHEDIR "/var/cache/pdnsd"
+#define SOCKPATH "/var/run/pdnsd/socket"
 
 #define TEMPDIR "/tmp";
 
--- pdnsd-1.2.5/src/status.c.orig	2006-12-09 20:36:07 +0500
+++ pdnsd-1.2.5/src/status.c	2006-12-09 20:36:08 +0500
@@ -56,7 +56,6 @@
 static char rcsid[]="$Id: status.c,v 1.34 2002/07/12 14:32:28 tmm Exp $";
 #endif
 
-char *sock_path=NULL;
 int stat_sock;
 
 
@@ -682,10 +681,10 @@
 	   so I conclude it is not necessary to count the null byte, but it probably makes no
 	   difference if you do.
 	*/
-	unsigned int sa_len = (offsetof(struct sockaddr_un, sun_path) + strlitlen("/pdnsd.status") + strlen(global.cache_dir));
+	unsigned int sa_len = (offsetof(struct sockaddr_un, sun_path) + strlen(global.sock_path));
 
 	sa=(struct sockaddr_un *)alloca(sa_len+1);
-	stpcpy(stpcpy(sa->sun_path,global.cache_dir),"/pdnsd.status");
+	stpcpy(sa->sun_path, global.sock_path);
 
 	if (unlink(sa->sun_path)!=0 && errno!=ENOENT) { /* Delete the socket */
 		log_warn("Failed to unlink %s: %s.\nStatus readback will be disabled",sa->sun_path, strerror(errno));
@@ -711,8 +710,6 @@
 		}
 		umask(old_mask);
 	}
-
-	if(stat_pipe) sock_path= strdup(sa->sun_path);
 }
 
 /*
--- pdnsd-1.2.5/src/main.c.orig	2006-12-09 20:36:07 +0500
+++ pdnsd-1.2.5/src/main.c	2006-12-09 20:36:48 +0500
@@ -70,7 +70,6 @@
 volatile int tcp_socket=-1;
 volatile int udp_socket=-1;
 sigset_t sigs_msk;
-char *conf_file=CONFDIR"/pdnsd.conf";
 
 
 /* version and licensing information */
@@ -440,6 +439,7 @@
 	}
 
 	if(!global.cache_dir)   global.cache_dir = CACHEDIR;
+	if(!global.sock_path)   global.sock_path = SOCKPATH;
 	if(!global.scheme_file) global.scheme_file = "/var/lib/pcmcia/scheme";
 	stat_pipe=global.stat_pipe;
 
@@ -710,8 +710,6 @@
 #endif
 	/* Close and delete the status socket */
 	if(stat_pipe) close(stat_sock);
-	if (sock_path && unlink(sock_path))
-		log_warn("Failed to unlink %s: %s",sock_path, strerror(errno));
 
 	free_rng();
 #if DEBUG>0
--- pdnsd-1.2.5/src/conff.h.orig	2006-12-09 20:36:07 +0500
+++ pdnsd-1.2.5/src/conff.h	2006-12-09 20:36:08 +0500
@@ -97,6 +97,7 @@
 typedef struct {
 	long          perm_cache;
 	char         *cache_dir;
+	char         *sock_path;
 	char         *pidfile;
 	int           port;
 	pdnsd_a       a;
--- pdnsd-1.2.5/src/conff.c.orig	2006-12-09 20:36:07 +0500
+++ pdnsd-1.2.5/src/conff.c	2006-12-09 20:37:08 +0500
@@ -40,9 +40,12 @@
 static char rcsid[]="$Id: conff.c,v 1.26 2001/07/02 18:55:27 tmm Exp $";
 #endif
 
+char *conf_file=CONFDIR"/pdnsd.conf";
+
 globparm_t global={
   perm_cache:        2048,
   cache_dir:         NULL,
+  sock_path:         NULL,
   pidfile:           NULL,
   port:              53,
 #ifdef ENABLE_IPV4
@@ -195,6 +198,7 @@
 
 	global_new=global;
 	global_new.cache_dir=NULL;
+	global_new.sock_path=NULL;
 	global_new.pidfile=NULL;
 	global_new.scheme_file=NULL;
 	global_new.deleg_only_zones=NULL;
@@ -206,6 +210,11 @@
 				       "Try restarting pdnsd instead.");
 			goto cleanup_return;
 		}
+		if(global_new.sock_path && strcmp(global_new.sock_path,global.sock_path)) {
+			*errstr=strdup("Cannot reload config file: the specified sock_path directory has changed.\n"
+				       "Try restarting pdnsd instead.");
+			goto cleanup_return;
+		}
 		if(global_new.pidfile && (!global.pidfile || strcmp(global_new.pidfile,global.pidfile))) {
 			*errstr=strdup("Cannot reload config file: the specified pid_file has changed.\n"
 				       "Try restarting pdnsd instead.");
@@ -292,6 +301,7 @@
 			goto cleanup_return;
 		}
 		free(global_new.cache_dir); global_new.cache_dir=global.cache_dir;
+		free(global_new.sock_path); global_new.sock_path=global.sock_path;
 		free(global_new.pidfile); global_new.pidfile=global.pidfile;
 		free(global_new.scheme_file); global_new.scheme_file=global.scheme_file;
 		free_zones(global.deleg_only_zones);
@@ -308,6 +318,7 @@
 
  cleanup_return:
 	free(global_new.cache_dir);
+	free(global_new.sock_path);
 	free(global_new.pidfile);
 	free(global_new.scheme_file);
 	free_zones(global_new.deleg_only_zones);
@@ -367,6 +378,7 @@
 	fsprintf_or_return(f,"\nConfiguration:\n==============\nGlobal:\n-------\n");
 	fsprintf_or_return(f,"\tCache size: %li kB\n",global.perm_cache);
 	fsprintf_or_return(f,"\tServer directory: %s\n",global.cache_dir);
+	fsprintf_or_return(f,"\tControl socket path: %s\n",global.sock_path);
 	fsprintf_or_return(f,"\tScheme file (for Linux pcmcia support): %s\n",global.scheme_file);
 	fsprintf_or_return(f,"\tServer port: %i\n",global.port);
 	{
--- pdnsd-1.2.5/src/conf-parser.c.orig	2006-12-09 20:36:07 +0500
+++ pdnsd-1.2.5/src/conf-parser.c	2006-12-09 20:36:08 +0500
@@ -476,6 +476,11 @@
 	    STRNDUP(global->cache_dir,ps,len);
 	    break;
 
+	  case SOCK_PATH:
+	    SCAN_STRING(ps,p,len);
+	    STRNDUP(global->sock_path,ps,len);
+	    break;
+
 	  case SERVER_PORT:
 	    SCAN_UNSIGNED_NUM(global->port,p,"server_port option")
 	    break;
--- pdnsd-1.2.5/src/conf-keywords.h.orig	2006-12-09 20:36:07 +0500
+++ pdnsd-1.2.5/src/conf-keywords.h	2006-12-09 20:36:08 +0500
@@ -18,6 +18,7 @@
 	
 	PERM_CACHE,
 	CACHE_DIR,
+	SOCK_PATH,
 	SERVER_PORT,
 	SERVER_IP,
 	SCHEME_FILE,
@@ -127,6 +128,7 @@
 	{"scheme_file",      SCHEME_FILE},
 	{"server_ip",        SERVER_IP},
 	{"server_port",      SERVER_PORT},
+ 	{"sock_path",        SOCK_PATH},
 	{"status_ctl",       STATUS_CTL},
 	{"strict_setuid",    STRICT_SETUID},
 	{"tcp_qtimeout",     TCP_QTIMEOUT},
--- pdnsd-1.2.5/src/pdnsd-ctl/pdnsd-ctl.c.orig	2006-12-09 20:36:07 +0500
+++ pdnsd-1.2.5/src/pdnsd-ctl/pdnsd-ctl.c	2006-12-09 20:36:08 +0500
@@ -83,11 +83,11 @@
 
 static const char *help_messages[] =
 {
-	"Usage: pdnsd-ctl [-c cachedir] [-q] <command> [options]\n\n"
+	"Usage: pdnsd-ctl [-c sockpath] [-q] <command> [options]\n\n"
 
 	"Command line options\n"
 
-	"-c\tcachedir\n\tSet the cache directory to cachedir (must match pdnsd setting).\n"
+	"-c\tsockpath\n\tSet control socket path to sockpath (must match pdnsd setting).\n"
 	"-q\n\tBe quiet unless output is specified by command or something goes wrong.\n"
 
 	"Commands and needed options are:\n"
@@ -184,7 +184,7 @@
 
 #define num_help_messages (sizeof(help_messages)/sizeof(char*))
 
-static int open_sock(const char *cache_dir)
+static int open_sock(const char *sock_path)
 {
 	struct sockaddr_un *sa;
 	unsigned int sa_len;
@@ -195,10 +195,10 @@
 		exit(2);
 	}
 
-	sa_len = (offsetof(struct sockaddr_un, sun_path) + strlitlen("/pdnsd.status") + strlen(cache_dir));
+	sa_len = (offsetof(struct sockaddr_un, sun_path) + strlen(sock_path));
 	sa=(struct sockaddr_un *)alloca(sa_len+1);
 	sa->sun_family=AF_UNIX;
-	stpcpy(stpcpy(sa->sun_path,cache_dir),"/pdnsd.status");
+	stpcpy(sa->sun_path,sock_path);
 
 	if (connect(sock,(struct sockaddr *)sa,sa_len)==-1) {
 		fprintf(stderr,"Error: could not open socket %s: %s\n",sa->sun_path,strerror(errno));
@@ -280,7 +280,7 @@
 
 int main(int argc, char *argv[])
 {
-	char *cache_dir= CACHEDIR;
+	char *sock_path= SOCKPATH;
 	int rv=0;
 	{
 		int i;
@@ -288,7 +288,7 @@
 		for(i=1;i<argc && (arg=argv[i]) && *arg=='-';++i) {
 			if(!strcmp(arg,"-c")) {
 				if(++i<argc) {
-					cache_dir= argv[i];
+					sock_path= argv[i];
 				}
 				else {
 					fprintf(stderr,"file name expected after -c option.\n");
@@ -346,7 +346,7 @@
 		case CTL_STATS:
 			if (argc!=1)
 				goto wrong_args;
-			pf=open_sock(cache_dir);
+			pf=open_sock(sock_path);
 			send_short(pf,cmd);
 			goto copy_pf;
 
@@ -357,7 +357,7 @@
 			acnt=2;
 			server_cmd=match_cmd(argv[2],server_cmds);
 			if(server_cmd==-1) goto bad_arg;
-			pf=open_sock(cache_dir);
+			pf=open_sock(sock_path);
 			send_short(pf,cmd);
 			send_string(pf,argv[1]);
 			send_short(pf,server_cmd);
@@ -372,7 +372,7 @@
 			acnt=2;
 			record_cmd=match_cmd(argv[2],record_cmds);
 			if(record_cmd==-1) goto bad_arg;
-			pf=open_sock(cache_dir);
+			pf=open_sock(sock_path);
 			send_short(pf,cmd);
 			send_short(pf,record_cmd);
 			send_string(pf,argv[1]);
@@ -406,7 +406,7 @@
 				else
 					goto bad_arg;
 			}
-			pf=open_sock(cache_dir);
+			pf=open_sock(sock_path);
 			send_short(pf,cmd);
 			send_string(pf,argv[1]);
 			send_string(pf,argv[2]);
@@ -452,7 +452,7 @@
 			}
 			if (acnt<argc)
 				goto bad_arg;
-			pf=open_sock(cache_dir);
+			pf=open_sock(sock_path);
 			send_short(pf,cmd);
 			send_short(pf,tp);
 			send_string(pf,argv[3]);
@@ -530,7 +530,7 @@
 					goto bad_arg;
 				}
 			}
-			pf=open_sock(cache_dir);
+			pf=open_sock(sock_path);
 			send_short(pf,cmd);
 			send_string(pf,argv[1]);
 			send_short(pf,tp);
@@ -541,13 +541,13 @@
 		case CTL_CONFIG:
 			if (argc>2)
 				goto wrong_args;
-			pf=open_sock(cache_dir);
+			pf=open_sock(sock_path);
 			send_short(pf,cmd);
 			send_string(pf,argc<2?NULL:argv[1]);
 			goto read_retval;
 
 		case CTL_EMPTY:
-			pf=open_sock(cache_dir);
+			pf=open_sock(sock_path);
 			send_short(pf,cmd);
 			if(argc>1) {
 				int i,totsz=0;
@@ -571,7 +571,7 @@
 		case CTL_DUMP:
 			if (argc>2)
 				goto wrong_args;
-			pf=open_sock(cache_dir);
+			pf=open_sock(sock_path);
 			send_short(pf,cmd);
 			send_string(pf,argc<2?NULL:argv[1]);
 			if((rv=read_short(pf)))
--- pdnsd-1.2.5/doc/pdnsd-ctl.8.orig	2006-12-09 20:36:07 +0500
+++ pdnsd-1.2.5/doc/pdnsd-ctl.8	2006-12-09 20:36:08 +0500
@@ -9,7 +9,7 @@
 \fBpdnsd\-ctl\fP \- controls pdnsd
 .SH SYNOPSIS
 .sp
-\fBpdnsd\-ctl\fP [\fB\-c\fP \fIcachedir\fP] [\fB\-q\fP] \fIcommand\fP [\fIoptions\fP]
+\fBpdnsd\-ctl\fP [\fB\-c\fP \fIsockpath\fP] [\fB\-q\fP] \fIcommand\fP [\fIoptions\fP]
 .SH "DESCRIPTION"
 .PP
 \fBpdnsd\-ctl\fP controls \fBpdnsd\fP, a proxy dns server with permanent caching.
@@ -18,8 +18,8 @@
 \fBpdnsd\-ctl\fP.
 .PP
 .TP
-\fB\-c\fP \fIcachedir\fP
-Set the cache directory to \fIcachedir\fP (must match pdnsd setting).
+\fB\-c\fP \fIsockpath\fP
+Set the control socket path to \fIsockpath\fP (must match pdnsd setting).
 This is only necessary if the directory differs from the default specified
 at compile time.
 .TP
 
design & coding: Vladimir Lettiev aka crux © 2004-2005