Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37657562
en ru br
Репозитории ALT
S:1.2.9a-alt2
5.1: 1.2.7-alt1
4.1: 1.2.6-alt1
4.0: 1.2.5-alt1
3.0: 1.2-alt1
www.altlinux.org/Changes

Группа :: Система/Серверы
Пакет: pdnsd

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

Патч: pdnsd-1.2.7-alt-sock_path.patch
Скачать


--- pdnsd/acconfig.h.orig	2006-03-27 21:17:04 +0600
+++ pdnsd/acconfig.h	2008-09-06 17:26:50 +0600
@@ -119,6 +119,7 @@
 #define CACHE_DBM DBM_NATIVE
 
 #define CACHEDIR "/var/cache/pdnsd"
+#define SOCKPATH "/var/run/pdnsd/socket"
 
 #define TEMPDIR "/tmp";
 
--- pdnsd/configure.in.orig	2007-07-29 18:23:54 +0600
+++ pdnsd/configure.in	2008-09-06 17:26:50 +0600
@@ -10,6 +10,7 @@ rpmspecrelease=`cut -d - -f 2- $srcdir/v
 distribution="Generic"
 target="autodetect"
 cachedir="/var/cache/$PACKAGE"
+sockpath="/var/run/$PACKAGE/socket"
 ipv4_default=1
 have_ipv4="yes"
 newrr="yes"
@@ -61,6 +62,11 @@ case $target in
     ;;
 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/doc/pdnsd-ctl.8.orig	2008-09-04 16:58:03 +0600
+++ pdnsd/doc/pdnsd-ctl.8	2008-09-06 17:27:15 +0600
@@ -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 [\fIarguments\fP]
+\fBpdnsd\-ctl\fP [\fB\-c\fP \fIsockpath\fP] [\fB\-q\fP] \fIcommand\fP [\fIarguments\fP]
 .SH "DESCRIPTION"
 .PP
 \fBpdnsd\-ctl\fP controls \fBpdnsd\fP, a proxy dns server with permanent caching.
@@ -18,8 +18,8 @@ the pdnsd command line or in the configu
 \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
--- pdnsd/src/conf-keywords.h.orig	2008-08-10 17:09:59 +0600
+++ pdnsd/src/conf-keywords.h	2008-09-06 17:26:50 +0600
@@ -32,6 +32,7 @@ enum {
 	
 	PERM_CACHE,
 	CACHE_DIR,
+	SOCK_PATH,
 	SERVER_PORT,
 	SERVER_IP,
 	SCHEME_FILE,
@@ -146,6 +147,7 @@ static const namevalue_t global_options[
 	{"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/src/conf-parser.c.orig	2008-08-26 14:51:04 +0600
+++ pdnsd/src/conf-parser.c	2008-09-06 17:26:50 +0600
@@ -548,6 +548,11 @@ int confparse(FILE* in, char *prestr, gl
 	    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/src/conff.c.orig	2008-07-31 22:44:57 +0600
+++ pdnsd/src/conff.c	2008-09-06 17:26:50 +0600
@@ -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
@@ -233,6 +236,7 @@ int reload_config_file(const char *nm, c
 
 	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;
@@ -244,6 +248,11 @@ int reload_config_file(const char *nm, c
 				       "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.");
@@ -330,6 +339,7 @@ int reload_config_file(const char *nm, c
 			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);
@@ -346,6 +356,7 @@ int reload_config_file(const char *nm, c
 
  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);
@@ -409,6 +420,7 @@ int report_conf_stat(int f)
 	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/src/conff.h.orig	2008-05-12 21:21:09 +0600
+++ pdnsd/src/conff.h	2008-09-06 17:26:50 +0600
@@ -118,6 +118,7 @@ typedef DYNAMIC_ARRAY(zone_t) *zone_arra
 typedef struct {
 	long          perm_cache;
 	char         *cache_dir;
+	char         *sock_path;
 	char         *pidfile;
 	int           port;
 	pdnsd_a       a;
--- pdnsd/src/main.c.orig	2008-07-25 20:07:25 +0600
+++ pdnsd/src/main.c	2008-09-06 17:26:50 +0600
@@ -70,7 +70,6 @@ FILE *dbg_file=NULL;
 volatile int tcp_socket=-1;
 volatile int udp_socket=-1;
 sigset_t sigs_msk;
-char *conf_file=CONFDIR"/pdnsd.conf";
 
 
 /* version and licensing information */
@@ -441,6 +440,7 @@ int main(int argc,char *argv[])
 	}
 
 	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;
 
@@ -711,8 +711,6 @@ int main(int argc,char *argv[])
 #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/src/pdnsd-ctl/pdnsd-ctl.c.orig	2008-09-04 17:37:54 +0600
+++ pdnsd/src/pdnsd-ctl/pdnsd-ctl.c	2008-09-06 17:29:42 +0600
@@ -106,11 +106,11 @@ static const char license_statement[] =
 
 static const char *help_messages[] =
 {
-	"Usage: pdnsd-ctl [-c cachedir] [-q] <command> [arguments]\n\n"
+	"Usage: pdnsd-ctl [-c sockpath] [-q] <command> [arguments]\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\n"
 
 	"Commands and needed arguments are:\n"
@@ -225,7 +225,7 @@ static const char *help_messages[] =
 
 #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;
@@ -236,10 +236,10 @@ static int open_sock(const char *cache_d
 		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));
@@ -321,7 +321,7 @@ static int match_cmd(const char *cmd, co
 
 int main(int argc, char *argv[])
 {
-	char *cache_dir= CACHEDIR;
+	char *sock_path= SOCKPATH;
 	int rv=0;
 	{
 		int i;
@@ -329,7 +329,7 @@ int main(int argc, char *argv[])
 		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");
@@ -388,7 +388,7 @@ int main(int argc, char *argv[])
 		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;
 
@@ -399,7 +399,7 @@ int main(int argc, char *argv[])
 			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);
@@ -414,7 +414,7 @@ int main(int argc, char *argv[])
 			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]);
@@ -448,7 +448,7 @@ int main(int argc, char *argv[])
 				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]);
@@ -577,7 +577,7 @@ int main(int argc, char *argv[])
 					break;
 				}
 
-				pf=open_sock(cache_dir);
+				pf=open_sock(sock_path);
 				send_short(pf,cmd);
 				send_short(pf,tp);
 				send_string(pf,argv[3]);
@@ -636,7 +636,7 @@ int main(int argc, char *argv[])
 					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);
@@ -647,7 +647,7 @@ int main(int argc, char *argv[])
 		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;
@@ -655,7 +655,7 @@ int main(int argc, char *argv[])
 		case CTL_INCLUDE:
 			if (argc!=2)
 				goto wrong_args;
-			pf=open_sock(cache_dir);
+			pf=open_sock(sock_path);
 			send_short(pf,cmd);
 			send_string(pf,argv[1]);
 			goto read_retval;
@@ -665,7 +665,7 @@ int main(int argc, char *argv[])
 
 			if (argc<2)
 				goto wrong_args;
-			pf=open_sock(cache_dir);
+			pf=open_sock(sock_path);
 			send_short(pf,cmd);
 			bufsz=0;
 			for(i=1;i<argc;++i)
@@ -689,7 +689,7 @@ int main(int argc, char *argv[])
 			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; size_t totsz=0;
@@ -713,7 +713,7 @@ int main(int argc, char *argv[])
 		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/src/status.c.orig	2008-05-12 21:22:15 +0600
+++ pdnsd/src/status.c	2008-09-06 17:26:50 +0600
@@ -57,7 +57,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;
 
 
@@ -759,10 +758,10 @@ void init_stat_sock()
 	   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));
@@ -788,8 +787,6 @@ void init_stat_sock()
 		}
 		umask(old_mask);
 	}
-
-	if(stat_pipe) sock_path= strdup(sa->sun_path);
 }
 
 /*
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin