Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
BIND
Commits
c7b1e7fd
Commit
c7b1e7fd
authored
Sep 05, 2018
by
Ondřej Surý
Browse files
Linux (glibc) has NPTL since LinuxThreads are no-more, so remove HAVE_LINUXTHREADS
parent
2f02552a
Changes
8
Hide whitespace changes
Inline
Side-by-side
PLATFORMS.md
View file @
c7b1e7fd
...
...
@@ -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)
acconfig.h
View file @
c7b1e7fd
...
...
@@ -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
...
...
bin/named/unix/os.c
View file @
c7b1e7fd
...
...
@@ -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
def
ined(__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
);
}
...
...
config.h.in
View file @
c7b1e7fd
...
...
@@ -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
...
...
config.h.win32
View file @
c7b1e7fd
...
...
@@ -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 */
...
...
configure
View file @
c7b1e7fd
...
...
@@ -15325,14 +15325,6 @@ fi
;;
esac
;;
#
# LinuxThreads requires some changes to the way we
# deal with signals.
#
*-linux*)
$as_echo "#define HAVE_LINUXTHREADS 1" >>confdefs.h
;;
esac
...
...
configure.in
View file @
c7b1e7fd
...
...
@@ -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
...
...
lib/isc/unix/app.c
View file @
c7b1e7fd
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment