From f377621e0aef1c2eb69e4473975b5d8cf68c7749 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 16 Aug 2010 14:22:14 -0400 Subject: [PATCH] Merge compat.h and missing.h into missing.h --HG-- branch : 1.7 --- Makefile.in | 54 ++++----- aix.c | 2 +- audit.c | 2 +- boottime.c | 1 - compat.h | 312 -------------------------------------------------- error.c | 2 +- fnmatch.c | 2 +- getcwd.c | 2 +- getdate.c | 2 +- getdate.y | 2 +- getline.c | 2 +- getprogname.c | 2 +- gettime.c | 2 +- glob.c | 2 +- isblank.c | 2 +- linux_audit.c | 3 +- memrchr.c | 2 +- missing.h | 295 ++++++++++++++++++++++++++++++++++++++++++++++- mksiglist.c | 4 +- nanosleep.c | 2 +- sesh.c | 2 +- setsid.c | 2 +- sigaction.c | 2 +- snprintf.c | 2 +- strcasecmp.c | 2 +- strerror.c | 2 +- strlcat.c | 3 +- strlcpy.c | 2 +- strsignal.c | 2 +- sudo.h | 2 +- sudo_noexec.c | 2 +- sudoreplay.c | 3 +- timestr.c | 2 +- utimes.c | 2 +- vasgroups.c | 2 +- zero_bytes.c | 2 +- 36 files changed, 354 insertions(+), 377 deletions(-) delete mode 100644 compat.h diff --git a/Makefile.in b/Makefile.in index dbfb1b165..023906ab1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -122,7 +122,7 @@ AUTH_SRCS = auth/afs.c auth/aix_auth.c auth/bsdauth.c auth/dce.c auth/fwtk.c \ auth/secureware.c auth/securid.c auth/securid5.c auth/sia.c \ auth/sudo_auth.c -HDRS = alloc.h bsm_audit.h compat.h def_data.h defaults.h error.h ins_2001.h \ +HDRS = alloc.h bsm_audit.h def_data.h defaults.h error.h ins_2001.h \ ins_classic.h ins_csops.h ins_goons.h insults.h interfaces.h lbuf.h \ linux_audit.h list.h logging.h missing.h mksiglist.h nonunix.h \ redblack.h parse.h sudo.h sudo_exec.h sudo_nss.h gram.h \ @@ -165,10 +165,10 @@ DISTFILES = $(SRCS) $(HDRS) ChangeLog HISTORY INSTALL INSTALL.configure \ visudo.cat visudo.man.in visudo.pod auth/API sudo.man.pl \ sudoers.man.pl -SUDODEP = $(srcdir)/sudo.h $(srcdir)/alloc.h $(srcdir)/compat.h \ - $(srcdir)/defaults.h $(srcdir)/error.h $(srcdir)/list.h \ - $(srcdir)/logging.h $(srcdir)/missing.h $(srcdir)/sudo_nss.h \ - $(devdir)/def_data.h pathnames.h config.h +SUDODEP = $(srcdir)/sudo.h $(srcdir)/alloc.h $(srcdir)/defaults.h \ + $(srcdir)/error.h $(srcdir)/list.h $(srcdir)/logging.h \ + $(srcdir)/missing.h $(srcdir)/sudo_nss.h $(devdir)/def_data.h \ + pathnames.h config.h AUTHDEP = $(SUDODEP) $(authdir)/sudo_auth.h @@ -237,7 +237,7 @@ $(devdir)/getdate.c: $(srcdir)/getdate.y siglist.c: mksiglist ./mksiglist > $@ -mksiglist: $(srcdir)/mksiglist.c $(srcdir)/mksiglist.h $(srcdir)/compat.h $(top_builddir)/config.h +mksiglist: $(srcdir)/mksiglist.c $(srcdir)/mksiglist.h $(srcdir)/missing.h $(top_builddir)/config.h $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFS) $(srcdir)/mksiglist.c -o $@ @DEV@$(srcdir)/mksiglist.h: $(srcdir)/siglist.in @@ -264,7 +264,7 @@ defaults.o: $(srcdir)/defaults.c $(SUDODEP) $(srcdir)/def_data.c $(authdir)/sudo $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/defaults.c env.o: $(srcdir)/env.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/env.c -error.o: $(srcdir)/error.c $(srcdir)/compat.h $(srcdir)/error.h config.h +error.o: $(srcdir)/error.c $(srcdir)/missing.h $(srcdir)/error.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/error.c exec.o: $(srcdir)/exec.c $(SUDODEP) $(srcdir)/sudo_exec.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/exec.c @@ -274,13 +274,13 @@ fileops.o: $(srcdir)/fileops.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/fileops.c find_path.o: $(srcdir)/find_path.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/find_path.c -fnmatch.o: $(srcdir)/fnmatch.c $(srcdir)/emul/fnmatch.h $(srcdir)/compat.h config.h +fnmatch.o: $(srcdir)/fnmatch.c $(srcdir)/emul/fnmatch.h $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/fnmatch.c get_pty.o: $(srcdir)/get_pty.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/get_pty.c -getcwd.o: $(srcdir)/getcwd.c $(srcdir)/compat.h config.h +getcwd.o: $(srcdir)/getcwd.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/getcwd.c -getdate.o: $(srcdir)/getdate.c $(srcdir)/compat.h config.h +getdate.o: $(srcdir)/getdate.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/getdate.c getline.o: $(srcdir)/getline.c config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/getline.c @@ -290,7 +290,7 @@ getspwuid.o: $(srcdir)/getspwuid.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/getspwuid.c gettime.o: $(srcdir)/gettime.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/gettime.c -glob.o: $(srcdir)/glob.c $(srcdir)/emul/glob.h $(srcdir)/compat.h config.h +glob.o: $(srcdir)/glob.c $(srcdir)/emul/glob.h $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/glob.c goodpath.o: $(srcdir)/goodpath.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/goodpath.c @@ -300,7 +300,7 @@ interfaces.o: $(srcdir)/interfaces.c $(SUDODEP) $(srcdir)/interfaces.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/interfaces.c iolog.o: $(srcdir)/iolog.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/iolog.c -isblank.o: $(srcdir)/isblank.c $(srcdir)/compat.h config.h +isblank.o: $(srcdir)/isblank.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/isblank.c lbuf.o: $(srcdir)/lbuf.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/lbuf.c @@ -318,7 +318,7 @@ memrchr.o: $(srcdir)/memrchr.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/memrchr.c mkstemps.o: $(srcdir)/mkstemps.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/mkstemps.c -nanosleep.o: $(srcdir)/nanosleep.c $(srcdir)/compat.h config.h +nanosleep.o: $(srcdir)/nanosleep.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/nanosleep.c parse.o: $(srcdir)/parse.c $(SUDODEP) $(srcdir)/parse.h $(srcdir)/list.h $(devdir)/gram.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/parse.c @@ -330,33 +330,33 @@ redblack.o: $(srcdir)/redblack.c $(SUDODEP) $(srcdir)/redblack.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/redblack.c set_perms.o: $(srcdir)/set_perms.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/set_perms.c -setsid.o: $(srcdir)/setsid.c $(srcdir)/compat.h config.h +setsid.o: $(srcdir)/setsid.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/setsid.c -sigaction.o: $(srcdir)/sigaction.c $(srcdir)/compat.h +sigaction.o: $(srcdir)/sigaction.c $(srcdir)/missing.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/sigaction.c -siglist.o: siglist.c $(srcdir)/compat.h config.h +siglist.o: siglist.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/siglist.c -snprintf.o: $(srcdir)/snprintf.c $(srcdir)/compat.h config.h +snprintf.o: $(srcdir)/snprintf.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/snprintf.c -strcasecmp.o: $(srcdir)/strcasecmp.c $(srcdir)/compat.h config.h +strcasecmp.o: $(srcdir)/strcasecmp.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/strcasecmp.c -strerror.o: $(srcdir)/strerror.c $(srcdir)/compat.h config.h +strerror.o: $(srcdir)/strerror.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/strerror.c -strlcat.o: $(srcdir)/strlcat.c $(srcdir)/compat.h config.h +strlcat.o: $(srcdir)/strlcat.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/strlcat.c -strlcpy.o: $(srcdir)/strlcpy.c $(srcdir)/compat.h config.h +strlcpy.o: $(srcdir)/strlcpy.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/strlcpy.c -strsignal.o: $(srcdir)/strsignal.c $(srcdir)/compat.h config.h +strsignal.o: $(srcdir)/strsignal.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/strsignal.c selinux.o: $(srcdir)/selinux.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/selinux.c sudo.o: $(srcdir)/sudo.c $(SUDODEP) sudo_usage.h $(srcdir)/interfaces.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/sudo.c -sudoreplay.o: $(srcdir)/sudoreplay.c $(srcdir)/alloc.h $(srcdir)/compat.h $(srcdir)/error.h $(srcdir)/missing.h config.h +sudoreplay.o: $(srcdir)/sudoreplay.c $(srcdir)/alloc.h $(srcdir)/missing.h $(srcdir)/error.h $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/sudoreplay.c sudo_edit.o: $(srcdir)/sudo_edit.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/sudo_edit.c -sudo_noexec.o: $(srcdir)/sudo_noexec.c $(srcdir)/compat.h config.h +sudo_noexec.o: $(srcdir)/sudo_noexec.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/sudo_noexec.c sudo_nss.o: $(srcdir)/sudo_nss.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/sudo_nss.c @@ -366,19 +366,19 @@ testsudoers.o: $(srcdir)/testsudoers.c $(SUDODEP) $(srcdir)/parse.h $(srcdir)/li $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/testsudoers.c tgetpass.o: $(srcdir)/tgetpass.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/tgetpass.c -timestr.o: $(srcdir)/timestr.c $(srcdir)/compat.h config.h +timestr.o: $(srcdir)/timestr.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/timestr.c toke.o: $(devdir)/toke.c $(SUDODEP) $(srcdir)/parse.h $(srcdir)/list.h $(devdir)/gram.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(devdir)/toke.c tsgetgrpw.o: $(srcdir)/tsgetgrpw.c $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/tsgetgrpw.c -utimes.o: $(srcdir)/utimes.c $(srcdir)/compat.h $(srcdir)/emul/utime.h config.h +utimes.o: $(srcdir)/utimes.c $(srcdir)/missing.h $(srcdir)/emul/utime.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/utimes.c vasgroups.o: $(srcdir)/vasgroups.c $(srcdir)/nonunix.h $(SUDODEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/vasgroups.c visudo.o: $(srcdir)/visudo.c $(SUDODEP) $(devdir)/gram.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/visudo.c -zero_bytes.o: $(srcdir)/zero_bytes.c $(srcdir)/compat.h config.h +zero_bytes.o: $(srcdir)/zero_bytes.c $(srcdir)/missing.h config.h $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(srcdir)/zero_bytes.c sudo_auth.o: $(authdir)/sudo_auth.c $(AUTHDEP) $(INSDEP) $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEFS) $(OPTIONS) $(authdir)/sudo_auth.c diff --git a/aix.c b/aix.c index 5735ec97a..ec0b9fb03 100644 --- a/aix.c +++ b/aix.c @@ -31,7 +31,7 @@ #include #include -#include "compat.h" +#include "missing.h" #include "alloc.h" #include "error.h" diff --git a/audit.c b/audit.c index 9226d301d..15ac8eea7 100644 --- a/audit.c +++ b/audit.c @@ -32,7 +32,7 @@ # include #endif -#include "compat.h" +#include "missing.h" #include "logging.h" #ifdef HAVE_BSM_AUDIT diff --git a/boottime.c b/boottime.c index 37c83158d..7c0410c70 100644 --- a/boottime.c +++ b/boottime.c @@ -47,7 +47,6 @@ # include #endif -#include "compat.h" #include "missing.h" /* diff --git a/compat.h b/compat.h deleted file mode 100644 index c01924d47..000000000 --- a/compat.h +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (c) 1996, 1998-2005, 2008-2010 - * Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F39502-99-1-0512. - */ - -#ifndef _SUDO_COMPAT_H -#define _SUDO_COMPAT_H - -/* - * Macros that may be missing on some Operating Systems - */ - -/* Deal with ANSI stuff reasonably. */ -#ifndef __P -# if defined (__cplusplus) || defined (__STDC__) -# define __P(args) args -# else -# define __P(args) () -# endif -#endif /* __P */ - -/* Define away __attribute__ for non-gcc or old gcc */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 5 -# define __attribute__(x) -#endif - -/* For silencing gcc warnings about rcsids */ -#ifndef __unused -# if defined(__GNUC__) && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ > 7) -# define __unused __attribute__((__unused__)) -# else -# define __unused -# endif -#endif - -/* For catching format string mismatches */ -#ifndef __printflike -# if defined(__GNUC__) && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 7) -# define __printflike(f, v) __attribute__((__format__ (__printf__, f, v))) -# else -# define __printflike(f, v) -# endif -#endif - -/* - * Some systems lack full limit definitions. - */ -#ifndef OPEN_MAX -# define OPEN_MAX 256 -#endif - -#ifndef INT_MAX -# define INT_MAX 0x7fffffff -#endif - -#ifndef PATH_MAX -# ifdef MAXPATHLEN -# define PATH_MAX MAXPATHLEN -# else -# ifdef _POSIX_PATH_MAX -# define PATH_MAX _POSIX_PATH_MAX -# else -# define PATH_MAX 1024 -# endif -# endif -#endif - -#ifndef MAXHOSTNAMELEN -# define MAXHOSTNAMELEN 64 -#endif - -/* - * Posix versions for those without... - */ -#ifndef _S_IFMT -# define _S_IFMT S_IFMT -#endif /* _S_IFMT */ -#ifndef _S_IFREG -# define _S_IFREG S_IFREG -#endif /* _S_IFREG */ -#ifndef _S_IFDIR -# define _S_IFDIR S_IFDIR -#endif /* _S_IFDIR */ -#ifndef _S_IFLNK -# define _S_IFLNK S_IFLNK -#endif /* _S_IFLNK */ -#ifndef S_ISREG -# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) -#endif /* S_ISREG */ -#ifndef S_ISDIR -# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) -#endif /* S_ISDIR */ - -/* - * Some OS's may not have this. - */ -#ifndef S_IRWXU -# define S_IRWXU 0000700 /* rwx for owner */ -#endif /* S_IRWXU */ - -/* - * These should be defined in but not everyone has them. - */ -#ifndef STDIN_FILENO -# define STDIN_FILENO 0 -#endif -#ifndef STDOUT_FILENO -# define STDOUT_FILENO 1 -#endif -#ifndef STDERR_FILENO -# define STDERR_FILENO 2 -#endif - -/* - * These should be defined in but not everyone has them. - */ -#ifndef SEEK_SET -# define SEEK_SET 0 -#endif -#ifndef SEEK_CUR -# define SEEK_CUR 1 -#endif -#ifndef SEEK_END -# define SEEK_END 2 -#endif - -/* - * BSD defines these in but others may not. - */ -#ifndef MIN -# define MIN(a,b) (((a)<(b))?(a):(b)) -#endif -#ifndef MAX -# define MAX(a,b) (((a)>(b))?(a):(b)) -#endif - -/* - * Simple isblank() macro and function for systems without it. - */ -#ifndef HAVE_ISBLANK -int isblank __P((int)); -# define isblank(_x) ((_x) == ' ' || (_x) == '\t') -#endif - -/* - * Old BSD systems lack strchr(), strrchr(), memset() and memcpy() - */ -#if !defined(HAVE_STRCHR) && !defined(strchr) -# define strchr(_s, _c) index(_s, _c) -#endif -#if !defined(HAVE_STRRCHR) && !defined(strrchr) -# define strrchr(_s, _c) rindex(_s, _c) -#endif -#if !defined(HAVE_MEMCPY) && !defined(memcpy) -# define memcpy(_d, _s, _n) (bcopy(_s, _d, _n)) -#endif -#if !defined(HAVE_MEMSET) && !defined(memset) -# define memset(_s, _x, _n) (bzero(_s, _n)) -#endif - -/* - * NCR's SVr4 has _innetgr(3) instead of innetgr(3) for some reason. - */ -#ifdef HAVE__INNETGR -# define innetgr(n, h, u, d) (_innetgr(n, h, u, d)) -# define HAVE_INNETGR 1 -#endif /* HAVE__INNETGR */ - -/* - * On POSIX systems, O_NOCTTY is the default so some OS's may lack this define. - */ -#ifndef O_NOCTTY -# define O_NOCTTY 0 -#endif /* O_NOCTTY */ - -/* - * Emulate POSIX signals via sigvec(2) - */ -#ifndef HAVE_SIGACTION -# define SA_ONSTACK SV_ONSTACK -# define SA_RESTART SV_INTERRUPT /* opposite effect */ -# define SA_RESETHAND SV_RESETHAND -# define sa_handler sv_handler -# define sa_mask sv_mask -# define sa_flags sv_flags -typedef struct sigvec sigaction_t; -typedef int sigset_t; -int sigaction __P((int sig, const sigaction_t *act, sigaction_t *oact)); -int sigemptyset __P((sigset_t *)); -int sigfillset __P((sigset_t *)); -int sigaddset __P((sigset_t *, int)); -int sigdelset __P((sigset_t *, int)); -int sigismember __P((sigset_t *, int)); -int sigprocmask __P((int, const sigset_t *, sigset_t *)); -#endif - -/* - * Extra sugar for POSIX signals to deal with the above emulation - * as well as the fact that SunOS has a SA_INTERRUPT flag. - */ -#ifdef HAVE_SIGACTION -# ifndef HAVE_SIGACTION_T -typedef struct sigaction sigaction_t; -# endif -# ifndef SA_INTERRUPT -# define SA_INTERRUPT 0 -# endif -# ifndef SA_RESTART -# define SA_RESTART 0 -# endif -#endif - -/* - * If dirfd() does not exists, hopefully dd_fd does. - */ -#if !defined(HAVE_DIRFD) && defined(HAVE_DD_FD) -# define dirfd(_d) ((_d)->dd_fd) -# define HAVE_DIRFD -#endif - -/* - * Define futimes() in terms of futimesat() if needed. - */ -#if !defined(HAVE_FUTIMES) && defined(HAVE_FUTIMESAT) -# define futimes(_f, _tv) futimesat(_f, NULL, _tv) -# define HAVE_FUTIMES -#endif - -#if !defined(HAVE_KILLPG) && !defined(killpg) -# define killpg(s) kill(-(s)) -#endif - -/* - * If we lack getprogname(), emulate with __progname if possible. - * Otherwise, add a prototype for use with our own getprogname.c. - */ -#ifndef HAVE_GETPROGNAME -# ifdef HAVE___PROGNAME -extern const char *__progname; -# define getprogname() (__progname) -# else -const char *getprogname __P((void)); -#endif /* HAVE___PROGNAME */ -#endif /* !HAVE_GETPROGNAME */ - -#ifndef timevalclear -# define timevalclear(tv) ((tv)->tv_sec = (tv)->tv_usec = 0) -#endif -#ifndef timevalisset -# define timevalisset(tv) ((tv)->tv_sec || (tv)->tv_usec) -#endif -#ifndef timevalcmp -# define timevalcmp(tv1, tv2, op) \ - (((tv1)->tv_sec == (tv2)->tv_sec) ? \ - ((tv1)->tv_usec op (tv2)->tv_usec) : \ - ((tv1)->tv_sec op (tv2)->tv_sec)) -#endif -#ifndef timevaladd -# define timevaladd(tv1, tv2) \ - do { \ - (tv1)->tv_sec += (tv2)->tv_sec; \ - (tv1)->tv_usec += (tv2)->tv_usec; \ - if ((tv1)->tv_usec >= 1000000) { \ - (tv1)->tv_sec++; \ - (tv1)->tv_usec -= 1000000; \ - } \ - } while (0) -#endif -#ifndef timevalsub -# define timevalsub(tv1, tv2) \ - do { \ - (tv1)->tv_sec -= (tv2)->tv_sec; \ - (tv1)->tv_usec -= (tv2)->tv_usec; \ - if ((tv1)->tv_usec < 0) { \ - (tv1)->tv_sec--; \ - (tv1)->tv_usec += 1000000; \ - } \ - } while (0) -#endif - -/* Not all systems define NSIG in signal.h */ -#if !defined(NSIG) -# if defined(_NSIG) -# define NSIG _NSIG -# elif defined(__NSIG) -# define NSIG __NSIG -# else -# define NSIG 64 -# endif -#endif - -#ifndef WCOREDUMP -# define WCOREDUMP(x) ((x) & 0x80) -#endif - -#endif /* _SUDO_COMPAT_H */ diff --git a/error.c b/error.c index 317f10561..3e81b4fd3 100644 --- a/error.c +++ b/error.c @@ -20,7 +20,7 @@ #include #include -#include +#include #include "error.h" static void _warning __P((int, const char *, va_list)); diff --git a/fnmatch.c b/fnmatch.c index 2255e5214..9b80e4fac 100644 --- a/fnmatch.c +++ b/fnmatch.c @@ -47,7 +47,7 @@ # include #endif /* HAVE_STRINGS_H */ -#include +#include #include "emul/fnmatch.h" #include "emul/charclass.h" diff --git a/getcwd.c b/getcwd.c index 109794ae8..0bbb86fc8 100644 --- a/getcwd.c +++ b/getcwd.c @@ -71,7 +71,7 @@ # endif #endif -#include +#include #define ISDOT(dp) \ (dp->d_name[0] == '.' && (dp->d_name[1] == '\0' || \ diff --git a/getdate.c b/getdate.c index 928246b88..8538fe367 100644 --- a/getdate.c +++ b/getdate.c @@ -50,7 +50,7 @@ #endif #include -#include "compat.h" +#include "missing.h" #define EPOCH 1970 diff --git a/getdate.y b/getdate.y index 2b2e3c9b3..709408319 100644 --- a/getdate.y +++ b/getdate.y @@ -39,7 +39,7 @@ #endif #include -#include "compat.h" +#include "missing.h" #define EPOCH 1970 diff --git a/getline.c b/getline.c index b7db37973..83a325f39 100644 --- a/getline.c +++ b/getline.c @@ -35,7 +35,7 @@ #endif /* HAVE_STRINGS_H */ #include -#include "compat.h" +#include "missing.h" #include "alloc.h" #ifndef LINE_MAX diff --git a/getprogname.c b/getprogname.c index f269405d0..96aa0bd0a 100644 --- a/getprogname.c +++ b/getprogname.c @@ -22,7 +22,7 @@ #include #include -#include +#include const char * getprogname() diff --git a/gettime.c b/gettime.c index 9a13003c4..656b3ec07 100644 --- a/gettime.c +++ b/gettime.c @@ -24,7 +24,7 @@ # include #endif -#include +#include /* * Get the current time via gettimeofday() for systems with diff --git a/glob.c b/glob.c index 9ffce3208..876eee6ae 100644 --- a/glob.c +++ b/glob.c @@ -95,7 +95,7 @@ #include #include -#include +#include #include "emul/glob.h" #include "emul/charclass.h" diff --git a/isblank.c b/isblank.c index e6ad58d49..b8732b2bf 100644 --- a/isblank.c +++ b/isblank.c @@ -15,7 +15,7 @@ */ #include -#include +#include #undef isblank int diff --git a/linux_audit.c b/linux_audit.c index ba87e7885..dabf6b33a 100644 --- a/linux_audit.c +++ b/linux_audit.c @@ -31,10 +31,9 @@ #include #include -#include "compat.h" +#include "missing.h" #include "error.h" #include "alloc.h" -#include "missing.h" #include "linux_audit.h" /* diff --git a/memrchr.c b/memrchr.c index 35e07de5f..80a25f64f 100644 --- a/memrchr.c +++ b/memrchr.c @@ -16,7 +16,7 @@ #include #include -#include +#include /* * Reverse memchr() diff --git a/missing.h b/missing.h index 749323a94..d471603eb 100644 --- a/missing.h +++ b/missing.h @@ -1,5 +1,6 @@ /* - * Copyright (c) 2009-2010 Todd C. Miller + * Copyright (c) 1996, 1998-2005, 2008-2010 + * Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -12,11 +13,303 @@ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Sponsored in part by the Defense Advanced Research Projects + * Agency (DARPA) and Air Force Research Laboratory, Air Force + * Materiel Command, USAF, under agreement number F39502-99-1-0512. */ #ifndef _SUDO_MISSING_H #define _SUDO_MISSING_H +/* + * Macros that may be missing on some Operating Systems + */ + +/* Deal with ANSI stuff reasonably. */ +#ifndef __P +# if defined (__cplusplus) || defined (__STDC__) +# define __P(args) args +# else +# define __P(args) () +# endif +#endif /* __P */ + +/* Define away __attribute__ for non-gcc or old gcc */ +#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 5 +# define __attribute__(x) +#endif + +/* For silencing gcc warnings about rcsids */ +#ifndef __unused +# if defined(__GNUC__) && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ > 7) +# define __unused __attribute__((__unused__)) +# else +# define __unused +# endif +#endif + +/* For catching format string mismatches */ +#ifndef __printflike +# if defined(__GNUC__) && (__GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define __printflike(f, v) __attribute__((__format__ (__printf__, f, v))) +# else +# define __printflike(f, v) +# endif +#endif + +/* + * Some systems lack full limit definitions. + */ +#ifndef OPEN_MAX +# define OPEN_MAX 256 +#endif + +#ifndef INT_MAX +# define INT_MAX 0x7fffffff +#endif + +#ifndef PATH_MAX +# ifdef MAXPATHLEN +# define PATH_MAX MAXPATHLEN +# else +# ifdef _POSIX_PATH_MAX +# define PATH_MAX _POSIX_PATH_MAX +# else +# define PATH_MAX 1024 +# endif +# endif +#endif + +#ifndef MAXHOSTNAMELEN +# define MAXHOSTNAMELEN 64 +#endif + +/* + * Posix versions for those without... + */ +#ifndef _S_IFMT +# define _S_IFMT S_IFMT +#endif /* _S_IFMT */ +#ifndef _S_IFREG +# define _S_IFREG S_IFREG +#endif /* _S_IFREG */ +#ifndef _S_IFDIR +# define _S_IFDIR S_IFDIR +#endif /* _S_IFDIR */ +#ifndef _S_IFLNK +# define _S_IFLNK S_IFLNK +#endif /* _S_IFLNK */ +#ifndef S_ISREG +# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) +#endif /* S_ISREG */ +#ifndef S_ISDIR +# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) +#endif /* S_ISDIR */ + +/* + * Some OS's may not have this. + */ +#ifndef S_IRWXU +# define S_IRWXU 0000700 /* rwx for owner */ +#endif /* S_IRWXU */ + +/* + * These should be defined in but not everyone has them. + */ +#ifndef STDIN_FILENO +# define STDIN_FILENO 0 +#endif +#ifndef STDOUT_FILENO +# define STDOUT_FILENO 1 +#endif +#ifndef STDERR_FILENO +# define STDERR_FILENO 2 +#endif + +/* + * These should be defined in but not everyone has them. + */ +#ifndef SEEK_SET +# define SEEK_SET 0 +#endif +#ifndef SEEK_CUR +# define SEEK_CUR 1 +#endif +#ifndef SEEK_END +# define SEEK_END 2 +#endif + +/* + * BSD defines these in but others may not. + */ +#ifndef MIN +# define MIN(a,b) (((a)<(b))?(a):(b)) +#endif +#ifndef MAX +# define MAX(a,b) (((a)>(b))?(a):(b)) +#endif + +/* + * Simple isblank() macro and function for systems without it. + */ +#ifndef HAVE_ISBLANK +int isblank __P((int)); +# define isblank(_x) ((_x) == ' ' || (_x) == '\t') +#endif + +/* + * Old BSD systems lack strchr(), strrchr(), memset() and memcpy() + */ +#if !defined(HAVE_STRCHR) && !defined(strchr) +# define strchr(_s, _c) index(_s, _c) +#endif +#if !defined(HAVE_STRRCHR) && !defined(strrchr) +# define strrchr(_s, _c) rindex(_s, _c) +#endif +#if !defined(HAVE_MEMCPY) && !defined(memcpy) +# define memcpy(_d, _s, _n) (bcopy(_s, _d, _n)) +#endif +#if !defined(HAVE_MEMSET) && !defined(memset) +# define memset(_s, _x, _n) (bzero(_s, _n)) +#endif + +/* + * NCR's SVr4 has _innetgr(3) instead of innetgr(3) for some reason. + */ +#ifdef HAVE__INNETGR +# define innetgr(n, h, u, d) (_innetgr(n, h, u, d)) +# define HAVE_INNETGR 1 +#endif /* HAVE__INNETGR */ + +/* + * On POSIX systems, O_NOCTTY is the default so some OS's may lack this define. + */ +#ifndef O_NOCTTY +# define O_NOCTTY 0 +#endif /* O_NOCTTY */ + +/* + * Emulate POSIX signals via sigvec(2) + */ +#ifndef HAVE_SIGACTION +# define SA_ONSTACK SV_ONSTACK +# define SA_RESTART SV_INTERRUPT /* opposite effect */ +# define SA_RESETHAND SV_RESETHAND +# define sa_handler sv_handler +# define sa_mask sv_mask +# define sa_flags sv_flags +typedef struct sigvec sigaction_t; +typedef int sigset_t; +int sigaction __P((int sig, const sigaction_t *act, sigaction_t *oact)); +int sigemptyset __P((sigset_t *)); +int sigfillset __P((sigset_t *)); +int sigaddset __P((sigset_t *, int)); +int sigdelset __P((sigset_t *, int)); +int sigismember __P((sigset_t *, int)); +int sigprocmask __P((int, const sigset_t *, sigset_t *)); +#endif + +/* + * Extra sugar for POSIX signals to deal with the above emulation + * as well as the fact that SunOS has a SA_INTERRUPT flag. + */ +#ifdef HAVE_SIGACTION +# ifndef HAVE_SIGACTION_T +typedef struct sigaction sigaction_t; +# endif +# ifndef SA_INTERRUPT +# define SA_INTERRUPT 0 +# endif +# ifndef SA_RESTART +# define SA_RESTART 0 +# endif +#endif + +/* + * If dirfd() does not exists, hopefully dd_fd does. + */ +#if !defined(HAVE_DIRFD) && defined(HAVE_DD_FD) +# define dirfd(_d) ((_d)->dd_fd) +# define HAVE_DIRFD +#endif + +/* + * Define futimes() in terms of futimesat() if needed. + */ +#if !defined(HAVE_FUTIMES) && defined(HAVE_FUTIMESAT) +# define futimes(_f, _tv) futimesat(_f, NULL, _tv) +# define HAVE_FUTIMES +#endif + +#if !defined(HAVE_KILLPG) && !defined(killpg) +# define killpg(s) kill(-(s)) +#endif + +/* + * If we lack getprogname(), emulate with __progname if possible. + * Otherwise, add a prototype for use with our own getprogname.c. + */ +#ifndef HAVE_GETPROGNAME +# ifdef HAVE___PROGNAME +extern const char *__progname; +# define getprogname() (__progname) +# else +const char *getprogname __P((void)); +#endif /* HAVE___PROGNAME */ +#endif /* !HAVE_GETPROGNAME */ + +#ifndef timevalclear +# define timevalclear(tv) ((tv)->tv_sec = (tv)->tv_usec = 0) +#endif +#ifndef timevalisset +# define timevalisset(tv) ((tv)->tv_sec || (tv)->tv_usec) +#endif +#ifndef timevalcmp +# define timevalcmp(tv1, tv2, op) \ + (((tv1)->tv_sec == (tv2)->tv_sec) ? \ + ((tv1)->tv_usec op (tv2)->tv_usec) : \ + ((tv1)->tv_sec op (tv2)->tv_sec)) +#endif +#ifndef timevaladd +# define timevaladd(tv1, tv2) \ + do { \ + (tv1)->tv_sec += (tv2)->tv_sec; \ + (tv1)->tv_usec += (tv2)->tv_usec; \ + if ((tv1)->tv_usec >= 1000000) { \ + (tv1)->tv_sec++; \ + (tv1)->tv_usec -= 1000000; \ + } \ + } while (0) +#endif +#ifndef timevalsub +# define timevalsub(tv1, tv2) \ + do { \ + (tv1)->tv_sec -= (tv2)->tv_sec; \ + (tv1)->tv_usec -= (tv2)->tv_usec; \ + if ((tv1)->tv_usec < 0) { \ + (tv1)->tv_sec--; \ + (tv1)->tv_usec += 1000000; \ + } \ + } while (0) +#endif + +/* Not all systems define NSIG in signal.h */ +#if !defined(NSIG) +# if defined(_NSIG) +# define NSIG _NSIG +# elif defined(__NSIG) +# define NSIG __NSIG +# else +# define NSIG 64 +# endif +#endif + +#ifndef WCOREDUMP +# define WCOREDUMP(x) ((x) & 0x80) +#endif + +#include #ifdef __STDC__ # include #else diff --git a/mksiglist.c b/mksiglist.c index 09b141419..94ac1abf8 100644 --- a/mksiglist.c +++ b/mksiglist.c @@ -28,7 +28,7 @@ #endif /* STDC_HEADERS */ #include -#include +#include int main(argc, argv) @@ -42,7 +42,7 @@ main(argc, argv) printf("#include \n"); printf("#include \n"); - printf("#include \n\n"); + printf("#include \n\n"); printf("const char *const my_sys_siglist[NSIG] = {\n"); for (i = 0; i < NSIG; i++) { if (my_sys_siglist[i] != NULL) { diff --git a/nanosleep.c b/nanosleep.c index ae2208b95..b7fb50729 100644 --- a/nanosleep.c +++ b/nanosleep.c @@ -29,7 +29,7 @@ #endif #include -#include "compat.h" +#include "missing.h" int nanosleep(ts, rts) diff --git a/sesh.c b/sesh.c index 3195e25b9..40016140b 100644 --- a/sesh.c +++ b/sesh.c @@ -27,7 +27,7 @@ #include #include -#include "compat.h" +#include "missing.h" int main (int argc, char **argv) diff --git a/setsid.c b/setsid.c index d8bba8b30..80c620c9c 100644 --- a/setsid.c +++ b/setsid.c @@ -26,7 +26,7 @@ #endif /* HAVE_UNISTD_H */ #include -#include +#include pid_t setsid() diff --git a/sigaction.c b/sigaction.c index e34d471c8..824917bb4 100644 --- a/sigaction.c +++ b/sigaction.c @@ -21,7 +21,7 @@ #include #include -#include +#include int sigaction(signo, sa, osa) diff --git a/snprintf.c b/snprintf.c index 4123a9d77..2ef67356a 100644 --- a/snprintf.c +++ b/snprintf.c @@ -76,7 +76,7 @@ # include #endif -#include +#include static int xxxprintf __P((char **, size_t, int, const char *, va_list)); diff --git a/strcasecmp.c b/strcasecmp.c index d14fdfb38..3298b42e9 100644 --- a/strcasecmp.c +++ b/strcasecmp.c @@ -16,7 +16,7 @@ #include #include -#include +#include /* * Case insensitive string compare routines, same semantics as str[n]cmp() diff --git a/strerror.c b/strerror.c index cacd3f634..0cd995daf 100644 --- a/strerror.c +++ b/strerror.c @@ -22,7 +22,7 @@ #include #include -#include +#include /* * Map errno -> error string. diff --git a/strlcat.c b/strlcat.c index 97a803b20..6f94a0984 100644 --- a/strlcat.c +++ b/strlcat.c @@ -20,8 +20,7 @@ #include #include -#include - +#include /* * Appends src to string dst of size siz (unlike strncat, siz is the diff --git a/strlcpy.c b/strlcpy.c index 8d301c3a5..175b137b7 100644 --- a/strlcpy.c +++ b/strlcpy.c @@ -19,7 +19,7 @@ #include #include -#include +#include /* * Copy src to string dst of size siz. At most siz-1 characters diff --git a/strsignal.c b/strsignal.c index cead4ada1..8414f646a 100644 --- a/strsignal.c +++ b/strsignal.c @@ -18,7 +18,7 @@ #include #include -#include +#include #if defined(HAVE_DECL_SYS_SIGLIST) && HAVE_DECL_SYS_SIGLIST == 1 # define my_sys_siglist sys_siglist diff --git a/sudo.h b/sudo.h index 2e734cc1c..06558898b 100644 --- a/sudo.h +++ b/sudo.h @@ -24,7 +24,7 @@ #include #include -#include "compat.h" +#include "missing.h" #include "alloc.h" #include "defaults.h" #include "error.h" diff --git a/sudo_noexec.c b/sudo_noexec.c index eff07b9ee..3632207b8 100644 --- a/sudo_noexec.c +++ b/sudo_noexec.c @@ -26,7 +26,7 @@ # include #endif -#include +#include /* * Dummy versions of the execve() family of syscalls. We don't need diff --git a/sudoreplay.c b/sudoreplay.c index 98cde87aa..4c4711e91 100644 --- a/sudoreplay.c +++ b/sudoreplay.c @@ -85,10 +85,9 @@ #include -#include "compat.h" +#include "missing.h" #include "alloc.h" #include "error.h" -#include "missing.h" #ifndef LINE_MAX # define LINE_MAX 2048 diff --git a/timestr.c b/timestr.c index 3b2a18dd7..d2fce9c45 100644 --- a/timestr.c +++ b/timestr.c @@ -28,7 +28,7 @@ #endif /* STDC_HEADERS */ #include -#include "compat.h" +#include "missing.h" char *get_timestr __P((time_t, int)); diff --git a/utimes.c b/utimes.c index 84f4c433c..2f1e0e044 100644 --- a/utimes.c +++ b/utimes.c @@ -29,7 +29,7 @@ # include #endif -#include +#include #ifndef HAVE_UTIMES /* diff --git a/vasgroups.c b/vasgroups.c index a7c6c34fb..158c03909 100644 --- a/vasgroups.c +++ b/vasgroups.c @@ -40,7 +40,7 @@ #include -#include "compat.h" +#include "missing.h" #include "logging.h" #include "nonunix.h" #include "sudo.h" diff --git a/zero_bytes.c b/zero_bytes.c index 7391780aa..efe0f9f6c 100644 --- a/zero_bytes.c +++ b/zero_bytes.c @@ -17,7 +17,7 @@ #include #include -#include +#include /* * Like bzero(3) but with a volatile pointer. The hope is that -- 2.40.0