commit 98670ba726486c39efff220ab1e074c62023aae7 from: Thomas Adam date: Thu Feb 23 21:58:18 2023 UTC portable: rework SHA detection Simply the SHA detection by not predicating on libcrypto, but instead checking individual header files. commit - 4680f704353811c8bb6ce65eac3714d1bd200c26 commit + 98670ba726486c39efff220ab1e074c62023aae7 blob - 7810a811f218e536fb05bf7f83bfa0a056b10d3a blob + 5ecb1e0be7519f3c6ebc7ef010454baac4c9b649 --- configure.ac +++ configure.ac @@ -61,6 +61,10 @@ AC_CHECK_HEADERS([ \ netinet/in.h \ paths.h \ poll.h \ + sha.h \ + sha1.h \ + sha2.h \ + sha256.h \ stddef.h \ stdint.h \ stdlib.h \ @@ -76,7 +80,39 @@ AC_CHECK_HEADERS([ \ unistd.h \ wchar.h \ ]) + +if test "x$ac_cv_header_sha2_h" = xyes; then + AC_DEFINE(HAVE_SHA2) +fi + +# Check for SHA1_DIGEST_LENGTH +have_sha1_digest_length=no +if test "x$ac_cv_header_sha_h" = xyes; then + AC_RUN_IFELSE([AC_LANG_PROGRAM( + [#include ], + [#if !defined(SHA1_DIGEST_LENGTH) && defined (SHA_DIGEST_LENGTH) + exit(1); + #endif + ])], + [have_sha1_digest_length=yes]) + AC_DEFINE(HAVE_SHA_AS_SHA1) +fi +if test "x$ac_cv_header_sha1_h" = xyes; then + AC_RUN_IFELSE([AC_LANG_PROGRAM( + [#include ], + [#if !defined(SHA1_DIGEST_LENGTH) && defined(SHA_DIGEST_LENGTH) + exit(1); + #endif + ] )], + [have_sha1_digest_length=yes]) + AC_DEFINE(HAVE_SHA1_AS_SHA1) +fi + +if test "x$have_sha1_digest_length" = "xno"; then + AC_DEFINE(NEEDS_SHA1_DEFS) +fi + # Checks for typ edefs, structures, and compiler characteristics. AC_CHECK_HEADER_STDBOOL AC_C_INLINE blob - b146547cc23b3c7916c1e7e886c8aebad9ba06a1 blob + 9d58d1d4f3c73ef9a8754f4cbf4e8532acff5a2a --- got/got.c +++ got/got.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include blob - a4d26d605a9162196cd0e43c6980234b14177126 blob + a7c0b49eb169b3371b17192a5ec228ef57483eb5 --- gotadmin/gotadmin.c +++ gotadmin/gotadmin.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include blob - b329e4f9f60f9e4fed88125a1e42e770bdd72872 blob + 0fba1db7959d1da077ff54a97824b6ec0255df29 --- gotctl/gotctl.c +++ gotctl/gotctl.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include blob - bf8a5a421921da98ed0c1b028b43a6967f4c4d8d blob + d74ab2f3a2865e540ecb51ffc8b273b3f0ebb8c1 --- gotd/auth.c +++ gotd/auth.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include blob - f9834ad580db42912c37793c7e7a4f5040fba6c2 blob + 46f51709d4e05be5f4a1bfc8d485317c05a72111 --- gotd/gotd.c +++ gotd/gotd.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include blob - c319a296e8455eef52ea66fdc7fe6136f8728b02 blob + ec712af51ff37e9a9c9342221a919cc6d0565305 --- gotd/imsg.c +++ gotd/imsg.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include blob - d94f3fbaa887157be0629404a08a4af77a5eb6d1 blob + 2c0352c2f41add38d42370550c49e764389806f5 --- gotd/listen.c +++ gotd/listen.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include blob - 0b4edb2a4f94902cb33b4804337c2118da943239 blob + 0394a37569c71ffd95c1fb0aeb7b1ed4b5eaf0a5 --- gotd/parse.y +++ gotd/parse.y @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include blob - 5c4d0cbff0ab9471a9c581e38be2edd6ea8581e8 blob + f9265999b49a290679c80586abd15f3aad813a2f --- gotd/privsep_stub.c +++ gotd/privsep_stub.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include blob - 2e9690ee161556cc94657a6be85b4a5ad0207db7 blob + 0b3f8f4df38cd7b80fc0ef9f616105f88ad2565a --- gotd/repo_imsg.c +++ gotd/repo_imsg.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include blob - e4033dad862d1bacc395074fae271b9400061e0f blob + 3e016920d6e5a18165d664b26db02064ceb0e529 --- gotd/repo_read.c +++ gotd/repo_read.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include blob - 2f5dab83d08781fed6e68c16de4b0fdcd02ef6ad blob + 319a93427d3f3e03ba19eef16c6c192b1160b7d8 --- gotd/repo_write.c +++ gotd/repo_write.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include blob - 9b04057a08fddc4e519b997e886e398a3f2a8fae blob + 2dab4b1899454a2d79c63b10b268cda3292031fd --- gotd/session.c +++ gotd/session.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include blob - cdb218153a373245b9c2f3e076f4ad83d8a03fbe blob + 23e06a43a397b5bc76b1d9cf4901e41465d7af8a --- gotsh/gotsh.c +++ gotsh/gotsh.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include blob - f33fd0788ee7f1d411b39595e069949c2355f35b blob + 44f5c1f1dfaa5a857e1ad3c7bae54e5f0ff4014c --- gotwebd/got_operations.c +++ gotwebd/got_operations.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include blob - 65888b789dad6e7039d96196f21546c1d75deeb0 blob + 7f871577f71bf7ed192f9f4d4775c3309b27e7b0 --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include blob - bea0461c4b1286b162ce1d279fb93dd847ff4ab5 blob + 9e131f7f8ea2410519cb28093419e4df01e1ddac --- gotwebd/pages.tmpl +++ gotwebd/pages.tmpl @@ -26,8 +26,6 @@ #include #include #include -#include -#include #include #include "got_error.h" blob - 1e0533b86a5cee6b686263c78b184b6dcc2d8424 blob + 3b09591adc5c3e61b1aff3e8c4f1b9fb6fcc43a8 --- include/got_compat.h +++ include/got_compat.h @@ -179,15 +179,35 @@ void uuid_to_string(uuid_t *, char **, uint32_t *); #include #endif -#if defined(HAVE_LIBCRYPTO) && !defined(__APPLE__) && !defined(__DragonFly__) -#include -#elif !defined(__APPLE__) && !defined(__DragonFly__) -#include -#elif defined(__DragonFly__) +#ifdef HAVE_SHA_AS_SHA1 +# include +#endif +#ifdef HAVE_SHA1_AS_SHA1 +# include +#endif +#ifdef HAVE_SHA2 +# include +#endif +#ifdef HAVE_SHA256 +# include +#endif + +/* Catch-all for systems where the header files don't exist and/or the below + * still are not defined. + */ +#ifndef SHA256_DIGEST_LENGTH +#define SHA256_DIGEST_LENGTH 32 +#endif + +#ifndef SHA256_DIGEST_STRING_LENGTH +#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) +#endif + +#if defined(__DragonFly__) #include #endif -#if !defined(HAVE_LIBCRYPTO) || defined(__APPLE__) || defined(__DragonFly__) +#ifdef NEEDS_SHA1_DEFS #define SHA1_DIGEST_LENGTH SHA_DIGEST_LENGTH #define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1) blob - 2ace4a8e74b2a0d188c898337da1a66100c24824 blob + 531a4c6c7f0f7ee650c3ef2b49aa61e0a2865500 --- lib/blame.c +++ lib/blame.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include blob - fc465bce11261cde06c093c839b9ad0db0bea20a blob + ae0d1c4a107ec6772002d0f5ae5e06b426fe3afe --- lib/commit_graph.c +++ lib/commit_graph.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include blob - 29330c9824aaad1442af3afa8d4c8397efd31716 blob + 4ba630b800dab6a323fdb7c5e2d6927c17956784 --- lib/deflate.c +++ lib/deflate.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include blob - f38c8f116519364b05b805ca2ab0d191d45b2bea blob + 618841b580474c8ab1894240045e221759e59487 --- lib/delta.c +++ lib/delta.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include blob - f93addaff823bf9b7e5bdcf0a04cf043a690a705 blob + 09b40b8dd8fc51e6f52338e23640fd344f9a41ea --- lib/delta_cache.c +++ lib/delta_cache.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include blob - bd198cdba82ee1ced9177d7a0137b0e3ecc3e6cc blob + 6f2dfcfbe30bcc4ee982d27c6380d19f5ac22b3a --- lib/diff.c +++ lib/diff.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include "got_compat.h" blob - 0b8099ecdf78b23d9f12810ac2ab81af968afc83 blob + ddbcb7a24e9176cc112a20f881d069c75b749a37 --- lib/diff3.c +++ lib/diff3.c @@ -69,7 +69,6 @@ #include #include -#include #include #include #include blob - 4e4766f50d17b735045d4dc39c6ade26747f55e4 blob + f024469b941b3c0d551b8050cdb33fe296707d8f --- lib/diffreg.c +++ lib/diffreg.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include blob - ce1571a07c3fe580d7e68be79a14d3064710c8a0 blob + 65f80e0880b3c1a7d26448fd7d30e83e481613c9 --- lib/error.c +++ lib/error.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include "got_compat.h" blob - a24dddf1bb9bebb6213ffa9606a113b65b9fb58b blob + 2dff9d2217e21cccb6effd088b7af5ea1198e111 --- lib/fetch.c +++ lib/fetch.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include blob - ce44ea025f1a8c3e0a6d9cf479a006ad7d5963fb blob + 80bb569a83d950fd120675d0358a60e766377675 --- lib/fileindex.c +++ lib/fileindex.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include blob - a2c0362befef56fd6b1c079495d468122777b622 blob + 0899cb3a60f2ec26d7d1d2ab84ee0dc40d2f085d --- lib/gotconfig.c +++ lib/gotconfig.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "got_compat.h" blob - e2487ef29210d28fa0a7186a77a4d7d7543d54a3 blob + c53fbbe58dae6a5d9e1e0e25106398709945c8db --- lib/hash.c +++ lib/hash.c @@ -17,7 +17,6 @@ #include #include -#include #include #include #include blob - 9450230f04804c87c6ae8ea065db52e2c32f3205 blob + 9440011aed7234a7fffaed90fe2fb8b55fb0d2c9 --- lib/inflate.c +++ lib/inflate.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include blob - 992a0f5ce17dafa30025415cf90543457d9517a8 blob + 7e7e6427733241033f8682fc9be241bf5de1823a --- lib/object.c +++ lib/object.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include blob - ec56215dbedb4e6aad7a0fb2798bd32bfd9e55bb blob + b1da1e4401a9bbc8ff1965298c713b5f73d95ba7 --- lib/object_cache.c +++ lib/object_cache.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include "got_error.h" blob - 0eaa9659577a8048060a67ff9229d857672d6857 blob + 3458a76c9475cc94b6aff79ea705d763984f159c --- lib/object_create.c +++ lib/object_create.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include blob - c678dbbaf4060b6835df596b7bd0567390ba95a8 blob + dc9175ad60883e788dd8423ab2847d17d17539ce --- lib/object_idset.c +++ lib/object_idset.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include blob - 4d6e14e537fa3cf5fd32bb4e512e90e8e85471b0 blob + 7c7d840b419d9c54504a2a26fdb31aec8a56906a --- lib/object_open_io.c +++ lib/object_open_io.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include blob - 6eeb99b9d479b86e4cf79f7aef07e4a7551b8dd7 blob + a09a1387ed6a59da493df3eba699bf1438a8006c --- lib/object_open_privsep.c +++ lib/object_open_privsep.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include blob - bc29fe7090ddf7dcb9f8aa95868f9f535e221528 blob + c18378157f7335d09333043c3626ca7abbaa6092 --- lib/object_parse.c +++ lib/object_parse.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include blob - 88f6c2f88020ad3de113adafe27195dcf9b25e57 blob + 74b04029ae57d75b6ece9157e077405bf3cedafa --- lib/pack.c +++ lib/pack.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include blob - fbc83c18e7eacb95774aa08efec6025d169f3822 blob + 1d2bcd07b13eee0369a1fdd6bcd48e349cd744b2 --- lib/pack_create.c +++ lib/pack_create.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include blob - 2898bba90e189539cf95d6c84dd73b803b5f6cec blob + 9880eed03a11e8a23ca257f6506fb6bc465e2d6e --- lib/pack_create_io.c +++ lib/pack_create_io.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include blob - e0a310d9523536daff287c092b243f9ac162846d blob + c142e7072d23a5474652d25759ba3212fcefc072 --- lib/pack_create_privsep.c +++ lib/pack_create_privsep.c @@ -19,7 +19,6 @@ #include #include -#include #include #include #include blob - b5f3ce0460190915c4f5a56709cfdc35dda7deab blob + 88f1642f3c6d71372fc384339a2be124e40aecfc --- lib/pack_index.c +++ lib/pack_index.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include blob - 45c7a47cfdc5b815a8d528143ca2e800bb744872 blob + 0758bbe85ffe3061227ab30c2fdfcdad6c012a06 --- lib/patch.c +++ lib/patch.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include blob - 3f6510f13d350b7193828875a70323cebb1abb7c blob + ad308a6c9b7dda90ed15a2273bf2b022c64e6c05 --- lib/privsep.c +++ lib/privsep.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include blob - e10563a380f7a4696e61fc8f50e3757261d37db6 blob + 178085a6d3a9da157f1c058c93758a7f8607f13f --- lib/read_gitconfig.c +++ lib/read_gitconfig.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include blob - ee630b5570e91c766e64ac8ee67cdb5d9a21958d blob + bb395ed8acf27a029c07482c594674dc90ca0213 --- lib/read_gitconfig_privsep.c +++ lib/read_gitconfig_privsep.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include blob - 7ae05201d58c2f815259ae6c0f07062124851282 blob + f67367d1512081ce314c3fdd7062701103036d17 --- lib/read_gotconfig_privsep.c +++ lib/read_gotconfig_privsep.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "got_error.h" blob - 0c4ac532389d6d66dfa1c161ea50408a233916b2 blob + e6c5b39513e6605848a31acea189b5cefa9825d2 --- lib/reference.c +++ lib/reference.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include blob - c51a63698f02d74d379fd7a7e7b57278180f3288 blob + dc6e10be3fb65b371d7477b1baeca9e65ee5ba53 --- lib/repository.c +++ lib/repository.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include blob - 6680e6ad362d41f7b564bbe9b6d7c24191a1628c blob + dbb8389afe03f47e77d8417a8687a9ca9b678e04 --- lib/repository_admin.c +++ lib/repository_admin.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include blob - da1670dbd313c4866455fad9ad5ca7209d25693a blob + ee84f81fb3bd9c00203b1b436fa5915616a2cb14 --- lib/send.c +++ lib/send.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include blob - 0825940f6378354306bbe2202cfef7eaf6f9f653 blob + 3c0e922f710512fb11185edf45470c7bed7253bb --- lib/serve.c +++ lib/serve.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include blob - ca175ba777bb563ac33ef1a6daada0dbb075c905 blob + bb6f7b48aba8f212300f99f8f6124870d2f9b8f4 --- lib/sigs.c +++ lib/sigs.c @@ -28,7 +28,6 @@ #include #include #include -#include #include "got_error.h" #include "got_date.h" blob - 4ffaf4a5bb40281af50f515fc18f3a951061fac0 blob + 3276b68b2bd0121b814c2594012e2db83a044bc5 --- lib/worktree.c +++ lib/worktree.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include blob - f8acd2fe55582f6b7ecd45bfed26391e314958e3 blob + 6899fcc655eccfe88e1d3e566ff3f224b5cbc71b --- lib/worktree_open.c +++ lib/worktree_open.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include blob - 7973e96590269ad32eab3b752ec17aa2b24a5b1a blob + 002c66e8605f11fc36aee7b6b641538953bc6a13 --- libexec/got-fetch-pack/got-fetch-pack.c +++ libexec/got-fetch-pack/got-fetch-pack.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include blob - beea353f8a279a27f1082ca510ad04af7944f929 blob + a7606b8b2937a303d4d0f298209c1dabd9bb721b --- libexec/got-index-pack/got-index-pack.c +++ libexec/got-index-pack/got-index-pack.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include blob - 82a415956cd1b4f11285582fef175f46ad7e3456 blob + 278ffbba28800315d824bf942dd2a401bd045cb6 --- libexec/got-read-blob/got-read-blob.c +++ libexec/got-read-blob/got-read-blob.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include blob - 580ad2a27a71135ebeb8ef129d16b2be1bdab8c4 blob + 1a2bbf0db3a492eb7b95f7e964508cdc0c505f2d --- libexec/got-read-commit/got-read-commit.c +++ libexec/got-read-commit/got-read-commit.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include blob - 32b9bc2f2840c9cee50874705bf0aae8dcce115d blob + ec661ca8daa84e29923797dbbf72c7809c986bf8 --- libexec/got-read-gitconfig/got-read-gitconfig.c +++ libexec/got-read-gitconfig/got-read-gitconfig.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include blob - 249115fc9b79d2ae37893d0399a79209e0377c32 blob + 4236ba777f0f997b7f5c92ac68e2480a8f3bf64f --- libexec/got-read-gotconfig/got-read-gotconfig.c +++ libexec/got-read-gotconfig/got-read-gotconfig.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include blob - 75104f0a91cddbe9349f52a27322ad16665088f1 blob + f32cb7bfb6961e17dda8f36484ee88cedf52059f --- libexec/got-read-object/got-read-object.c +++ libexec/got-read-object/got-read-object.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include blob - e0171fddfbd6b9ff02575d23a1f0be4cc89aac37 blob + f62b5b34419a28d58f8666b7c7f128f4fdde0513 --- libexec/got-read-pack/got-read-pack.c +++ libexec/got-read-pack/got-read-pack.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include blob - 61efac815682cddee28e9cde4b2675386e753f62 blob + 0674441331f634dc5326c1b041622ea0e37a3121 --- libexec/got-read-patch/got-read-patch.c +++ libexec/got-read-patch/got-read-patch.c @@ -42,7 +42,6 @@ #include #include #include -#include #include #include #include blob - 81bdcfb0766e9e20f2539bfea2c001880305cad0 blob + dec83c1a875916235977245236b2aa9d6bcf2b03 --- libexec/got-read-tag/got-read-tag.c +++ libexec/got-read-tag/got-read-tag.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include blob - 304918f1bfbcea2e14123c5ce870242ae1849519 blob + a578eadbbddbc594dac437cf55427bbc85eadb71 --- libexec/got-read-tree/got-read-tree.c +++ libexec/got-read-tree/got-read-tree.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include blob - f5bc0144890b580f2cf6a45f8793151da47821c0 blob + 6d16143a6eaa88639c64666308cd31dc48b99012 --- libexec/got-send-pack/got-send-pack.c +++ libexec/got-send-pack/got-send-pack.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include blob - 5e4320f08ea33f72c2dbce99a0977f069e7b6874 blob + 644249ca63d93911e506cc4411f40c1836d527df --- regress/fetch/fetch_test.c +++ regress/fetch/fetch_test.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include blob - fdd31201a239c2c52874d1961c4eeea47ef28349 blob + 4c9b401d8ebeee2041343bc28f08b71d287a0f1d --- regress/idset/idset_test.c +++ regress/idset/idset_test.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include blob - 4bc522279d5a0829ae24e230bd9dc7c6cf314973 blob + 538114b0dd798c030f1eb44257fbac707152a44f --- tog/tog.c +++ tog/tog.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include