Bug 270023 - usr.sbin/pkg doesn't compile with OpenSSL 3
Summary: usr.sbin/pkg doesn't compile with OpenSSL 3
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.1-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: Baptiste Daroussin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-08 04:41 UTC by Enji Cooper
Modified: 2023-05-19 08:18 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer freebsd_triage 2023-03-08 04:41:03 UTC
Compiling usr.bin/pkg with OpenSSL 3 results in a host of -Wdeprecated-declaration errors. This doesn't seem to happen with newer versions of pkg from ports -- I'm guessing that there are some changes that need to be synced from the GH repo.

Here are some example failures:
```
/usr/local/include/openssl/sha.h:76:1: note: 'SHA256_Final' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 int SHA256_Final(unsigned char *md, SHA256_CTX *c);
^
/usr/local/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/usr/local/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
/usr/src/usr.sbin/pkg/pkg.c:456:2: error: 'SHA256_Init' is deprecated [-Werror,-Wdeprecated-declarations]
        SHA256_Init(&sha256);
        ^
/usr/local/include/openssl/sha.h:73:1: note: 'SHA256_Init' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 int SHA256_Init(SHA256_CTX *c);
^
/usr/local/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/usr/local/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
/usr/src/usr.sbin/pkg/pkg.c:459:3: error: 'SHA256_Update' is deprecated [-Werror,-Wdeprecated-declarations]
                SHA256_Update(&sha256, buffer, r);
                ^
/usr/local/include/openssl/sha.h:74:1: note: 'SHA256_Update' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 int SHA256_Update(SHA256_CTX *c,
^
/usr/local/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/usr/local/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
/usr/src/usr.sbin/pkg/pkg.c:466:2: error: 'SHA256_Final' is deprecated [-Werror,-Wdeprecated-declarations]
        SHA256_Final(hash, &sha256);
        ^
/usr/local/include/openssl/sha.h:76:1: note: 'SHA256_Final' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 int SHA256_Final(unsigned char *md, SHA256_CTX *c);
^
/usr/local/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/usr/local/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
6 errors generated.
*** Error code 1
```
Comment 1 Enji Cooper freebsd_committer freebsd_triage 2023-03-08 04:41:47 UTC
For anyone else wondering: this issue is present in stable/13 and main.
Comment 2 Baptiste Daroussin freebsd_committer freebsd_triage 2023-03-09 16:17:40 UTC
pkg has close to 0 relationship to pkg in github.
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-03-09 16:44:16 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=b2654064c2d11a1ee36667b3ff8b0f4d2536af74

commit b2654064c2d11a1ee36667b3ff8b0f4d2536af74
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2023-03-09 16:38:30 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2023-03-09 16:43:01 +0000

    pkg(7): use libmd for sha256 instead of openssl

    OpenSSL 3.0 has deprecated the sha256 api, let's use libmd which has the
    same API instead.

    In order to avoid the collision in definitions (sha256.h cannot be
    included in the same file as a file where openssl headers has been
    included) let's move the sha256 related code in its own file

    PR:             270023
    Reported by:    ngie

 usr.sbin/pkg/Makefile     |   4 +-
 usr.sbin/pkg/hash.c (new) | 112 ++++++++++++++++++++++++++++++++++++++++++++++
 usr.sbin/pkg/hash.h (new) |  32 +++++++++++++
 usr.sbin/pkg/pkg.c        |  78 +-------------------------------
 4 files changed, 147 insertions(+), 79 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-05-19 08:18:20 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=7bc2192380e10f3469ab4eda69ade324aae976cd

commit 7bc2192380e10f3469ab4eda69ade324aae976cd
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2023-03-09 16:38:30 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2023-05-19 08:16:51 +0000

    pkg(7): use libmd for sha256 instead of openssl

    OpenSSL 3.0 has deprecated the sha256 api, let's use libmd which has the
    same API instead.

    In order to avoid the collision in definitions (sha256.h cannot be
    included in the same file as a file where openssl headers has been
    included) let's move the sha256 related code in its own file

    PR:             270023
    Reported by:    ngie

    (cherry picked from commit b2654064c2d11a1ee36667b3ff8b0f4d2536af74)

 usr.sbin/pkg/Makefile     |   4 +-
 usr.sbin/pkg/hash.c (new) | 112 ++++++++++++++++++++++++++++++++++++++++++++++
 usr.sbin/pkg/hash.h (new) |  32 +++++++++++++
 usr.sbin/pkg/pkg.c        |  78 +-------------------------------
 4 files changed, 147 insertions(+), 79 deletions(-)