Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sudo-project
GitHub Repository: sudo-project/sudo
Path: blob/main/include/sudo_compat.h
1532 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
#ifndef O_DIRECTORY
149
# define O_DIRECTORY 0
150
#endif
151
152
/*
153
* BSD defines these in <sys/param.h> but we don't include that anymore.
154
*/
155
#ifndef MIN
156
# define MIN(a,b) (((a)<(b))?(a):(b))
157
#endif
158
#ifndef MAX
159
# define MAX(a,b) (((a)>(b))?(a):(b))
160
#endif
161
162
/* Macros to set/clear/test flags. */
163
#undef SET
164
#define SET(t, f) ((t) |= (f))
165
#undef CLR
166
#define CLR(t, f) ((t) &= ~(f))
167
#undef ISSET
168
#define ISSET(t, f) ((t) & (f))
169
170
/*
171
* Some systems define this in <sys/param.h> but we don't include that anymore.
172
*/
173
#ifndef howmany
174
# define howmany(x, y) (((x) + ((y) - 1)) / (y))
175
#endif
176
177
/*
178
* Simple isblank() macro and function for systems without it.
179
*/
180
#ifndef HAVE_ISBLANK
181
sudo_dso_public int isblank(int);
182
# define isblank(_x) ((_x) == ' ' || (_x) == '\t')
183
#endif
184
185
/*
186
* NCR's SVr4 has _innetgr(3) instead of innetgr(3) for some reason.
187
*/
188
#ifdef HAVE__INNETGR
189
# define innetgr(n, h, u, d) (_innetgr(n, h, u, d))
190
# define HAVE_INNETGR 1
191
#endif /* HAVE__INNETGR */
192
193
/*
194
* The nitems macro may be defined in sys/param.h
195
*/
196
#ifndef nitems
197
# define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
198
#endif
199
200
/*
201
* If dirfd() does not exists, hopefully dd_fd does.
202
*/
203
#if !defined(HAVE_DIRFD) && defined(HAVE_DD_FD)
204
# define dirfd(_d) ((_d)->dd_fd)
205
# define HAVE_DIRFD
206
#endif
207
208
#if !defined(HAVE_KILLPG) && !defined(killpg)
209
# define killpg(p, s) kill(-(p), (s))
210
#endif
211
212
/*
213
* Declare errno if errno.h doesn't do it for us.
214
*/
215
#if defined(HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO
216
extern int errno;
217
#endif /* !HAVE_DECL_ERRNO */
218
219
/* Not all systems define NSIG in signal.h */
220
#if defined(HAVE_DECL_NSIG) && !HAVE_DECL_NSIG
221
# if defined(HAVE_DECL__NSIG) && HAVE_DECL__NSIG
222
# define NSIG _NSIG
223
# elif defined(HAVE_DECL___NSIG) && HAVE_DECL___NSIG
224
# define NSIG __NSIG
225
# else
226
# define NSIG 64
227
# endif
228
#endif
229
230
/* For sig2str() */
231
#if !defined(HAVE_DECL_SIG2STR_MAX) || !HAVE_DECL_SIG2STR_MAX
232
# define SIG2STR_MAX 32
233
#endif
234
235
/* WCOREDUMP is not POSIX, this usually works (verified on AIX). */
236
#ifndef WCOREDUMP
237
# define WCOREDUMP(x) ((x) & 0x80)
238
#endif
239
240
/* W_EXITCODE is not POSIX but the encoding of wait status is. */
241
#ifndef W_EXITCODE
242
# define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
243
#endif
244
245
/* Number of bits in a byte. */
246
#ifndef NBBY
247
# ifdef __NBBY
248
# define NBBY __NBBY
249
# else
250
# define NBBY 8
251
# endif
252
#endif
253
254
#ifndef HAVE_SETEUID
255
# if defined(HAVE_SETRESUID)
256
# define seteuid(u) setresuid(-1, (u), -1)
257
# define setegid(g) setresgid(-1, (g), -1)
258
# define HAVE_SETEUID 1
259
# elif defined(HAVE_SETREUID)
260
# define seteuid(u) setreuid(-1, (u))
261
# define setegid(g) setregid(-1, (g))
262
# define HAVE_SETEUID 1
263
# endif
264
#endif /* HAVE_SETEUID */
265
266
/*
267
* Older HP-UX does not declare setresuid() or setresgid().
268
*/
269
#if defined(HAVE_DECL_SETRESUID) && !HAVE_DECL_SETRESUID
270
int setresuid(uid_t, uid_t, uid_t);
271
int setresgid(gid_t, gid_t, gid_t);
272
#endif
273
#if defined(HAVE_DECL_GETRESUID) && !HAVE_DECL_GETRESUID
274
int getresuid(uid_t *, uid_t *, uid_t *);
275
int getresgid(gid_t *, gid_t *, gid_t *);
276
#endif
277
278
/*
279
* HP-UX does not declare innetgr() or getdomainname().
280
* Solaris does not declare getdomainname().
281
*/
282
#if defined(HAVE_DECL_INNETGR) && !HAVE_DECL_INNETGR
283
int innetgr(const char *, const char *, const char *, const char *);
284
#endif
285
#if defined(HAVE_DECL__INNETGR) && !HAVE_DECL__INNETGR
286
int _innetgr(const char *, const char *, const char *, const char *);
287
#endif
288
#if defined(HAVE_DECL_GETDOMAINNAME) && !HAVE_DECL_GETDOMAINNAME
289
int getdomainname(char *, size_t);
290
#endif
291
292
/*
293
* HP-UX 11.00 has broken pread/pwrite on 32-bit machines when
294
* _FILE_OFFSET_BITS == 64. Use pread64/pwrite64 instead.
295
*/
296
#if defined(__hpux) && !defined(__LP64__)
297
# ifdef HAVE_PREAD64
298
# undef pread
299
# define pread(_a, _b, _c, _d) pread64((_a), (_b), (_c), (_d))
300
# if defined(HAVE_DECL_PREAD64) && !HAVE_DECL_PREAD64
301
ssize_t pread64(int fd, void *buf, size_t nbytes, off64_t offset);
302
# endif
303
# endif
304
# ifdef HAVE_PWRITE64
305
# undef pwrite
306
# define pwrite(_a, _b, _c, _d) pwrite64((_a), (_b), (_c), (_d))
307
# if defined(HAVE_DECL_PWRITE64) && !HAVE_DECL_PWRITE64
308
ssize_t pwrite64(int fd, const void *buf, size_t nbytes, off64_t offset);
309
# endif
310
# endif
311
#endif /* __hpux && !__LP64__ */
312
313
/*
314
* Older systems may lack fseeko(3), just use fseek(3) instead.
315
*/
316
#ifndef HAVE_FSEEKO
317
# define fseeko(f, o, w) fseek((f), (long)(o), (w))
318
#endif
319
320
/*
321
* Functions "missing" from libc.
322
* All libc replacements are prefixed with "sudo_" to avoid namespace issues.
323
*/
324
325
struct passwd;
326
struct stat;
327
struct timespec;
328
struct termios;
329
struct tm;
330
331
#ifndef HAVE_CFMAKERAW
332
sudo_dso_public void sudo_cfmakeraw(struct termios *term);
333
# undef cfmakeraw
334
# define cfmakeraw(_a) sudo_cfmakeraw((_a))
335
#endif /* HAVE_CFMAKERAW */
336
#ifndef HAVE_CLOSEFROM
337
sudo_dso_public void sudo_closefrom(int);
338
# undef closefrom
339
# define closefrom(_a) sudo_closefrom((_a))
340
#endif /* HAVE_CLOSEFROM */
341
#ifndef HAVE_EXPLICIT_BZERO
342
sudo_dso_public void sudo_explicit_bzero(void *s, size_t n);
343
# undef explicit_bzero
344
# define explicit_bzero(_a, _b) sudo_explicit_bzero((_a), (_b))
345
#endif /* HAVE_EXPLICIT_BZERO */
346
#ifndef HAVE_FREEZERO
347
sudo_dso_public void sudo_freezero(void *p, size_t n);
348
# undef freezero
349
# define freezero(_a, _b) sudo_freezero((_a), (_b))
350
#endif /* HAVE_FREEZERO */
351
#ifndef HAVE_GETGROUPLIST
352
sudo_dso_public int sudo_getgrouplist(const char *name, GETGROUPS_T basegid, GETGROUPS_T *groups, int *ngroupsp);
353
# undef getgrouplist
354
# define getgrouplist(_a, _b, _c, _d) sudo_getgrouplist((_a), (_b), (_c), (_d))
355
#endif /* GETGROUPLIST */
356
#if !defined(HAVE_GETDELIM)
357
sudo_dso_public ssize_t sudo_getdelim(char ** restrict bufp, size_t * restrict bufsizep, int delim, FILE * restrict fp);
358
# undef getdelim
359
# define getdelim(_a, _b, _c, _d) sudo_getdelim((_a), (_b), (_c), (_d))
360
#elif defined(HAVE_DECL_GETDELIM) && !HAVE_DECL_GETDELIM
361
/* getdelim present in libc but missing prototype (old gcc fixed includes?) */
362
ssize_t getdelim(char ** restrict bufp, size_t * restrict bufsizep, int delim, FILE * restrict fp);
363
#endif /* HAVE_GETDELIM */
364
#ifndef HAVE_GETUSERSHELL
365
sudo_dso_public char *sudo_getusershell(void);
366
# undef getusershell
367
# define getusershell() sudo_getusershell()
368
sudo_dso_public void sudo_setusershell(void);
369
# undef setusershell
370
# define setusershell() sudo_setusershell()
371
sudo_dso_public void sudo_endusershell(void);
372
# undef endusershell
373
# define endusershell() sudo_endusershell()
374
#elif HAVE_DECL_GETUSERSHELL == 0
375
/* Older Solaris has getusershell() et al but does not declare it. */
376
char *getusershell(void);
377
void setusershell(void);
378
void endusershell(void);
379
#endif /* HAVE_GETUSERSHELL */
380
#ifndef HAVE_GMTIME_R
381
sudo_dso_public struct tm *sudo_gmtime_r(const time_t * restrict, struct tm * restrict);
382
# undef gmtime_r
383
# define gmtime_r(_a, _b) sudo_gmtime_r((_a), (_b))
384
#endif /* HAVE_GMTIME_R */
385
#ifndef HAVE_LOCALTIME_R
386
sudo_dso_public struct tm *sudo_localtime_r(const time_t * restrict, struct tm * restrict);
387
# undef localtime_r
388
# define localtime_r(_a, _b) sudo_localtime_r((_a), (_b))
389
#endif /* HAVE_LOCALTIME_R */
390
#ifndef HAVE_TIMEGM
391
sudo_dso_public time_t sudo_timegm(struct tm *);
392
#endif /* HAVE_TIMEGM */
393
#ifndef HAVE_UTIMENSAT
394
sudo_dso_public int sudo_utimensat(int fd, const char *file, const struct timespec times[2], int flag);
395
# undef utimensat
396
# define utimensat(_a, _b, _c, _d) sudo_utimensat((_a), (_b), (_c), (_d))
397
#endif /* HAVE_UTIMENSAT */
398
#ifndef HAVE_FCHMODAT
399
sudo_dso_public int sudo_fchmodat(int dfd, const char *path, mode_t mode, int flag);
400
# undef fchmodat
401
# define fchmodat(_a, _b, _c, _d) sudo_fchmodat((_a), (_b), (_c), (_d))
402
#endif /* HAVE_FCHMODAT */
403
#ifndef HAVE_FSTATAT
404
sudo_dso_public int sudo_fstatat(int dfd, const char * restrict path, struct stat * restrict sb, int flag);
405
# undef fstatat
406
# define fstatat(_a, _b, _c, _d) sudo_fstatat((_a), (_b), (_c), (_d))
407
#endif /* HAVE_FSTATAT */
408
#ifndef HAVE_FUTIMENS
409
sudo_dso_public int sudo_futimens(int fd, const struct timespec times[2]);
410
# undef futimens
411
# define futimens(_a, _b) sudo_futimens((_a), (_b))
412
#endif /* HAVE_FUTIMENS */
413
#if !defined(HAVE_SNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
414
sudo_dso_public int sudo_snprintf(char * restrict str, size_t n, char const * restrict fmt, ...) sudo_printflike(3, 4);
415
# undef snprintf
416
# define snprintf sudo_snprintf
417
#endif /* HAVE_SNPRINTF */
418
#if !defined(HAVE_VSNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
419
sudo_dso_public int sudo_vsnprintf(char * restrict str, size_t n, const char * restrict fmt, va_list ap) sudo_printflike(3, 0);
420
# undef vsnprintf
421
# define vsnprintf sudo_vsnprintf
422
#endif /* HAVE_VSNPRINTF */
423
#if !defined(HAVE_ASPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
424
sudo_dso_public int sudo_asprintf(char ** restrict str, char const * restrict fmt, ...) sudo_printflike(2, 3);
425
# undef asprintf
426
# define asprintf sudo_asprintf
427
#endif /* HAVE_ASPRINTF */
428
#if !defined(HAVE_VASPRINTF) || defined(PREFER_PORTABLE_SNPRINTF)
429
sudo_dso_public int sudo_vasprintf(char ** restrict str, const char * restrict fmt, va_list ap) sudo_printflike(2, 0);
430
# undef vasprintf
431
# define vasprintf sudo_vasprintf
432
#endif /* HAVE_VASPRINTF */
433
#ifndef HAVE_STRLCAT
434
sudo_dso_public size_t sudo_strlcat(char * restrict dst, const char * restrict src, size_t siz);
435
# undef strlcat
436
# define strlcat(_a, _b, _c) sudo_strlcat((_a), (_b), (_c))
437
#endif /* HAVE_STRLCAT */
438
#ifndef HAVE_STRLCPY
439
sudo_dso_public size_t sudo_strlcpy(char * restrict dst, const char * restrict src, size_t siz);
440
# undef strlcpy
441
# define strlcpy(_a, _b, _c) sudo_strlcpy((_a), (_b), (_c))
442
#endif /* HAVE_STRLCPY */
443
#ifndef HAVE_STRNDUP
444
sudo_dso_public char *sudo_strndup(const char *str, size_t maxlen);
445
# undef strndup
446
# define strndup(_a, _b) sudo_strndup((_a), (_b))
447
#endif /* HAVE_STRNDUP */
448
#ifndef HAVE_STRNLEN
449
sudo_dso_public size_t sudo_strnlen(const char *str, size_t maxlen);
450
# undef strnlen
451
# define strnlen(_a, _b) sudo_strnlen((_a), (_b))
452
#endif /* HAVE_STRNLEN */
453
#ifndef HAVE_FCHOWNAT
454
sudo_dso_public int sudo_fchownat(int dfd, const char *path, uid_t uid, gid_t gid, int flag);
455
# undef fchownat
456
# define fchownat(_a, _b, _c, _d, _e) sudo_fchownat((_a), (_b), (_c), (_d), (_e))
457
#endif /* HAVE_FCHOWNAT */
458
#ifndef HAVE_MEMRCHR
459
sudo_dso_public void *sudo_memrchr(const void *s, int c, size_t n);
460
# undef memrchr
461
# define memrchr(_a, _b, _c) sudo_memrchr((_a), (_b), (_c))
462
#endif /* HAVE_MEMRCHR */
463
#ifndef HAVE_MKDIRAT
464
sudo_dso_public int sudo_mkdirat(int dfd, const char *path, mode_t mode);
465
# undef mkdirat
466
# define mkdirat(_a, _b, _c) sudo_mkdirat((_a), (_b), (_c))
467
#endif /* HAVE_MKDIRAT */
468
#if !defined(HAVE_MKDTEMPAT) || !defined(HAVE_MKOSTEMPSAT)
469
# if defined(HAVE_MKDTEMPAT_NP) && defined(HAVE_MKOSTEMPSAT_NP)
470
# undef mkdtempat
471
# define mkdtempat mkdtempat_np
472
# undef mkostempsat
473
# define mkostempsat mkostempsat_np
474
# else
475
sudo_dso_public char *sudo_mkdtemp(char *path);
476
# undef mkdtemp
477
# define mkdtemp(_a) sudo_mkdtemp((_a))
478
sudo_dso_public char *sudo_mkdtempat(int dfd, char *path);
479
# undef mkdtempat
480
# define mkdtempat(_a, _b) sudo_mkdtempat((_a), (_b))
481
sudo_dso_public int sudo_mkostempsat(int dfd, char *path, int slen, int flags);
482
# undef mkostempsat
483
# define mkostempsat(_a, _b, _c, _d) sudo_mkostempsat((_a), (_b), (_c), (_d))
484
sudo_dso_public int sudo_mkstemp(char *path);
485
# undef mkstemp
486
# define mkstemp(_a) sudo_mkstemp((_a))
487
sudo_dso_public int sudo_mkstemps(char *path, int slen);
488
# undef mkstemps
489
# define mkstemps(_a, _b) sudo_mkstemps((_a), (_b))
490
# endif /* HAVE_MKDTEMPAT_NP || HAVE_MKOSTEMPSAT_NP */
491
#endif /* !HAVE_MKDTEMPAT || !HAVE_MKOSTEMPSAT */
492
#ifndef HAVE_NANOSLEEP
493
sudo_dso_public int sudo_nanosleep(const struct timespec *timeout, struct timespec *remainder);
494
#undef nanosleep
495
# define nanosleep(_a, _b) sudo_nanosleep((_a), (_b))
496
#endif /* HAVE_NANOSLEEP */
497
#ifndef HAVE_OPENAT
498
sudo_dso_public int sudo_openat(int dfd, const char *path, int flags, mode_t mode);
499
# undef openat
500
# define openat(_a, _b, _c, _d) sudo_openat((_a), (_b), (_c), (_d))
501
#endif /* HAVE_OPENAT */
502
#ifndef HAVE_PW_DUP
503
sudo_dso_public struct passwd *sudo_pw_dup(const struct passwd *pw);
504
# undef pw_dup
505
# define pw_dup(_a) sudo_pw_dup((_a))
506
#endif /* HAVE_PW_DUP */
507
#ifndef HAVE_STRSIGNAL
508
sudo_dso_public char *sudo_strsignal(int signo);
509
# undef strsignal
510
# define strsignal(_a) sudo_strsignal((_a))
511
#endif /* HAVE_STRSIGNAL */
512
#ifndef HAVE_SIG2STR
513
sudo_dso_public int sudo_sig2str(int signo, char *signame);
514
# undef sig2str
515
# define sig2str(_a, _b) sudo_sig2str((_a), (_b))
516
#endif /* HAVE_SIG2STR */
517
#ifndef HAVE_STR2SIG
518
sudo_dso_public int sudo_str2sig(const char *signame, int *signum);
519
# undef str2sig
520
# define str2sig(_a, _b) sudo_str2sig((_a), (_b))
521
#endif /* HAVE_STR2SIG */
522
#if !defined(HAVE_INET_NTOP) && defined(NEED_INET_NTOP)
523
sudo_dso_public const char *sudo_inet_ntop(int af, const void * restrict src, char * restrict dst, socklen_t size);
524
# undef inet_ntop
525
# define inet_ntop(_a, _b, _c, _d) sudo_inet_ntop((_a), (_b), (_c), (_d))
526
#endif /* HAVE_INET_NTOP */
527
#ifndef HAVE_INET_PTON
528
sudo_dso_public int sudo_inet_pton(int af, const char * restrict src, void * restrict dst);
529
# undef inet_pton
530
# define inet_pton(_a, _b, _c) sudo_inet_pton((_a), (_b), (_c))
531
#endif /* HAVE_INET_PTON */
532
#ifndef HAVE_GETPROGNAME
533
sudo_dso_public const char *sudo_getprogname(void);
534
# undef getprogname
535
# define getprogname() sudo_getprogname()
536
#endif /* HAVE_GETPROGNAME */
537
#ifndef HAVE_SETPROGNAME
538
sudo_dso_public void sudo_setprogname(const char *name);
539
# undef setprogname
540
# define setprogname(_a) sudo_setprogname(_a)
541
#endif /* HAVE_SETPROGNAME */
542
#ifndef HAVE_REALLOCARRAY
543
sudo_dso_public void *sudo_reallocarray(void *ptr, size_t nmemb, size_t size);
544
# undef reallocarray
545
# define reallocarray(_a, _b, _c) sudo_reallocarray((_a), (_b), (_c))
546
#endif /* HAVE_REALLOCARRAY */
547
#ifndef HAVE_REALPATH
548
sudo_dso_public char *sudo_realpath(const char * restrict path, char * restrict resolved);
549
# undef realpath
550
# define realpath(_a, _b) sudo_realpath((_a), (_b))
551
#endif /* HAVE_REALPATH */
552
#ifndef HAVE_DUP3
553
sudo_dso_public int sudo_dup3(int oldd, int newd, int flags);
554
# undef dup3
555
# define dup3(_a, _b, _c) sudo_dup3((_a), (_b), (_c))
556
#endif /* HAVE_DUP3 */
557
#ifndef HAVE_PIPE2
558
sudo_dso_public int sudo_pipe2(int fildes[2], int flags);
559
# undef pipe2
560
# define pipe2(_a, _b) sudo_pipe2((_a), (_b))
561
#endif /* HAVE_PIPE2 */
562
#ifndef HAVE_PREAD
563
sudo_dso_public ssize_t sudo_pread(int fd, void *buf, size_t nbytes, off_t offset);
564
# undef pread
565
# define pread(_a, _b, _c, _d) sudo_pread((_a), (_b), (_c), (_d))
566
#endif /* HAVE_PREAD */
567
#ifndef HAVE_PWRITE
568
sudo_dso_public ssize_t sudo_pwrite(int fd, const void *buf, size_t nbytes, off_t offset);
569
# undef pwrite
570
# define pwrite(_a, _b, _c, _d) sudo_pwrite((_a), (_b), (_c), (_d))
571
#endif /* HAVE_PWRITE */
572
#ifndef HAVE_UNLINKAT
573
sudo_dso_public int sudo_unlinkat(int dfd, const char *path, int flag);
574
# undef unlinkat
575
# define unlinkat(_a, _b, _c) sudo_unlinkat((_a), (_b), (_c))
576
#endif /* HAVE_UNLINKAT */
577
578
#endif /* SUDO_COMPAT_H */
579
580