uringmachine 0.15 → 0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +3 -0
  3. data/.gitmodules +4 -0
  4. data/CHANGELOG.md +12 -0
  5. data/TODO.md +12 -3
  6. data/examples/bm_send.rb +86 -0
  7. data/ext/um/um.c +28 -1
  8. data/ext/um/um.h +3 -0
  9. data/ext/um/um_class.c +17 -0
  10. data/ext/um/um_stream_class.c +0 -1
  11. data/ext/um/um_utils.c +38 -15
  12. data/lib/uringmachine/version.rb +1 -1
  13. data/lib/uringmachine.rb +4 -3
  14. data/test/test_um.rb +76 -0
  15. data/vendor/libressl/.github/scripts/changelog.sh +74 -0
  16. data/vendor/libressl/.github/workflows/android.yml +35 -0
  17. data/vendor/libressl/.github/workflows/cifuzz.yml +33 -0
  18. data/vendor/libressl/.github/workflows/cmake-config.yml +98 -0
  19. data/vendor/libressl/.github/workflows/coverity.yml +69 -0
  20. data/vendor/libressl/.github/workflows/emscripten.yml +71 -0
  21. data/vendor/libressl/.github/workflows/fedora-rawhide.yml +39 -0
  22. data/vendor/libressl/.github/workflows/freebsd.yml +71 -0
  23. data/vendor/libressl/.github/workflows/linux.yml +71 -0
  24. data/vendor/libressl/.github/workflows/macos.yml +37 -0
  25. data/vendor/libressl/.github/workflows/release.yml +81 -0
  26. data/vendor/libressl/.github/workflows/rust-openssl.yml +47 -0
  27. data/vendor/libressl/.github/workflows/solaris.yml +37 -0
  28. data/vendor/libressl/.github/workflows/windows.yml +70 -0
  29. data/vendor/libressl/.gitignore +333 -0
  30. data/vendor/libressl/CMakeLists.txt +581 -0
  31. data/vendor/libressl/COPYING +133 -0
  32. data/vendor/libressl/ChangeLog +3280 -0
  33. data/vendor/libressl/FindLibreSSL.cmake +232 -0
  34. data/vendor/libressl/LibreSSLConfig.cmake.in +36 -0
  35. data/vendor/libressl/Makefile.am +60 -0
  36. data/vendor/libressl/Makefile.am.common +20 -0
  37. data/vendor/libressl/OPENBSD_BRANCH +1 -0
  38. data/vendor/libressl/README.md +238 -0
  39. data/vendor/libressl/README.mingw.md +43 -0
  40. data/vendor/libressl/apps/CMakeLists.txt +18 -0
  41. data/vendor/libressl/apps/Makefile.am +5 -0
  42. data/vendor/libressl/apps/nc/CMakeLists.txt +67 -0
  43. data/vendor/libressl/apps/nc/Makefile.am +64 -0
  44. data/vendor/libressl/apps/nc/compat/accept4.c +17 -0
  45. data/vendor/libressl/apps/nc/compat/readpassphrase.c +205 -0
  46. data/vendor/libressl/apps/nc/compat/socket.c +29 -0
  47. data/vendor/libressl/apps/nc/compat/sys/socket.h +30 -0
  48. data/vendor/libressl/apps/ocspcheck/CMakeLists.txt +44 -0
  49. data/vendor/libressl/apps/ocspcheck/Makefile.am +45 -0
  50. data/vendor/libressl/apps/ocspcheck/compat/.gitignore +0 -0
  51. data/vendor/libressl/apps/openssl/CMakeLists.txt +97 -0
  52. data/vendor/libressl/apps/openssl/Makefile.am +108 -0
  53. data/vendor/libressl/apps/openssl/apps_win.c +138 -0
  54. data/vendor/libressl/apps/openssl/certhash_win.c +13 -0
  55. data/vendor/libressl/apps/openssl/compat/clock_gettime_osx.c +26 -0
  56. data/vendor/libressl/apps/openssl/compat/poll_win.c +329 -0
  57. data/vendor/libressl/appveyor.yml +53 -0
  58. data/vendor/libressl/autogen.sh +15 -0
  59. data/vendor/libressl/check-release.sh +86 -0
  60. data/vendor/libressl/cmake_export_symbol.cmake +71 -0
  61. data/vendor/libressl/cmake_uninstall.cmake.in +36 -0
  62. data/vendor/libressl/config +17 -0
  63. data/vendor/libressl/configure.ac +165 -0
  64. data/vendor/libressl/crypto/CMakeLists.txt +863 -0
  65. data/vendor/libressl/crypto/Makefile.am +962 -0
  66. data/vendor/libressl/crypto/Makefile.am.arc4random +46 -0
  67. data/vendor/libressl/crypto/Makefile.am.elf-mips +14 -0
  68. data/vendor/libressl/crypto/Makefile.am.elf-mips64 +14 -0
  69. data/vendor/libressl/crypto/Makefile.am.elf-x86_64 +35 -0
  70. data/vendor/libressl/crypto/Makefile.am.macosx-x86_64 +35 -0
  71. data/vendor/libressl/crypto/Makefile.am.masm-x86_64 +22 -0
  72. data/vendor/libressl/crypto/Makefile.am.mingw64-x86_64 +23 -0
  73. data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_darwin.c +60 -0
  74. data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_linux.c +62 -0
  75. data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_none.c +26 -0
  76. data/vendor/libressl/crypto/arch/aarch64/crypto_cpu_caps_windows.c +36 -0
  77. data/vendor/libressl/crypto/arch/loongarch64/crypto_arch.h +21 -0
  78. data/vendor/libressl/crypto/arch/mips/crypto_arch.h +21 -0
  79. data/vendor/libressl/crypto/bn/arch/loongarch64/bn_arch.h +23 -0
  80. data/vendor/libressl/crypto/bn/arch/mips/bn_arch.h +24 -0
  81. data/vendor/libressl/crypto/compat/.gitignore +31 -0
  82. data/vendor/libressl/crypto/compat/arc4random.h +41 -0
  83. data/vendor/libressl/crypto/compat/b_win.c +55 -0
  84. data/vendor/libressl/crypto/compat/bsd-asprintf.c +96 -0
  85. data/vendor/libressl/crypto/compat/crypto_lock_win.c +56 -0
  86. data/vendor/libressl/crypto/compat/explicit_bzero_win.c +13 -0
  87. data/vendor/libressl/crypto/compat/freezero.c +32 -0
  88. data/vendor/libressl/crypto/compat/getdelim.c +78 -0
  89. data/vendor/libressl/crypto/compat/getline.c +40 -0
  90. data/vendor/libressl/crypto/compat/getopt_long.c +528 -0
  91. data/vendor/libressl/crypto/compat/getpagesize.c +18 -0
  92. data/vendor/libressl/crypto/compat/getprogname_linux.c +23 -0
  93. data/vendor/libressl/crypto/compat/getprogname_unimpl.c +7 -0
  94. data/vendor/libressl/crypto/compat/getprogname_windows.c +13 -0
  95. data/vendor/libressl/crypto/compat/posix_win.c +296 -0
  96. data/vendor/libressl/crypto/compat/syslog_r.c +19 -0
  97. data/vendor/libressl/crypto/compat/ui_openssl_win.c +334 -0
  98. data/vendor/libressl/dist.sh +22 -0
  99. data/vendor/libressl/gen-coverage-report.sh +58 -0
  100. data/vendor/libressl/gen-openbsd-tags.sh +20 -0
  101. data/vendor/libressl/include/CMakeLists.txt +61 -0
  102. data/vendor/libressl/include/Makefile.am +79 -0
  103. data/vendor/libressl/include/arch/loongarch64/opensslconf.h +150 -0
  104. data/vendor/libressl/include/arch/mips/opensslconf.h +150 -0
  105. data/vendor/libressl/include/compat/arpa/inet.h +15 -0
  106. data/vendor/libressl/include/compat/arpa/nameser.h +25 -0
  107. data/vendor/libressl/include/compat/cet.h +19 -0
  108. data/vendor/libressl/include/compat/dirent.h +17 -0
  109. data/vendor/libressl/include/compat/dirent_msvc.h +611 -0
  110. data/vendor/libressl/include/compat/endian.h +161 -0
  111. data/vendor/libressl/include/compat/err.h +95 -0
  112. data/vendor/libressl/include/compat/fcntl.h +32 -0
  113. data/vendor/libressl/include/compat/getopt.h +50 -0
  114. data/vendor/libressl/include/compat/limits.h +25 -0
  115. data/vendor/libressl/include/compat/netdb.h +10 -0
  116. data/vendor/libressl/include/compat/netinet/in.h +19 -0
  117. data/vendor/libressl/include/compat/netinet/ip.h +49 -0
  118. data/vendor/libressl/include/compat/netinet/tcp.h +10 -0
  119. data/vendor/libressl/include/compat/poll.h +63 -0
  120. data/vendor/libressl/include/compat/pthread.h +122 -0
  121. data/vendor/libressl/include/compat/readpassphrase.h +44 -0
  122. data/vendor/libressl/include/compat/resolv.h +24 -0
  123. data/vendor/libressl/include/compat/stdint.h +31 -0
  124. data/vendor/libressl/include/compat/stdio.h +65 -0
  125. data/vendor/libressl/include/compat/stdlib.h +57 -0
  126. data/vendor/libressl/include/compat/string.h +98 -0
  127. data/vendor/libressl/include/compat/sys/_null.h +18 -0
  128. data/vendor/libressl/include/compat/sys/ioctl.h +11 -0
  129. data/vendor/libressl/include/compat/sys/mman.h +19 -0
  130. data/vendor/libressl/include/compat/sys/param.h +15 -0
  131. data/vendor/libressl/include/compat/sys/queue.h +536 -0
  132. data/vendor/libressl/include/compat/sys/select.h +10 -0
  133. data/vendor/libressl/include/compat/sys/socket.h +18 -0
  134. data/vendor/libressl/include/compat/sys/stat.h +129 -0
  135. data/vendor/libressl/include/compat/sys/time.h +37 -0
  136. data/vendor/libressl/include/compat/sys/tree.h +1006 -0
  137. data/vendor/libressl/include/compat/sys/types.h +69 -0
  138. data/vendor/libressl/include/compat/sys/uio.h +17 -0
  139. data/vendor/libressl/include/compat/syslog.h +38 -0
  140. data/vendor/libressl/include/compat/time.h +59 -0
  141. data/vendor/libressl/include/compat/unistd.h +83 -0
  142. data/vendor/libressl/include/compat/win32netcompat.h +57 -0
  143. data/vendor/libressl/include/openssl/Makefile.am.tpl +45 -0
  144. data/vendor/libressl/libcrypto.pc.in +28 -0
  145. data/vendor/libressl/libressl.pub +2 -0
  146. data/vendor/libressl/libssl.pc.in +28 -0
  147. data/vendor/libressl/libtls.pc.in +28 -0
  148. data/vendor/libressl/m4/ax_add_fortify_source.m4 +80 -0
  149. data/vendor/libressl/m4/ax_check_compile_flag.m4 +53 -0
  150. data/vendor/libressl/m4/check-hardening-options.m4 +110 -0
  151. data/vendor/libressl/m4/check-libc.m4 +189 -0
  152. data/vendor/libressl/m4/check-os-options.m4 +181 -0
  153. data/vendor/libressl/m4/disable-compiler-warnings.m4 +44 -0
  154. data/vendor/libressl/man/CMakeLists.txt +26 -0
  155. data/vendor/libressl/man/links +2780 -0
  156. data/vendor/libressl/man/update_links.sh +25 -0
  157. data/vendor/libressl/openssl.pc.in +11 -0
  158. data/vendor/libressl/patches/bn_shift.patch +34 -0
  159. data/vendor/libressl/patches/crypto_arch.h.patch +34 -0
  160. data/vendor/libressl/patches/crypto_namespace.h.patch +22 -0
  161. data/vendor/libressl/patches/netcat.c.patch +178 -0
  162. data/vendor/libressl/patches/openssl.c.patch +12 -0
  163. data/vendor/libressl/patches/opensslfeatures.h.patch +49 -0
  164. data/vendor/libressl/patches/patch-amd64-crypto-cpu-caps.c.patch +20 -0
  165. data/vendor/libressl/patches/patch-i386-crypto-cpu-caps.c.patch +20 -0
  166. data/vendor/libressl/patches/speed.c.patch +114 -0
  167. data/vendor/libressl/patches/ssl_namespace.h.patch +21 -0
  168. data/vendor/libressl/patches/tls.h.patch +16 -0
  169. data/vendor/libressl/patches/tls_config.c.patch +15 -0
  170. data/vendor/libressl/patches/win32_amd64_bn_arch.h.patch +28 -0
  171. data/vendor/libressl/patches/windows_headers.patch +80 -0
  172. data/vendor/libressl/scripts/config.guess +1774 -0
  173. data/vendor/libressl/scripts/config.sub +1907 -0
  174. data/vendor/libressl/scripts/i686-w64-mingw32.cmake +9 -0
  175. data/vendor/libressl/scripts/test +210 -0
  176. data/vendor/libressl/scripts/wrap-compiler-for-flag-check +31 -0
  177. data/vendor/libressl/scripts/x86_64-w64-mingw32.cmake +9 -0
  178. data/vendor/libressl/ssl/CMakeLists.txt +183 -0
  179. data/vendor/libressl/ssl/Makefile.am +187 -0
  180. data/vendor/libressl/tests/CMakeLists.txt +970 -0
  181. data/vendor/libressl/tests/Makefile.am +944 -0
  182. data/vendor/libressl/tests/aeadtest.sh +30 -0
  183. data/vendor/libressl/tests/arc4randomforktest.sh +21 -0
  184. data/vendor/libressl/tests/asn1time_small.test +10 -0
  185. data/vendor/libressl/tests/cmake/CMakeLists.txt +52 -0
  186. data/vendor/libressl/tests/cmake/crypto.c +7 -0
  187. data/vendor/libressl/tests/cmake/ssl.c +6 -0
  188. data/vendor/libressl/tests/cmake/tls.c +6 -0
  189. data/vendor/libressl/tests/compat/pipe2.c +186 -0
  190. data/vendor/libressl/tests/dtlstest.sh +28 -0
  191. data/vendor/libressl/tests/evptest.sh +22 -0
  192. data/vendor/libressl/tests/keypairtest.sh +27 -0
  193. data/vendor/libressl/tests/mlkem_tests.sh +39 -0
  194. data/vendor/libressl/tests/ocsptest.bat +25 -0
  195. data/vendor/libressl/tests/ocsptest.sh +23 -0
  196. data/vendor/libressl/tests/openssl.cnf +29 -0
  197. data/vendor/libressl/tests/optionstest.c +381 -0
  198. data/vendor/libressl/tests/pidwraptest.c +85 -0
  199. data/vendor/libressl/tests/pidwraptest.sh +26 -0
  200. data/vendor/libressl/tests/quictest.bat +27 -0
  201. data/vendor/libressl/tests/quictest.sh +30 -0
  202. data/vendor/libressl/tests/renegotiation_test.bat +27 -0
  203. data/vendor/libressl/tests/renegotiation_test.sh +30 -0
  204. data/vendor/libressl/tests/rfc5280time_small.test +10 -0
  205. data/vendor/libressl/tests/servertest.bat +27 -0
  206. data/vendor/libressl/tests/servertest.sh +30 -0
  207. data/vendor/libressl/tests/shutdowntest.bat +27 -0
  208. data/vendor/libressl/tests/shutdowntest.sh +30 -0
  209. data/vendor/libressl/tests/ssltest.bat +32 -0
  210. data/vendor/libressl/tests/ssltest.sh +48 -0
  211. data/vendor/libressl/tests/testdsa.bat +47 -0
  212. data/vendor/libressl/tests/testdsa.sh +57 -0
  213. data/vendor/libressl/tests/testenc.bat +85 -0
  214. data/vendor/libressl/tests/testenc.sh +93 -0
  215. data/vendor/libressl/tests/testrsa.bat +47 -0
  216. data/vendor/libressl/tests/testrsa.sh +57 -0
  217. data/vendor/libressl/tests/testssl.bat +171 -0
  218. data/vendor/libressl/tests/tlstest.bat +27 -0
  219. data/vendor/libressl/tests/tlstest.sh +28 -0
  220. data/vendor/libressl/tls/CMakeLists.txt +125 -0
  221. data/vendor/libressl/tls/Makefile.am +76 -0
  222. data/vendor/libressl/tls/compat/ftruncate.c +17 -0
  223. data/vendor/libressl/tls/compat/pread.c +29 -0
  224. data/vendor/libressl/tls/compat/pwrite.c +29 -0
  225. data/vendor/libressl/update.sh +460 -0
  226. data/vendor/liburing/.github/workflows/ci.yml +8 -0
  227. data/vendor/liburing/configure +23 -2
  228. data/vendor/liburing/examples/helpers.c +1 -1
  229. data/vendor/liburing/examples/helpers.h +1 -1
  230. data/vendor/liburing/examples/reg-wait.c +3 -3
  231. data/vendor/liburing/examples/zcrx.c +5 -5
  232. data/vendor/liburing/liburing.spec +1 -1
  233. data/vendor/liburing/src/include/liburing/io_uring.h +16 -0
  234. data/vendor/liburing/src/include/liburing.h +20 -4
  235. data/vendor/liburing/src/lib.h +2 -4
  236. data/vendor/liburing/src/liburing-ffi.map +7 -0
  237. data/vendor/liburing/src/liburing.map +7 -0
  238. data/vendor/liburing/src/register.c +5 -0
  239. data/vendor/liburing/src/sanitize.c +5 -4
  240. data/vendor/liburing/src/setup.c +43 -28
  241. data/vendor/liburing/test/Makefile +7 -0
  242. data/vendor/liburing/test/cmd-discard.c +2 -2
  243. data/vendor/liburing/test/evfd-short-read.c +84 -0
  244. data/vendor/liburing/test/fdinfo-sqpoll.c +117 -0
  245. data/vendor/liburing/test/fdinfo.c +1 -1
  246. data/vendor/liburing/test/fixed-buf-merge.c +2 -2
  247. data/vendor/liburing/test/futex-kill.c +135 -0
  248. data/vendor/liburing/test/helpers.c +1 -1
  249. data/vendor/liburing/test/helpers.h +1 -1
  250. data/vendor/liburing/test/init-mem.c +50 -12
  251. data/vendor/liburing/test/io_uring_passthrough.c +25 -6
  252. data/vendor/liburing/test/msg-ring.c +123 -9
  253. data/vendor/liburing/test/recv-bundle-short-ooo.c +16 -1
  254. data/vendor/liburing/test/recv-inc-ooo.c +411 -0
  255. data/vendor/liburing/test/recv-mshot-fair.c +513 -0
  256. data/vendor/liburing/test/reg-wait.c +14 -14
  257. data/vendor/liburing/test/send-zerocopy.c +4 -4
  258. data/vendor/liburing/test/timerfd-short-read.c +81 -0
  259. data/vendor/liburing/test/timestamp.c +382 -0
  260. data/vendor/liburing/test/zcrx.c +22 -22
  261. metadata +222 -2
@@ -0,0 +1,296 @@
1
+ /*
2
+ * Public domain
3
+ *
4
+ * BSD socket emulation code for Winsock2
5
+ * File IO compatibility shims
6
+ * Brent Cook <bcook@openbsd.org>
7
+ * Kinichiro Inoguchi <inoguchi@openbsd.org>
8
+ */
9
+
10
+ #define NO_REDEF_POSIX_FUNCTIONS
11
+
12
+ #include <sys/time.h>
13
+
14
+ #include <ws2tcpip.h>
15
+ #include <windows.h>
16
+
17
+ #include <errno.h>
18
+ #include <fcntl.h>
19
+ #include <stdint.h>
20
+ #include <stdio.h>
21
+ #include <stdlib.h>
22
+ #include <string.h>
23
+ #include <unistd.h>
24
+
25
+ #include <sys/stat.h>
26
+
27
+ static int
28
+ is_socket(int fd)
29
+ {
30
+ // Border case: Don't break std* file descriptors
31
+ if (fd < 3)
32
+ return 0;
33
+
34
+ // All locally-allocated file descriptors will have the high bit set
35
+ return (fd & 0x80000000) == 0;
36
+ }
37
+
38
+ static int
39
+ get_real_fd(int fd)
40
+ {
41
+ return (fd & 0x7fffffff);
42
+ }
43
+
44
+ void
45
+ posix_perror(const char *s)
46
+ {
47
+ fprintf(stderr, "%s: %s\n", s, strerror(errno));
48
+ }
49
+
50
+ FILE *
51
+ posix_fopen(const char *path, const char *mode)
52
+ {
53
+ if (strchr(mode, 'b') == NULL) {
54
+ char *bin_mode = NULL;
55
+ if (asprintf(&bin_mode, "%sb", mode) == -1)
56
+ return NULL;
57
+ FILE *f = fopen(path, bin_mode);
58
+ free(bin_mode);
59
+ return f;
60
+ }
61
+
62
+ return fopen(path, mode);
63
+ }
64
+
65
+ int
66
+ libressl_fstat(int fd, struct stat *statbuf)
67
+ {
68
+ return fstat(get_real_fd(fd), statbuf);
69
+ }
70
+
71
+ int
72
+ posix_open(const char *path, ...)
73
+ {
74
+ va_list ap;
75
+ int mode = 0;
76
+ int flags;
77
+
78
+ va_start(ap, path);
79
+ flags = va_arg(ap, int);
80
+ if (flags & O_CREAT)
81
+ mode = va_arg(ap, int);
82
+ va_end(ap);
83
+
84
+ flags |= O_BINARY;
85
+ if (flags & O_CLOEXEC) {
86
+ flags &= ~O_CLOEXEC;
87
+ flags |= O_NOINHERIT;
88
+ }
89
+ flags &= ~O_NONBLOCK;
90
+
91
+ const int fh = open(path, flags, mode);
92
+
93
+ // Set high bit to mark file descriptor as a file handle
94
+ return fh + 0x80000000;
95
+ }
96
+
97
+ char *
98
+ posix_fgets(char *s, int size, FILE *stream)
99
+ {
100
+ char *ret = fgets(s, size, stream);
101
+ if (ret != NULL) {
102
+ size_t end = strlen(ret);
103
+ if (end >= 2 && ret[end - 2] == '\r' && ret[end - 1] == '\n') {
104
+ ret[end - 2] = '\n';
105
+ ret[end - 1] = '\0';
106
+ }
107
+ }
108
+ return ret;
109
+ }
110
+
111
+ int
112
+ posix_rename(const char *oldpath, const char *newpath)
113
+ {
114
+ return MoveFileEx(oldpath, newpath, MOVEFILE_REPLACE_EXISTING) ? 0 : -1;
115
+ }
116
+
117
+ static int
118
+ wsa_errno(int err)
119
+ {
120
+ switch (err) {
121
+ case WSAENOBUFS:
122
+ errno = ENOMEM;
123
+ break;
124
+ case WSAEACCES:
125
+ errno = EACCES;
126
+ break;
127
+ case WSANOTINITIALISED:
128
+ errno = EPERM;
129
+ break;
130
+ case WSAEHOSTUNREACH:
131
+ case WSAENETDOWN:
132
+ errno = EIO;
133
+ break;
134
+ case WSAEFAULT:
135
+ errno = EFAULT;
136
+ break;
137
+ case WSAEINTR:
138
+ errno = EINTR;
139
+ break;
140
+ case WSAEINVAL:
141
+ errno = EINVAL;
142
+ break;
143
+ case WSAEINPROGRESS:
144
+ errno = EINPROGRESS;
145
+ break;
146
+ case WSAEWOULDBLOCK:
147
+ errno = EAGAIN;
148
+ break;
149
+ case WSAEOPNOTSUPP:
150
+ errno = ENOTSUP;
151
+ break;
152
+ case WSAEMSGSIZE:
153
+ errno = EFBIG;
154
+ break;
155
+ case WSAENOTSOCK:
156
+ errno = ENOTSOCK;
157
+ break;
158
+ case WSAENOPROTOOPT:
159
+ errno = ENOPROTOOPT;
160
+ break;
161
+ case WSAECONNREFUSED:
162
+ errno = ECONNREFUSED;
163
+ break;
164
+ case WSAEAFNOSUPPORT:
165
+ errno = EAFNOSUPPORT;
166
+ break;
167
+ case WSAEBADF:
168
+ errno = EBADF;
169
+ break;
170
+ case WSAENETRESET:
171
+ case WSAENOTCONN:
172
+ case WSAECONNABORTED:
173
+ case WSAECONNRESET:
174
+ case WSAESHUTDOWN:
175
+ case WSAETIMEDOUT:
176
+ errno = EPIPE;
177
+ break;
178
+ }
179
+ return -1;
180
+ }
181
+
182
+ int
183
+ posix_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
184
+ {
185
+ int rc = connect(sockfd, addr, addrlen);
186
+ if (rc == SOCKET_ERROR)
187
+ return wsa_errno(WSAGetLastError());
188
+ return rc;
189
+ }
190
+
191
+ int
192
+ posix_close(int fd)
193
+ {
194
+ int rc;
195
+ if (is_socket(fd)) {
196
+ if ((rc = closesocket(fd)) == SOCKET_ERROR) {
197
+ int err = WSAGetLastError();
198
+ rc = wsa_errno(err);
199
+ }
200
+ } else {
201
+ rc = close(get_real_fd(fd));
202
+ }
203
+ return rc;
204
+ }
205
+
206
+ ssize_t
207
+ posix_read(int fd, void *buf, size_t count)
208
+ {
209
+ ssize_t rc;
210
+ if (is_socket(fd)) {
211
+ if ((rc = recv(fd, buf, count, 0)) == SOCKET_ERROR) {
212
+ int err = WSAGetLastError();
213
+ rc = wsa_errno(err);
214
+ }
215
+ } else {
216
+ rc = read(get_real_fd(fd), buf, count);
217
+ }
218
+ return rc;
219
+ }
220
+
221
+ ssize_t
222
+ posix_write(int fd, const void *buf, size_t count)
223
+ {
224
+ ssize_t rc;
225
+ if (is_socket(fd)) {
226
+ if ((rc = send(fd, buf, count, 0)) == SOCKET_ERROR) {
227
+ rc = wsa_errno(WSAGetLastError());
228
+ }
229
+ } else {
230
+ rc = write(get_real_fd(fd), buf, count);
231
+ }
232
+ return rc;
233
+ }
234
+
235
+ int
236
+ posix_getsockopt(int sockfd, int level, int optname,
237
+ void *optval, socklen_t *optlen)
238
+ {
239
+ int rc;
240
+ if (is_socket(sockfd)) {
241
+ rc = getsockopt(sockfd, level, optname, (char *)optval, optlen);
242
+ if (rc != 0) {
243
+ rc = wsa_errno(WSAGetLastError());
244
+ }
245
+ } else {
246
+ rc = -1;
247
+ }
248
+ return rc;
249
+ }
250
+
251
+ int
252
+ posix_setsockopt(int sockfd, int level, int optname,
253
+ const void *optval, socklen_t optlen)
254
+ {
255
+ int rc;
256
+ if (is_socket(sockfd)) {
257
+ rc = setsockopt(sockfd, level, optname, (char *)optval, optlen);
258
+ if (rc != 0) {
259
+ rc = wsa_errno(WSAGetLastError());
260
+ }
261
+ } else {
262
+ rc = -1;
263
+ }
264
+ return rc;
265
+ }
266
+
267
+ uid_t getuid(void)
268
+ {
269
+ /* Windows fstat sets 0 as st_uid */
270
+ return 0;
271
+ }
272
+
273
+ #ifdef _MSC_VER
274
+ struct timezone;
275
+ int gettimeofday(struct timeval *tp, void *tzp)
276
+ {
277
+ /*
278
+ * Note: some broken versions only have 8 trailing zero's, the correct
279
+ * epoch has 9 trailing zero's
280
+ */
281
+ static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);
282
+
283
+ SYSTEMTIME system_time;
284
+ FILETIME file_time;
285
+ uint64_t time;
286
+
287
+ GetSystemTime(&system_time);
288
+ SystemTimeToFileTime(&system_time, &file_time);
289
+ time = ((uint64_t)file_time.dwLowDateTime);
290
+ time += ((uint64_t)file_time.dwHighDateTime) << 32;
291
+
292
+ tp->tv_sec = (long long)((time - EPOCH) / 10000000L);
293
+ tp->tv_usec = (long)(system_time.wMilliseconds * 1000);
294
+ return 0;
295
+ }
296
+ #endif
@@ -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
+ }
@@ -0,0 +1,334 @@
1
+ /* $OpenBSD: ui_openssl.c,v 1.22 2014/07/11 08:44:49 jsing Exp $ */
2
+ /* Written by Richard Levitte (richard@levitte.org) and others
3
+ * for the OpenSSL project 2001.
4
+ */
5
+ /* ====================================================================
6
+ * Copyright (c) 2001 The OpenSSL Project. All rights reserved.
7
+ *
8
+ * Redistribution and use in source and binary forms, with or without
9
+ * modification, are permitted provided that the following conditions
10
+ * are met:
11
+ *
12
+ * 1. Redistributions of source code must retain the above copyright
13
+ * notice, this list of conditions and the following disclaimer.
14
+ *
15
+ * 2. Redistributions in binary form must reproduce the above copyright
16
+ * notice, this list of conditions and the following disclaimer in
17
+ * the documentation and/or other materials provided with the
18
+ * distribution.
19
+ *
20
+ * 3. All advertising materials mentioning features or use of this
21
+ * software must display the following acknowledgment:
22
+ * "This product includes software developed by the OpenSSL Project
23
+ * for use in the OpenSSL Toolkit. (https://www.openssl.org/)"
24
+ *
25
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26
+ * endorse or promote products derived from this software without
27
+ * prior written permission. For written permission, please contact
28
+ * openssl-core@openssl.org.
29
+ *
30
+ * 5. Products derived from this software may not be called "OpenSSL"
31
+ * nor may "OpenSSL" appear in their names without prior written
32
+ * permission of the OpenSSL Project.
33
+ *
34
+ * 6. Redistributions of any form whatsoever must retain the following
35
+ * acknowledgment:
36
+ * "This product includes software developed by the OpenSSL Project
37
+ * for use in the OpenSSL Toolkit (https://www.openssl.org/)"
38
+ *
39
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
51
+ * ====================================================================
52
+ *
53
+ * This product includes cryptographic software written by Eric Young
54
+ * (eay@cryptsoft.com). This product includes software written by Tim
55
+ * Hudson (tjh@cryptsoft.com).
56
+ *
57
+ */
58
+
59
+ /* The lowest level part of this file was previously in crypto/des/read_pwd.c,
60
+ * Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
61
+ * All rights reserved.
62
+ *
63
+ * This package is an SSL implementation written
64
+ * by Eric Young (eay@cryptsoft.com).
65
+ * The implementation was written so as to conform with Netscapes SSL.
66
+ *
67
+ * This library is free for commercial and non-commercial use as long as
68
+ * the following conditions are aheared to. The following conditions
69
+ * apply to all code found in this distribution, be it the RC4, RSA,
70
+ * lhash, DES, etc., code; not just the SSL code. The SSL documentation
71
+ * included with this distribution is covered by the same copyright terms
72
+ * except that the holder is Tim Hudson (tjh@cryptsoft.com).
73
+ *
74
+ * Copyright remains Eric Young's, and as such any Copyright notices in
75
+ * the code are not to be removed.
76
+ * If this package is used in a product, Eric Young should be given attribution
77
+ * as the author of the parts of the library used.
78
+ * This can be in the form of a textual message at program startup or
79
+ * in documentation (online or textual) provided with the package.
80
+ *
81
+ * Redistribution and use in source and binary forms, with or without
82
+ * modification, are permitted provided that the following conditions
83
+ * are met:
84
+ * 1. Redistributions of source code must retain the copyright
85
+ * notice, this list of conditions and the following disclaimer.
86
+ * 2. Redistributions in binary form must reproduce the above copyright
87
+ * notice, this list of conditions and the following disclaimer in the
88
+ * documentation and/or other materials provided with the distribution.
89
+ * 3. All advertising materials mentioning features or use of this software
90
+ * must display the following acknowledgement:
91
+ * "This product includes cryptographic software written by
92
+ * Eric Young (eay@cryptsoft.com)"
93
+ * The word 'cryptographic' can be left out if the rouines from the library
94
+ * being used are not cryptographic related :-).
95
+ * 4. If you include any Windows specific code (or a derivative thereof) from
96
+ * the apps directory (application code) you must include an acknowledgement:
97
+ * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
98
+ *
99
+ * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
100
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
101
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
102
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
103
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
104
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
105
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
106
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
107
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
108
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
109
+ * SUCH DAMAGE.
110
+ *
111
+ * The licence and distribution terms for any publically available version or
112
+ * derivative of this code cannot be changed. i.e. this code cannot simply be
113
+ * copied and put under another distribution licence
114
+ * [including the GNU Public Licence.]
115
+ */
116
+
117
+ #include <sys/ioctl.h>
118
+
119
+ #include <openssl/opensslconf.h>
120
+
121
+ #include <errno.h>
122
+ #include <signal.h>
123
+ #include <stdio.h>
124
+ #include <string.h>
125
+ #include <unistd.h>
126
+
127
+ #include "ui_local.h"
128
+
129
+ #ifndef NX509_SIG
130
+ #define NX509_SIG 32
131
+ #endif
132
+
133
+ DWORD console_mode;
134
+ static FILE *tty_in, *tty_out;
135
+ static int is_a_tty;
136
+
137
+ /* Declare static functions */
138
+ static int read_till_nl(FILE *);
139
+ static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl);
140
+
141
+ static int read_string(UI *ui, UI_STRING *uis);
142
+ static int write_string(UI *ui, UI_STRING *uis);
143
+
144
+ static int open_console(UI *ui);
145
+ static int echo_console(UI *ui);
146
+ static int noecho_console(UI *ui);
147
+ static int close_console(UI *ui);
148
+
149
+ static const UI_METHOD ui_openssl = {
150
+ .name = "OpenSSL default user interface",
151
+ .ui_open_session = open_console,
152
+ .ui_write_string = write_string,
153
+ .ui_read_string = read_string,
154
+ .ui_close_session = close_console,
155
+ };
156
+
157
+ /* The method with all the built-in thingies */
158
+ const UI_METHOD *
159
+ UI_OpenSSL(void)
160
+ {
161
+ return &ui_openssl;
162
+ }
163
+
164
+ /* The following function makes sure that info and error strings are printed
165
+ before any prompt. */
166
+ static int
167
+ write_string(UI *ui, UI_STRING *uis)
168
+ {
169
+ switch (UI_get_string_type(uis)) {
170
+ case UIT_ERROR:
171
+ case UIT_INFO:
172
+ fputs(UI_get0_output_string(uis), tty_out);
173
+ fflush(tty_out);
174
+ break;
175
+ default:
176
+ break;
177
+ }
178
+ return 1;
179
+ }
180
+
181
+ static int
182
+ read_string(UI *ui, UI_STRING *uis)
183
+ {
184
+ int ok = 0;
185
+
186
+ switch (UI_get_string_type(uis)) {
187
+ case UIT_BOOLEAN:
188
+ fputs(UI_get0_output_string(uis), tty_out);
189
+ fputs(UI_get0_action_string(uis), tty_out);
190
+ fflush(tty_out);
191
+ return read_string_inner(ui, uis,
192
+ UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 0);
193
+ case UIT_PROMPT:
194
+ fputs(UI_get0_output_string(uis), tty_out);
195
+ fflush(tty_out);
196
+ return read_string_inner(ui, uis,
197
+ UI_get_input_flags(uis) & UI_INPUT_FLAG_ECHO, 1);
198
+ case UIT_VERIFY:
199
+ fprintf(tty_out, "Verifying - %s",
200
+ UI_get0_output_string(uis));
201
+ fflush(tty_out);
202
+ if ((ok = read_string_inner(ui, uis, UI_get_input_flags(uis) &
203
+ UI_INPUT_FLAG_ECHO, 1)) <= 0)
204
+ return ok;
205
+ if (strcmp(UI_get0_result_string(uis),
206
+ UI_get0_test_string(uis)) != 0) {
207
+ fprintf(tty_out, "Verify failure\n");
208
+ fflush(tty_out);
209
+ return 0;
210
+ }
211
+ break;
212
+ default:
213
+ break;
214
+ }
215
+ return 1;
216
+ }
217
+
218
+
219
+ /* Internal functions to read a string without echoing */
220
+ static int
221
+ read_till_nl(FILE *in)
222
+ {
223
+ #define SIZE 4
224
+ char buf[SIZE + 1];
225
+
226
+ do {
227
+ if (!fgets(buf, SIZE, in))
228
+ return 0;
229
+ } while (strchr(buf, '\n') == NULL);
230
+ return 1;
231
+ }
232
+
233
+ static int
234
+ read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl)
235
+ {
236
+ static int ps;
237
+ int ok;
238
+ char result[BUFSIZ];
239
+ int maxsize = BUFSIZ - 1;
240
+ char *p;
241
+
242
+ ok = 0;
243
+ ps = 0;
244
+
245
+ ps = 1;
246
+
247
+ if (!echo && !noecho_console(ui))
248
+ goto error;
249
+ ps = 2;
250
+
251
+ result[0] = '\0';
252
+ p = fgets(result, maxsize, tty_in);
253
+ if (!p)
254
+ goto error;
255
+ if (feof(tty_in))
256
+ goto error;
257
+ if (ferror(tty_in))
258
+ goto error;
259
+ if ((p = strchr(result, '\n')) != NULL) {
260
+ if (strip_nl)
261
+ *p = '\0';
262
+ } else if (!read_till_nl(tty_in))
263
+ goto error;
264
+ if (UI_set_result(ui, uis, result) >= 0)
265
+ ok = 1;
266
+
267
+ error:
268
+ if (!echo)
269
+ fprintf(tty_out, "\n");
270
+ if (ps >= 2 && !echo && !echo_console(ui))
271
+ ok = 0;
272
+
273
+ explicit_bzero(result, BUFSIZ);
274
+ return ok;
275
+ }
276
+
277
+
278
+ /* Internal functions to open, handle and close a channel to the console. */
279
+ static int
280
+ open_console(UI *ui)
281
+ {
282
+ CRYPTO_w_lock(CRYPTO_LOCK_UI);
283
+ is_a_tty = 1;
284
+
285
+ tty_in = stdin;
286
+ tty_out = stderr;
287
+
288
+ HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
289
+ if (handle != NULL && handle != INVALID_HANDLE_VALUE) {
290
+ if (GetFileType(handle) == FILE_TYPE_CHAR)
291
+ return GetConsoleMode(handle, &console_mode);
292
+ else
293
+ return 1;
294
+ }
295
+ return 0;
296
+ }
297
+
298
+ static int
299
+ noecho_console(UI *ui)
300
+ {
301
+ HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
302
+ if (handle != NULL && handle != INVALID_HANDLE_VALUE) {
303
+ if (GetFileType(handle) == FILE_TYPE_CHAR)
304
+ return SetConsoleMode(handle, console_mode & ~ENABLE_ECHO_INPUT);
305
+ else
306
+ return 1;
307
+ }
308
+ return 0;
309
+ }
310
+
311
+ static int
312
+ echo_console(UI *ui)
313
+ {
314
+ HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
315
+ if (handle != NULL && handle != INVALID_HANDLE_VALUE) {
316
+ if (GetFileType(handle) == FILE_TYPE_CHAR)
317
+ return SetConsoleMode(handle, console_mode);
318
+ else
319
+ return 1;
320
+ }
321
+ return 0;
322
+ }
323
+
324
+ static int
325
+ close_console(UI *ui)
326
+ {
327
+ if (tty_in != stdin)
328
+ fclose(tty_in);
329
+ if (tty_out != stderr)
330
+ fclose(tty_out);
331
+ CRYPTO_w_unlock(CRYPTO_LOCK_UI);
332
+
333
+ return 1;
334
+ }
@@ -0,0 +1,22 @@
1
+ #!/bin/sh
2
+ #
3
+ # Copyright (c) 2014 Brent Cook
4
+ #
5
+ # Permission to use, copy, modify, and distribute this software for any
6
+ # purpose with or without fee is hereby granted, provided that the above
7
+ # copyright notice and this permission notice appear in all copies.
8
+ #
9
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+ #
17
+ set -e
18
+
19
+ rm -f man/*.[35] include/openssl/*.h
20
+ ./autogen.sh
21
+ ./configure
22
+ make -j4 distcheck