Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37417286
en ru br
ALT Linux repositórios
S:9.16.44-alt1
5.0: 9.3.6-alt5
4.1: 9.3.6-alt4.M41.2
+updates:9.3.6-alt4.M41.1
4.0: 9.3.6-alt4.M41.1
+updates:9.3.6-alt4.M41.1
3.0: 9.2.4.rel-alt2

Group :: Sistema/Servidores
RPM: bind

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

Patch: bind-9.2.4rc5-obsd-pidfile.patch
Download


diff -uprk.orig bind-9.2.4rc5.orig/bin/named/include/named/globals.h bind-9.2.4rc5/bin/named/include/named/globals.h
--- bind-9.2.4rc5.orig/bin/named/include/named/globals.h	2004-03-09 09:09:21 +0300
+++ bind-9.2.4rc5/bin/named/include/named/globals.h	2004-06-30 18:18:25 +0400
@@ -105,6 +105,8 @@ EXTERN const char *		ns_g_defaultpidfile
 							     "/run/named.pid");
 EXTERN const char *		lwresd_g_defaultpidfile INIT(NS_LOCALSTATEDIR
 							    "/run/lwresd.pid");
+EXTERN const char *		ns_g_pidfile		INIT(NS_LOCALSTATEDIR
+								"/run/named.pid");
 EXTERN const char *		ns_g_username		INIT(NULL);
 
 #undef EXTERN
diff -uprk.orig bind-9.2.4rc5.orig/bin/named/main.c bind-9.2.4rc5/bin/named/main.c
--- bind-9.2.4rc5.orig/bin/named/main.c	2004-04-20 17:54:17 +0400
+++ bind-9.2.4rc5/bin/named/main.c	2004-06-30 18:18:25 +0400
@@ -231,7 +231,7 @@ usage(void) {
 	fprintf(stderr,
 		"usage: named [-c conffile] [-d debuglevel] "
 		"[-f|-g] [-n number_of_cpus]\n"
-		"             [-p port] [-s] [-t chrootdir] [-u username]\n");
+		"             [-p port] [-s] [-t chrootdir] [-u username] [-i pidfile]\n");
 }
 
 static void
@@ -328,9 +328,8 @@ parse_command_line(int argc, char *argv[
 			ns_g_foreground = ISC_TRUE;
 			ns_g_logstderr = ISC_TRUE;
 			break;
-		/* XXXBEW -i should be removed */
 		case 'i':
-			lwresd_g_defaultpidfile = isc_commandline_argument;
+			ns_g_pidfile = isc_commandline_argument;
 			break;
 		case 'l':
 			ns_g_lwresdonly = ISC_TRUE;
@@ -471,6 +470,12 @@ static void
 setup(void) {
 	isc_result_t result;
 
+        /*
+	 * Write pidfile before chroot if specified on the command line
+	 */
+	if (ns_g_pidfile != NULL)
+		ns_os_preopenpidfile(ns_g_pidfile);
+
 	/*
 	 * Get the user and group information before changing the root
 	 * directory, so the administrator does not need to keep a copy
diff -uprk.orig bind-9.2.4rc5.orig/bin/named/server.c bind-9.2.4rc5/bin/named/server.c
--- bind-9.2.4rc5.orig/bin/named/server.c	2004-06-30 18:18:05 +0400
+++ bind-9.2.4rc5/bin/named/server.c	2004-06-30 18:18:25 +0400
@@ -2177,13 +2177,17 @@ load_configuration(const char *filename,
 		}
 	}
 
-	obj = NULL;
-	if (ns_config_get(maps, "pid-file", &obj) == ISC_R_SUCCESS)
-		ns_os_writepidfile(cfg_obj_asstring(obj), first_time);
-	else if (ns_g_lwresdonly)
-		ns_os_writepidfile(lwresd_g_defaultpidfile, first_time);
-	else
-		ns_os_writepidfile(ns_g_defaultpidfile, first_time);
+	if (ns_g_pidfile != NULL) {
+		ns_os_writepidfile(ns_g_pidfile, first_time);
+	} else {
+		obj = NULL;
+		if (ns_config_get(maps, "pid-file", &obj) == ISC_R_SUCCESS)
+			ns_os_writepidfile(cfg_obj_asstring(obj), first_time);
+		else if (ns_g_lwresdonly)
+			ns_os_writepidfile(lwresd_g_defaultpidfile, first_time);
+		else
+			ns_os_writepidfile(ns_g_defaultpidfile, first_time);
+	}
 
 	obj = NULL;
 	result = ns_config_get(maps, "statistics-file", &obj);
diff -uprk.orig bind-9.2.4rc5.orig/bin/named/unix/include/named/os.h bind-9.2.4rc5/bin/named/unix/include/named/os.h
--- bind-9.2.4rc5.orig/bin/named/unix/include/named/os.h	2004-06-30 18:18:05 +0400
+++ bind-9.2.4rc5/bin/named/unix/include/named/os.h	2004-06-30 18:18:25 +0400
@@ -53,6 +53,9 @@ int
 ns_os_open_randomdev(void);
 
 void
+ns_os_preopenpidfile(const char *filename);
+
+void
 ns_os_writepidfile(const char *filename, isc_boolean_t first_time);
 
 void
diff -uprk.orig bind-9.2.4rc5.orig/bin/named/unix/os.c bind-9.2.4rc5/bin/named/unix/os.c
--- bind-9.2.4rc5.orig/bin/named/unix/os.c	2004-06-30 18:18:05 +0400
+++ bind-9.2.4rc5/bin/named/unix/os.c	2004-06-30 18:19:26 +0400
@@ -47,6 +47,8 @@
 #include <named/os.h>
 
 static char *pidfile = NULL;
+static int pidfilefd = -1;
+static isc_boolean_t preopenpidfile = ISC_FALSE;
 static int devnullfd = -1;
 
 /*
@@ -512,19 +514,13 @@ cleanup_pidfile(void) {
 	pidfile = NULL;
 }
 
-void
-ns_os_writepidfile(const char *filename, isc_boolean_t first_time) {
+static int
+open_pidfile(const char *filename, isc_boolean_t first_time) {
 	int fd;
-	FILE *lockfile;
 	size_t len;
-	pid_t pid;
 	char strbuf[ISC_STRERRORSIZE];
 	void (*report)(const char *, ...);
 
-	/*
-	 * The caller must ensure any required synchronization.
-	 */
-
 	report = first_time ? ns_main_earlyfatal : ns_main_earlywarning;
 
 	cleanup_pidfile();
@@ -534,7 +530,7 @@ ns_os_writepidfile(const char *filename,
 	if (pidfile == NULL) {
 		isc__strerror(errno, strbuf, sizeof(strbuf));
 		(*report)("couldn't malloc '%s': %s", filename, strbuf);
-		return;
+		return -1;
 	}
 	/* This is safe. */
 	strcpy(pidfile, filename);
@@ -545,15 +541,46 @@ ns_os_writepidfile(const char *filename,
 		(*report)("couldn't open pid file '%s': %s", filename, strbuf);
 		free(pidfile);
 		pidfile = NULL;
-		return;
+		return -1;
 	}
+
+	return fd;
+}
+
+void
+ns_os_preopenpidfile(const char *filename) {
+	pidfilefd = open_pidfile(filename, ISC_TRUE);
+	preopenpidfile = ISC_TRUE;
+}
+
+void
+ns_os_writepidfile(const char *filename, isc_boolean_t first_time) {
+	int fd;
+	FILE *lockfile;
+	pid_t pid;
+	char strbuf[ISC_STRERRORSIZE];
+	void (*report)(const char *, ...);
+
+	/*
+	 * The caller must ensure any required synchronization.
+	 */
+
+	report = first_time ? ns_main_earlyfatal : ns_main_earlywarning;
+
+	if (preopenpidfile == ISC_TRUE)
+		fd = pidfilefd;
+	else
+		fd = open_pidfile(filename, first_time);
+
+	if (fd < 0) return;
+
 	lockfile = fdopen(fd, "w");
 	if (lockfile == NULL) {
 		isc__strerror(errno, strbuf, sizeof(strbuf));
 		(*report)("could not fdopen() pid file '%s': %s",
 			  filename, strbuf);
 		(void)close(fd);
-		cleanup_pidfile();
+		if (preopenpidfile == ISC_FALSE) cleanup_pidfile();
 		return;
 	}
 #ifdef HAVE_LINUXTHREADS
@@ -564,22 +591,23 @@ ns_os_writepidfile(const char *filename,
 	if (fprintf(lockfile, "%ld\n", (long)pid) < 0) {
 		(*report)("fprintf() to pid file '%s' failed", filename);
 		(void)fclose(lockfile);
-		cleanup_pidfile();
+		if (preopenpidfile == ISC_FALSE) cleanup_pidfile();
 		return;
 	}
 	if (fflush(lockfile) == EOF) {
 		(*report)("fflush() to pid file '%s' failed", filename);
 		(void)fclose(lockfile);
-		cleanup_pidfile();
+		if (preopenpidfile == ISC_FALSE) cleanup_pidfile();
 		return;
 	}
 	(void)fclose(lockfile);
+	if (preopenpidfile == ISC_TRUE) pidfilefd = -1;
 }
 
 void
 ns_os_shutdown(void) {
 	closelog();
-	cleanup_pidfile();
+	if (preopenpidfile == ISC_FALSE) cleanup_pidfile();
 }
 
 void
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009