]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Linux (glibc) has NPTL since LinuxThreads are no-more, so remove HAVE_LINUXTHREADS
authorOndřej Surý <ondrej@sury.org>
Wed, 5 Sep 2018 11:24:15 +0000 (13:24 +0200)
committerOndřej Surý <ondrej@sury.org>
Fri, 7 Sep 2018 10:17:40 +0000 (12:17 +0200)
PLATFORMS.md
acconfig.h
bin/named/unix/os.c
config.h.in
config.h.win32
configure
configure.in
lib/isc/unix/app.c

index 6f2c0deaf6003b98b5268adbb9c64b5b870dd31a..840af14b34d3c8c4afb00abde1466e837f5ed7e5 100644 (file)
@@ -66,3 +66,4 @@ These are platforms on which BIND is known *not* to build or run:
 * Windows Server 2012 and older
 * Platforms that don't support IPv6 Advanced Socket API (RFC 3542)
 * Platforms that don't support atomic operations (via compiler or library)
+* Linux without NPTL (Native POSIX Thread Library)
index ee05bbc862d41c3eacf6d1b62c4042752e047aec..4b1304f2734dca9f90c470028bd47dd63a8d216e 100644 (file)
@@ -23,9 +23,6 @@
 /** define if sigwait() is the UnixWare flavor */
 #undef HAVE_UNIXWARE_SIGWAIT
 
-/** define if LinuxThreads is in use */
-#undef HAVE_LINUXTHREADS
-
 /** define if sysconf() is available */
 #undef HAVE_SYSCONF
 
index 00052e8cf8c4a44bcea38ed9e67629f52e955e15..1571b88be9ed306b235951619234e22d87818527 100644 (file)
@@ -68,7 +68,6 @@ static int singletonfd = -1;
 
 /*
  * Linux defines:
- *     (T) HAVE_LINUXTHREADS
  *     (C) HAVE_SYS_CAPABILITY_H
  *     (P) HAVE_SYS_PRCTL_H
  * The possible cases are:
@@ -103,10 +102,6 @@ static int singletonfd = -1;
  * It will be nice when Linux threads work properly with setuid().
  */
 
-#ifdef HAVE_LINUXTHREADS
-static pid_t mainpid = 0;
-#endif
-
 static struct passwd *runas_pw = NULL;
 static bool done_setuid = false;
 static int dfd[2] = { -1, -1 };
@@ -201,7 +196,7 @@ linux_initialprivs(void) {
         */
        SET_CAP(CAP_SYS_CHROOT);
 
-#if defined(HAVE_SYS_PRCTL_H) || !defined(HAVE_LINUXTHREADS)
+#if defined(HAVE_SYS_PRCTL_H)
        /*
         * We can setuid() only if either the kernel supports keeping
         * capabilities after setuid() (which we don't know until we've
@@ -317,9 +312,6 @@ named_os_init(const char *progname) {
 #ifdef HAVE_SYS_CAPABILITY_H
        linux_initialprivs();
 #endif
-#ifdef HAVE_LINUXTHREADS
-       mainpid = getpid();
-#endif
 #ifdef SIGXFSZ
        signal(SIGXFSZ, SIG_IGN);
 #endif
@@ -362,10 +354,6 @@ named_os_daemonize(void) {
         * We're the child.
         */
 
-#ifdef HAVE_LINUXTHREADS
-       mainpid = getpid();
-#endif
-
        if (setsid() == -1) {
                strerror_r(errno, strbuf, sizeof(strbuf));
                named_main_earlyfatal("setsid(): %s", strbuf);
@@ -499,20 +487,6 @@ named_os_changeuser(void) {
 
        done_setuid = true;
 
-#ifdef HAVE_LINUXTHREADS
-#ifdef HAVE_SYS_CAPABILITY_H
-       if (!non_root_caps) {
-               named_main_earlyfatal("-u with Linux threads not supported: "
-                                     "requires kernel support for "
-                                     "prctl(PR_SET_KEEPCAPS)");
-       }
-#else
-       named_main_earlyfatal("-u with Linux threads not supported: "
-                             "no capabilities support or capabilities "
-                             "disabled at build time");
-#endif
-#endif
-
        if (setgid(runas_pw->pw_gid) < 0) {
                strerror_r(errno, strbuf, sizeof(strbuf));
                named_main_earlyfatal("setgid(): %s", strbuf);
@@ -534,7 +508,7 @@ named_os_changeuser(void) {
                                        strbuf);
        }
 #endif
-#if defined(HAVE_SYS_CAPABILITY_H) && !defined(HAVE_LINUXTHREADS)
+#if defined(HAVE_SYS_CAPABILITY_H)
        linux_minprivs();
 #endif
 }
@@ -548,7 +522,7 @@ ns_os_uid(void) {
 
 void
 named_os_adjustnofile(void) {
-#ifdef HAVE_LINUXTHREADS
+#if defined(__linux__)
        isc_result_t result;
        isc_resourcevalue_t newvalue;
 
@@ -570,11 +544,7 @@ named_os_minprivs(void) {
        linux_keepcaps();
 #endif
 
-#ifdef HAVE_LINUXTHREADS
-       named_os_changeuser(); /* Call setuid() before threads are started */
-#endif
-
-#if defined(HAVE_SYS_CAPABILITY_H) && defined(HAVE_LINUXTHREADS)
+#if defined(HAVE_SYS_CAPABILITY_H)
        linux_minprivs();
 #endif
 }
@@ -759,21 +729,16 @@ named_os_openfile(const char *filename, mode_t mode, bool switch_user) {
        free(f);
 
        if (switch_user && runas_pw != NULL) {
-#ifndef HAVE_LINUXTHREADS
                gid_t oldgid = getgid();
-#endif
                /* Set UID/GID to the one we'll be running with eventually */
                setperms(runas_pw->pw_uid, runas_pw->pw_gid);
 
                fd = safe_open(filename, mode, false);
 
-#ifndef HAVE_LINUXTHREADS
                /* Restore UID/GID to root */
                setperms(0, oldgid);
-#endif /* HAVE_LINUXTHREADS */
 
                if (fd == -1) {
-#ifndef HAVE_LINUXTHREADS
                        fd = safe_open(filename, mode, false);
                        if (fd != -1) {
                                named_main_earlywarning("Required root "
@@ -786,13 +751,6 @@ named_os_openfile(const char *filename, mode_t mode, bool switch_user) {
                        named_main_earlywarning("Please check file and "
                                                "directory permissions "
                                                "or reconfigure the filename.");
-#else /* HAVE_LINUXTHREADS */
-                       named_main_earlywarning("Could not open "
-                                               "'%s'.", filename);
-                       named_main_earlywarning("Please check file and "
-                                               "directory permissions "
-                                               "or reconfigure the filename.");
-#endif /* HAVE_LINUXTHREADS */
                }
        } else {
                fd = safe_open(filename, mode, false);
@@ -846,11 +804,7 @@ named_os_writepidfile(const char *filename, bool first_time) {
                cleanup_pidfile();
                return;
        }
-#ifdef HAVE_LINUXTHREADS
-       pid = mainpid;
-#else
        pid = getpid();
-#endif
        if (fprintf(fh, "%ld\n", (long)pid) < 0) {
                (*report)("fprintf() to pid file '%s' failed", filename);
                (void)fclose(fh);
@@ -956,11 +910,7 @@ named_os_shutdownmsg(char *command, isc_buffer_t *text) {
                return;
        }
 
-#ifdef HAVE_LINUXTHREADS
-       pid = mainpid;
-#else
        pid = getpid();
-#endif
 
        (void)isc_buffer_printf(text, "pid: %ld", (long)pid);
 }
index 0c5941ff64051357dca9074e7bda6b4d28077936..c5283ae70e53d0dc8fbecc2cd00762ec2e746bc4 100644 (file)
@@ -23,9 +23,6 @@
 /** define if sigwait() is the UnixWare flavor */
 #undef HAVE_UNIXWARE_SIGWAIT
 
-/** define if LinuxThreads is in use */
-#undef HAVE_LINUXTHREADS
-
 /** define if sysconf() is available */
 #undef HAVE_SYSCONF
 
index fe881f50cd931e9e0dde3a6ebf22cae7e0ec755e..15d42b928bde5ec4d28d51f7012c3cdda9f07e9a 100644 (file)
@@ -73,9 +73,6 @@
 /* define on Solaris to get sigwait() to work using pthreads semantics */
 /* #undef _POSIX_PTHREAD_SEMANTICS */
 
-/* define if LinuxThreads is in use */
-/* #undef HAVE_LINUXTHREADS */
-
 /* define if catgets() is available */
 /* #undef HAVE_CATGETS */
 
index 41d04d9ce83874fc0ecbc584868f8690038ec248..dda2137af9f67291806d02df3d07529f237e4598 100755 (executable)
--- a/configure
+++ b/configure
 
                        ;;
                esac
-               ;;
-       #
-       # LinuxThreads requires some changes to the way we
-       # deal with signals.
-       #
-       *-linux*)
-               $as_echo "#define HAVE_LINUXTHREADS 1" >>confdefs.h
-
                ;;
 esac
 
index 29cb31ca6a3bfa9c5b50170c80a7a80aad9ee0be..ce82ce1dc0ac61e7e53be3554b4aec97e8fa9fb0 100644 (file)
@@ -752,13 +752,6 @@ case "$host" in
                        ;;
                esac
                ;;
-       #
-       # LinuxThreads requires some changes to the way we
-       # deal with signals.
-       #
-       *-linux*)
-               AC_DEFINE(HAVE_LINUXTHREADS)
-               ;;
 esac
 
 # Look for functions relating to thread naming
index db82bdd6afb48eeafea9c2a71ae66319a89b8867..a02311f7fcd81d4d7e5e1ce1d532ccebc174fa9f 100644 (file)
@@ -144,20 +144,6 @@ static struct {
        (void *)isc__app_unblock
 };
 
-#ifdef HAVE_LINUXTHREADS
-/*!
- * Linux has sigwait(), but it appears to prevent signal handlers from
- * running, even if they're not in the set being waited for.  This makes
- * it impossible to get the default actions for SIGILL, SIGSEGV, etc.
- * Instead of messing with it, we just use sigsuspend() instead.
- */
-#undef HAVE_SIGWAIT
-/*!
- * We need to remember which thread is the main thread...
- */
-static pthread_t               main_thread;
-#endif
-
 #ifndef HAVE_SIGWAIT
 static void
 exit_action(int arg) {
@@ -208,10 +194,6 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
         * Start an ISC library application.
         */
 
-#ifdef HAVE_LINUXTHREADS
-       main_thread = pthread_self();
-#endif /* HAVE_LINUXTHREADS */
-
        result = isc_mutex_init(&ctx->readylock);
        if (result != ISC_R_SUCCESS)
                return (result);
@@ -388,10 +370,6 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
 
        REQUIRE(VALID_APPCTX(ctx));
 
-#ifdef HAVE_LINUXTHREADS
-       REQUIRE(main_thread == pthread_self());
-#endif
-
        LOCK(&ctx->lock);
 
        if (!ctx->running) {
@@ -564,23 +542,6 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
                        /* BIND9 internal, but using multiple contexts */
                        ctx->want_shutdown = true;
                else {
-#ifdef HAVE_LINUXTHREADS
-                       if (isc_bind9) {
-                               /* BIND9 internal, single context */
-                               int result;
-
-                               result = pthread_kill(main_thread, SIGTERM);
-                               if (result != 0) {
-                                       strerror_r(result,
-                                                     strbuf, sizeof(strbuf));
-                                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                                        "isc_app_shutdown() "
-                                                        "pthread_kill: %s",
-                                                        strbuf);
-                                       return (ISC_R_UNEXPECTED);
-                               }
-                       }
-#else
                        if (isc_bind9) {
                                /* BIND9 internal, single context */
                                if (kill(getpid(), SIGTERM) < 0) {
@@ -592,7 +553,6 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
                                        return (ISC_R_UNEXPECTED);
                                }
                        }
-#endif /* HAVE_LINUXTHREADS */
                        else {
                                /* External, multiple contexts */
                                LOCK(&ctx->readylock);
@@ -637,23 +597,6 @@ isc__app_ctxsuspend(isc_appctx_t *ctx0) {
                        ctx->want_reload = true;
                else {
                        ctx->want_reload = true;
-#ifdef HAVE_LINUXTHREADS
-                       if (isc_bind9) {
-                               /* BIND9 internal, single context */
-                               int result;
-
-                               result = pthread_kill(main_thread, SIGHUP);
-                               if (result != 0) {
-                                       strerror_r(result,
-                                                     strbuf, sizeof(strbuf));
-                                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                                        "isc_app_reload() "
-                                                        "pthread_kill: %s",
-                                                        strbuf);
-                                       return (ISC_R_UNEXPECTED);
-                               }
-                       }
-#else
                        if (isc_bind9) {
                                /* BIND9 internal, single context */
                                if (kill(getpid(), SIGHUP) < 0) {
@@ -665,7 +608,6 @@ isc__app_ctxsuspend(isc_appctx_t *ctx0) {
                                        return (ISC_R_UNEXPECTED);
                                }
                        }
-#endif /* HAVE_LINUXTHREADS */
                        else {
                                /* External, multiple contexts */
                                LOCK(&ctx->readylock);