]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add trampoline functions for SUID up/down
authorAlan T. DeKok <aland@freeradius.org>
Sun, 8 Feb 2026 15:48:44 +0000 (10:48 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 8 Feb 2026 15:48:44 +0000 (10:48 -0500)
some libraries should call suid up/down, but we don't want to
link them to libfreeradius-server.  So we instead createxi
trampoline functions.

src/lib/server/base.c
src/lib/util/misc.c
src/lib/util/misc.h

index a1a448030b195609a8e9e34f0a27bd8f9106d94a..1e9cbe773d550eea4b2f9fb2169032db7bf875a7 100644 (file)
@@ -124,6 +124,9 @@ int server_init(CONF_SECTION *cs, char const *conf_dir, fr_dict_t *dict)
         */
        if (packet_global_init() < 0) return -1;
 
+       fr_suid_up = rad_suid_up;
+       fr_suid_down = rad_suid_down;
+
        return 0;
 }
 
@@ -137,4 +140,7 @@ void server_free(void)
         *      Free xlat instance data, and call any detach methods
         */
        xlat_instances_free();
+
+       fr_suid_up = fr_suid_noop;
+       fr_suid_down = fr_suid_noop;
 }
index 0c2ecdf8f133097c8646737b4e3eb33b2cd241d8..0158d846d1a4805c78c121c4f3f160291014ab66 100644 (file)
@@ -558,3 +558,13 @@ char const *fr_filename_common_trim(char const *path, char const *common)
 
        return p_p;
 }
+
+/*
+ *     Trampoline points for wrapping rad_suid_up() and rad_suid_down().
+ */
+void fr_suid_noop(void)
+{
+}
+
+fr_suid_t fr_suid_up = fr_suid_noop;
+fr_suid_t fr_suid_down = fr_suid_noop;
index ca61a10c18a1879038379506187e3d30fd55d242..70ba928bd872c6c72042eb9c596495c615076504 100644 (file)
@@ -157,6 +157,17 @@ int                fr_digest_cmp(uint8_t const *a, uint8_t const *b, size_t length) CC_HINT(no
 char const     *fr_filename(char const *path);
 char const     *fr_filename_common_trim(char const *path, char const *common);
 
+/*
+ *     Some libraries need to call suid up/down, except that those are functions in the server, and we don't
+ *     want to link everything to the server library.  As a result, we include trampoline functions which do
+ *     nothing, but which can be over-written by the server when is starts.
+ */
+typedef void (*fr_suid_t)(void);
+
+void           fr_suid_noop(void);
+extern         fr_suid_t fr_suid_up;
+extern         fr_suid_t fr_suid_down;
+
 #ifdef __cplusplus
 }
 #endif