diff options
-rw-r--r-- | crypto/Makefile.am | 14 | ||||
-rw-r--r-- | crypto/compat/getprogname_linux.c | 9 | ||||
-rw-r--r-- | crypto/compat/getprogname_windows.c | 13 | ||||
-rw-r--r-- | crypto/compat/posix_win.c | 7 | ||||
-rw-r--r-- | crypto/compat/syslog_r.c | 19 | ||||
-rw-r--r-- | include/compat/stdlib.h | 4 | ||||
-rw-r--r-- | include/compat/syslog.h | 37 | ||||
-rw-r--r-- | m4/check-libc.m4 | 4 | ||||
-rw-r--r-- | tls/Makefile.am | 1 | ||||
-rw-r--r-- | tls/compat/getuid.c | 18 |
10 files changed, 107 insertions, 19 deletions
diff --git a/crypto/Makefile.am b/crypto/Makefile.am index d2c7431..4bf6b46 100644 --- a/crypto/Makefile.am +++ b/crypto/Makefile.am | |||
@@ -87,6 +87,7 @@ if HOST_WIN | |||
87 | -echo posix_write >> crypto_portable.sym | 87 | -echo posix_write >> crypto_portable.sym |
88 | -echo posix_getsockopt >> crypto_portable.sym | 88 | -echo posix_getsockopt >> crypto_portable.sym |
89 | -echo posix_setsockopt >> crypto_portable.sym | 89 | -echo posix_setsockopt >> crypto_portable.sym |
90 | -echo getuid >> crypto_portable.sym | ||
90 | -grep -v BIO_s_log crypto_portable.sym > crypto_portable.sym.tmp | 91 | -grep -v BIO_s_log crypto_portable.sym > crypto_portable.sym.tmp |
91 | -mv crypto_portable.sym.tmp crypto_portable.sym | 92 | -mv crypto_portable.sym.tmp crypto_portable.sym |
92 | endif | 93 | endif |
@@ -162,6 +163,15 @@ if !HAVE_GETPAGESIZE | |||
162 | libcompat_la_SOURCES += compat/getpagesize.c | 163 | libcompat_la_SOURCES += compat/getpagesize.c |
163 | endif | 164 | endif |
164 | 165 | ||
166 | if !HAVE_GETPROGNAME | ||
167 | if HOST_LINUX | ||
168 | libcompat_la_SOURCES += compat/getprogname_linux.c | ||
169 | endif | ||
170 | if HOST_WIN | ||
171 | libcompat_la_SOURCES += compat/getprogname_windows.c | ||
172 | endif | ||
173 | endif | ||
174 | |||
165 | if !HAVE_TIMEGM | 175 | if !HAVE_TIMEGM |
166 | libcompat_la_SOURCES += compat/timegm.c | 176 | libcompat_la_SOURCES += compat/timegm.c |
167 | endif | 177 | endif |
@@ -174,6 +184,10 @@ if !HAVE_RECALLOCARRAY | |||
174 | libcompat_la_SOURCES += compat/recallocarray.c | 184 | libcompat_la_SOURCES += compat/recallocarray.c |
175 | endif | 185 | endif |
176 | 186 | ||
187 | if !HAVE_SYSLOG_R | ||
188 | libcompat_la_SOURCES += compat/syslog_r.c | ||
189 | endif | ||
190 | |||
177 | if !HAVE_TIMINGSAFE_MEMCMP | 191 | if !HAVE_TIMINGSAFE_MEMCMP |
178 | libcompat_la_SOURCES += compat/timingsafe_memcmp.c | 192 | libcompat_la_SOURCES += compat/timingsafe_memcmp.c |
179 | endif | 193 | endif |
diff --git a/crypto/compat/getprogname_linux.c b/crypto/compat/getprogname_linux.c new file mode 100644 index 0000000..fefe5ea --- /dev/null +++ b/crypto/compat/getprogname_linux.c | |||
@@ -0,0 +1,9 @@ | |||
1 | #include <stdlib.h> | ||
2 | |||
3 | #include <errno.h> | ||
4 | |||
5 | const char * | ||
6 | getprogname(void) | ||
7 | { | ||
8 | return program_invocation_short_name; | ||
9 | } | ||
diff --git a/crypto/compat/getprogname_windows.c b/crypto/compat/getprogname_windows.c new file mode 100644 index 0000000..eb04ec0 --- /dev/null +++ b/crypto/compat/getprogname_windows.c | |||
@@ -0,0 +1,13 @@ | |||
1 | #include <stdlib.h> | ||
2 | |||
3 | #include <windows.h> | ||
4 | |||
5 | const char * | ||
6 | getprogname(void) | ||
7 | { | ||
8 | static char progname[MAX_PATH + 1]; | ||
9 | DWORD length = GetModuleFileName(NULL, progname, sizeof (progname) - 1); | ||
10 | if (length < 0) | ||
11 | return "?"; | ||
12 | return progname; | ||
13 | } | ||
diff --git a/crypto/compat/posix_win.c b/crypto/compat/posix_win.c index d6e2dcb..b73f023 100644 --- a/crypto/compat/posix_win.c +++ b/crypto/compat/posix_win.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * BSD socket emulation code for Winsock2 | 4 | * BSD socket emulation code for Winsock2 |
5 | * File IO compatibility shims | 5 | * File IO compatibility shims |
6 | * Brent Cook <bcook@openbsd.org> | 6 | * Brent Cook <bcook@openbsd.org> |
7 | * Kinichiro Inoguchi <inoguchi@openbsd.org> | ||
7 | */ | 8 | */ |
8 | 9 | ||
9 | #define NO_REDEF_POSIX_FUNCTIONS | 10 | #define NO_REDEF_POSIX_FUNCTIONS |
@@ -208,6 +209,12 @@ posix_setsockopt(int sockfd, int level, int optname, | |||
208 | return rc == 0 ? 0 : wsa_errno(WSAGetLastError()); | 209 | return rc == 0 ? 0 : wsa_errno(WSAGetLastError()); |
209 | } | 210 | } |
210 | 211 | ||
212 | uid_t getuid(void) | ||
213 | { | ||
214 | /* Windows fstat sets 0 as st_uid */ | ||
215 | return 0; | ||
216 | } | ||
217 | |||
211 | #ifdef _MSC_VER | 218 | #ifdef _MSC_VER |
212 | struct timezone; | 219 | struct timezone; |
213 | int gettimeofday(struct timeval * tp, struct timezone * tzp) | 220 | int gettimeofday(struct timeval * tp, struct timezone * tzp) |
diff --git a/crypto/compat/syslog_r.c b/crypto/compat/syslog_r.c new file mode 100644 index 0000000..d68169d --- /dev/null +++ b/crypto/compat/syslog_r.c | |||
@@ -0,0 +1,19 @@ | |||
1 | #include <syslog.h> | ||
2 | |||
3 | void | ||
4 | syslog_r(int pri, struct syslog_data *data, const char *fmt, ...) | ||
5 | { | ||
6 | va_list ap; | ||
7 | |||
8 | va_start(ap, fmt); | ||
9 | vsyslog_r(pri, data, fmt, ap); | ||
10 | va_end(ap); | ||
11 | } | ||
12 | |||
13 | void | ||
14 | vsyslog_r(int pri, struct syslog_data *data, const char *fmt, va_list ap) | ||
15 | { | ||
16 | #ifdef HAVE_SYSLOG | ||
17 | vsyslog(pri, fmt, ap); | ||
18 | #endif | ||
19 | } | ||
diff --git a/include/compat/stdlib.h b/include/compat/stdlib.h index cc04856..e629884 100644 --- a/include/compat/stdlib.h +++ b/include/compat/stdlib.h | |||
@@ -29,6 +29,10 @@ uint32_t arc4random_uniform(uint32_t upper_bound); | |||
29 | void freezero(void *ptr, size_t sz); | 29 | void freezero(void *ptr, size_t sz); |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | #ifndef HAVE_GETPROGNAME | ||
33 | const char * getprogname(void); | ||
34 | #endif | ||
35 | |||
32 | #ifndef HAVE_REALLOCARRAY | 36 | #ifndef HAVE_REALLOCARRAY |
33 | void *reallocarray(void *, size_t, size_t); | 37 | void *reallocarray(void *, size_t, size_t); |
34 | #endif | 38 | #endif |
diff --git a/include/compat/syslog.h b/include/compat/syslog.h new file mode 100644 index 0000000..f400ff6 --- /dev/null +++ b/include/compat/syslog.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * syslog.h compatibility shim | ||
4 | */ | ||
5 | |||
6 | #ifndef _WIN32 | ||
7 | #include_next <syslog.h> | ||
8 | #endif | ||
9 | |||
10 | #ifndef LIBCRYPTOCOMPAT_SYSLOG_H | ||
11 | #define LIBCRYPTOCOMPAT_SYSLOG_H | ||
12 | |||
13 | #ifndef HAVE_SYSLOG_R | ||
14 | |||
15 | #include <stdarg.h> | ||
16 | |||
17 | #ifdef _WIN32 | ||
18 | #define LOG_INFO 6 /* informational */ | ||
19 | #define LOG_USER (1<<3) /* random user-level messages */ | ||
20 | #define LOG_LOCAL2 (18<<3) /* reserved for local use */ | ||
21 | #endif | ||
22 | |||
23 | struct syslog_data { | ||
24 | int log_stat; | ||
25 | const char *log_tag; | ||
26 | int log_fac; | ||
27 | int log_mask; | ||
28 | }; | ||
29 | |||
30 | #define SYSLOG_DATA_INIT {0, (const char *)0, LOG_USER, 0xff} | ||
31 | |||
32 | void syslog_r(int, struct syslog_data *, const char *, ...); | ||
33 | void vsyslog_r(int, struct syslog_data *, const char *, va_list); | ||
34 | |||
35 | #endif | ||
36 | |||
37 | #endif | ||
diff --git a/m4/check-libc.m4 b/m4/check-libc.m4 index 4a3d6c7..e511f6d 100644 --- a/m4/check-libc.m4 +++ b/m4/check-libc.m4 | |||
@@ -6,6 +6,7 @@ AC_CHECK_FUNCS([asprintf freezero memmem]) | |||
6 | AC_CHECK_FUNCS([readpassphrase reallocarray recallocarray]) | 6 | AC_CHECK_FUNCS([readpassphrase reallocarray recallocarray]) |
7 | AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum]) | 7 | AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum]) |
8 | AC_CHECK_FUNCS([timegm _mkgmtime timespecsub]) | 8 | AC_CHECK_FUNCS([timegm _mkgmtime timespecsub]) |
9 | AC_CHECK_FUNCS([getprogname syslog syslog_r]) | ||
9 | AC_CACHE_CHECK([for getpagesize], ac_cv_func_getpagesize, [ | 10 | AC_CACHE_CHECK([for getpagesize], ac_cv_func_getpagesize, [ |
10 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | 11 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
11 | // Since Android NDK v16 getpagesize is defined as inline inside unistd.h | 12 | // Since Android NDK v16 getpagesize is defined as inline inside unistd.h |
@@ -33,6 +34,9 @@ AM_CONDITIONAL([HAVE_STRNLEN], [test "x$ac_cv_func_strnlen" = xyes]) | |||
33 | AM_CONDITIONAL([HAVE_STRSEP], [test "x$ac_cv_func_strsep" = xyes]) | 34 | AM_CONDITIONAL([HAVE_STRSEP], [test "x$ac_cv_func_strsep" = xyes]) |
34 | AM_CONDITIONAL([HAVE_STRTONUM], [test "x$ac_cv_func_strtonum" = xyes]) | 35 | AM_CONDITIONAL([HAVE_STRTONUM], [test "x$ac_cv_func_strtonum" = xyes]) |
35 | AM_CONDITIONAL([HAVE_TIMEGM], [test "x$ac_cv_func_timegm" = xyes]) | 36 | AM_CONDITIONAL([HAVE_TIMEGM], [test "x$ac_cv_func_timegm" = xyes]) |
37 | AM_CONDITIONAL([HAVE_GETPROGNAME], [test "x$ac_cv_func_getprogname" = xyes]) | ||
38 | AM_CONDITIONAL([HAVE_SYSLOG], [test "x$ac_cv_func_syslog" = xyes]) | ||
39 | AM_CONDITIONAL([HAVE_SYSLOG_R], [test "x$ac_cv_func_syslog_r" = xyes]) | ||
36 | ]) | 40 | ]) |
37 | 41 | ||
38 | AC_DEFUN([CHECK_SYSCALL_COMPAT], [ | 42 | AC_DEFUN([CHECK_SYSCALL_COMPAT], [ |
diff --git a/tls/Makefile.am b/tls/Makefile.am index 58c0344..fec147e 100644 --- a/tls/Makefile.am +++ b/tls/Makefile.am | |||
@@ -33,7 +33,6 @@ noinst_HEADERS = tls_internal.h | |||
33 | 33 | ||
34 | if HOST_WIN | 34 | if HOST_WIN |
35 | libtls_la_SOURCES += compat/ftruncate.c | 35 | libtls_la_SOURCES += compat/ftruncate.c |
36 | libtls_la_SOURCES += compat/getuid.c | ||
37 | libtls_la_SOURCES += compat/pread.c | 36 | libtls_la_SOURCES += compat/pread.c |
38 | libtls_la_SOURCES += compat/pwrite.c | 37 | libtls_la_SOURCES += compat/pwrite.c |
39 | endif | 38 | endif |
diff --git a/tls/compat/getuid.c b/tls/compat/getuid.c deleted file mode 100644 index 9a46317..0000000 --- a/tls/compat/getuid.c +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * | ||
4 | * Kinichiro Inoguchi <inoguchi@openbsd.org> | ||
5 | */ | ||
6 | |||
7 | #ifdef _WIN32 | ||
8 | |||
9 | #include <unistd.h> | ||
10 | |||
11 | uid_t | ||
12 | getuid(void) | ||
13 | { | ||
14 | /* Windows fstat sets 0 as st_uid */ | ||
15 | return 0; | ||
16 | } | ||
17 | |||
18 | #endif | ||