]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Try and fix -C unlang lsan
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 18 Jul 2018 00:52:32 +0000 (20:52 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 18 Jul 2018 00:52:32 +0000 (20:52 -0400)
src/bin/radiusd.c
src/lib/server/base.h
src/lib/server/util.c
src/lib/util/debug.c

index b3520b63f3f926f103fd3f326250aae10aed46aa..789c9f14b30118c7184e328440c204c8448eb172 100644 (file)
@@ -893,11 +893,19 @@ cleanup:
        fr_strerror_free();
 
        /*
-        *  Anything not cleaned up by the above is allocated in the NULL
-        *  top level context, and is likely leaked memory.
+        *      Anything not cleaned up by the above is
+        *      allocated in the NULL top level context,
+        *      and is likely leaked memory.
         */
        if (talloc_memory_report) fr_log_talloc_report(NULL);
 
+       /*
+        *      If we're running under LSAN, try and SUID
+        *      back up so we don't inteferere with the
+        *      onexit() handler.
+        */
+       if (!rad_suid_is_down_permanent() && (fr_get_lsan_state() == 1)) rad_suid_up();
+
        return ret;
 }
 
index 415add33aeb853aef3655069e121015c33ee880a..5aba8701e78b9225a4ea8066b6b7c08ce6ea7242 100644 (file)
@@ -78,8 +78,6 @@ extern "C" {
  */
 typedef struct request_data_t request_data_t;
 
-
-
 /** Return codes indicating the result of the module call
  *
  * All module functions must return one of the codes listed below (apart from
@@ -449,6 +447,7 @@ void                rad_suid_set_down_uid(uid_t uid);
 void           rad_suid_down(void);
 void           rad_suid_up(void);
 void           rad_suid_down_permanent(void);
+bool           rad_suid_is_down_permanent(void);
 /* regex.c */
 
 #ifdef HAVE_REGEX
index 35bf96e4e1c01c1ef3e6753e3a421a2d2b376558..2975b065e498c2bad083e2fac6b5669818325c84 100644 (file)
@@ -31,6 +31,8 @@ RCSID("$Id$")
 #include <sys/stat.h>
 #include <fcntl.h>
 
+static bool suid_down_permanent = false;       //!< Record whether we've permanently dropped privilledges
+
 /*
  *     The signal() function in Solaris 2.5.1 sets SA_NODEFER in
  *     sa_flags, which causes grief if signal() is called in the
@@ -1362,6 +1364,8 @@ void rad_suid_down_permanent(void)
        }
 
        fr_reset_dumpable();
+
+       suid_down_permanent = true;
 }
 #  else
 /*
@@ -1425,25 +1429,41 @@ void rad_suid_down_permanent(void)
        }
 
        fr_reset_dumpable();
+
+       suid_down_permanent = true;
 }
 #  endif /* HAVE_SETRESUID && HAVE_GETRESUID */
 #else  /* HAVE_SETUID */
 void rad_suid_set_down_uid(uid_t uid)
 {
 }
+
 void rad_suid_up(void)
 {
 }
+
 void rad_suid_down(void)
 {
        fr_reset_dumpable();
 }
+
 void rad_suid_down_permanent(void)
 {
        fr_reset_dumpable();
 }
 #endif /* HAVE_SETUID */
 
+/** Return whether we've permanently dropped root privileges
+ *
+ * @return
+ *     - true if root privileges have been dropped.
+ *     - false if root privileges have not been dropped.
+ */
+bool rad_suid_is_down_permanent(void)
+{
+       return suid_down_permanent;
+}
+
 /** Alter the effective user id
  *
  * @param uid to set
index da4206e2386290ff72328045dbaa8279eb48ebf5..f5280a7c43ca76c9889be4e3bfa11c58ff385930 100644 (file)
@@ -947,8 +947,8 @@ int fr_log_talloc_report(TALLOC_CTX const *ctx)
 {
 #define TALLOC_REPORT_MAX_DEPTH 20
 
-       FILE *log;
-       int fd;
+       FILE    *log;
+       int     fd;
 
        fd = dup(fr_fault_log_fd);
        if (fd < 0) {