Browse Source

Add proper SUID bit detection (fixes #416)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2436 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.23
Stefan Bühler 13 years ago
parent
commit
9c7cdb8011
  1. 1
      NEWS
  2. 1
      configure.ac
  3. 1
      src/CMakeLists.txt
  4. 1
      src/config.h.cmake
  5. 13
      src/server.c

1
NEWS

@ -15,6 +15,7 @@ NEWS
* Remove the optional port info from SERVER_NAME (thx Mr_Bond)
* Fix mod_proxy RoundRobin (off by one problem if only one backend is up)
* Rename configure.in to configure.ac, with small cleanups (fixes #1932)
* Add proper SUID bit detection (fixes #416)
- 1.4.22 - 2009-03-07
* Fix wrong lua type for CACHE_MISS/CACHE_HIT in mod_cml (fixes #533)

1
configure.ac

@ -77,6 +77,7 @@ dnl AC_FUNC_REALLOC
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_FUNC_STRFTIME
AC_CHECK_FUNCS([issetugid])
dnl Checks for database.
MYSQL_INCLUDE=""

1
src/CMakeLists.txt

@ -145,6 +145,7 @@ CHECK_C_SOURCE_COMPILES("
struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;
return 0;
}" HAVE_IPV6)
CHECK_FUNCTION_EXISTS(issetugid HAVE_ISSETUGID)
## refactor me
MACRO(XCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags)

1
src/config.h.cmake

@ -30,6 +30,7 @@
#cmakedefine HAVE_PTHREAD_H
#cmakedefine HAVE_INET_ATON
#cmakedefine HAVE_IPV6
#cmakedefine HAVE_ISSETUGID
/* XATTR */
#cmakedefine HAVE_ATTR_ATTRIBUTES_H

13
src/server.c

@ -64,6 +64,17 @@
/* #define USE_ALARM */
#endif
#ifdef HAVE_GETUID
# ifndef HAVE_ISSETUGID
static int l_issetugid() {
return (geteuid() != getuid() || getegid() != getgid());
}
# define issetugid l_issetugid
# endif
#endif
static volatile sig_atomic_t srv_shutdown = 0;
static volatile sig_atomic_t graceful_shutdown = 0;
static volatile sig_atomic_t handle_sig_alarm = 1;
@ -589,7 +600,7 @@ int main (int argc, char **argv) {
/* UID handling */
#ifdef HAVE_GETUID
if (!i_am_root && (geteuid() == 0 || getegid() == 0)) {
if (!i_am_root && issetugid()) {
/* we are setuid-root */
log_error_write(srv, __FILE__, __LINE__, "s",

Loading…
Cancel
Save