2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 14:25:15 +00:00

Move gcc-style __attribute__ macros to config.h.in

Renamed __malloc -> sudo_malloclike, __printflike -> sudo_printflike,
__printf0like -> sudo_printf0like.
Add sudo_noreturn instead of __attribute__((__noreturn__)).
We do not use stdnoreturn.h since it has been deprecated in C23
in favor of the [[noreturn]] attribute.
This commit is contained in:
Todd C. Miller
2022-09-07 07:48:31 -06:00
parent c341608072
commit 304726a215
21 changed files with 185 additions and 134 deletions

View File

@@ -1451,7 +1451,53 @@
code using `volatile' can become incorrect without. Disable with care. */
#undef volatile
/* Symbol visibility controls */
#ifndef __GNUC_PREREQ__
# ifdef __GNUC__
# define __GNUC_PREREQ__(ma, mi) \
((__GNUC__ > (ma)) || (__GNUC__ == (ma) && __GNUC_MINOR__ >= (mi)))
# else
# define __GNUC_PREREQ__(ma, mi) 0
# endif
#endif
/* Define away __attribute__ for non-gcc or old gcc. */
#if !defined(__attribute__) && !__GNUC_PREREQ__(2, 5)
# define __attribute__(x)
#endif
/* For functions that call exit() directly. */
#if __GNUC_PREREQ__(2, 5)
# define sudo_noreturn __attribute__((__noreturn__))
#else
# define sudo_noreturn
#endif
/* For malloc-like functions that return uninitialized or zeroed memory. */
#if __GNUC_PREREQ__(2, 96)
# define sudo_malloclike __attribute__((__malloc__))
#else
# define sudo_malloclike
#endif
/* Compile-time checking for function arguments that must not be NULL. */
#if __GNUC_PREREQ__(3, 3)
# define sudo_attr_nonnull(_a) __attribute__((__nonnull__ (_a)))
#else
# define sudo_attr_nonnull(_a)
#endif
/* For catching format string mismatches. */
#if __GNUC_PREREQ__(2, 7)
# define sudo_printflike(_f, _v) __attribute__((__format__ (__printf__, _f, _v))) sudo_attr_nonnull(_f)
# define sudo_printf0like(_f, _v) __attribute__((__format__ (__printf__, _f, _v)))
# define sudo_attr_fmt_arg(_f) __attribute__((__format_arg__ (_f)))
#else
# define sudo_printflike(_f, _v)
# define sudo_printf0like(_f, _v)
# define sudo_attr_fmt_arg(_f)
#endif
/* Symbol visibility controls. */
#ifdef HAVE_DSO_VISIBILITY
# if defined(__GNUC__)
# define sudo_dso_public __attribute__((__visibility__("default")))

View File

@@ -5533,7 +5533,53 @@ dnl
AH_TOP([#ifndef SUDO_CONFIG_H
#define SUDO_CONFIG_H])
AH_BOTTOM([/* Symbol visibility controls */
AH_BOTTOM([#ifndef __GNUC_PREREQ__
# ifdef __GNUC__
# define __GNUC_PREREQ__(ma, mi) \
((__GNUC__ > (ma)) || (__GNUC__ == (ma) && __GNUC_MINOR__ >= (mi)))
# else
# define __GNUC_PREREQ__(ma, mi) 0
# endif
#endif
/* Define away __attribute__ for non-gcc or old gcc. */
#if !defined(__attribute__) && !__GNUC_PREREQ__(2, 5)
# define __attribute__(x)
#endif
/* For functions that call exit() directly. */
#if __GNUC_PREREQ__(2, 5)
# define sudo_noreturn __attribute__((__noreturn__))
#else
# define sudo_noreturn
#endif
/* For malloc-like functions that return uninitialized or zeroed memory. */
#if __GNUC_PREREQ__(2, 96)
# define sudo_malloclike __attribute__((__malloc__))
#else
# define sudo_malloclike
#endif
/* Compile-time checking for function arguments that must not be NULL. */
#if __GNUC_PREREQ__(3, 3)
# define sudo_attr_nonnull(_a) __attribute__((__nonnull__ (_a)))
#else
# define sudo_attr_nonnull(_a)
#endif
/* For catching format string mismatches. */
#if __GNUC_PREREQ__(2, 7)
# define sudo_printflike(_f, _v) __attribute__((__format__ (__printf__, _f, _v))) sudo_attr_nonnull(_f)
# define sudo_printf0like(_f, _v) __attribute__((__format__ (__printf__, _f, _v)))
# define sudo_attr_fmt_arg(_f) __attribute__((__format_arg__ (_f)))
#else
# define sudo_printflike(_f, _v)
# define sudo_printf0like(_f, _v)
# define sudo_attr_fmt_arg(_f)
#endif
/* Symbol visibility controls. */
#ifdef HAVE_DSO_VISIBILITY
# if defined(__GNUC__)
# define sudo_dso_public __attribute__((__visibility__("default")))

View File

@@ -37,54 +37,6 @@
* Macros and functions that may be missing on some operating systems.
*/
#ifndef __GNUC_PREREQ__
# ifdef __GNUC__
# define __GNUC_PREREQ__(ma, mi) \
((__GNUC__ > (ma)) || (__GNUC__ == (ma) && __GNUC_MINOR__ >= (mi)))
# else
# define __GNUC_PREREQ__(ma, mi) 0
# endif
#endif
/* Define away __attribute__ for non-gcc or old gcc */
#if !defined(__attribute__) && !__GNUC_PREREQ__(2, 5)
# define __attribute__(x)
#endif
/* For malloc-like functions that return uninitialized or zeroed memory. */
#ifndef __malloc
# if __GNUC_PREREQ__(2, 96)
# define __malloc __attribute__((__malloc__))
# else
# define __malloc
# endif
#endif
/* For catching format string mismatches */
#ifndef __printflike
# if __GNUC_PREREQ__(3, 3)
# define __printflike(f, v) __attribute__((__format__ (__printf__, f, v))) __attribute__((__nonnull__ (f)))
# elif __GNUC_PREREQ__(2, 7)
# define __printflike(f, v) __attribute__((__format__ (__printf__, f, v)))
# else
# define __printflike(f, v)
# endif
#endif
#ifndef __printf0like
# if __GNUC_PREREQ__(2, 7)
# define __printf0like(f, v) __attribute__((__format__ (__printf__, f, v)))
# else
# define __printf0like(f, v)
# endif
#endif
#ifndef __format_arg
# if __GNUC_PREREQ__(2, 7)
# define __format_arg(f) __attribute__((__format_arg__ (f)))
# else
# define __format_arg(f)
# endif
#endif
#ifdef HAVE_FALLTHROUGH_ATTRIBUTE
# define FALLTHROUGH __attribute__((__fallthrough__))
#else
@@ -493,22 +445,22 @@ sudo_dso_public int sudo_futimens(int fd, const struct timespec *times);
# define futimens(_a, _b) sudo_futimens((_a), (_b))
#endif /* HAVE_FUTIMENS */
#if !defined(HAVE_SNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
sudo_dso_public int sudo_snprintf(char *str, size_t n, char const *fmt, ...) __printflike(3, 4);
sudo_dso_public int sudo_snprintf(char *str, size_t n, char const *fmt, ...) sudo_printflike(3, 4);
# undef snprintf
# define snprintf sudo_snprintf
#endif /* HAVE_SNPRINTF */
#if !defined(HAVE_VSNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
sudo_dso_public int sudo_vsnprintf(char *str, size_t n, const char *fmt, va_list ap) __printflike(3, 0);
sudo_dso_public int sudo_vsnprintf(char *str, size_t n, const char *fmt, va_list ap) sudo_printflike(3, 0);
# undef vsnprintf
# define vsnprintf sudo_vsnprintf
#endif /* HAVE_VSNPRINTF */
#if !defined(HAVE_ASPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
sudo_dso_public int sudo_asprintf(char **str, char const *fmt, ...) __printflike(2, 3);
sudo_dso_public int sudo_asprintf(char **str, char const *fmt, ...) sudo_printflike(2, 3);
# undef asprintf
# define asprintf sudo_asprintf
#endif /* HAVE_ASPRINTF */
#if !defined(HAVE_VASPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
sudo_dso_public int sudo_vasprintf(char **str, const char *fmt, va_list ap) __printflike(2, 0);
sudo_dso_public int sudo_vasprintf(char **str, const char *fmt, va_list ap) sudo_printflike(2, 0);
# undef vasprintf
# define vasprintf sudo_vasprintf
#endif /* HAVE_VASPRINTF */

View File

@@ -265,13 +265,13 @@ sudo_dso_public int sudo_debug_get_active_instance_v1(void);
sudo_dso_public int sudo_debug_get_fds_v1(unsigned char **fds);
sudo_dso_public int sudo_debug_get_instance_v1(const char *program);
sudo_dso_public int sudo_debug_parse_flags_v1(struct sudo_conf_debug_file_list *debug_files, const char *entry);
sudo_dso_public void sudo_debug_printf2_v1(const char *func, const char *file, int line, int level, const char *fmt, ...) __printf0like(5, 6);
sudo_dso_public void sudo_debug_printf_nvm_v1(int pri, const char *fmt, ...) __printf0like(2, 3);
sudo_dso_public void sudo_debug_printf2_v1(const char *func, const char *file, int line, int level, const char *fmt, ...) sudo_printf0like(5, 6);
sudo_dso_public void sudo_debug_printf_nvm_v1(int pri, const char *fmt, ...) sudo_printf0like(2, 3);
sudo_dso_public int sudo_debug_register_v1(const char *program, const char *const subsystems[], unsigned int ids[], struct sudo_conf_debug_file_list *debug_files);
sudo_dso_public int sudo_debug_register_v2(const char *program, const char *const subsystems[], unsigned int ids[], struct sudo_conf_debug_file_list *debug_files, int minfd);
sudo_dso_public int sudo_debug_set_active_instance_v1(int inst);
sudo_dso_public void sudo_debug_update_fd_v1(int ofd, int nfd);
sudo_dso_public void sudo_debug_vprintf2_v1(const char *func, const char *file, int line, int level, const char *fmt, va_list ap) __printf0like(5, 0);
sudo_dso_public void sudo_debug_vprintf2_v1(const char *func, const char *file, int line, int level, const char *fmt, va_list ap) sudo_printf0like(5, 0);
sudo_dso_public void sudo_debug_write2_v1(int fd, const char *func, const char *file, int line, const char *str, int len, int errnum);
sudo_dso_public bool sudo_debug_needed_v1(int level);

View File

@@ -164,20 +164,20 @@ typedef bool (*sudo_warn_setlocale_t)(bool, int *);
sudo_dso_public int sudo_fatal_callback_deregister_v1(sudo_fatal_callback_t func);
sudo_dso_public int sudo_fatal_callback_register_v1(sudo_fatal_callback_t func);
sudo_dso_public char *sudo_warn_gettext_v1(const char *domainname, const char *msgid) __format_arg(2);
sudo_dso_public char *sudo_warn_gettext_v1(const char *domainname, const char *msgid) sudo_attr_fmt_arg(2);
sudo_dso_public void sudo_warn_set_locale_func_v1(sudo_warn_setlocale_t func);
sudo_dso_public void sudo_fatal_nodebug_v1(const char *fmt, ...) __printf0like(1, 2) __attribute__((__noreturn__));
sudo_dso_public void sudo_fatalx_nodebug_v1(const char *fmt, ...) __printflike(1, 2) __attribute__((__noreturn__));
sudo_dso_public void sudo_gai_fatal_nodebug_v1(int errnum, const char *fmt, ...) __printflike(2, 3) __attribute__((__noreturn__));
sudo_dso_public void sudo_vfatal_nodebug_v1(const char *fmt, va_list ap) __printf0like(1, 0) __attribute__((__noreturn__));
sudo_dso_public void sudo_vfatalx_nodebug_v1(const char *fmt, va_list ap) __printflike(1, 0) __attribute__((__noreturn__));
sudo_dso_public void sudo_gai_vfatal_nodebug_v1(int errnum, const char *fmt, va_list ap) __printflike(2, 0) __attribute__((__noreturn__));
sudo_dso_public void sudo_warn_nodebug_v1(const char *fmt, ...) __printf0like(1, 2);
sudo_dso_public void sudo_warnx_nodebug_v1(const char *fmt, ...) __printflike(1, 2);
sudo_dso_public void sudo_gai_warn_nodebug_v1(int errnum, const char *fmt, ...) __printflike(2, 3);
sudo_dso_public void sudo_vwarn_nodebug_v1(const char *fmt, va_list ap) __printf0like(1, 0);
sudo_dso_public void sudo_vwarnx_nodebug_v1(const char *fmt, va_list ap) __printflike(1, 0);
sudo_dso_public void sudo_gai_vwarn_nodebug_v1(int errnum, const char *fmt, va_list ap) __printflike(2, 0);
sudo_dso_public sudo_noreturn void sudo_fatal_nodebug_v1(const char *fmt, ...) sudo_printf0like(1, 2);
sudo_dso_public sudo_noreturn void sudo_fatalx_nodebug_v1(const char *fmt, ...) sudo_printflike(1, 2);
sudo_dso_public sudo_noreturn void sudo_gai_fatal_nodebug_v1(int errnum, const char *fmt, ...) sudo_printflike(2, 3);
sudo_dso_public sudo_noreturn void sudo_vfatal_nodebug_v1(const char *fmt, va_list ap) sudo_printf0like(1, 0);
sudo_dso_public sudo_noreturn void sudo_vfatalx_nodebug_v1(const char *fmt, va_list ap) sudo_printflike(1, 0);
sudo_dso_public sudo_noreturn void sudo_gai_vfatal_nodebug_v1(int errnum, const char *fmt, va_list ap) sudo_printflike(2, 0);
sudo_dso_public void sudo_warn_nodebug_v1(const char *fmt, ...) sudo_printf0like(1, 2);
sudo_dso_public void sudo_warnx_nodebug_v1(const char *fmt, ...) sudo_printflike(1, 2);
sudo_dso_public void sudo_gai_warn_nodebug_v1(int errnum, const char *fmt, ...) sudo_printflike(2, 3);
sudo_dso_public void sudo_vwarn_nodebug_v1(const char *fmt, va_list ap) sudo_printf0like(1, 0);
sudo_dso_public void sudo_vwarnx_nodebug_v1(const char *fmt, va_list ap) sudo_printflike(1, 0);
sudo_dso_public void sudo_gai_vwarn_nodebug_v1(int errnum, const char *fmt, va_list ap) sudo_printflike(2, 0);
sudo_dso_public void sudo_warn_set_conversation_v1(sudo_conv_t conv);
#define sudo_fatal_callback_deregister(_a) sudo_fatal_callback_deregister_v1((_a))

View File

@@ -38,8 +38,8 @@ typedef int (*sudo_lbuf_output_t)(const char *);
sudo_dso_public void sudo_lbuf_init_v1(struct sudo_lbuf *lbuf, sudo_lbuf_output_t output, int indent, const char *continuation, int cols);
sudo_dso_public void sudo_lbuf_destroy_v1(struct sudo_lbuf *lbuf);
sudo_dso_public bool sudo_lbuf_append_v1(struct sudo_lbuf *lbuf, const char *fmt, ...) __printflike(2, 3);
sudo_dso_public bool sudo_lbuf_append_quoted_v1(struct sudo_lbuf *lbuf, const char *set, const char *fmt, ...) __printflike(3, 4);
sudo_dso_public bool sudo_lbuf_append_v1(struct sudo_lbuf *lbuf, const char *fmt, ...) sudo_printflike(2, 3);
sudo_dso_public bool sudo_lbuf_append_quoted_v1(struct sudo_lbuf *lbuf, const char *set, const char *fmt, ...) sudo_printflike(3, 4);
sudo_dso_public void sudo_lbuf_print_v1(struct sudo_lbuf *lbuf);
sudo_dso_public bool sudo_lbuf_error_v1(struct sudo_lbuf *lbuf);
sudo_dso_public void sudo_lbuf_clearerr_v1(struct sudo_lbuf *lbuf);

View File

@@ -249,9 +249,9 @@ sudo_dso_public bool sudo_mkdir_parents_v1(const char *path, uid_t uid, gid_t gi
#define sudo_mkdir_parents(_a, _b, _c, _d, _e) sudo_mkdir_parents_v1((_a), (_b), (_c), (_d), (_e))
/* mmap_alloc.c */
sudo_dso_public void *sudo_mmap_alloc_v1(size_t size) __malloc;
sudo_dso_public void *sudo_mmap_alloc_v1(size_t size) sudo_malloclike;
#define sudo_mmap_alloc(_a) sudo_mmap_alloc_v1(_a)
sudo_dso_public void *sudo_mmap_allocarray_v1(size_t count, size_t size) __malloc;
sudo_dso_public void *sudo_mmap_allocarray_v1(size_t count, size_t size) sudo_malloclike;
#define sudo_mmap_allocarray(_a, _b) sudo_mmap_allocarray_v1((_a), (_b))
sudo_dso_public char *sudo_mmap_strdup_v1(const char *str);
#define sudo_mmap_strdup(_a) sudo_mmap_strdup_v1(_a)
@@ -271,7 +271,7 @@ sudo_dso_public void initprogname2(const char *, const char * const *);
/* rcstr.c */
sudo_dso_public char *sudo_rcstr_dup(const char *src);
sudo_dso_public char *sudo_rcstr_alloc(size_t len) __malloc;
sudo_dso_public char *sudo_rcstr_alloc(size_t len) sudo_malloclike;
sudo_dso_public char *sudo_rcstr_addref(const char *s);
sudo_dso_public void sudo_rcstr_delref(const char *s);

View File

@@ -349,7 +349,7 @@ closefrom_nodebug(int lowfd)
#define MAX_MAILFLAGS 63
static void __attribute__((__noreturn__))
static sudo_noreturn void
exec_mailer(int pipein)
{
const struct eventlog_config *evl_conf = eventlog_getconf();

View File

@@ -38,7 +38,7 @@ struct alias_warned {
};
SLIST_HEAD(alias_warned_list, alias_warned);
static bool alias_warnx(const char *file, int line, int column, bool strict, bool quiet, const char *fmt, ...) __printflike(6, 7);
static bool alias_warnx(const char *file, int line, int column, bool strict, bool quiet, const char *fmt, ...) sudo_printflike(6, 7);
static bool
alias_warned(struct alias_warned_list *warned, char *name)

View File

@@ -87,8 +87,8 @@ static struct option long_opts[] = {
};
sudo_dso_public int main(int argc, char *argv[]);
static void help(void) __attribute__((__noreturn__));
static void usage(int);
static sudo_noreturn void help(void);
static sudo_noreturn void usage(void);
static bool convert_sudoers_sudoers(struct sudoers_parse_tree *parse_tree, const char *output_file, struct cvtsudoers_config *conf);
static bool parse_sudoers(const char *input_file, struct cvtsudoers_config *conf);
static bool parse_ldif(struct sudoers_parse_tree *parse_tree, const char *input_file, struct cvtsudoers_config *conf);
@@ -207,7 +207,7 @@ main(int argc, char *argv[])
conf->order_increment = sudo_strtonum(optarg, 1, UINT_MAX, &errstr);
if (errstr != NULL) {
sudo_warnx(U_("order increment: %s: %s"), optarg, U_(errstr));
usage(1);
usage();
}
break;
case 'l':
@@ -226,7 +226,7 @@ main(int argc, char *argv[])
conf->sudo_order = sudo_strtonum(optarg, 0, UINT_MAX, &errstr);
if (errstr != NULL) {
sudo_warnx(U_("starting order: %s: %s"), optarg, U_(errstr));
usage(1);
usage();
}
break;
case 'p':
@@ -236,7 +236,7 @@ main(int argc, char *argv[])
conf->order_padding = sudo_strtonum(optarg, 1, UINT_MAX, &errstr);
if (errstr != NULL ) {
sudo_warnx(U_("order padding: %s: %s"), optarg, U_(errstr));
usage(1);
usage();
}
break;
case 's':
@@ -256,7 +256,7 @@ main(int argc, char *argv[])
pwfile = optarg;
break;
default:
usage(1);
usage();
}
}
argc -= optind;
@@ -275,7 +275,7 @@ main(int argc, char *argv[])
input_format = format_sudoers;
} else {
sudo_warnx(U_("unsupported input format %s"), conf->input_format);
usage(1);
usage();
}
}
if (conf->output_format != NULL) {
@@ -293,23 +293,23 @@ main(int argc, char *argv[])
conf->store_options = false;
} else {
sudo_warnx(U_("unsupported output format %s"), conf->output_format);
usage(1);
usage();
}
}
if (conf->filter != NULL) {
/* We always expand aliases when filtering (may change in future). */
if (!cvtsudoers_parse_filter(conf->filter))
usage(1);
usage();
}
if (conf->defstr != NULL) {
conf->defaults = cvtsudoers_parse_defaults(conf->defstr);
if (conf->defaults == -1)
usage(1);
usage();
}
if (conf->supstr != NULL) {
conf->suppress = cvtsudoers_parse_suppression(conf->supstr);
if (conf->suppress == -1)
usage(1);
usage();
}
/* Apply padding to sudo_order if present. */
@@ -1485,21 +1485,26 @@ done:
}
static void
usage(int fatal)
print_usage(FILE *fp)
{
(void) fprintf(fatal ? stderr : stdout, "usage: %s [-ehMpV] [-b dn] "
(void) fprintf(fp, "usage: %s [-ehMpV] [-b dn] "
"[-c conf_file ] [-d deftypes] [-f output_format] [-i input_format] "
"[-I increment] [-m filter] [-o output_file] [-O start_point] "
"[-P padding] [-s sections] [input_file]\n", getprogname());
if (fatal)
exit(EXIT_FAILURE);
}
static void
usage(void)
{
print_usage(stderr);
exit(EXIT_FAILURE);
}
static void
help(void)
{
(void) printf(_("%s - convert between sudoers file formats\n\n"), getprogname());
usage(0);
print_usage(stdout);
(void) puts(_("\nOptions:\n"
" -b, --base=dn the base DN for sudo LDAP queries\n"
" -c, --config=conf_file the path to the configuration file\n"

View File

@@ -87,7 +87,7 @@ struct cvtsudoers_filter {
/* cvtsudoers.c */
extern struct cvtsudoers_filter *filters;
void log_warnx(const char *fmt, ...) __printflike(1, 2);
void log_warnx(const char *fmt, ...) sudo_printflike(1, 2);
/* cvtsudoers_csv.c */
bool convert_sudoers_csv(struct sudoers_parse_tree *parse_tree, const char *output_file, struct cvtsudoers_config *conf);

View File

@@ -73,7 +73,7 @@ static bool store_timespec(const char *str, struct sudo_defs_types *def);
static bool store_rlimit(const char *str, struct sudo_defs_types *def);
static bool list_op(const char *str, size_t, struct list_members *list, enum list_ops op);
static bool valid_path(struct sudo_defs_types *def, const char *val, const char *file, int line, int column, bool quiet);
static bool defaults_warnx(const char *file, int line, int column, bool quiet, const char *fmt, ...) __printflike(5, 6);
static bool defaults_warnx(const char *file, int line, int column, bool quiet, const char *fmt, ...) sudo_printflike(5, 6);
/*
* Table describing compile-time and run-time options.

View File

@@ -72,8 +72,8 @@ struct log_details;
bool sudoers_warn_setlocale(bool restore, int *cookie);
bool sudoers_setlocale(int locale_type, int *prev_locale);
int sudoers_getlocale(void);
int audit_failure(char *const argv[], char const *const fmt, ...) __printflike(2, 3);
int vaudit_failure(char *const argv[], char const *const fmt, va_list ap) __printflike(2, 0);
int audit_failure(char *const argv[], char const *const fmt, ...) sudo_printflike(2, 3);
int vaudit_failure(char *const argv[], char const *const fmt, va_list ap) sudo_printflike(2, 0);
bool log_allowed(struct eventlog *evlog);
bool log_exit_status(int exit_status);
bool log_auth_failure(int status, unsigned int tries);
@@ -81,15 +81,15 @@ bool log_denial(int status, bool inform_user);
bool log_failure(int status, int flags);
bool log_server_alert(struct eventlog *evlog, struct timespec *now, const char *message, const char *errstr);
bool log_server_reject(struct eventlog *evlog, const char *message);
bool log_warning(int flags, const char *fmt, ...) __printflike(2, 3);
bool log_warningx(int flags, const char *fmt, ...) __printflike(2, 3);
bool gai_log_warning(int flags, int errnum, const char *fmt, ...) __printflike(3, 4);
bool log_warning(int flags, const char *fmt, ...) sudo_printflike(2, 3);
bool log_warningx(int flags, const char *fmt, ...) sudo_printflike(2, 3);
bool gai_log_warning(int flags, int errnum, const char *fmt, ...) sudo_printflike(3, 4);
bool sudoers_initlocale(const char *ulocale, const char *slocale);
bool sudoers_locale_callback(const char *file, int line, int column, const union sudo_defs_val *sd_un, int op);
void sudoers_to_eventlog(struct eventlog *evlog, const char *cmnd, char * const argv[], char *const envp[], const char *uuid_str);
void init_eventlog_config(void);
bool init_log_details(struct log_details *details, struct eventlog *evlog);
bool log_parse_error(const char *file, int line, int column, const char *fmt, va_list ap) __printf0like(4, 0);
bool log_parse_error(const char *file, int line, int column, const char *fmt, va_list ap) sudo_printf0like(4, 0);
bool mail_parse_errors(void);
#endif /* SUDOERS_LOGGING_H */

View File

@@ -175,12 +175,12 @@ extern time_t get_date(char *);
static int list_sessions(int, char **, const char *, const char *, const char *);
static int parse_expr(struct search_node_list *, char **, bool);
static void read_keyboard(int fd, int what, void *v);
static void help(void) __attribute__((__noreturn__));
static sudo_noreturn void help(void);
static sudo_noreturn void usage(void);
static int replay_session(int iolog_dir_fd, const char *iolog_dir,
struct timespec *offset, struct timespec *max_wait, const char *decimal,
bool interactive, bool suspend_wait);
static void sudoreplay_cleanup(void);
static void usage(int);
static void write_output(int fd, int what, void *v);
static void restore_terminal_size(void);
static void setup_terminal(struct eventlog *evlog, bool interactive, bool resize);
@@ -302,7 +302,7 @@ main(int argc, char *argv[])
exitcode = EXIT_SUCCESS;
goto done;
default:
usage(1);
usage();
/* NOTREACHED */
}
@@ -316,7 +316,7 @@ main(int argc, char *argv[])
}
if (argc != 1)
usage(1);
usage();
/* By default we replay stdout, stderr and ttyout. */
if (def_filter) {
@@ -1645,23 +1645,26 @@ read_keyboard(int fd, int what, void *v)
}
static void
usage(int fatal)
print_usage(FILE *fp)
{
fprintf(fatal ? stderr : stdout,
_("usage: %s [-hnRS] [-d dir] [-m num] [-s num] ID\n"),
fprintf(fp, _("usage: %s [-hnRS] [-d dir] [-m num] [-s num] ID\n"),
getprogname());
fprintf(fatal ? stderr : stdout,
_("usage: %s [-h] [-d dir] -l [search expression]\n"),
fprintf(fp, _("usage: %s [-h] [-d dir] -l [search expression]\n"),
getprogname());
if (fatal)
exit(EXIT_FAILURE);
}
static void
usage(void)
{
print_usage(stderr);
exit(EXIT_FAILURE);
}
static void
help(void)
{
(void) printf(_("%s - replay sudo session logs\n\n"), getprogname());
usage(0);
print_usage(stdout);
(void) puts(_("\nOptions:\n"
" -d, --directory=dir specify directory for session logs\n"
" -f, --filter=filter specify which I/O type(s) to display\n"

View File

@@ -61,7 +61,7 @@ enum sudoers_formats {
* Function Prototypes
*/
static void dump_sudoers(struct sudo_lbuf *lbuf);
static void usage(void) __attribute__((__noreturn__));
static sudo_noreturn void usage(void);
static void set_runaspw(const char *);
static void set_runasgr(const char *);
static bool cb_runas_default(const char *file, int line, int column, const union sudo_defs_val *, int);

View File

@@ -36,7 +36,7 @@ bool fill_cmnd(const char *, size_t);
bool fill(const char *, size_t);
bool ipv6_valid(const char *s);
int sudoers_trace_print(const char *);
void sudoerserrorf(const char *, ...) __printf0like(1, 2);
void sudoerserrorf(const char *, ...) sudo_printf0like(1, 2);
void sudoerserror(const char *);
bool push_include(const char *, bool);

View File

@@ -50,7 +50,7 @@ union timestamp_entry_storage {
sudo_dso_public int main(int argc, char *argv[]);
static void usage(void) __attribute__((__noreturn__));
static sudo_noreturn void usage(void);
static void dump_entry(struct timestamp_entry *entry, off_t pos);
static bool valid_entry(union timestamp_entry_storage *u, off_t pos);
static bool convert_entry(union timestamp_entry_storage *record, struct timespec *off);

View File

@@ -90,14 +90,14 @@ static char *get_editor(int *editor_argc, char ***editor_argv);
static bool check_syntax(const char *, bool, bool, bool, bool);
static bool edit_sudoers(struct sudoersfile *, char *, int, char **, int);
static bool install_sudoers(struct sudoersfile *, bool, bool);
static bool visudo_track_error(const char *file, int line, int column, const char *fmt, va_list args) __printf0like(4, 0);
static bool visudo_track_error(const char *file, int line, int column, const char *fmt, va_list args) sudo_printf0like(4, 0);
static int print_unused(struct sudoers_parse_tree *, struct alias *, void *);
static bool reparse_sudoers(char *, int, char **, bool, bool);
static int run_command(const char *, char *const *);
static void parse_sudoers_options(void);
static void setup_signals(void);
static void help(void) __attribute__((__noreturn__));
static void usage(int);
static sudo_noreturn void help(void);
static sudo_noreturn void usage(void);
static void visudo_cleanup(void);
extern void get_hostname(void);
@@ -151,7 +151,7 @@ main(int argc, char *argv[])
textdomain("sudoers");
if (argc < 1)
usage(1);
usage();
/* Register fatal/fatalx callback. */
sudo_fatal_callback_register(visudo_cleanup);
@@ -208,7 +208,7 @@ main(int argc, char *argv[])
export_path = optarg;
break;
default:
usage(1);
usage();
}
}
argc -= optind;
@@ -226,7 +226,7 @@ main(int argc, char *argv[])
}
break;
default:
usage(1);
usage();
}
if (fflag) {
@@ -1215,20 +1215,20 @@ quit(int signo)
_exit(signo);
}
#define VISUDO_USAGE "usage: %s [-chqsV] [[-f] sudoers ]\n"
static void
usage(int fatal)
usage(void)
{
(void) fprintf(fatal ? stderr : stdout,
"usage: %s [-chqsV] [[-f] sudoers ]\n", getprogname());
if (fatal)
exit(EXIT_FAILURE);
(void) fprintf(stderr, VISUDO_USAGE, getprogname());
exit(EXIT_FAILURE);
}
static void
help(void)
{
(void) printf(_("%s - safely edit the sudoers file\n\n"), getprogname());
usage(0);
(void) printf(VISUDO_USAGE, getprogname());
(void) puts(_("\nOptions:\n"
" -c, --check check-only mode\n"
" -f, --file=sudoers specify sudoers file location\n"

View File

@@ -47,9 +47,9 @@ int tgetpass_flags;
/*
* Local functions.
*/
static void help(void) __attribute__((__noreturn__));
static void usage_excl(void) __attribute__((__noreturn__));
static void usage_excl_ticket(void) __attribute__((__noreturn__));
static sudo_noreturn void help(void);
static sudo_noreturn void usage_excl(void);
static sudo_noreturn void usage_excl_ticket(void);
/*
* Mapping of command line flags to name/value settings.

View File

@@ -44,7 +44,6 @@
static bool verbose;
sudo_dso_public int main(int argc, char *argv[], char *envp[]);
static void usage(void) __attribute__((__noreturn__));
static bool
report_status(int status, const char *what)
@@ -179,7 +178,7 @@ try_wordexp(void)
}
#endif
static void
static sudo_noreturn void
usage(void)
{
fprintf(stderr, "usage: %s [-v] rexec | /path/to/sudo_noexec.so\n",

View File

@@ -277,7 +277,7 @@ extern int sudo_debug_instance;
int sudo_edit(struct command_details *details);
/* parse_args.c */
void usage(void) __attribute__((__noreturn__));
sudo_noreturn void usage(void);
/* openbsd.c */
int os_init_openbsd(int argc, char *argv[], char *envp[]);