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.
This commit is contained in:
Todd C. Miller
2020-05-18 04:47:21 -06:00
parent b66cf649f5
commit d85d370c63
7 changed files with 25 additions and 1 deletions

View File

@@ -24,6 +24,7 @@
#ifndef SUDO_COMPAT_H
#define SUDO_COMPAT_H
#include <sys/types.h> /* for gid_t, mode_t, size_t, ssize_t, uid_t */
#include <stdio.h>
#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_VASPRINTF) || \
!defined(HAVE_VSYSLOG) || defined(PREFER_PORTABLE_SNPRINTF)

View File

@@ -19,6 +19,12 @@
#ifndef SUDO_CONF_H
#define SUDO_CONF_H
#ifdef HAVE_STDBOOL_H
# include <stdbool.h>
#else
# include "compat/stdbool.h"
#endif
#include "sudo_queue.h"
/* Flags for sudo_conf_read() */

View File

@@ -19,13 +19,13 @@
#ifndef SUDO_DEBUG_H
#define SUDO_DEBUG_H
#include <sys/types.h> /* for id_t, size_t, ssize_t, time_t */
#include <stdarg.h>
#ifdef HAVE_STDBOOL_H
# include <stdbool.h>
#else
# include "compat/stdbool.h"
#endif
#include <sys/types.h>
#include "sudo_queue.h"
/*

View File

@@ -19,6 +19,8 @@
#ifndef SUDO_IOLOG_H
#define SUDO_IOLOG_H
#include <sys/types.h> /* for gid_t, mode_t, size_t, ssize_t, uid_t */
#ifdef HAVE_ZLIB_H
# include <zlib.h> /* for gzFile */
#endif

View File

@@ -16,6 +16,17 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef SUDO_JSON_H
#define SUDO_JSON_H
#include <sys/types.h> /* for id_t */
#ifdef HAVE_STDBOOL_H
# include <stdbool.h>
#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 */

View File

@@ -19,6 +19,7 @@
#ifndef SUDO_UTIL_H
#define SUDO_UTIL_H
#include <sys/types.h> /* for dev_t, mode_t, gid_t, size_t, ssize_t, uid_t */
#ifdef HAVE_STDBOOL_H
# include <stdbool.h>
#else

View File

@@ -24,6 +24,7 @@
#ifndef SUDOERS_SUDOERS_H
#define SUDOERS_SUDOERS_H
#include <sys/types.h> /* for gid_t, mode_t, pid_t, size_t, uid_t */
#include <limits.h>
#ifdef HAVE_STDBOOL_H
# include <stdbool.h>