Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sudo-project
GitHub Repository: sudo-project/sudo
Path: blob/main/include/sudo_compat.h
3811 views
1
/*
2
* SPDX-License-Identifier: ISC
3
*
4
* Copyright (c) 1996, 1998-2005, 2008, 2009-2024
5
* Todd C. Miller <[email protected]>
6
*
7
* Permission to use, copy, modify, and distribute this software for any
8
* purpose with or without fee is hereby granted, provided that the above
9
* copyright notice and this permission notice appear in all copies.
10
*
11
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
*
19
* Sponsored in part by the Defense Advanced Research Projects
20
* Agency (DARPA) and Air Force Research Laboratory, Air Force
21
* Materiel Command, USAF, under agreement number F39502-99-1-0512.
22
*/
23
24
#ifndef SUDO_COMPAT_H
25
#define SUDO_COMPAT_H
26
27
#include <sys/types.h> /* for gid_t, mode_t, size_t, ssize_t, time_t, uid_t */
28
#include <sys/stat.h> /* to avoid problems with mismatched headers and libc */
29
#include <unistd.h> /* to avoid problems with mismatched headers and libc */
30
#include <stdio.h>
31
#if !defined(HAVE_UTIMENSAT) || !defined(HAVE_FUTIMENS)
32
# include <time.h>
33
#endif
34
#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_VASPRINTF) || \
35
!defined(HAVE_VSYSLOG) || defined(PREFER_PORTABLE_SNPRINTF)
36
# include <stdarg.h>
37
#endif
38
39
/*
40
* Macros and functions that may be missing on some operating systems.
41
*/
42
43
#ifndef NODEV
44
# define NODEV ((dev_t)-1) /* non-existent device */
45
#endif
46
47
/*
48
* Given the pointer x to the member m of the struct s, return
49
* a pointer to the containing structure.
50
*/
51
#ifndef __containerof
52
# define __containerof(x, s, m) ((s *)((char *)(x) - offsetof(s, m)))
53
#endif
54
55
/*
56
* Pre-C99 compilers may lack a va_copy macro.
57
*/
58
#ifndef HAVE_VA_COPY
59
# ifdef HAVE___VA_COPY
60
# define va_copy(d, s) __va_copy(d, s)
61
# else
62
# define va_copy(d, s) memcpy(&(d), &(s), sizeof(d));
63
# endif
64
#endif
65
66
/*
67
* Some systems lack full limit definitions.
68
*/
69
#if defined(HAVE_DECL_LLONG_MAX) && !HAVE_DECL_LLONG_MAX
70
# if defined(HAVE_DECL_QUAD_MAX) && HAVE_DECL_QUAD_MAX
71
# define LLONG_MAX QUAD_MAX
72
# else
73
# define LLONG_MAX 0x7fffffffffffffffLL
74
# endif
75
#endif
76
77
#if defined(HAVE_DECL_LLONG_MIN) && !HAVE_DECL_LLONG_MIN
78
# if defined(HAVE_DECL_QUAD_MIN) && HAVE_DECL_QUAD_MIN
79
# define LLONG_MIN QUAD_MIN
80
# else
81
# define LLONG_MIN (-0x7fffffffffffffffLL-1)
82
# endif
83
#endif
84
85
#if defined(HAVE_DECL_ULLONG_MAX) && !HAVE_DECL_ULLONG_MAX
86
# if defined(HAVE_DECL_UQUAD_MAX) && HAVE_DECL_UQUAD_MAX
87
# define ULLONG_MAX UQUAD_MAX
88
# else
89
# define ULLONG_MAX 0xffffffffffffffffULL
90
# endif
91
#endif
92
93
#if defined(HAVE_DECL_SIZE_MAX) && !HAVE_DECL_SIZE_MAX
94
# if defined(HAVE_DECL_SIZE_T_MAX) && HAVE_DECL_SIZE_T_MAX
95
# define SIZE_MAX SIZE_T_MAX
96
# else
97
# define SIZE_MAX ULONG_MAX
98
# endif
99
#endif
100
101
#if defined(HAVE_DECL_SSIZE_MAX) && !HAVE_DECL_SSIZE_MAX
102
# define SSIZE_MAX LONG_MAX
103
#endif
104
105
#if defined(HAVE_DECL_PATH_MAX) && !HAVE_DECL_PATH_MAX
106
# if defined(HAVE_DECL__POSIX_PATH_MAX) && HAVE_DECL__POSIX_PATH_MAX
107
# define PATH_MAX _POSIX_PATH_MAX
108
# else
109
# define PATH_MAX 256
110
# endif
111
#endif
112
113
/* ACCESSPERMS and ALLPERMS are handy BSDisms. */
114
#ifndef ACCESSPERMS
115
# define ACCESSPERMS 00777
116
#endif /* ACCESSPERMS */
117
#ifndef ALLPERMS
118
# define ALLPERMS 07777
119
#endif /* ALLPERMS */
120
121
/* For futimens() and utimensat() emulation. */
122
#if !defined(HAVE_FUTIMENS) && !defined(HAVE_UTIMENSAT)
123
# ifndef UTIME_OMIT
124
# define UTIME_OMIT -1L
125
# endif
126
# ifndef UTIME_NOW
127
# define UTIME_NOW -2L
128
# endif
129
#endif
130
#if !defined(HAVE_OPENAT) || (!defined(HAVE_FUTIMENS) && !defined(HAVE_UTIMENSAT)) || !defined(HAVE_FCHMODAT) || !defined(HAVE_FSTATAT) || !defined(HAVE_UNLINKAT)
131
# ifndef AT_FDCWD
132
# define AT_FDCWD -100
133
# endif
134
# ifndef AT_SYMLINK_NOFOLLOW
135
# define AT_SYMLINK_NOFOLLOW 0x02
136
# endif
137
#endif
138
139
/* For dup3() and pipe2() emulation. */
140
#if (!defined(HAVE_PIPE2) || !defined(HAVE_DUP3)) && defined(O_NONBLOCK)
141
# if !defined(O_CLOEXEC) || O_CLOEXEC > 0xffffffff
142
# undef O_CLOEXEC
143
# define O_CLOEXEC 0x80000000
144
# endif
145
#endif
146
147
/* Older systems lack O_DIRECTORY. */
148
#if defined(HAVE_DECL_O_DIRECTORY) && !HAVE_DECL_O_DIRECTORY
149
# define O_DIRECTORY 0
150
#endif
151
152
/* Older systems lack O_NOFOLLOW. */
153
#if defined(HAVE_DECL_O_NOFOLLOW) && !HAVE_DECL_O_NOFOLLOW
154
# define O_NOFOLLOW 0
155
#endif
156
157
/*
158
* BSD defines these in <sys/param.h> but we don't include that anymore.
159
*/
160
#ifndef MIN
161
# define MIN(a,b) (((a)<(b))?(a):(b))
162
#endif
163
#ifndef MAX
164
# define MAX(a,b) (((a)>(b))?(a):(b))
165
#endif
166
167
/* Macros to set/clear/test flags. */
168
#undef SET
169
#define SET(t, f) ((t) |= (f))
170
#undef CLR
171
#define CLR(t, f) ((t) &= ~(f))
172
#undef ISSET
173
#define ISSET(t, f) ((t) & (f))
174
175
/*
176
* Some systems define this in <sys/param.h> but we don't include that anymore.
177
*/
178
#ifndef howmany
179
# define howmany(x, y) (((x) + ((y) - 1)) / (y))
180
#endif
181
182
/*
183
* Simple isblank() macro and function for systems without it.
184
*/
185
#ifndef HAVE_ISBLANK
186
sudo_dso_public int isblank(int);
187
# define isblank(_x) ((_x) == ' ' || (_x) == '\t')
188
#endif
189
190
/*
191
* NCR's SVr4 has _innetgr(3) instead of innetgr(3) for some reason.
192
*/
193
#ifdef HAVE__INNETGR
194
# define innetgr(n, h, u, d) (_innetgr(n, h, u, d))
195
# define HAVE_INNETGR 1
196
#endif /* HAVE__INNETGR */
197
198
/*
199
* The nitems macro may be defined in sys/param.h
200
*/
201
#ifndef nitems
202
# define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
203
#endif
204
205
/*
206
* If dirfd() does not exists, hopefully dd_fd does.
207
*/
208
#if !defined(HAVE_DIRFD) && defined(HAVE_DD_FD)
209
# define dirfd(_d) ((_d)->dd_fd)
210
# define HAVE_DIRFD
211
#endif
212
213
#if !defined(HAVE_KILLPG) && !defined(killpg)
214
# define killpg(p, s) kill(-(p), (s))
215
#endif
216
217
/*
218
* Declare errno if errno.h doesn't do it for us.
219
*/
220
#if defined(HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO
221
extern int errno;
222
#endif /* !HAVE_DECL_ERRNO */
223
224
/* Not all systems define NSIG in signal.h */
225
#if defined(HAVE_DECL_NSIG) && !HAVE_DECL_NSIG
226
# if defined(HAVE_DECL__NSIG) && HAVE_DECL__NSIG
227
# define NSIG _NSIG
228
# elif defined(HAVE_DECL___NSIG) && HAVE_DECL___NSIG
229
# define NSIG __NSIG
230
# else
231
# define NSIG 64
232
# endif
233
#endif
234
235
/* For sig2str() */
236
#if !defined(HAVE_DECL_SIG2STR_MAX) || !HAVE_DECL_SIG2STR_MAX
237
# define SIG2STR_MAX 32
238
#endif
239
240
/* WCOREDUMP is not POSIX, this usually works (verified on AIX). */
241
#ifndef WCOREDUMP
242
# define WCOREDUMP(x) ((x) & 0x80)
243
#endif
244
245
/* W_EXITCODE is not POSIX but the encoding of wait status is. */
246
#ifndef W_EXITCODE
247
# define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
248
#endif
249
250
/* Number of bits in a byte. */
251
#ifndef NBBY
252
# ifdef __NBBY
253
# define NBBY __NBBY
254
# else
255
# define NBBY 8
256
# endif
257
#endif
258
259
#ifndef HAVE_SETEUID
260
# if defined(HAVE_SETRESUID)
261
# define seteuid(u) setresuid(-1, (u), -1)
262
# define setegid(g) setresgid(-1, (g), -1)
263
# define HAVE_SETEUID 1
264
# elif defined(HAVE_SETREUID)
265
# define seteuid(u) setreuid(-1, (u))
266
# define setegid(g) setregid(-1, (g))
267
# define HAVE_SETEUID 1
268
# endif
269
#endif /* HAVE_SETEUID */
270
271
/*
272
* Older HP-UX does not declare setresuid() or setresgid().
273
*/
274
#if defined(HAVE_DECL_SETRESUID) && !HAVE_DECL_SETRESUID
275
int setresuid(uid_t, uid_t, uid_t);
276
int setresgid(gid_t, gid_t, gid_t);
277
#endif
278
#if defined(HAVE_DECL_GETRESUID) && !HAVE_DECL_GETRESUID
279
int getresuid(uid_t *, uid_t *, uid_t *);
280
int getresgid(gid_t *, gid_t *, gid_t *);
281
#endif
282
283
/*
284
* HP-UX does not declare innetgr() or getdomainname().
285
* Solaris does not declare getdomainname().
286
*/
287
#if defined(HAVE_DECL_INNETGR) && !HAVE_DECL_INNETGR
288
int innetgr(const char *, const char *, const char *, const char *);
289
#endif
290
#if defined(HAVE_DECL__INNETGR) && !HAVE_DECL__INNETGR
291
int _innetgr(const char *, const char *, const char *, const char *);
292
#endif
293
#if defined(HAVE_DECL_GETDOMAINNAME) && !HAVE_DECL_GETDOMAINNAME
294
int getdomainname(char *, size_t);
295
#endif
296
297
/*
298
* HP-UX 11.00 has broken pread/pwrite on 32-bit machines when
299
* _FILE_OFFSET_BITS == 64. Use pread64/pwrite64 instead.
300
*/
301
#if defined(__hpux) && !defined(__LP64__)
302
# ifdef HAVE_PREAD64
303
# undef pread
304
# define pread(_a, _b, _c, _d) pread64((_a), (_b), (_c), (_d))
305
# if defined(HAVE_DECL_PREAD64) && !HAVE_DECL_PREAD64
306
ssize_t pread64(int fd, void *buf, size_t nbytes, off64_t offset);
307
# endif
308
# endif
309
# ifdef HAVE_PWRITE64
310
# undef pwrite
311
# define pwrite(_a, _b, _c, _d) pwrite64((_a), (_b), (_c), (_d))
312
# if defined(HAVE_DECL_PWRITE64) && !HAVE_DECL_PWRITE64
313
ssize_t pwrite64(int fd, const void *buf, size_t nbytes, off64_t offset);
314
# endif
315
# endif
316
#endif /* __hpux && !__LP64__ */
317
318
/*
319
* Older systems may lack fseeko(3), just use fseek(3) instead.
320
*/
321
#ifndef HAVE_FSEEKO
322
# define fseeko(f, o, w) fseek((f), (long)(o), (w))
323
#endif
324
325
/*
326
* Functions "missing" from libc.
327
* All libc replacements are prefixed with "sudo_" to avoid namespace issues.
328
*/
329
330
struct passwd;
331
struct stat;
332
struct timespec;
333
struct termios;
334
struct tm;
335
336
#ifndef HAVE_CFMAKERAW
337
sudo_dso_public void sudo_cfmakeraw(struct termios *term);
338
# undef cfmakeraw
339
# define cfmakeraw(_a) sudo_cfmakeraw((_a))
340
#endif /* HAVE_CFMAKERAW */
341
#ifndef HAVE_CLOSEFROM
342
sudo_dso_public void sudo_closefrom(int);
343
# undef closefrom
344
# define closefrom(_a) sudo_closefrom((_a))
345
#endif /* HAVE_CLOSEFROM */
346
#ifndef HAVE_EXPLICIT_BZERO
347
sudo_dso_public void sudo_explicit_bzero(void *s, size_t n);
348
# undef explicit_bzero
349
# define explicit_bzero(_a, _b) sudo_explicit_bzero((_a), (_b))
350
#endif /* HAVE_EXPLICIT_BZERO */
351
#ifndef HAVE_FREEZERO
352
sudo_dso_public void sudo_freezero(void *p, size_t n);
353
# undef freezero
354
# define freezero(_a, _b) sudo_freezero((_a), (_b))
355
#endif /* HAVE_FREEZERO */
356
#ifndef HAVE_GETGROUPLIST
357
sudo_dso_public int sudo_getgrouplist(const char *name, GETGROUPS_T basegid, GETGROUPS_T *groups, int *ngroupsp);
358
# undef getgrouplist
359
# define getgrouplist(_a, _b, _c, _d) sudo_getgrouplist((_a), (_b), (_c), (_d))
360
#endif /* GETGROUPLIST */
361
#if !defined(HAVE_GETDELIM)
362
sudo_dso_public ssize_t sudo_getdelim(char ** restrict bufp, size_t * restrict bufsizep, int delim, FILE * restrict fp);
363
# undef getdelim
364
# define getdelim(_a, _b, _c, _d) sudo_getdelim((_a), (_b), (_c), (_d))
365
#elif defined(HAVE_DECL_GETDELIM) && !HAVE_DECL_GETDELIM
366
/* getdelim present in libc but missing prototype (old gcc fixed includes?) */
367
ssize_t getdelim(char ** restrict bufp, size_t * restrict bufsizep, int delim, FILE * restrict fp);
368
#endif /* HAVE_GETDELIM */
369
#ifndef HAVE_GETUSERSHELL
370
sudo_dso_public char *sudo_getusershell(void);
371
# undef getusershell
372
# define getusershell() sudo_getusershell()
373
sudo_dso_public void sudo_setusershell(void);
374
# undef setusershell
375
# define setusershell() sudo_setusershell()
376
sudo_dso_public void sudo_endusershell(void);
377
# undef endusershell
378
# define endusershell() sudo_endusershell()
379
#elif HAVE_DECL_GETUSERSHELL == 0
380
/* Older Solaris has getusershell() et al but does not declare it. */
381
char *getusershell(void);
382
void setusershell(void);
383
void endusershell(void);
384
#endif /* HAVE_GETUSERSHELL */
385
#ifndef HAVE_GMTIME_R
386
sudo_dso_public struct tm *sudo_gmtime_r(const time_t * restrict, struct tm * restrict);
387
# undef gmtime_r
388
# define gmtime_r(_a, _b) sudo_gmtime_r((_a), (_b))
389
#endif /* HAVE_GMTIME_R */
390
#ifndef HAVE_LOCALTIME_R
391
sudo_dso_public struct tm *sudo_localtime_r(const time_t * restrict, struct tm * restrict);
392
# undef localtime_r
393
# define localtime_r(_a, _b) sudo_localtime_r((_a), (_b))
394
#endif /* HAVE_LOCALTIME_R */
395
#ifndef HAVE_TIMEGM
396
sudo_dso_public time_t sudo_timegm(struct tm *);
397
#endif /* HAVE_TIMEGM */
398
#ifndef HAVE_UTIMENSAT
399
sudo_dso_public int sudo_utimensat(int fd, const char *file, const struct timespec times[2], int flag);
400
# undef utimensat
401
# define utimensat(_a, _b, _c, _d) sudo_utimensat((_a), (_b), (_c), (_d))
402
#endif /* HAVE_UTIMENSAT */
403
#ifndef HAVE_FCHMODAT
404
sudo_dso_public int sudo_fchmodat(int dfd, const char *path, mode_t mode, int flag);
405
# undef fchmodat
406
# define fchmodat(_a, _b, _c, _d) sudo_fchmodat((_a), (_b), (_c), (_d))
407
#endif /* HAVE_FCHMODAT */
408
#ifndef HAVE_FSTATAT
409
sudo_dso_public int sudo_fstatat(int dfd, const char * restrict path, struct stat * restrict sb, int flag);
410
# undef fstatat
411
# define fstatat(_a, _b, _c, _d) sudo_fstatat((_a), (_b), (_c), (_d))
412
#endif /* HAVE_FSTATAT */
413
#ifndef HAVE_FUTIMENS
414
sudo_dso_public int sudo_futimens(int fd, const struct timespec times[2]);
415
# undef futimens
416
# define futimens(_a, _b) sudo_futimens((_a), (_b))
417
#endif /* HAVE_FUTIMENS */
418
#if !defined(HAVE_SNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
419
sudo_dso_public int sudo_snprintf(char * restrict str, size_t n, char const * restrict fmt, ...) sudo_printflike(3, 4);
420
# undef snprintf
421
# define snprintf sudo_snprintf
422
#endif /* HAVE_SNPRINTF */
423
#if !defined(HAVE_VSNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
424
sudo_dso_public int sudo_vsnprintf(char * restrict str, size_t n, const char * restrict fmt, va_list ap) sudo_printflike(3, 0);
425
# undef vsnprintf
426
# define vsnprintf sudo_vsnprintf
427
#endif /* HAVE_VSNPRINTF */
428
#if !defined(HAVE_ASPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
429
sudo_dso_public int sudo_asprintf(char ** restrict str, char const * restrict fmt, ...) sudo_printflike(2, 3);
430
# undef asprintf
431
# define asprintf sudo_asprintf
432
#endif /* HAVE_ASPRINTF */
433
#if !defined(HAVE_VASPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
434
sudo_dso_public int sudo_vasprintf(char ** restrict str, const char * restrict fmt, va_list ap) sudo_printflike(2, 0);
435
# undef vasprintf
436
# define vasprintf sudo_vasprintf
437
#endif /* HAVE_VASPRINTF */
438
#ifndef HAVE_STRLCAT
439
sudo_dso_public size_t sudo_strlcat(char * restrict dst, const char * restrict src, size_t siz);
440
# undef strlcat
441
# define strlcat(_a, _b, _c) sudo_strlcat((_a), (_b), (_c))
442
#endif /* HAVE_STRLCAT */
443
#ifndef HAVE_STRLCPY
444
sudo_dso_public size_t sudo_strlcpy(char * restrict dst, const char * restrict src, size_t siz);
445
# undef strlcpy
446
# define strlcpy(_a, _b, _c) sudo_strlcpy((_a), (_b), (_c))
447
#endif /* HAVE_STRLCPY */
448
#ifndef HAVE_STRNDUP
449
sudo_dso_public char *sudo_strndup(const char *str, size_t maxlen);
450
# undef strndup
451
# define strndup(_a, _b) sudo_strndup((_a), (_b))
452
#endif /* HAVE_STRNDUP */
453
#ifndef HAVE_STRNLEN
454
sudo_dso_public size_t sudo_strnlen(const char *str, size_t maxlen);
455
# undef strnlen
456
# define strnlen(_a, _b) sudo_strnlen((_a), (_b))
457
#endif /* HAVE_STRNLEN */
458
#ifndef HAVE_FCHOWNAT
459
sudo_dso_public int sudo_fchownat(int dfd, const char *path, uid_t uid, gid_t gid, int flag);
460
# undef fchownat
461
# define fchownat(_a, _b, _c, _d, _e) sudo_fchownat((_a), (_b), (_c), (_d), (_e))
462
#endif /* HAVE_FCHOWNAT */
463
#ifndef HAVE_MEMRCHR
464
sudo_dso_public void *sudo_memrchr(const void *s, int c, size_t n);
465
# undef memrchr
466
# define memrchr(_a, _b, _c) sudo_memrchr((_a), (_b), (_c))
467
#endif /* HAVE_MEMRCHR */
468
#ifndef HAVE_MKDIRAT
469
sudo_dso_public int sudo_mkdirat(int dfd, const char *path, mode_t mode);
470
# undef mkdirat
471
# define mkdirat(_a, _b, _c) sudo_mkdirat((_a), (_b), (_c))
472
#endif /* HAVE_MKDIRAT */
473
#if !defined(HAVE_MKDTEMPAT) || !defined(HAVE_MKOSTEMPSAT)
474
# if defined(HAVE_MKDTEMPAT_NP) && defined(HAVE_MKOSTEMPSAT_NP)
475
# undef mkdtempat
476
# define mkdtempat mkdtempat_np
477
# undef mkostempsat
478
# define mkostempsat mkostempsat_np
479
# else
480
sudo_dso_public char *sudo_mkdtemp(char *path);
481
# undef mkdtemp
482
# define mkdtemp(_a) sudo_mkdtemp((_a))
483
sudo_dso_public char *sudo_mkdtempat(int dfd, char *path);
484
# undef mkdtempat
485
# define mkdtempat(_a, _b) sudo_mkdtempat((_a), (_b))
486
sudo_dso_public int sudo_mkostempsat(int dfd, char *path, int slen, int flags);
487
# undef mkostempsat
488
# define mkostempsat(_a, _b, _c, _d) sudo_mkostempsat((_a), (_b), (_c), (_d))
489
sudo_dso_public int sudo_mkstemp(char *path);
490
# undef mkstemp
491
# define mkstemp(_a) sudo_mkstemp((_a))
492
sudo_dso_public int sudo_mkstemps(char *path, int slen);
493
# undef mkstemps
494
# define mkstemps(_a, _b) sudo_mkstemps((_a), (_b))
495
# endif /* HAVE_MKDTEMPAT_NP || HAVE_MKOSTEMPSAT_NP */
496
#endif /* !HAVE_MKDTEMPAT || !HAVE_MKOSTEMPSAT */
497
#ifndef HAVE_NANOSLEEP
498
sudo_dso_public int sudo_nanosleep(const struct timespec *timeout, struct timespec *remainder);
499
#undef nanosleep
500
# define nanosleep(_a, _b) sudo_nanosleep((_a), (_b))
501
#endif /* HAVE_NANOSLEEP */
502
#ifndef HAVE_OPENAT
503
sudo_dso_public int sudo_openat(int dfd, const char *path, int flags, mode_t mode);
504
# undef openat
505
# define openat(_a, _b, _c, _d) sudo_openat((_a), (_b), (_c), (_d))
506
#endif /* HAVE_OPENAT */
507
#ifndef HAVE_PW_DUP
508
sudo_dso_public struct passwd *sudo_pw_dup(const struct passwd *pw);
509
# undef pw_dup
510
# define pw_dup(_a) sudo_pw_dup((_a))
511
#endif /* HAVE_PW_DUP */
512
#ifndef HAVE_STRSIGNAL
513
sudo_dso_public char *sudo_strsignal(int signo);
514
# undef strsignal
515
# define strsignal(_a) sudo_strsignal((_a))
516
#endif /* HAVE_STRSIGNAL */
517
#ifndef HAVE_SIG2STR
518
sudo_dso_public int sudo_sig2str(int signo, char *signame);
519
# undef sig2str
520
# define sig2str(_a, _b) sudo_sig2str((_a), (_b))
521
#endif /* HAVE_SIG2STR */
522
#ifndef HAVE_STR2SIG
523
sudo_dso_public int sudo_str2sig(const char *signame, int *signum);
524
# undef str2sig
525
# define str2sig(_a, _b) sudo_str2sig((_a), (_b))
526
#endif /* HAVE_STR2SIG */
527
#if !defined(HAVE_INET_NTOP) && defined(NEED_INET_NTOP)
528
sudo_dso_public const char *sudo_inet_ntop(int af, const void * restrict src, char * restrict dst, socklen_t size);
529
# undef inet_ntop
530
# define inet_ntop(_a, _b, _c, _d) sudo_inet_ntop((_a), (_b), (_c), (_d))
531
#endif /* HAVE_INET_NTOP */
532
#ifndef HAVE_INET_PTON
533
sudo_dso_public int sudo_inet_pton(int af, const char * restrict src, void * restrict dst);
534
# undef inet_pton
535
# define inet_pton(_a, _b, _c) sudo_inet_pton((_a), (_b), (_c))
536
#endif /* HAVE_INET_PTON */
537
#ifndef HAVE_GETPROGNAME
538
sudo_dso_public const char *sudo_getprogname(void);
539
# undef getprogname
540
# define getprogname() sudo_getprogname()
541
#endif /* HAVE_GETPROGNAME */
542
#ifndef HAVE_SETPROGNAME
543
sudo_dso_public void sudo_setprogname(const char *name);
544
# undef setprogname
545
# define setprogname(_a) sudo_setprogname(_a)
546
#endif /* HAVE_SETPROGNAME */
547
#ifndef HAVE_REALLOCARRAY
548
sudo_dso_public void *sudo_reallocarray(void *ptr, size_t nmemb, size_t size);
549
# undef reallocarray
550
# define reallocarray(_a, _b, _c) sudo_reallocarray((_a), (_b), (_c))
551
#endif /* HAVE_REALLOCARRAY */
552
#ifndef HAVE_REALPATH
553
sudo_dso_public char *sudo_realpath(const char * restrict path, char * restrict resolved);
554
# undef realpath
555
# define realpath(_a, _b) sudo_realpath((_a), (_b))
556
#endif /* HAVE_REALPATH */
557
#ifndef HAVE_DUP3
558
sudo_dso_public int sudo_dup3(int oldd, int newd, int flags);
559
# undef dup3
560
# define dup3(_a, _b, _c) sudo_dup3((_a), (_b), (_c))
561
#endif /* HAVE_DUP3 */
562
#ifndef HAVE_PIPE2
563
sudo_dso_public int sudo_pipe2(int fildes[2], int flags);
564
# undef pipe2
565
# define pipe2(_a, _b) sudo_pipe2((_a), (_b))
566
#endif /* HAVE_PIPE2 */
567
#ifndef HAVE_PREAD
568
sudo_dso_public ssize_t sudo_pread(int fd, void *buf, size_t nbytes, off_t offset);
569
# undef pread
570
# define pread(_a, _b, _c, _d) sudo_pread((_a), (_b), (_c), (_d))
571
#endif /* HAVE_PREAD */
572
#ifndef HAVE_PWRITE
573
sudo_dso_public ssize_t sudo_pwrite(int fd, const void *buf, size_t nbytes, off_t offset);
574
# undef pwrite
575
# define pwrite(_a, _b, _c, _d) sudo_pwrite((_a), (_b), (_c), (_d))
576
#endif /* HAVE_PWRITE */
577
#ifndef HAVE_UNLINKAT
578
sudo_dso_public int sudo_unlinkat(int dfd, const char *path, int flag);
579
# undef unlinkat
580
# define unlinkat(_a, _b, _c) sudo_unlinkat((_a), (_b), (_c))
581
#endif /* HAVE_UNLINKAT */
582
583
#endif /* SUDO_COMPAT_H */
584
585