randombit / botan

Cryptography Toolkit
https://botan.randombit.net
BSD 2-Clause "Simplified" License
2.58k stars 568 forks source link

Cygwin 6.3 and "Failure... No filesystem access enabled" #824

Closed noloader closed 7 years ago

noloader commented 7 years ago

This may be related to Issue 276, Let fuzzer test handle unavailable filesystem access properly:

$ ./configure.py
   INFO: ./configure.py invoked with options ""
   INFO: Platform: OS="CYGWIN_NT-6.3" machine="x86_64" proc=""
   INFO: Guessing target OS is cygwin (use --os to set)
   INFO: Guessing to use compiler gcc (use --cc to set)
   INFO: Guessing target processor is a x86_64/x86_64 (use --cpu to set)
   INFO: Target is gcc-cygwin-x86_64-x86_64
WARNING: Shared libs not supported on cygwin, disabling shared lib support
   INFO: Skipping, dependency failure - certstor_sqlite3 sessions_sqlite3
   INFO: Skipping, incompatible OS - darwin_secrandom dyn_load locking_allocator
   INFO: Skipping, no enabled compression schemes - compression
   INFO: Skipping, requires external dependency - boost bzip2 lzma openssl pkcs11 sqlite3 tpm zlib
   INFO: Loading modules adler32 aead aes aes_ni aes_ssse3 aont asn1 auto_rng base base64 bcrypt bigint blake2 block blowfish camellia cascade cast cbc cbc_mac ccm cecpq1 certstor_sql cfb chacha chacha20poly1305 chacha_sse2 clmul cmac codec_filt comb4p crc24 crc32 cryptoapi_rng cryptobox ctr curve25519 des dev_random dh dl_algo dl_group dlies dsa eax ec_gfp ec_group ecc_key ecdh ecdsa ecgdsa ecies eckcdsa elgamal eme_oaep eme_pkcs1 eme_raw emsa1 emsa_pkcs1 emsa_pssr emsa_raw emsa_x931 entropy fd_unix ffi filters fpe_fe1 gcm gmac gost_28147 gost_3410 gost_3411 hash hash_id hex hkdf hmac hmac_drbg http_util idea idea_sse2 iso9796 kasumi kdf kdf1 kdf1_iso18033 kdf2 keccak keypair lion mac mce mceies md4 md5 mdx_hash mgf1 misty1 mode_pad modes mp newhope noekeon noekeon_simd numbertheory ocb ofb par_hash passhash9 pbes2 pbkdf pbkdf1 pbkdf2 pem pk_pad poly1305 prf_tls prf_x942 proc_walk pubkey rc4 rdrand rdrand_rng rdseed rfc3394 rfc6979 rmd160 rng rsa salsa20 seed serpent serpent_simd sessions_sql sha1 sha1_sse2 sha2_32 sha2_64 sha3 shake shake_cipher simd siphash siv skein sp800_108 sp800_56c srp6 stateful_rng stream system_rng threefish threefish_avx2 tiger tls tls_cbc tss twofish utils whirlpool win32_stats x509 x919_mac xmss xtea xts
   INFO: Assuming CPU is little endian
   INFO: Assuming unaligned memory access works
   INFO: Using symlink to link files into build dir (use --link-method to change)
   INFO: Botan 2.0.0 (VC git:c46692e9562e0faa6961532c21998d5cd5c2ee20) (unreleased undated) build setup is complete

And then:

$ ./botan-test.exe
Testing Botan 2.0.0 (unreleased, revision git:c46692e9562e0faa6961532c21998d5cd5c2ee20, distribution unspecified)
Starting tests rng:HMAC_DRBG with seed '14978AA4FF880E84'
block ran 1 tests 1 FAILED
Failure 1: No filesystem access enabled.
stream ran 1 tests 1 FAILED
Failure 1: No filesystem access enabled.
hash ran 1 tests 1 FAILED
Failure 1: No filesystem access enabled.
mac ran 1 tests 1 FAILED
Failure 1: No filesystem access enabled.
modes ran 1 tests 1 FAILED
Failure 1: No filesystem access enabled.
pbkdf ran 1 tests 1 FAILED
Failure 1: No filesystem access enabled.
HMAC_DRBG(SHA-1) ran 240 tests in 11.57 msec all ok
HMAC_DRBG(SHA-224) ran 240 tests in 16.75 msec all ok
HMAC_DRBG(SHA-256) ran 240 tests in 16.96 msec all ok
HMAC_DRBG(SHA-384) ran 240 tests in 19.53 msec all ok
HMAC_DRBG(SHA-512) ran 240 tests in 19.52 msec all ok
HMAC_DRBG(SHA-512-256) ran 240 tests in 19.33 msec all ok
...

$ uname -a
CYGWIN_NT-6.3 asus-windows8 2.6.1(0.305/5/3) 2016-12-16 11:55 x86_64 Cygwin
$ uname -m
x86_64
$ uname -s
CYGWIN_NT-6.3
$ uname -a
CYGWIN_NT-6.3-WOW asus-windows8 2.6.1(0.305/5/3) 2016-12-16 11:50 i686 Cygwin
$ uname -m
i686
$ uname -s
CYGWIN_NT-6.3-WOW
randombit commented 7 years ago

I think we see the same problem on MinGW, there is no code to use the Windows filesystem API. We only support readdir or a C++ filesystem library (either Boost or MSVC's version).

Or wait, unlike MinGW, Cygwin supports Unix APIs, right? So maybe this works:

diff --git a/src/build-data/os/cygwin.txt b/src/build-data/os/cygwin.txt
index 956f5b28d..a1234dc13 100644
--- a/src/build-data/os/cygwin.txt
+++ b/src/build-data/os/cygwin.txt
@@ -13,6 +13,7 @@ doc_dir docs
 <target_features>
 gettimeofday
 timegm
+readdir
 threads
 filesystem
 </target_features>

Would be good to support Win32 API in the filesystem code (for MinGW if nothing else), it is a simple function (just needs to do a recursive readdir and return all results). But I don't have any Windows dev machines, and hate programming blind using CI to check work (AppVeyor builds have 2-6 hour turnaround which makes testing commits a lot like how 60s batch programming must have been).

noloader commented 7 years ago

@randombit,

Yep, that fixed it. Thanks.

asus-windows8:botan$ ./botan-test.exe
Testing Botan 2.0.0 (unreleased, revision git:c46692e9562e0faa6961532c21998d5cd5c2ee20, distribution unspecified)
Starting tests rng:HMAC_DRBG with seed '14978CA42341E6A0'
AES-128 ran 10422 tests in 51.41 msec all ok
AES-192 ran 12150 tests in 55.47 msec all ok
AES-256 ran 13878 tests in 63.27 msec all ok
...
randombit commented 7 years ago

Fixed on master, thanks