#150 libstrl issues on Linux

2.7.3
closed-out-of-date
Packaging (15)
5
2013-10-01
2012-12-07
No

The strlcat/strlcpy problem remains. Right now these are the known issues:

1) If a previous version of opendkim installed a libstrl, we will detect its presence and assume we don't need to install a new one. Then RPM removes the old one when the old package is installed, and now the installed binaries won't run.

2) libdns from the unbound package also exports strlcat/strlcpy, which are in conflict with the ones we install and try to use. To add to this, some programs (e.g., opendkim-spam) actually don't need what's in libdns, so just linking against that is also the wrong thing. Similar issues might appear with libbsd or other-party libstrl installations.

We might want to revert to doing dkim_strlcat() and dkim_strlcpy() but put them in their own library like libopendkimutil. it would be a shame to pollute the filesystem with yet another strlcat/strlcpy, hiowever.

Discussion

  • I think a better solution is to use libbsd on Linux. Then, if the platform is Linux, you can assume any strl.h you find is your own and build strl. libbsd puts the header in bsd/string.h. Here's a patch to do this for 2.7.4. I didn't check if 2.8 needs any additional IFDEF. Sorry for the inlne patch, but I can't figure out the SF U/I to attach a file at 2AM.

    diff -u opendkim-2.7.4/configure.ac opendkim-2.7.4/configure.ac
    --- opendkim-2.7.4/configure.ac
    +++ opendkim-2.7.4/configure.ac
    @@ -182,6 +182,9 @@

    AC_CHECK_FUNCS([dup2 endpwent getcwd gethostname gethostbyname getaddrinfo gethostbyname2 gettimeofday isascii memchr memmove memset regcomp select socket strcasecmp strchr strdup strerror strncasecmp strrchr strstr strtol strtoul strtoull])

    +bsdstrl_h_found="no"
    +AC_CHECK_HEADERS([bsd/string.h], [bsdstrl_h_found="yes"])
    +
    strl_found="no"
    libstrl_found="no"
    strl_h_found="no"
    @@ -218,11 +221,11 @@
    saved_LIBS="$LIBS"
    LIBS=""
    AC_SEARCH_LIBS([strlcat],
    - [strl],
    + [bsd strl],
    [libstrl_found="yes"],
    [strl_found="no"])
    AC_SEARCH_LIBS([strlcpy],
    - [strl],
    + [bsd strl],
    [libstrl_found="yes"],
    [strl_found="no"])
    STRL_LIBS="$LIBS"
    @@ -236,13 +239,18 @@
    fi
    # we need to include <strl.h> if:
    # (a) strlcat and strlcpy weren't found, since we'll be rolling our own; OR
    -# (b) an installed strl.h was found
    -if test x"$strl_h_found" = x"yes" -o \( x"$strl_found" = x"no" -a x"$libstrl_found" = x"no" \)
    +# (b) an installed strl.h was found and no installed bsd/string.h was found
    +if test x"$strl_h_found" = x"yes" -o \( x"$strl_found" = x"no" -a x"$libstrl_found" = x"no" \) -a x"$bsdstrl_h_found" = x"no"
    then
    AC_DEFINE([USE_STRL_H], 1,
    [Define to 1 if you need to include <strl.h> to get the `strlcat()' and `strlcpy()' functions.])
    fi

    +if test x"$bsdstrl_h_found" = x"yes"
    +then
    + AC_DEFINE([USE_BSD_H], 1,
    + [Define to 1 if you need to include <bsd/string.h> to get the `strlcat()' and `strlcpy()' functions.])
    +fi
    #
    # Checks for structure members
    #
    diff -u opendkim-2.7.4/miltertest/miltertest.c opendkim-2.7.4/miltertest/miltertest.c
    --- opendkim-2.7.4/miltertest/miltertest.c
    +++ opendkim-2.7.4/miltertest/miltertest.c
    @@ -38,6 +38,11 @@
    /* libopendkim includes */
    #include <dkim.h>

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    --- opendkim-2.7.4.orig/stats/opendkim-importstats.c
    +++ opendkim-2.7.4/stats/opendkim-importstats.c
    @@ -23,6 +23,11 @@
    /* OpenDKIM includes */
    #include "stats.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/opendkim/reputation.c
    +++ opendkim-2.7.4/opendkim/reputation.c
    @@ -22,6 +22,11 @@
    /* libopendkim includes */
    #include <dkim.h>

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/opendkim/util.c
    +++ opendkim-2.7.4/opendkim/util.c
    @@ -47,6 +47,11 @@
    # endif /* SOLARIS <= 20600 */
    #endif /* SOLARIS */

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/opendkim/opendkim-ar.c
    +++ opendkim-2.7.4/opendkim/opendkim-ar.c
    @@ -22,6 +22,11 @@
    # include <sysexits.h>
    #endif /* ARTEST */

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/opendkim/stats.c
    +++ opendkim-2.7.4/opendkim/stats.c
    @@ -41,6 +41,11 @@
    /* libopendkim includes */
    #include <dkim.h>

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/opendkim/opendkim-testkey.c
    +++ opendkim-2.7.4/opendkim/opendkim-testkey.c
    @@ -39,6 +39,11 @@
    #include <dkim.h>
    #include <dkim-test.h>

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/opendkim/flowrate.c
    +++ opendkim-2.7.4/opendkim/flowrate.c
    @@ -16,6 +16,11 @@
    #include <string.h>
    #include <stdlib.h>

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/opendkim/opendkim-spam.c
    +++ opendkim-2.7.4/opendkim/opendkim-spam.c
    @@ -24,6 +24,11 @@
    # include <odbx.h>
    #endif /* USE_ODBX */

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/opendkim/opendkim.c
    +++ opendkim-2.7.4/opendkim/opendkim.c
    @@ -98,6 +98,11 @@
    # include "vbr.h"
    #endif /* _FFR_VBR */

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/opendkim/opendkim-db.c
    +++ opendkim-2.7.4/opendkim/opendkim-db.c
    @@ -37,6 +37,11 @@
    /* libopendkim includes */
    #include <dkim.h>

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/opendkim/test.c
    +++ opendkim-2.7.4/opendkim/test.c
    @@ -22,6 +22,11 @@
    #include "build-config.h"
    #include <dkim.h>

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/opendkim/config.c
    +++ opendkim-2.7.4/opendkim/config.c
    @@ -23,6 +23,11 @@
    /* libopendkim includes */
    #include <dkim.h>

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/util.c
    +++ opendkim-2.7.4/libopendkim/util.c
    @@ -27,6 +27,11 @@
    #include "dkim-internal.h"
    #include "util.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/dkim.c
    +++ opendkim-2.7.4/libopendkim/dkim.c
    @@ -92,6 +92,11 @@
    #include "util.h"
    #include "base64.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/dkim-cache.c
    +++ opendkim-2.7.4/libopendkim/dkim-cache.c
    @@ -27,6 +27,11 @@
    #include "dkim-internal.h"
    #include "dkim-cache.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/dkim-canon.c
    +++ opendkim-2.7.4/libopendkim/dkim-canon.c
    @@ -45,6 +45,11 @@
    #include "dkim-util.h"
    #include "util.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/dkim-test.c
    +++ opendkim-2.7.4/libopendkim/dkim-test.c
    @@ -36,6 +36,11 @@
    #include "dkim-util.h"
    #include "dkim-test.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/dkim-keys.c
    +++ opendkim-2.7.4/libopendkim/dkim-keys.c
    @@ -29,6 +29,11 @@
    #include "dkim-test.h"
    #include "util.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/dkim-policy.c
    +++ opendkim-2.7.4/libopendkim/dkim-policy.c
    @@ -34,6 +34,11 @@
    #include "dkim-test.h"
    #include "util.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/tests/t-test123.c
    +++ opendkim-2.7.4/libopendkim/tests/t-test123.c
    @@ -22,6 +22,11 @@
    #include "../dkim.h"
    #include "t-testdata.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/tests/t-test127.c
    +++ opendkim-2.7.4/libopendkim/tests/t-test127.c
    @@ -22,6 +22,11 @@
    #include "../dkim.h"
    #include "t-testdata.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/tests/t-test142.c
    +++ opendkim-2.7.4/libopendkim/tests/t-test142.c
    @@ -22,6 +22,11 @@
    #include "../dkim.h"
    #include "t-testdata.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/tests/t-test131.c
    +++ opendkim-2.7.4/libopendkim/tests/t-test131.c
    @@ -23,6 +23,11 @@
    #include "../dkim.h"
    #include "t-testdata.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/tests/t-test122.c
    +++ opendkim-2.7.4/libopendkim/tests/t-test122.c
    @@ -22,6 +22,11 @@
    #include "../dkim.h"
    #include "t-testdata.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/tests/t-test86.c
    +++ opendkim-2.7.4/libopendkim/tests/t-test86.c
    @@ -26,6 +26,11 @@
    #include "../dkim.h"
    #include "t-testdata.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/tests/t-test56.c
    +++ opendkim-2.7.4/libopendkim/tests/t-test56.c
    @@ -22,6 +22,11 @@
    #include "../dkim.h"
    #include "t-testdata.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/tests/t-test136.c
    +++ opendkim-2.7.4/libopendkim/tests/t-test136.c
    @@ -22,6 +22,11 @@
    #include "../dkim.h"
    #include "t-testdata.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/tests/t-test88.c
    +++ opendkim-2.7.4/libopendkim/tests/t-test88.c
    @@ -22,6 +22,11 @@
    #include "../dkim.h"
    #include "t-testdata.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/tests/t-test42.c
    +++ opendkim-2.7.4/libopendkim/tests/t-test42.c
    @@ -26,6 +26,11 @@
    #include "../dkim.h"
    #include "t-testdata.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/tests/t-test55.c
    +++ opendkim-2.7.4/libopendkim/tests/t-test55.c
    @@ -22,6 +22,11 @@
    #include "../dkim.h"
    #include "t-testdata.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/tests/t-test84.c
    +++ opendkim-2.7.4/libopendkim/tests/t-test84.c
    @@ -26,6 +26,11 @@
    #include "../dkim.h"
    #include "t-testdata.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/tests/t-test73.c
    +++ opendkim-2.7.4/libopendkim/tests/t-test73.c
    @@ -27,6 +27,11 @@
    #include "../dkim.h"
    #include "t-testdata.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>
    only in patch2:
    unchanged:
    --- opendkim-2.7.4.orig/libopendkim/tests/t-test57.c
    +++ opendkim-2.7.4/libopendkim/tests/t-test57.c
    @@ -24,6 +24,11 @@
    #include "../dkim.h"
    #include "t-testdata.h"

    +/* libbsd if found */
    +#ifdef USE_BSD_H
    +# include <bsd/string.h>
    +#endif /* USE_BSD_H */
    +
    /* libstrl if needed */
    #ifdef USE_STRL_H
    # include <strl.h>

     
    • assigned_to: nobody --> cm-msk
     
  • Can you either attach that to the bug as a file or email it to me? It ate or compressed spaces which means extracting it from the bug comment will be pretty much guaranteed not to apply cleanly, and that's a bit much to do by hand.

    Since most of it amounts to adding an include group for <bsd/string.h> anywhere there's one for <strl.h>, maybe I can automate all but the configure.ac part. We'll see who gets to it first.

     
  • Managed to automate it. Patch applied on and pushed to "develop".

     
    • priority: 6 --> 5
     
    • assigned_to: cm-msk --> nobody
     
    • assigned_to: Murray S. Kucherawy
     
    • status: open --> closed-out-of-date
     
  • Overtaken by events; our libstrl is being removed from the package.