diff options
author | Zack Weinberg <zackw@panix.com> | 2021-03-18 12:01:53 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2021-03-18 12:01:53 -0400 |
commit | 3a000f1075de44a3812d865d95a8a75b552e5d86 (patch) | |
tree | 1b26aac1ba5e0b5ce7f7eeeea6f59eaf35bb4c3f | |
parent | f0b79206fd841fada9e5372941d3623a21a50c0c (diff) | |
download | libxcrypt-3a000f1075de44a3812d865d95a8a75b552e5d86.tar.gz libxcrypt-3a000f1075de44a3812d865d95a8a75b552e5d86.tar.bz2 libxcrypt-3a000f1075de44a3812d865d95a8a75b552e5d86.zip |
Don’t apply --enable-obsolete-api-enosys mode to fcrypt.
fcrypt is the only function that has two alternative implementations,
selected by configure options, one of which is an alias for another
function. This is interfering with my plans to handle symbol
versioning with objcopy instead of a maze of #ifdefs.
fcrypt is not part of POSIX. In GNU libc, our most important
compatibility target, it has always been another name for crypt:
in particular it has always supported all of the same hashing
methods as crypt itself. Therefore, it seems to me we should
treat it the same as any other obsolete alternative name for
crypt (e.g. xcrypt): either not available at all, or available
to old binaries with all the same functionality it’s ever had.
Accordingly, remove the --enable-obsolete-api-enosys version of
fcrypt. Also, don’t bother testing it in ka-tester, since we know by
construction it’s just another name for crypt.
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | lib/crypt-static.c | 24 | ||||
-rw-r--r-- | test/fcrypt-enosys.c | 82 | ||||
-rw-r--r-- | test/ka-tester.c | 17 |
4 files changed, 6 insertions, 120 deletions
diff --git a/Makefile.am b/Makefile.am index 0002545..0c5ca0b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -404,7 +404,7 @@ endif if ENABLE_OBSOLETE_API libcrypt_la_SOURCES += lib/crypt-des-obsolete.c -check_PROGRAMS += test/des-obsolete test/des-obsolete_r test/fcrypt-enosys +check_PROGRAMS += test/des-obsolete test/des-obsolete_r endif TESTS = $(check_PROGRAMS) @@ -451,7 +451,6 @@ test_gensalt_extradata_LDADD = $(COMMON_TEST_OBJECTS) test_checksalt_LDADD = $(COMMON_TEST_OBJECTS) test_des_obsolete_LDADD = $(COMMON_TEST_OBJECTS) test_des_obsolete_r_LDADD = $(COMMON_TEST_OBJECTS) -test_fcrypt_enosys_LDADD = $(COMMON_TEST_OBJECTS) test_crypt_badargs_LDADD = $(COMMON_TEST_OBJECTS) test_short_outbuf_LDADD = $(COMMON_TEST_OBJECTS) test_preferred_method_LDADD = $(COMMON_TEST_OBJECTS) diff --git a/lib/crypt-static.c b/lib/crypt-static.c index 1e8a919..b9286e8 100644 --- a/lib/crypt-static.c +++ b/lib/crypt-static.c @@ -22,39 +22,19 @@ own files so that a statically-linked program that doesn't use them will not have the state objects in its data segment. */ -#if INCLUDE_crypt || INCLUDE_fcrypt +#if INCLUDE_crypt char * crypt (const char *key, const char *setting) { static struct crypt_data nr_crypt_ctx; return crypt_r (key, setting, &nr_crypt_ctx); } -#endif - -#if INCLUDE_crypt SYMVER_crypt; #endif +/* For code compatibility with old glibc. */ #if INCLUDE_fcrypt -#if ENABLE_OBSOLETE_API_ENOSYS -char * -fcrypt (ARG_UNUSED (const char *key), ARG_UNUSED (const char *setting)) -{ - /* This function is not supported in this configuration. */ - errno = ENOSYS; - -#if ENABLE_FAILURE_TOKENS - /* Return static buffer filled with a failure-token. */ - static char retval[3]; - make_failure_token (setting, retval, 3); - return retval; -#else - return NULL; -#endif -} -#else strong_alias (crypt, fcrypt); -#endif SYMVER_fcrypt; #endif diff --git a/test/fcrypt-enosys.c b/test/fcrypt-enosys.c deleted file mode 100644 index 4761897..0000000 --- a/test/fcrypt-enosys.c +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 2019 Björn Esser <besser82@fedoraproject.org> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "crypt-port.h" - -#if ENABLE_OBSOLETE_API && ENABLE_OBSOLETE_API_ENOSYS - -#include <errno.h> -#include <stdio.h> - -symver_ref("fcrypt", fcrypt, SYMVER_FLOOR); - -int -main (void) -{ - int status = 0; - - /* Explicitly reset errno as required by POSIX. */ - errno = 0; - - char *retval = fcrypt ("ThisIsVerySecret", ".."); - - if (errno != ENOSYS) - { - printf ("FAIL: %s: errno does NOT equal ENOSYS.\n" - "expected: %d, %s, got: %d, %s\n", "fcrypt", - ENOSYS, strerror (ENOSYS), errno, strerror (errno)); - status = 1; - } - -#if ENABLE_FAILURE_TOKENS - if (strcmp (retval, "*0")) - { - printf ("FAIL: %s: did NOT return *0 (failure-token). " - "got: %s\n", "fcrypt", retval); - status = 1; - } - - retval = fcrypt ("ThisIsVerySecret", retval); - - if (strcmp (retval, "*1")) - { - printf ("FAIL: %s: did NOT return *1 (failure-token). " - "got: %s\n", "fcrypt", retval); - status = 1; - } -#else - if (retval != NULL) - { - printf ("FAIL: %s: did NOT return NULL. got: %s\n", - "fcrypt", retval); - status = 1; - } -#endif - - return status; -} - -#else - -int -main (void) -{ - return 77; /* UNSUPPORTED */ -} - -#endif diff --git a/test/ka-tester.c b/test/ka-tester.c index d22e034..7d1ad15 100644 --- a/test/ka-tester.c +++ b/test/ka-tester.c @@ -13,10 +13,6 @@ #include <stdlib.h> #include <errno.h> -#if ENABLE_OBSOLETE_API && !ENABLE_OBSOLETE_API_ENOSYS -symver_ref("fcrypt", fcrypt, SYMVER_FLOOR); -#endif - /* The precalculated hashes in ka-table.inc, and some of the relationships among groups of test cases (see ka-table-gen.py) are invalidated if the execution character set is not ASCII. */ @@ -24,7 +20,7 @@ static_assert(' ' == 0x20 && 'C' == 0x43 && '~' == 0x7E, "Execution character set does not appear to be ASCII"); /* This test verifies three things at once: - - crypt, crypt_r, crypt_rn, crypt_ra, and fcrypt (if enabled) + - crypt, crypt_r, crypt_rn, and crypt_ra all produce the same outputs for the same inputs. - given hash <- crypt(phrase, setting), then hash == crypt(phrase, hash) also. @@ -147,7 +143,7 @@ report_result (const char *tag, const char *hash, int errnm, } static int -calc_hashes_crypt_fcrypt (void) +calc_hashes_crypt (void) { char *hash; const struct testcase *t; @@ -159,13 +155,6 @@ calc_hashes_crypt_fcrypt (void) hash = crypt (t->input, t->salt); status |= report_result ("crypt", hash, errno, t, ENABLE_FAILURE_TOKENS); - -#if ENABLE_OBSOLETE_API && !ENABLE_OBSOLETE_API_ENOSYS - errno = 0; - hash = fcrypt (t->input, t->salt); - status |= report_result ("fcrypt", hash, errno, t, - ENABLE_FAILURE_TOKENS); -#endif } return status; @@ -243,7 +232,7 @@ main (void) if (tests[0].input == 0) return 77; - status |= calc_hashes_crypt_fcrypt (); + status |= calc_hashes_crypt (); status |= calc_hashes_crypt_r_rn (); status |= calc_hashes_crypt_ra_recrypt (); |