Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/dist/bind/bin/named reapply (relevant parts of) lost patch:



details:   https://anonhg.NetBSD.org/src/rev/b90dd3b151e0
branches:  trunk
changeset: 514153:b90dd3b151e0
user:      mrg <mrg%NetBSD.org@localhost>
date:      Fri Aug 24 08:37:33 2001 +0000

description:
reapply (relevant parts of) lost patch:

revision 1.3
date: 1999/02/22 02:37:27;  author: mrg;  state: Exp;  lines: +19 -1
if we are chrooting, write a symlink for the pid file so that ndc, etc,
continue to work as normal.  this allows named to run in a chroot jail
with zero loss of functionality.

diffstat:

 dist/bind/bin/named/ns_main.c |  20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diffs (34 lines):

diff -r a0d531ce2889 -r b90dd3b151e0 dist/bind/bin/named/ns_main.c
--- a/dist/bind/bin/named/ns_main.c     Fri Aug 24 06:42:46 2001 +0000
+++ b/dist/bind/bin/named/ns_main.c     Fri Aug 24 08:37:33 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ns_main.c,v 1.9 2001/05/17 22:59:40 itojun Exp $       */
+/*     $NetBSD: ns_main.c,v 1.10 2001/08/24 08:37:33 mrg Exp $ */
 
 #if !defined(lint) && !defined(SABER)
 static const char sccsid[] = "@(#)ns_main.c    4.55 (Berkeley) 7/1/91";
@@ -421,6 +421,24 @@
         */
        if (chroot_dir != NULL) {
 #ifdef HAVE_CHROOT
+               char *where;
+
+               /*
+                * first, symlink our pidfile from outside the chroot to
+                * inside, so that ndc still works properly, etc.
+                */
+               if (asprintf(&where, "%s%s", chroot_dir, _PATH_PIDFILE) < 0) {
+                       fprintf(stderr, "malloc failed: %s\n", strerror(errno));
+                       exit(1);
+               }
+               (void)unlink(_PATH_PIDFILE);
+               if (symlink(where, _PATH_PIDFILE) < 0) {
+                       fprintf(stderr, "symlink %s -> %s failed: %s\n",
+                               _PATH_PIDFILE, where, strerror(errno));
+                       exit(1);
+               }
+               free(where);
+
                if (chroot(chroot_dir) < 0) {
                        fprintf(stderr, "chroot %s failed: %s\n", chroot_dir,
                                strerror(errno));



Home | Main Index | Thread Index | Old Index