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;
}
*/
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
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
#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
}
fr_reset_dumpable();
+
+ suid_down_permanent = true;
}
# else
/*
}
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
{
#define TALLOC_REPORT_MAX_DEPTH 20
- FILE *log;
- int fd;
+ FILE *log;
+ int fd;
fd = dup(fr_fault_log_fd);
if (fd < 0) {