From d85d370c63126a0d69950f79761099ffb466e87c Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 18 May 2020 04:47:21 -0600 Subject: [PATCH] Add dependent system includes to make sudo_*.h more standalone. In the past we've relied on the various .c files to include the system headers that define types that the sudo_*.h headers require. This is fragile and can cause issues when includes get re-ordered. --- include/sudo_compat.h | 1 + include/sudo_conf.h | 6 ++++++ include/sudo_debug.h | 2 +- include/sudo_iolog.h | 2 ++ include/sudo_json.h | 13 +++++++++++++ include/sudo_util.h | 1 + plugins/sudoers/sudoers.h | 1 + 7 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/sudo_compat.h b/include/sudo_compat.h index 43924cc35..51afd6fcb 100644 --- a/include/sudo_compat.h +++ b/include/sudo_compat.h @@ -24,6 +24,7 @@ #ifndef SUDO_COMPAT_H #define SUDO_COMPAT_H +#include /* for gid_t, mode_t, size_t, ssize_t, uid_t */ #include #if !defined(HAVE_VSNPRINTF) || !defined(HAVE_VASPRINTF) || \ !defined(HAVE_VSYSLOG) || defined(PREFER_PORTABLE_SNPRINTF) diff --git a/include/sudo_conf.h b/include/sudo_conf.h index c3cf556e2..5664b30a4 100644 --- a/include/sudo_conf.h +++ b/include/sudo_conf.h @@ -19,6 +19,12 @@ #ifndef SUDO_CONF_H #define SUDO_CONF_H +#ifdef HAVE_STDBOOL_H +# include +#else +# include "compat/stdbool.h" +#endif + #include "sudo_queue.h" /* Flags for sudo_conf_read() */ diff --git a/include/sudo_debug.h b/include/sudo_debug.h index 0124b0b19..08479be16 100644 --- a/include/sudo_debug.h +++ b/include/sudo_debug.h @@ -19,13 +19,13 @@ #ifndef SUDO_DEBUG_H #define SUDO_DEBUG_H +#include /* for id_t, size_t, ssize_t, time_t */ #include #ifdef HAVE_STDBOOL_H # include #else # include "compat/stdbool.h" #endif -#include #include "sudo_queue.h" /* diff --git a/include/sudo_iolog.h b/include/sudo_iolog.h index 4d56cda4b..c0db13901 100644 --- a/include/sudo_iolog.h +++ b/include/sudo_iolog.h @@ -19,6 +19,8 @@ #ifndef SUDO_IOLOG_H #define SUDO_IOLOG_H +#include /* for gid_t, mode_t, size_t, ssize_t, uid_t */ + #ifdef HAVE_ZLIB_H # include /* for gzFile */ #endif diff --git a/include/sudo_json.h b/include/sudo_json.h index 417d61b7d..811e10079 100644 --- a/include/sudo_json.h +++ b/include/sudo_json.h @@ -16,6 +16,17 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifndef SUDO_JSON_H +#define SUDO_JSON_H + +#include /* for id_t */ + +#ifdef HAVE_STDBOOL_H +# include +#else +# include "compat/stdbool.h" +#endif + /* * JSON values may be of the following types. */ @@ -83,3 +94,5 @@ __dso_public char *sudo_json_get_buf_v1(struct json_container *json); __dso_public unsigned int sudo_json_get_len_v1(struct json_container *json); #define sudo_json_get_len(_a) sudo_json_get_len_v1((_a)) + +#endif /* SUDO_JSON_H */ diff --git a/include/sudo_util.h b/include/sudo_util.h index a60ba9003..fbdd2f55c 100644 --- a/include/sudo_util.h +++ b/include/sudo_util.h @@ -19,6 +19,7 @@ #ifndef SUDO_UTIL_H #define SUDO_UTIL_H +#include /* for dev_t, mode_t, gid_t, size_t, ssize_t, uid_t */ #ifdef HAVE_STDBOOL_H # include #else diff --git a/plugins/sudoers/sudoers.h b/plugins/sudoers/sudoers.h index 1b0f220c7..bac131b2f 100644 --- a/plugins/sudoers/sudoers.h +++ b/plugins/sudoers/sudoers.h @@ -24,6 +24,7 @@ #ifndef SUDOERS_SUDOERS_H #define SUDOERS_SUDOERS_H +#include /* for gid_t, mode_t, pid_t, size_t, uid_t */ #include #ifdef HAVE_STDBOOL_H # include