From 30b403b0f01a06a2daadde809d7a2a615d52e4d3 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Fri, 23 Feb 2024 20:33:52 +0100 Subject: [PATCH] os: unexport Fopen(), Fclose(), Popen(), Pclose(), System() These functions are just used for reading auth file or calling xkbcomp while dropping privileges, in case the Xserver is started as unprivileged user with suid-root. Thus, shouldn't be used (and aren't used) by drivers. Signed-off-by: Enrico Weigelt, metux IT consult Part-of: --- include/os.h | 21 --------------------- os/osdep.h | 15 +++++++++++++++ xkb/ddxLoad.c | 5 ++++- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/include/os.h b/include/os.h index 84770c535..24ab2ba07 100644 --- a/include/os.h +++ b/include/os.h @@ -327,27 +327,6 @@ extern _X_EXPORT void OsAbort(void) _X_NORETURN; -#if !defined(WIN32) -extern _X_EXPORT void * -Popen(const char *, const char *); -extern _X_EXPORT int -Pclose(void *); -extern _X_EXPORT void * -Fopen(const char *, const char *); -extern _X_EXPORT int -Fclose(void *); -#else - -extern const char * -Win32TempDir(void); - -extern int -System(const char *cmdline); - -#define Fopen(a,b) fopen(a,b) -#define Fclose(a) fclose(a) -#endif - extern _X_EXPORT Bool PrivsElevated(void); diff --git a/os/osdep.h b/os/osdep.h index 59e6c5e95..705416de3 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -144,6 +144,21 @@ struct utsname { static inline void uname(struct utsname *uts) { gethostname(uts->nodename, sizeof(uts->nodename)); } + +const char *Win32TempDir(void); + +int System(const char *cmdline); +static inline void Fclose(void *f) { fclose(f); } +static inline void *Fopen(const char *a, const char *b) { return fopen(a,b); } + +#else /* WIN32 */ + +int System(const char *); +void *Popen(const char *, const char *); +void *Fopen(const char *, const char *); +int Fclose(void *f); +int Pclose(void *f); + #endif /* WIN32 */ void AutoResetServer(int sig); diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c index 3f9de20c1..18e0ec3be 100644 --- a/xkb/ddxLoad.c +++ b/xkb/ddxLoad.c @@ -37,12 +37,15 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include + +#include "os/osdep.h" + #include "inputstr.h" #include "scrnintstr.h" #include "windowstr.h" #include -#include #define PRE_ERROR_MSG "\"The XKEYBOARD keymap compiler (xkbcomp) reports:\"" #define ERROR_PREFIX "\"> \""