From dce7387ae2c7293204031c7698d2fca5995e3f84 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Fri, 30 Apr 2021 18:02:18 -0700 Subject: openbsd: Update to 6.9 --- pkg/openbsd/patch/0009-patch-Avoid-d_namlen.patch | 8 +- ...10-patch-Fix-with-musl-s-basename-dirname.patch | 46 -- ...ix-GNU-long-name-handling-with-short-read.patch | 176 +++++++ ...ix-GNU-long-name-handling-with-short-read.patch | 176 ------- ...11-pax-Support-xz-compression-with-J-flag.patch | 90 ++++ ...12-pax-Support-xz-compression-with-J-flag.patch | 90 ---- ...ogname-Explicitly-discard-const-qualifier.patch | 23 + ...ase-Support-systems-without-VSTATUS-and-T.patch | 38 ++ ...ogname-Explicitly-discard-const-qualifier.patch | 23 - .../patch/0014-Remove-getpass-definition.patch | 36 ++ ...ase-Support-systems-without-VSTATUS-and-T.patch | 38 -- .../patch/0015-Remove-getpass-definition.patch | 36 -- .../patch/0015-doas-Port-to-linux-musl.patch | 564 +++++++++++++++++++++ .../patch/0016-doas-Port-to-linux-musl.patch | 562 -------------------- ...0016-pwcache-Don-t-use-fixed-buffer-sizes.patch | 92 ++++ .../patch/0017-Add-standalone-freezero.patch | 51 ++ ...0017-pwcache-Don-t-use-fixed-buffer-sizes.patch | 92 ---- .../patch/0018-Add-standalone-freezero.patch | 51 -- ...-written-lexer-to-avoid-cycle-in-bootstra.patch | 327 ++++++++++++ .../0019-m4-Use-_Noreturn-instead-of-__dead.patch | 25 + ...-written-lexer-to-avoid-cycle-in-bootstra.patch | 327 ------------ .../patch/0020-m4-Add-missing-includes.patch | 50 ++ .../0020-m4-Use-_Noreturn-instead-of-__dead.patch | 25 - .../patch/0021-libutil-Add-missing-includes.patch | 24 + .../patch/0021-m4-Add-missing-includes.patch | 50 -- .../0022-acme-client-Add-missing-includes.patch | 25 + .../patch/0022-libutil-Add-missing-includes.patch | 24 - .../0023-acme-client-Add-missing-includes.patch | 25 - .../patch/0023-rsync-Add-missing-includes.patch | 40 ++ .../patch/0024-rsync-Add-missing-includes.patch | 40 -- ...c-Use-standard-S_ISVTX-instead-of-S_ISTXT.patch | 34 ++ ...25-rsync-Avoid-pointer-arithmetic-on-void.patch | 149 ++++++ ...c-Use-standard-S_ISVTX-instead-of-S_ISTXT.patch | 34 -- ...0026-Include-sys-sysmacros.h-if-necessary.patch | 73 +++ ...-Use-1-instead-of-INFTIM-for-poll-timeout.patch | 25 - ...-Portability-fixes-from-libressl-portable.patch | 194 +++++++ ...27-rsync-Avoid-pointer-arithmetic-on-void.patch | 148 ------ ...0028-Include-sys-sysmacros.h-if-necessary.patch | 73 --- .../0028-pax-Ignore-EOPNOTSUPP-from-fchmodat.patch | 26 + ...-client-Fix-build-with-old-bison-versions.patch | 24 + ...-Portability-fixes-from-libressl-portable.patch | 194 ------- .../0030-pax-Ignore-EOPNOTSUPP-from-fchmodat.patch | 26 - .../0030-rsync-Add-implementation-of-MD4.patch | 414 +++++++++++++++ ...-client-Fix-build-with-old-bison-versions.patch | 24 - ...-pax-Fix-some-incorrect-format-specifiers.patch | 48 ++ ...cpy-to-set-TMAGIC-and-TVERSION-to-avoid-w.patch | 27 + .../0032-rsync-Add-implementation-of-MD4.patch | 414 --------------- ...-pax-Fix-some-incorrect-format-specifiers.patch | 48 -- ...sync-Fix-some-incorrect-format-specifiers.patch | 25 + ...34-m4-Declare-dopaste-only-when-it-s-used.patch | 26 + ...cpy-to-set-TMAGIC-and-TVERSION-to-avoid-w.patch | 27 - ...sync-Fix-some-incorrect-format-specifiers.patch | 25 - ...36-m4-Declare-dopaste-only-when-it-s-used.patch | 26 - pkg/openbsd/sha256 | 4 +- pkg/openbsd/url | 4 +- pkg/openbsd/ver | 2 +- 56 files changed, 2610 insertions(+), 2678 deletions(-) delete mode 100644 pkg/openbsd/patch/0010-patch-Fix-with-musl-s-basename-dirname.patch create mode 100644 pkg/openbsd/patch/0010-pax-Fix-GNU-long-name-handling-with-short-read.patch delete mode 100644 pkg/openbsd/patch/0011-pax-Fix-GNU-long-name-handling-with-short-read.patch create mode 100644 pkg/openbsd/patch/0011-pax-Support-xz-compression-with-J-flag.patch delete mode 100644 pkg/openbsd/patch/0012-pax-Support-xz-compression-with-J-flag.patch create mode 100644 pkg/openbsd/patch/0012-setprogname-Explicitly-discard-const-qualifier.patch create mode 100644 pkg/openbsd/patch/0013-readpassphrase-Support-systems-without-VSTATUS-and-T.patch delete mode 100644 pkg/openbsd/patch/0013-setprogname-Explicitly-discard-const-qualifier.patch create mode 100644 pkg/openbsd/patch/0014-Remove-getpass-definition.patch delete mode 100644 pkg/openbsd/patch/0014-readpassphrase-Support-systems-without-VSTATUS-and-T.patch delete mode 100644 pkg/openbsd/patch/0015-Remove-getpass-definition.patch create mode 100644 pkg/openbsd/patch/0015-doas-Port-to-linux-musl.patch delete mode 100644 pkg/openbsd/patch/0016-doas-Port-to-linux-musl.patch create mode 100644 pkg/openbsd/patch/0016-pwcache-Don-t-use-fixed-buffer-sizes.patch create mode 100644 pkg/openbsd/patch/0017-Add-standalone-freezero.patch delete mode 100644 pkg/openbsd/patch/0017-pwcache-Don-t-use-fixed-buffer-sizes.patch delete mode 100644 pkg/openbsd/patch/0018-Add-standalone-freezero.patch create mode 100644 pkg/openbsd/patch/0018-m4-Use-hand-written-lexer-to-avoid-cycle-in-bootstra.patch create mode 100644 pkg/openbsd/patch/0019-m4-Use-_Noreturn-instead-of-__dead.patch delete mode 100644 pkg/openbsd/patch/0019-m4-Use-hand-written-lexer-to-avoid-cycle-in-bootstra.patch create mode 100644 pkg/openbsd/patch/0020-m4-Add-missing-includes.patch delete mode 100644 pkg/openbsd/patch/0020-m4-Use-_Noreturn-instead-of-__dead.patch create mode 100644 pkg/openbsd/patch/0021-libutil-Add-missing-includes.patch delete mode 100644 pkg/openbsd/patch/0021-m4-Add-missing-includes.patch create mode 100644 pkg/openbsd/patch/0022-acme-client-Add-missing-includes.patch delete mode 100644 pkg/openbsd/patch/0022-libutil-Add-missing-includes.patch delete mode 100644 pkg/openbsd/patch/0023-acme-client-Add-missing-includes.patch create mode 100644 pkg/openbsd/patch/0023-rsync-Add-missing-includes.patch delete mode 100644 pkg/openbsd/patch/0024-rsync-Add-missing-includes.patch create mode 100644 pkg/openbsd/patch/0024-rsync-Use-standard-S_ISVTX-instead-of-S_ISTXT.patch create mode 100644 pkg/openbsd/patch/0025-rsync-Avoid-pointer-arithmetic-on-void.patch delete mode 100644 pkg/openbsd/patch/0025-rsync-Use-standard-S_ISVTX-instead-of-S_ISTXT.patch create mode 100644 pkg/openbsd/patch/0026-Include-sys-sysmacros.h-if-necessary.patch delete mode 100644 pkg/openbsd/patch/0026-rsync-Use-1-instead-of-INFTIM-for-poll-timeout.patch create mode 100644 pkg/openbsd/patch/0027-nc-Portability-fixes-from-libressl-portable.patch delete mode 100644 pkg/openbsd/patch/0027-rsync-Avoid-pointer-arithmetic-on-void.patch delete mode 100644 pkg/openbsd/patch/0028-Include-sys-sysmacros.h-if-necessary.patch create mode 100644 pkg/openbsd/patch/0028-pax-Ignore-EOPNOTSUPP-from-fchmodat.patch create mode 100644 pkg/openbsd/patch/0029-acme-client-Fix-build-with-old-bison-versions.patch delete mode 100644 pkg/openbsd/patch/0029-nc-Portability-fixes-from-libressl-portable.patch delete mode 100644 pkg/openbsd/patch/0030-pax-Ignore-EOPNOTSUPP-from-fchmodat.patch create mode 100644 pkg/openbsd/patch/0030-rsync-Add-implementation-of-MD4.patch delete mode 100644 pkg/openbsd/patch/0031-acme-client-Fix-build-with-old-bison-versions.patch create mode 100644 pkg/openbsd/patch/0031-pax-Fix-some-incorrect-format-specifiers.patch create mode 100644 pkg/openbsd/patch/0032-pax-Use-memcpy-to-set-TMAGIC-and-TVERSION-to-avoid-w.patch delete mode 100644 pkg/openbsd/patch/0032-rsync-Add-implementation-of-MD4.patch delete mode 100644 pkg/openbsd/patch/0033-pax-Fix-some-incorrect-format-specifiers.patch create mode 100644 pkg/openbsd/patch/0033-rsync-Fix-some-incorrect-format-specifiers.patch create mode 100644 pkg/openbsd/patch/0034-m4-Declare-dopaste-only-when-it-s-used.patch delete mode 100644 pkg/openbsd/patch/0034-pax-Use-memcpy-to-set-TMAGIC-and-TVERSION-to-avoid-w.patch delete mode 100644 pkg/openbsd/patch/0035-rsync-Fix-some-incorrect-format-specifiers.patch delete mode 100644 pkg/openbsd/patch/0036-m4-Declare-dopaste-only-when-it-s-used.patch diff --git a/pkg/openbsd/patch/0009-patch-Avoid-d_namlen.patch b/pkg/openbsd/patch/0009-patch-Avoid-d_namlen.patch index 33d744a0..2c934216 100644 --- a/pkg/openbsd/patch/0009-patch-Avoid-d_namlen.patch +++ b/pkg/openbsd/patch/0009-patch-Avoid-d_namlen.patch @@ -1,4 +1,4 @@ -From 91483dfca3aa6373451120db45c60198faa0766e Mon Sep 17 00:00:00 2001 +From 602381b693ff286ed17a9a04bfceaeb255992843 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 4 Jun 2016 18:40:37 -0700 Subject: [PATCH] patch: Avoid d_namlen @@ -8,10 +8,10 @@ Subject: [PATCH] patch: Avoid d_namlen 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/patch/backupfile.c b/usr.bin/patch/backupfile.c -index d9e40bcba..1d7858ae3 100644 +index ed0767762e0..fc05e48e68d 100644 --- a/usr.bin/patch/backupfile.c +++ b/usr.bin/patch/backupfile.c -@@ -95,7 +95,7 @@ max_backup_version(const char *file, const char *dir) +@@ -106,7 +106,7 @@ max_backup_version(const char *file, const char *dir) file_name_length = strlen(file); while ((dp = readdir(dirp)) != NULL) { @@ -21,5 +21,5 @@ index d9e40bcba..1d7858ae3 100644 this_version = version_number(file, dp->d_name, file_name_length); -- -2.12.2 +2.31.1 diff --git a/pkg/openbsd/patch/0010-patch-Fix-with-musl-s-basename-dirname.patch b/pkg/openbsd/patch/0010-patch-Fix-with-musl-s-basename-dirname.patch deleted file mode 100644 index 80a1db3a..00000000 --- a/pkg/openbsd/patch/0010-patch-Fix-with-musl-s-basename-dirname.patch +++ /dev/null @@ -1,46 +0,0 @@ -From e16acc0e80f475b2139eabe1b07b7eb0521a7918 Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Sat, 4 Jun 2016 20:13:35 -0700 -Subject: [PATCH] patch: Fix with musl's basename/dirname - ---- - usr.bin/patch/backupfile.c | 15 ++++++++------- - 1 file changed, 8 insertions(+), 7 deletions(-) - -diff --git a/usr.bin/patch/backupfile.c b/usr.bin/patch/backupfile.c -index 1d7858ae3..243d00e32 100644 ---- a/usr.bin/patch/backupfile.c -+++ b/usr.bin/patch/backupfile.c -@@ -53,21 +53,22 @@ static void invalid_arg(const char *, const char *, int); - char * - find_backup_file_name(const char *file) - { -- char *dir, *base_versions; -+ char *path, *base_versions; - int highest_backup; - - if (backup_type == simple) - return concat(file, simple_backup_suffix); -- base_versions = concat(basename(file), ".~"); -- if (base_versions == NULL) -+ path = strdup(file); -+ if (path == NULL) - return NULL; -- dir = dirname(file); -- if (dir == NULL) { -- free(base_versions); -+ base_versions = concat(basename(path), ".~"); -+ if (base_versions == NULL) { -+ free(path); - return NULL; - } -- highest_backup = max_backup_version(base_versions, dir); -+ highest_backup = max_backup_version(base_versions, dirname(path)); - free(base_versions); -+ free(path); - if (backup_type == numbered_existing && highest_backup == 0) - return concat(file, simple_backup_suffix); - return make_version_name(file, highest_backup + 1); --- -2.12.2 - diff --git a/pkg/openbsd/patch/0010-pax-Fix-GNU-long-name-handling-with-short-read.patch b/pkg/openbsd/patch/0010-pax-Fix-GNU-long-name-handling-with-short-read.patch new file mode 100644 index 00000000..b88aa2b8 --- /dev/null +++ b/pkg/openbsd/patch/0010-pax-Fix-GNU-long-name-handling-with-short-read.patch @@ -0,0 +1,176 @@ +From ec3fd37495e977af375a98a472d19ae0ccbcd874 Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Sat, 3 Dec 2016 20:49:24 -0800 +Subject: [PATCH] pax: Fix GNU long name handling with short read + +--- + bin/pax/ar_subs.c | 66 +++++++++++++++++++++++++++++++++------------ + bin/pax/buf_subs.c | 4 +-- + bin/pax/file_subs.c | 25 +---------------- + 3 files changed, 51 insertions(+), 44 deletions(-) + +diff --git a/bin/pax/ar_subs.c b/bin/pax/ar_subs.c +index e5b0a4ee5d1..f0a55abe2f7 100644 +--- a/bin/pax/ar_subs.c ++++ b/bin/pax/ar_subs.c +@@ -37,6 +37,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -51,6 +52,7 @@ + static void wr_archive(ARCHD *, int is_app); + static int get_arc(void); + static int next_head(ARCHD *); ++static int rd_gnu_string(ARCHD *); + extern sigset_t s_mask; + + /* +@@ -93,16 +95,8 @@ list(void) + * step through the archive until the format says it is done + */ + while (next_head(arcn) == 0) { +- if (arcn->type == PAX_GLL || arcn->type == PAX_GLF) { +- /* +- * we need to read, to get the real filename +- */ +- off_t cnt; +- if (!rd_wrfile(arcn, arcn->type == PAX_GLF +- ? -1 : -2, &cnt)) +- (void)rd_skip(cnt + arcn->pad); ++ if (rd_gnu_string(arcn)) + continue; +- } + + /* + * check for pattern, and user specified options match. +@@ -208,15 +202,8 @@ extract(void) + * says it is done + */ + while (next_head(arcn) == 0) { +- if (arcn->type == PAX_GLL || arcn->type == PAX_GLF) { +- /* +- * we need to read, to get the real filename +- */ +- if (!rd_wrfile(arcn, arcn->type == PAX_GLF +- ? -1 : -2, &cnt)) +- (void)rd_skip(cnt + arcn->pad); ++ if (rd_gnu_string(arcn)) + continue; +- } + + /* + * check for pattern, and user specified options match. When +@@ -1243,3 +1230,48 @@ get_arc(void) + paxwarn(1, "Sorry, unable to determine archive format."); + return(-1); + } ++ ++/* ++ * rd_gnu_string() ++ * Read the file contents into an allocated string if it is a GNU tar ++ * long link/file. ++ * Return: ++ * 1 if gnu string read, 0 otherwise ++ */ ++ ++static int ++rd_gnu_string(ARCHD *arcn) ++{ ++ char **strp; ++ ++ switch (arcn->type) { ++ case PAX_GLF: ++ strp = &gnu_name_string; ++ break; ++ case PAX_GLL: ++ strp = &gnu_link_string; ++ break; ++ default: ++ strp = NULL; ++ break; ++ } ++ if (!strp) ++ return 0; ++ /* ++ * we need to read, to get the real filename ++ */ ++ if (*strp) ++ err(1, "WARNING! Major Internal Error! GNU hack Failing!"); ++ *strp = malloc(arcn->sb.st_size + 1); ++ if (*strp == NULL) { ++ paxwarn(1, "Out of memory"); ++ (void)rd_skip(arcn->skip + arcn->pad); ++ } else if (rd_wrbuf(*strp, arcn->sb.st_size) < arcn->sb.st_size) { ++ free(*strp); ++ *strp = NULL; ++ } else { ++ (*strp)[arcn->sb.st_size] = '\0'; ++ (void)rd_skip(arcn->pad); ++ } ++ return 1; ++} +diff --git a/bin/pax/buf_subs.c b/bin/pax/buf_subs.c +index 68534dcbe25..e84f9e0d3d6 100644 +--- a/bin/pax/buf_subs.c ++++ b/bin/pax/buf_subs.c +@@ -673,9 +673,7 @@ rd_wrfile(ARCHD *arcn, int ofd, off_t *left) + * pass the blocksize of the file being written to the write routine, + * if the size is zero, use the default MINFBSZ + */ +- if (ofd < 0) +- sz = PAXPATHLEN + 1; /* GNU tar long link/file */ +- else if (fstat(ofd, &sb) == 0) { ++ if (fstat(ofd, &sb) == 0) { + if (sb.st_blksize > 0) + sz = (int)sb.st_blksize; + } else +diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c +index 89b4872988b..8aa3d249923 100644 +--- a/bin/pax/file_subs.c ++++ b/bin/pax/file_subs.c +@@ -919,7 +919,6 @@ file_write(int fd, char *str, int cnt, int *rem, int *isempt, int sz, + char *end; + int wcnt; + char *st = str; +- char **strp; + + /* + * while we have data to process +@@ -978,29 +977,7 @@ file_write(int fd, char *str, int cnt, int *rem, int *isempt, int sz, + /* + * have non-zero data in this file system block, have to write + */ +- switch (fd) { +- case -1: +- strp = &gnu_name_string; +- break; +- case -2: +- strp = &gnu_link_string; +- break; +- default: +- strp = NULL; +- break; +- } +- if (strp) { +- if (*strp) +- err(1, "WARNING! Major Internal Error! GNU hack Failing!"); +- *strp = malloc(wcnt + 1); +- if (*strp == NULL) { +- paxwarn(1, "Out of memory"); +- return(-1); +- } +- memcpy(*strp, st, wcnt); +- (*strp)[wcnt] = '\0'; +- break; +- } else if (write(fd, st, wcnt) != wcnt) { ++ if (write(fd, st, wcnt) != wcnt) { + syswarn(1, errno, "Failed write to file %s", name); + return(-1); + } +-- +2.26.2 + diff --git a/pkg/openbsd/patch/0011-pax-Fix-GNU-long-name-handling-with-short-read.patch b/pkg/openbsd/patch/0011-pax-Fix-GNU-long-name-handling-with-short-read.patch deleted file mode 100644 index b88aa2b8..00000000 --- a/pkg/openbsd/patch/0011-pax-Fix-GNU-long-name-handling-with-short-read.patch +++ /dev/null @@ -1,176 +0,0 @@ -From ec3fd37495e977af375a98a472d19ae0ccbcd874 Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Sat, 3 Dec 2016 20:49:24 -0800 -Subject: [PATCH] pax: Fix GNU long name handling with short read - ---- - bin/pax/ar_subs.c | 66 +++++++++++++++++++++++++++++++++------------ - bin/pax/buf_subs.c | 4 +-- - bin/pax/file_subs.c | 25 +---------------- - 3 files changed, 51 insertions(+), 44 deletions(-) - -diff --git a/bin/pax/ar_subs.c b/bin/pax/ar_subs.c -index e5b0a4ee5d1..f0a55abe2f7 100644 ---- a/bin/pax/ar_subs.c -+++ b/bin/pax/ar_subs.c -@@ -37,6 +37,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -51,6 +52,7 @@ - static void wr_archive(ARCHD *, int is_app); - static int get_arc(void); - static int next_head(ARCHD *); -+static int rd_gnu_string(ARCHD *); - extern sigset_t s_mask; - - /* -@@ -93,16 +95,8 @@ list(void) - * step through the archive until the format says it is done - */ - while (next_head(arcn) == 0) { -- if (arcn->type == PAX_GLL || arcn->type == PAX_GLF) { -- /* -- * we need to read, to get the real filename -- */ -- off_t cnt; -- if (!rd_wrfile(arcn, arcn->type == PAX_GLF -- ? -1 : -2, &cnt)) -- (void)rd_skip(cnt + arcn->pad); -+ if (rd_gnu_string(arcn)) - continue; -- } - - /* - * check for pattern, and user specified options match. -@@ -208,15 +202,8 @@ extract(void) - * says it is done - */ - while (next_head(arcn) == 0) { -- if (arcn->type == PAX_GLL || arcn->type == PAX_GLF) { -- /* -- * we need to read, to get the real filename -- */ -- if (!rd_wrfile(arcn, arcn->type == PAX_GLF -- ? -1 : -2, &cnt)) -- (void)rd_skip(cnt + arcn->pad); -+ if (rd_gnu_string(arcn)) - continue; -- } - - /* - * check for pattern, and user specified options match. When -@@ -1243,3 +1230,48 @@ get_arc(void) - paxwarn(1, "Sorry, unable to determine archive format."); - return(-1); - } -+ -+/* -+ * rd_gnu_string() -+ * Read the file contents into an allocated string if it is a GNU tar -+ * long link/file. -+ * Return: -+ * 1 if gnu string read, 0 otherwise -+ */ -+ -+static int -+rd_gnu_string(ARCHD *arcn) -+{ -+ char **strp; -+ -+ switch (arcn->type) { -+ case PAX_GLF: -+ strp = &gnu_name_string; -+ break; -+ case PAX_GLL: -+ strp = &gnu_link_string; -+ break; -+ default: -+ strp = NULL; -+ break; -+ } -+ if (!strp) -+ return 0; -+ /* -+ * we need to read, to get the real filename -+ */ -+ if (*strp) -+ err(1, "WARNING! Major Internal Error! GNU hack Failing!"); -+ *strp = malloc(arcn->sb.st_size + 1); -+ if (*strp == NULL) { -+ paxwarn(1, "Out of memory"); -+ (void)rd_skip(arcn->skip + arcn->pad); -+ } else if (rd_wrbuf(*strp, arcn->sb.st_size) < arcn->sb.st_size) { -+ free(*strp); -+ *strp = NULL; -+ } else { -+ (*strp)[arcn->sb.st_size] = '\0'; -+ (void)rd_skip(arcn->pad); -+ } -+ return 1; -+} -diff --git a/bin/pax/buf_subs.c b/bin/pax/buf_subs.c -index 68534dcbe25..e84f9e0d3d6 100644 ---- a/bin/pax/buf_subs.c -+++ b/bin/pax/buf_subs.c -@@ -673,9 +673,7 @@ rd_wrfile(ARCHD *arcn, int ofd, off_t *left) - * pass the blocksize of the file being written to the write routine, - * if the size is zero, use the default MINFBSZ - */ -- if (ofd < 0) -- sz = PAXPATHLEN + 1; /* GNU tar long link/file */ -- else if (fstat(ofd, &sb) == 0) { -+ if (fstat(ofd, &sb) == 0) { - if (sb.st_blksize > 0) - sz = (int)sb.st_blksize; - } else -diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c -index 89b4872988b..8aa3d249923 100644 ---- a/bin/pax/file_subs.c -+++ b/bin/pax/file_subs.c -@@ -919,7 +919,6 @@ file_write(int fd, char *str, int cnt, int *rem, int *isempt, int sz, - char *end; - int wcnt; - char *st = str; -- char **strp; - - /* - * while we have data to process -@@ -978,29 +977,7 @@ file_write(int fd, char *str, int cnt, int *rem, int *isempt, int sz, - /* - * have non-zero data in this file system block, have to write - */ -- switch (fd) { -- case -1: -- strp = &gnu_name_string; -- break; -- case -2: -- strp = &gnu_link_string; -- break; -- default: -- strp = NULL; -- break; -- } -- if (strp) { -- if (*strp) -- err(1, "WARNING! Major Internal Error! GNU hack Failing!"); -- *strp = malloc(wcnt + 1); -- if (*strp == NULL) { -- paxwarn(1, "Out of memory"); -- return(-1); -- } -- memcpy(*strp, st, wcnt); -- (*strp)[wcnt] = '\0'; -- break; -- } else if (write(fd, st, wcnt) != wcnt) { -+ if (write(fd, st, wcnt) != wcnt) { - syswarn(1, errno, "Failed write to file %s", name); - return(-1); - } --- -2.26.2 - diff --git a/pkg/openbsd/patch/0011-pax-Support-xz-compression-with-J-flag.patch b/pkg/openbsd/patch/0011-pax-Support-xz-compression-with-J-flag.patch new file mode 100644 index 00000000..00f8a8b9 --- /dev/null +++ b/pkg/openbsd/patch/0011-pax-Support-xz-compression-with-J-flag.patch @@ -0,0 +1,90 @@ +From ac4a17dd01df3889bac917b0dc34ba9fd15aa7fe Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Sat, 3 Dec 2016 23:50:27 -0800 +Subject: [PATCH] pax: Support xz compression with -J flag + +--- + bin/pax/options.c | 25 ++++++++++++++++++++++--- + 1 file changed, 22 insertions(+), 3 deletions(-) + +diff --git a/bin/pax/options.c b/bin/pax/options.c +index c7e64a5d22c..917414c999a 100644 +--- a/bin/pax/options.c ++++ b/bin/pax/options.c +@@ -154,6 +154,7 @@ static int xz_id(char *_blk, int _size); + #define GZIP_CMD "gzip" /* command to run as gzip */ + #define COMPRESS_CMD "compress" /* command to run as compress */ + #define BZIP2_CMD "bzip2" /* command to run as bzip2 */ ++#define XZ_CMD "xz" /* command to run as xz */ + + /* + * Format specific routine table +@@ -300,7 +301,7 @@ pax_options(int argc, char **argv) + /* + * process option flags + */ +- while ((c=getopt(argc,argv,"ab:cdf:ijklno:p:rs:tuvwx:zB:DE:G:HLOPT:U:XYZ0")) ++ while ((c=getopt(argc,argv,"ab:cdf:ijklno:p:rs:tuvwx:zB:DE:G:HJLOPT:U:XYZ0")) + != -1) { + switch (c) { + case 'a': +@@ -556,6 +557,12 @@ pax_options(int argc, char **argv) + Hflag = 1; + flg |= CHF; + break; ++ case 'J': ++ /* ++ * use xz. Non standard option. ++ */ ++ gzip_program = XZ_CMD; ++ break; + case 'L': + /* + * follow symlinks +@@ -731,7 +738,7 @@ tar_options(int argc, char **argv) + * process option flags + */ + while ((c = getoldopt(argc, argv, +- "b:cef:hjmopqruts:vwxzBC:HI:LNOPXZ014578")) != -1) { ++ "b:cef:hjmopqruts:vwxzBC:HI:JLNOPXZ014578")) != -1) { + switch (c) { + case 'b': + /* +@@ -880,6 +887,12 @@ tar_options(int argc, char **argv) + incfiles[nincfiles - 1].file = optarg; + incfiles[nincfiles - 1].dir = chdname; + break; ++ case 'J': ++ /* ++ * use xz. Non standard option. ++ */ ++ gzip_program = XZ_CMD; ++ break; + case 'L': + /* + * follow symlinks +@@ -1164,7 +1177,7 @@ cpio_options(int argc, char **argv) + dflag = 1; + act = -1; + nodirs = 1; +- while ((c=getopt(argc,argv,"abcdfijklmoprstuvzABC:E:F:H:I:LO:SZ6")) != -1) ++ while ((c=getopt(argc,argv,"abcdfijklmoprstuvzABC:E:F:H:I:JLO:SZ6")) != -1) + switch (c) { + case 'a': + /* +@@ -1348,6 +1361,12 @@ cpio_options(int argc, char **argv) + (void)fputs("\n\n", stderr); + cpio_usage(); + break; ++ case 'J': ++ /* ++ * use xz. Non standard option. ++ */ ++ gzip_program = XZ_CMD; ++ break; + case 'L': + /* + * follow symbolic links +-- +2.26.2 + diff --git a/pkg/openbsd/patch/0012-pax-Support-xz-compression-with-J-flag.patch b/pkg/openbsd/patch/0012-pax-Support-xz-compression-with-J-flag.patch deleted file mode 100644 index 00f8a8b9..00000000 --- a/pkg/openbsd/patch/0012-pax-Support-xz-compression-with-J-flag.patch +++ /dev/null @@ -1,90 +0,0 @@ -From ac4a17dd01df3889bac917b0dc34ba9fd15aa7fe Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Sat, 3 Dec 2016 23:50:27 -0800 -Subject: [PATCH] pax: Support xz compression with -J flag - ---- - bin/pax/options.c | 25 ++++++++++++++++++++++--- - 1 file changed, 22 insertions(+), 3 deletions(-) - -diff --git a/bin/pax/options.c b/bin/pax/options.c -index c7e64a5d22c..917414c999a 100644 ---- a/bin/pax/options.c -+++ b/bin/pax/options.c -@@ -154,6 +154,7 @@ static int xz_id(char *_blk, int _size); - #define GZIP_CMD "gzip" /* command to run as gzip */ - #define COMPRESS_CMD "compress" /* command to run as compress */ - #define BZIP2_CMD "bzip2" /* command to run as bzip2 */ -+#define XZ_CMD "xz" /* command to run as xz */ - - /* - * Format specific routine table -@@ -300,7 +301,7 @@ pax_options(int argc, char **argv) - /* - * process option flags - */ -- while ((c=getopt(argc,argv,"ab:cdf:ijklno:p:rs:tuvwx:zB:DE:G:HLOPT:U:XYZ0")) -+ while ((c=getopt(argc,argv,"ab:cdf:ijklno:p:rs:tuvwx:zB:DE:G:HJLOPT:U:XYZ0")) - != -1) { - switch (c) { - case 'a': -@@ -556,6 +557,12 @@ pax_options(int argc, char **argv) - Hflag = 1; - flg |= CHF; - break; -+ case 'J': -+ /* -+ * use xz. Non standard option. -+ */ -+ gzip_program = XZ_CMD; -+ break; - case 'L': - /* - * follow symlinks -@@ -731,7 +738,7 @@ tar_options(int argc, char **argv) - * process option flags - */ - while ((c = getoldopt(argc, argv, -- "b:cef:hjmopqruts:vwxzBC:HI:LNOPXZ014578")) != -1) { -+ "b:cef:hjmopqruts:vwxzBC:HI:JLNOPXZ014578")) != -1) { - switch (c) { - case 'b': - /* -@@ -880,6 +887,12 @@ tar_options(int argc, char **argv) - incfiles[nincfiles - 1].file = optarg; - incfiles[nincfiles - 1].dir = chdname; - break; -+ case 'J': -+ /* -+ * use xz. Non standard option. -+ */ -+ gzip_program = XZ_CMD; -+ break; - case 'L': - /* - * follow symlinks -@@ -1164,7 +1177,7 @@ cpio_options(int argc, char **argv) - dflag = 1; - act = -1; - nodirs = 1; -- while ((c=getopt(argc,argv,"abcdfijklmoprstuvzABC:E:F:H:I:LO:SZ6")) != -1) -+ while ((c=getopt(argc,argv,"abcdfijklmoprstuvzABC:E:F:H:I:JLO:SZ6")) != -1) - switch (c) { - case 'a': - /* -@@ -1348,6 +1361,12 @@ cpio_options(int argc, char **argv) - (void)fputs("\n\n", stderr); - cpio_usage(); - break; -+ case 'J': -+ /* -+ * use xz. Non standard option. -+ */ -+ gzip_program = XZ_CMD; -+ break; - case 'L': - /* - * follow symbolic links --- -2.26.2 - diff --git a/pkg/openbsd/patch/0012-setprogname-Explicitly-discard-const-qualifier.patch b/pkg/openbsd/patch/0012-setprogname-Explicitly-discard-const-qualifier.patch new file mode 100644 index 00000000..a645a9e4 --- /dev/null +++ b/pkg/openbsd/patch/0012-setprogname-Explicitly-discard-const-qualifier.patch @@ -0,0 +1,23 @@ +From 7cc3b8b8b1ca390b6ed65d3234827bc7393f9300 Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Sun, 11 Dec 2016 14:36:13 -0800 +Subject: [PATCH] setprogname: Explicitly discard const qualifier + +--- + lib/libc/gen/setprogname.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/libc/gen/setprogname.c b/lib/libc/gen/setprogname.c +index bce4cbdac44..0c1573c9162 100644 +--- a/lib/libc/gen/setprogname.c ++++ b/lib/libc/gen/setprogname.c +@@ -27,5 +27,5 @@ setprogname(const char *progname) + if (tmpn == NULL) + __progname = (char *)progname; + else +- __progname = tmpn + 1; ++ __progname = (char *)tmpn + 1; + } +-- +2.14.2 + diff --git a/pkg/openbsd/patch/0013-readpassphrase-Support-systems-without-VSTATUS-and-T.patch b/pkg/openbsd/patch/0013-readpassphrase-Support-systems-without-VSTATUS-and-T.patch new file mode 100644 index 00000000..78660907 --- /dev/null +++ b/pkg/openbsd/patch/0013-readpassphrase-Support-systems-without-VSTATUS-and-T.patch @@ -0,0 +1,38 @@ +From d36036bbd959091b6442d003128342ed515af01b Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Sun, 26 Feb 2017 17:01:33 -0800 +Subject: [PATCH] readpassphrase: Support systems without VSTATUS and TCSASOFT + +--- + lib/libc/gen/readpassphrase.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/lib/libc/gen/readpassphrase.c b/lib/libc/gen/readpassphrase.c +index a1aeb342b..a50eaf003 100644 +--- a/lib/libc/gen/readpassphrase.c ++++ b/lib/libc/gen/readpassphrase.c +@@ -32,6 +32,10 @@ + #include + #include + ++#ifndef TCSASOFT ++#define TCSASOFT 0 ++#endif ++ + static volatile sig_atomic_t signo[_NSIG]; + + static void handler(int); +@@ -81,8 +85,10 @@ restart: + memcpy(&term, &oterm, sizeof(term)); + if (!(flags & RPP_ECHO_ON)) + term.c_lflag &= ~(ECHO | ECHONL); ++#ifdef VSTATUS + if (term.c_cc[VSTATUS] != _POSIX_VDISABLE) + term.c_cc[VSTATUS] = _POSIX_VDISABLE; ++#endif + (void)tcsetattr(input, TCSAFLUSH|TCSASOFT, &term); + } else { + memset(&term, 0, sizeof(term)); +-- +2.12.2 + diff --git a/pkg/openbsd/patch/0013-setprogname-Explicitly-discard-const-qualifier.patch b/pkg/openbsd/patch/0013-setprogname-Explicitly-discard-const-qualifier.patch deleted file mode 100644 index a645a9e4..00000000 --- a/pkg/openbsd/patch/0013-setprogname-Explicitly-discard-const-qualifier.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 7cc3b8b8b1ca390b6ed65d3234827bc7393f9300 Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Sun, 11 Dec 2016 14:36:13 -0800 -Subject: [PATCH] setprogname: Explicitly discard const qualifier - ---- - lib/libc/gen/setprogname.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/libc/gen/setprogname.c b/lib/libc/gen/setprogname.c -index bce4cbdac44..0c1573c9162 100644 ---- a/lib/libc/gen/setprogname.c -+++ b/lib/libc/gen/setprogname.c -@@ -27,5 +27,5 @@ setprogname(const char *progname) - if (tmpn == NULL) - __progname = (char *)progname; - else -- __progname = tmpn + 1; -+ __progname = (char *)tmpn + 1; - } --- -2.14.2 - diff --git a/pkg/openbsd/patch/0014-Remove-getpass-definition.patch b/pkg/openbsd/patch/0014-Remove-getpass-definition.patch new file mode 100644 index 00000000..f2adafda --- /dev/null +++ b/pkg/openbsd/patch/0014-Remove-getpass-definition.patch @@ -0,0 +1,36 @@ +From e76fda424564544bc8298fb5be7cda966451497d Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Sun, 26 Feb 2017 17:12:56 -0800 +Subject: [PATCH] Remove getpass definition + +It is a legacy function and musl already provides an implementation. +--- + lib/libc/gen/readpassphrase.c | 12 ++---------- + 1 file changed, 2 insertions(+), 10 deletions(-) + +diff --git a/lib/libc/gen/readpassphrase.c b/lib/libc/gen/readpassphrase.c +index a50eaf003..57c6dc527 100644 +--- a/lib/libc/gen/readpassphrase.c ++++ b/lib/libc/gen/readpassphrase.c +@@ -183,16 +183,8 @@ restart: + } + DEF_WEAK(readpassphrase); + +-char * +-getpass(const char *prompt) +-{ +- static char buf[_PASSWORD_LEN + 1]; +- +- return(readpassphrase(prompt, buf, sizeof(buf), RPP_ECHO_OFF)); +-} +- +-static void handler(int s) ++static void ++handler(int s) + { +- + signo[s] = 1; + } +-- +2.12.2 + diff --git a/pkg/openbsd/patch/0014-readpassphrase-Support-systems-without-VSTATUS-and-T.patch b/pkg/openbsd/patch/0014-readpassphrase-Support-systems-without-VSTATUS-and-T.patch deleted file mode 100644 index 78660907..00000000 --- a/pkg/openbsd/patch/0014-readpassphrase-Support-systems-without-VSTATUS-and-T.patch +++ /dev/null @@ -1,38 +0,0 @@ -From d36036bbd959091b6442d003128342ed515af01b Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Sun, 26 Feb 2017 17:01:33 -0800 -Subject: [PATCH] readpassphrase: Support systems without VSTATUS and TCSASOFT - ---- - lib/libc/gen/readpassphrase.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/lib/libc/gen/readpassphrase.c b/lib/libc/gen/readpassphrase.c -index a1aeb342b..a50eaf003 100644 ---- a/lib/libc/gen/readpassphrase.c -+++ b/lib/libc/gen/readpassphrase.c -@@ -32,6 +32,10 @@ - #include - #include - -+#ifndef TCSASOFT -+#define TCSASOFT 0 -+#endif -+ - static volatile sig_atomic_t signo[_NSIG]; - - static void handler(int); -@@ -81,8 +85,10 @@ restart: - memcpy(&term, &oterm, sizeof(term)); - if (!(flags & RPP_ECHO_ON)) - term.c_lflag &= ~(ECHO | ECHONL); -+#ifdef VSTATUS - if (term.c_cc[VSTATUS] != _POSIX_VDISABLE) - term.c_cc[VSTATUS] = _POSIX_VDISABLE; -+#endif - (void)tcsetattr(input, TCSAFLUSH|TCSASOFT, &term); - } else { - memset(&term, 0, sizeof(term)); --- -2.12.2 - diff --git a/pkg/openbsd/patch/0015-Remove-getpass-definition.patch b/pkg/openbsd/patch/0015-Remove-getpass-definition.patch deleted file mode 100644 index f2adafda..00000000 --- a/pkg/openbsd/patch/0015-Remove-getpass-definition.patch +++ /dev/null @@ -1,36 +0,0 @@ -From e76fda424564544bc8298fb5be7cda966451497d Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Sun, 26 Feb 2017 17:12:56 -0800 -Subject: [PATCH] Remove getpass definition - -It is a legacy function and musl already provides an implementation. ---- - lib/libc/gen/readpassphrase.c | 12 ++---------- - 1 file changed, 2 insertions(+), 10 deletions(-) - -diff --git a/lib/libc/gen/readpassphrase.c b/lib/libc/gen/readpassphrase.c -index a50eaf003..57c6dc527 100644 ---- a/lib/libc/gen/readpassphrase.c -+++ b/lib/libc/gen/readpassphrase.c -@@ -183,16 +183,8 @@ restart: - } - DEF_WEAK(readpassphrase); - --char * --getpass(const char *prompt) --{ -- static char buf[_PASSWORD_LEN + 1]; -- -- return(readpassphrase(prompt, buf, sizeof(buf), RPP_ECHO_OFF)); --} -- --static void handler(int s) -+static void -+handler(int s) - { -- - signo[s] = 1; - } --- -2.12.2 - diff --git a/pkg/openbsd/patch/0015-doas-Port-to-linux-musl.patch b/pkg/openbsd/patch/0015-doas-Port-to-linux-musl.patch new file mode 100644 index 00000000..4e2b0a68 --- /dev/null +++ b/pkg/openbsd/patch/0015-doas-Port-to-linux-musl.patch @@ -0,0 +1,564 @@ +From 3eac1566f49c5edb13c41009b571b1b391f5f841 Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Sun, 26 Feb 2017 16:50:55 -0800 +Subject: [PATCH] doas: Port to linux/musl + +Remove -a login style option and BSD authentication. Instead, compare +against shadow file. + +Use timestamp files in /run/doas instead of TIOC*VERAUTH to implement +persist. + +Use initgroups/setgid/setuid instead of setusercontext. + +Provide UID_MAX and GID_MAX defaults. + +Use LOGIN_NAME_MAX instead of _PW_NAME_LEN. + +Remove call to closefrom. + +Replace calls to errc with err after setting errno. + +Call openlog at start to set syslog identity. + +Remove unveil/pledge since they aren't supported on Linux. + +Simplify handling of PATH in the environment since we don't have +login.conf with per-user default PATH. +--- + usr.bin/doas/doas.1 | 9 --- + usr.bin/doas/doas.c | 159 ++++++++++++++--------------------------- + usr.bin/doas/doas.h | 6 +- + usr.bin/doas/env.c | 17 ++--- + usr.bin/doas/parse.y | 1 + + usr.bin/doas/persist.c | 133 ++++++++++++++++++++++++++++++++++ + 6 files changed, 196 insertions(+), 129 deletions(-) + create mode 100644 usr.bin/doas/persist.c + +diff --git a/usr.bin/doas/doas.1 b/usr.bin/doas/doas.1 +index 4d2e09777c8..a91705e8e3f 100644 +--- a/usr.bin/doas/doas.1 ++++ b/usr.bin/doas/doas.1 +@@ -22,7 +22,6 @@ + .Sh SYNOPSIS + .Nm doas + .Op Fl Lns +-.Op Fl a Ar style + .Op Fl C Ar config + .Op Fl u Ar user + .Ar command +@@ -67,14 +66,6 @@ The working directory is not changed. + .Pp + The options are as follows: + .Bl -tag -width tenletters +-.It Fl a Ar style +-Use the specified authentication style when validating the user, +-as allowed by +-.Pa /etc/login.conf . +-A list of doas-specific authentication methods may be configured by adding an +-.Sq auth-doas +-entry in +-.Xr login.conf 5 . + .It Fl C Ar config + Parse and check the configuration file + .Ar config , +diff --git a/usr.bin/doas/doas.c b/usr.bin/doas/doas.c +index be05be3a968..46b0ceb136b 100644 +--- a/usr.bin/doas/doas.c ++++ b/usr.bin/doas/doas.c +@@ -20,8 +20,6 @@ + #include + + #include +-#include +-#include + #include + #include + #include +@@ -33,13 +31,22 @@ + #include + #include + #include ++#include + + #include "doas.h" + ++#ifndef UID_MAX ++#define UID_MAX 65535 ++#endif ++ ++#ifndef GID_MAX ++#define GID_MAX 65535 ++#endif ++ + static void __dead + usage(void) + { +- fprintf(stderr, "usage: doas [-Lns] [-a style] [-C config] [-u user]" ++ fprintf(stderr, "usage: doas [-Lns] [-C config] [-u user]" + " command [args]\n"); + exit(1); + } +@@ -199,23 +206,36 @@ checkconfig(const char *confpath, int argc, char **argv, + } + } + ++static int ++verifypasswd(const char *user, const char *pass) ++{ ++ struct spwd *sp; ++ char *p1, *p2; ++ ++ sp = getspnam(user); ++ if (!sp) ++ return 0; ++ p1 = sp->sp_pwdp; ++ if (p1[0] == '!' || p1[0] == '*') ++ return 0; ++ p2 = crypt(pass, p1); ++ if (!p2) ++ return 0; ++ return strcmp(p1, p2) == 0; ++} ++ + static void +-authuser(char *myname, char *login_style, int persist) ++authuser(char *myname, int persist) + { + char *challenge = NULL, *response, rbuf[1024], cbuf[128]; +- auth_session_t *as; +- int fd = -1; ++ int fd = -1, valid = 0; + +- if (persist) +- fd = open("/dev/tty", O_RDWR); +- if (fd != -1) { +- if (ioctl(fd, TIOCCHKVERAUTH) == 0) ++ if (persist) { ++ fd = openpersist(&valid); ++ if (valid) + goto good; + } + +- if (!(as = auth_userchallenge(myname, login_style, "auth-doas", +- &challenge))) +- errx(1, "Authentication failed"); + if (!challenge) { + char host[HOST_NAME_MAX + 1]; + if (gethostname(host, sizeof(host))) +@@ -227,75 +247,31 @@ authuser(char *myname, char *login_style, int persist) + response = readpassphrase(challenge, rbuf, sizeof(rbuf), + RPP_REQUIRE_TTY); + if (response == NULL && errno == ENOTTY) { +- syslog(LOG_AUTHPRIV | LOG_NOTICE, +- "tty required for %s", myname); ++ syslog(LOG_NOTICE, "tty required for %s", myname); + errx(1, "a tty is required"); + } +- if (!auth_userresponse(as, response, 0)) { ++ if (!verifypasswd(myname, response)) { + explicit_bzero(rbuf, sizeof(rbuf)); +- syslog(LOG_AUTHPRIV | LOG_NOTICE, +- "failed auth for %s", myname); ++ syslog(LOG_NOTICE, "failed auth for %s", myname); + errx(1, "Authentication failed"); + } + explicit_bzero(rbuf, sizeof(rbuf)); + good: + if (fd != -1) { +- int secs = 5 * 60; +- ioctl(fd, TIOCSETVERAUTH, &secs); ++ setpersist(fd); + close(fd); + } + } + +-int +-unveilcommands(const char *ipath, const char *cmd) +-{ +- char *path = NULL, *p; +- int unveils = 0; +- +- if (strchr(cmd, '/') != NULL) { +- if (unveil(cmd, "x") != -1) +- unveils++; +- goto done; +- } +- +- if (!ipath) { +- errno = ENOENT; +- goto done; +- } +- path = strdup(ipath); +- if (!path) { +- errno = ENOENT; +- goto done; +- } +- for (p = path; p && *p; ) { +- char buf[PATH_MAX]; +- char *cp = strsep(&p, ":"); +- +- if (cp) { +- int r = snprintf(buf, sizeof buf, "%s/%s", cp, cmd); +- if (r >= 0 && r < sizeof buf) { +- if (unveil(buf, "x") != -1) +- unveils++; +- } +- } +- } +-done: +- free(path); +- return (unveils); +-} +- + int + main(int argc, char **argv) + { +- const char *safepath = "/bin:/sbin:/usr/bin:/usr/sbin:" +- "/usr/local/bin:/usr/local/sbin"; + const char *confpath = NULL; + char *shargv[] = { NULL, NULL }; + char *sh; +- const char *p; + const char *cmd; + char cmdline[LINE_MAX]; +- char mypwbuf[_PW_BUF_LEN], targpwbuf[_PW_BUF_LEN]; ++ char mypwbuf[1024], targpwbuf[1024]; + struct passwd mypwstore, targpwstore; + struct passwd *mypw, *targpw; + const struct rule *rule; +@@ -308,28 +284,20 @@ main(int argc, char **argv) + int nflag = 0; + char cwdpath[PATH_MAX]; + const char *cwd; +- char *login_style = NULL; + char **envp; + + setprogname("doas"); +- +- closefrom(STDERR_FILENO + 1); ++ openlog("doas", 0, LOG_AUTHPRIV); + + uid = getuid(); + +- while ((ch = getopt(argc, argv, "a:C:Lnsu:")) != -1) { ++ while ((ch = getopt(argc, argv, "C:Lnsu:")) != -1) { + switch (ch) { +- case 'a': +- login_style = optarg; +- break; + case 'C': + confpath = optarg; + break; + case 'L': +- i = open("/dev/tty", O_RDWR); +- if (i != -1) +- ioctl(i, TIOCCLRVERAUTH); +- exit(i == -1); ++ exit(clearpersist() != 0); + case 'u': + if (parseuid(optarg, &target) != 0) + errx(1, "unknown user"); +@@ -399,47 +367,30 @@ main(int argc, char **argv) + cmd = argv[0]; + if (!permit(uid, groups, ngroups, &rule, target, cmd, + (const char **)argv + 1)) { +- syslog(LOG_AUTHPRIV | LOG_NOTICE, +- "command not permitted for %s: %s", mypw->pw_name, cmdline); +- errc(1, EPERM, NULL); ++ syslog(LOG_NOTICE, "command not permitted for %s: %s", mypw->pw_name, cmdline); ++ errno = EPERM; ++ err(1, NULL); + } + + if (!(rule->options & NOPASS)) { + if (nflag) + errx(1, "Authentication required"); + +- authuser(mypw->pw_name, login_style, rule->options & PERSIST); ++ authuser(mypw->pw_name, rule->options & PERSIST); + } + +- if ((p = getenv("PATH")) != NULL) +- formerpath = strdup(p); +- if (formerpath == NULL) +- formerpath = ""; +- +- if (unveil(_PATH_LOGIN_CONF, "r") == -1 || +- unveil(_PATH_LOGIN_CONF ".db", "r") == -1) +- err(1, "unveil"); +- if (rule->cmd) { +- if (setenv("PATH", safepath, 1) == -1) +- err(1, "failed to set PATH '%s'", safepath); +- } +- if (unveilcommands(getenv("PATH"), cmd) == 0) +- goto fail; +- +- if (pledge("stdio rpath getpw exec id", NULL) == -1) +- err(1, "pledge"); +- + rv = getpwuid_r(target, &targpwstore, targpwbuf, sizeof(targpwbuf), &targpw); + if (rv != 0) + err(1, "getpwuid_r failed"); + if (targpw == NULL) + errx(1, "no passwd entry for target"); + +- if (setusercontext(NULL, targpw, target, LOGIN_SETGROUP | +- LOGIN_SETPATH | +- LOGIN_SETPRIORITY | LOGIN_SETRESOURCES | LOGIN_SETUMASK | +- LOGIN_SETUSER) != 0) +- errx(1, "failed to set user context for target"); ++ if (initgroups(targpw->pw_name, targpw->pw_gid) == -1) ++ err(1, "initgroups"); ++ if (setgid(targpw->pw_gid) == -1) ++ err(1, "setgid"); ++ if (setuid(targpw->pw_uid) == -1) ++ err(1, "setuid"); + + if (pledge("stdio rpath exec", NULL) == -1) + err(1, "pledge"); +@@ -453,23 +404,17 @@ main(int argc, char **argv) + err(1, "pledge"); + + if (!(rule->options & NOLOG)) { +- syslog(LOG_AUTHPRIV | LOG_INFO, +- "%s ran command %s as %s from %s", ++ syslog(LOG_INFO, "%s ran command %s as %s from %s", + mypw->pw_name, cmdline, targpw->pw_name, cwd); + } + + envp = prepenv(rule, mypw, targpw); + +- /* setusercontext set path for the next process, so reset it for us */ + if (rule->cmd) { + if (setenv("PATH", safepath, 1) == -1) + err(1, "failed to set PATH '%s'", safepath); +- } else { +- if (setenv("PATH", formerpath, 1) == -1) +- err(1, "failed to set PATH '%s'", formerpath); + } + execvpe(cmd, argv, envp); +-fail: + if (errno == ENOENT) + errx(1, "%s: command not found", cmd); + err(1, "%s", cmd); +diff --git a/usr.bin/doas/doas.h b/usr.bin/doas/doas.h +index 0b3585822eb..63254dabfca 100644 +--- a/usr.bin/doas/doas.h ++++ b/usr.bin/doas/doas.h +@@ -29,13 +29,17 @@ extern struct rule **rules; + extern size_t nrules; + extern int parse_errors; + +-extern const char *formerpath; ++extern const char *safepath; + + struct passwd; + + char **prepenv(const struct rule *, const struct passwd *, + const struct passwd *); + ++int openpersist(int *valid); ++int setpersist(int fd); ++int clearpersist(void); ++ + #define PERMIT 1 + #define DENY 2 + +diff --git a/usr.bin/doas/env.c b/usr.bin/doas/env.c +index 2d93a4089b6..dc9be691955 100644 +--- a/usr.bin/doas/env.c ++++ b/usr.bin/doas/env.c +@@ -28,7 +28,7 @@ + + #include "doas.h" + +-const char *formerpath; ++const char *safepath = "/bin"; + + struct envnode { + RB_ENTRY(envnode) node; +@@ -103,7 +103,7 @@ createenv(const struct rule *rule, const struct passwd *mypw, + addnode(env, "DOAS_USER", mypw->pw_name); + addnode(env, "HOME", targpw->pw_dir); + addnode(env, "LOGNAME", targpw->pw_name); +- addnode(env, "PATH", getenv("PATH")); ++ addnode(env, "PATH", safepath); + addnode(env, "SHELL", targpw->pw_shell); + addnode(env, "USER", targpw->pw_name); + +@@ -200,17 +200,10 @@ fillenv(struct env *env, const char **envlist) + /* assign value or inherit from environ */ + if (eq) { + val = eq + 1; +- if (*val == '$') { +- if (strcmp(val + 1, "PATH") == 0) +- val = formerpath; +- else +- val = getenv(val + 1); +- } ++ if (*val == '$') ++ val = getenv(val + 1); + } else { +- if (strcmp(name, "PATH") == 0) +- val = formerpath; +- else +- val = getenv(name); ++ val = getenv(name); + } + /* at last, we have something to insert */ + if (val) { +diff --git a/usr.bin/doas/parse.y b/usr.bin/doas/parse.y +index eaaf8c4b2e6..587fd2c93a8 100644 +--- a/usr.bin/doas/parse.y ++++ b/usr.bin/doas/parse.y +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + #include + #include +diff --git a/usr.bin/doas/persist.c b/usr.bin/doas/persist.c +new file mode 100644 +index 00000000000..4ad1bf1efbf +--- /dev/null ++++ b/usr.bin/doas/persist.c +@@ -0,0 +1,133 @@ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "doas.h" ++ ++#define PERSIST_DIR "/run/doas" ++#define PERSIST_TIMEOUT 5 * 60 ++ ++static int ++ttyid(dev_t *tty) ++{ ++ int fd, i; ++ char buf[BUFSIZ], *p; ++ ssize_t n; ++ ++ fd = open("/proc/self/stat", O_RDONLY); ++ if (fd == -1) ++ return -1; ++ n = read(fd, buf, sizeof(buf) - 1); ++ if (n >= 0) ++ buf[n] = '\0'; ++ /* check that we read the whole file */ ++ n = read(fd, buf, 1); ++ close(fd); ++ if (n != 0) ++ return -1; ++ p = strrchr(buf, ')'); ++ if (!p) ++ return -1; ++ ++p; ++ /* ttr_nr is the 5th field after executable name, so skip the next 4 */ ++ for (i = 0; i < 4; ++i) { ++ p = strchr(++p, ' '); ++ if (!p) ++ return -1; ++ } ++ *tty = strtol(p, &p, 10); ++ if (*p != ' ') ++ return -1; ++ return 0; ++} ++ ++static int ++persistpath(char *buf, size_t len) ++{ ++ dev_t tty; ++ int n; ++ ++ if (ttyid(&tty) < 0) ++ return -1; ++ n = snprintf(buf, len, PERSIST_DIR "/%ju-%ju", (uintmax_t)getuid(), (uintmax_t)tty); ++ if (n < 0 || n >= (int)len) ++ return -1; ++ return 0; ++} ++ ++int ++openpersist(int *valid) ++{ ++ char path[256]; ++ struct stat st; ++ struct timespec ts; ++ int fd; ++ ++ if (stat(PERSIST_DIR, &st) < 0) { ++ if (errno != ENOENT) ++ return -1; ++ if (mkdir(PERSIST_DIR, 0700) < 0) ++ return -1; ++ } else if (st.st_uid != 0 || st.st_mode != (S_IFDIR | 0700)) { ++ return -1; ++ } ++ if (persistpath(path, sizeof(path)) < 0) ++ return -1; ++ fd = open(path, O_RDONLY); ++ if (fd == -1) { ++ char tmp[256]; ++ struct timespec ts[2] = { { .tv_nsec = UTIME_OMIT }, { 0 } }; ++ int n; ++ ++ n = snprintf(tmp, sizeof(tmp), PERSIST_DIR "/.tmp-%d", getpid()); ++ if (n < 0 || n >= (int)sizeof(tmp)) ++ return -1; ++ fd = open(tmp, O_RDONLY | O_CREAT | O_EXCL, 0); ++ if (fd == -1) ++ return -1; ++ if (futimens(fd, ts) < 0 || rename(tmp, path) < 0) { ++ close(fd); ++ unlink(tmp); ++ return -1; ++ } ++ *valid = 0; ++ } else { ++ *valid = clock_gettime(CLOCK_BOOTTIME, &ts) == 0 && ++ fstat(fd, &st) == 0 && ++ (ts.tv_sec < st.st_mtim.tv_sec || ++ (ts.tv_sec == st.st_mtim.tv_sec && ts.tv_nsec < st.st_mtim.tv_nsec)) && ++ st.st_mtime - ts.tv_sec <= PERSIST_TIMEOUT; ++ } ++ return fd; ++} ++ ++int ++setpersist(int fd) ++{ ++ struct timespec times[2]; ++ ++ if (clock_gettime(CLOCK_BOOTTIME, ×[1]) < 0) ++ return -1; ++ times[0].tv_nsec = UTIME_OMIT; ++ times[1].tv_sec += PERSIST_TIMEOUT; ++ return futimens(fd, times); ++} ++ ++int ++clearpersist(void) ++{ ++ char path[256]; ++ ++ if (persistpath(path, sizeof(path)) < 0) ++ return -1; ++ if (unlink(path) < 0 && errno != ENOENT) ++ return -1; ++ return 0; ++} +-- +2.31.1 + diff --git a/pkg/openbsd/patch/0016-doas-Port-to-linux-musl.patch b/pkg/openbsd/patch/0016-doas-Port-to-linux-musl.patch deleted file mode 100644 index 321ba7b5..00000000 --- a/pkg/openbsd/patch/0016-doas-Port-to-linux-musl.patch +++ /dev/null @@ -1,562 +0,0 @@ -From 9e07250958968c674c1b1041d8b2887c9e1edfc3 Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Sun, 26 Feb 2017 16:50:55 -0800 -Subject: [PATCH] doas: Port to linux/musl - -Remove -a login style option and BSD authentication. Instead, compare -against shadow file. - -Use timestamp files in /run/doas instead of TIOC*VERAUTH to implement -persist. - -Use initgroups/setgid/setuid instead of setusercontext. - -Provide UID_MAX and GID_MAX defaults. - -Use LOGIN_NAME_MAX instead of _PW_NAME_LEN. - -Remove call to closefrom. - -Replace calls to errc with err after setting errno. - -Call openlog at start to set syslog identity. - -Remove unveil/pledge since they aren't supported on Linux. - -Simplify handling of PATH in the environment since we don't have -login.conf with per-user default PATH. ---- - usr.bin/doas/doas.1 | 9 --- - usr.bin/doas/doas.c | 158 ++++++++++++++--------------------------- - usr.bin/doas/doas.h | 6 +- - usr.bin/doas/env.c | 17 ++--- - usr.bin/doas/parse.y | 1 + - usr.bin/doas/persist.c | 133 ++++++++++++++++++++++++++++++++++ - 6 files changed, 196 insertions(+), 128 deletions(-) - create mode 100644 usr.bin/doas/persist.c - -diff --git a/usr.bin/doas/doas.1 b/usr.bin/doas/doas.1 -index fc769bdb336..c7196e347a9 100644 ---- a/usr.bin/doas/doas.1 -+++ b/usr.bin/doas/doas.1 -@@ -22,7 +22,6 @@ - .Sh SYNOPSIS - .Nm doas - .Op Fl Lns --.Op Fl a Ar style - .Op Fl C Ar config - .Op Fl u Ar user - .Ar command -@@ -67,14 +66,6 @@ The working directory is not changed. - .Pp - The options are as follows: - .Bl -tag -width tenletters --.It Fl a Ar style --Use the specified authentication style when validating the user, --as allowed by --.Pa /etc/login.conf . --A list of doas-specific authentication methods may be configured by adding an --.Sq auth-doas --entry in --.Xr login.conf 5 . - .It Fl C Ar config - Parse and check the configuration file - .Ar config , -diff --git a/usr.bin/doas/doas.c b/usr.bin/doas/doas.c -index a723c67a3eb..8b0c2931f92 100644 ---- a/usr.bin/doas/doas.c -+++ b/usr.bin/doas/doas.c -@@ -20,8 +20,6 @@ - #include - - #include --#include --#include - #include - #include - #include -@@ -33,13 +31,22 @@ - #include - #include - #include -+#include - - #include "doas.h" - -+#ifndef UID_MAX -+#define UID_MAX 65535 -+#endif -+ -+#ifndef GID_MAX -+#define GID_MAX 65535 -+#endif -+ - static void __dead - usage(void) - { -- fprintf(stderr, "usage: doas [-Lns] [-a style] [-C config] [-u user]" -+ fprintf(stderr, "usage: doas [-Lns] [-C config] [-u user]" - " command [args]\n"); - exit(1); - } -@@ -197,23 +204,36 @@ checkconfig(const char *confpath, int argc, char **argv, - } - } - -+static int -+verifypasswd(const char *user, const char *pass) -+{ -+ struct spwd *sp; -+ char *p1, *p2; -+ -+ sp = getspnam(user); -+ if (!sp) -+ return 0; -+ p1 = sp->sp_pwdp; -+ if (p1[0] == '!' || p1[0] == '*') -+ return 0; -+ p2 = crypt(pass, p1); -+ if (!p2) -+ return 0; -+ return strcmp(p1, p2) == 0; -+} -+ - static void --authuser(char *myname, char *login_style, int persist) -+authuser(char *myname, int persist) - { - char *challenge = NULL, *response, rbuf[1024], cbuf[128]; -- auth_session_t *as; -- int fd = -1; -+ int fd = -1, valid = 0; - -- if (persist) -- fd = open("/dev/tty", O_RDWR); -- if (fd != -1) { -- if (ioctl(fd, TIOCCHKVERAUTH) == 0) -+ if (persist) { -+ fd = openpersist(&valid); -+ if (valid) - goto good; - } - -- if (!(as = auth_userchallenge(myname, login_style, "auth-doas", -- &challenge))) -- errx(1, "Authorization failed"); - if (!challenge) { - char host[HOST_NAME_MAX + 1]; - if (gethostname(host, sizeof(host))) -@@ -225,75 +245,31 @@ authuser(char *myname, char *login_style, int persist) - response = readpassphrase(challenge, rbuf, sizeof(rbuf), - RPP_REQUIRE_TTY); - if (response == NULL && errno == ENOTTY) { -- syslog(LOG_AUTHPRIV | LOG_NOTICE, -- "tty required for %s", myname); -+ syslog(LOG_NOTICE, "tty required for %s", myname); - errx(1, "a tty is required"); - } -- if (!auth_userresponse(as, response, 0)) { -+ if (!verifypasswd(myname, response)) { - explicit_bzero(rbuf, sizeof(rbuf)); -- syslog(LOG_AUTHPRIV | LOG_NOTICE, -- "failed auth for %s", myname); -+ syslog(LOG_NOTICE, "failed auth for %s", myname); - errx(1, "Authorization failed"); - } - explicit_bzero(rbuf, sizeof(rbuf)); - good: - if (fd != -1) { -- int secs = 5 * 60; -- ioctl(fd, TIOCSETVERAUTH, &secs); -+ setpersist(fd); - close(fd); - } - } - --int --unveilcommands(const char *ipath, const char *cmd) --{ -- char *path = NULL, *p; -- int unveils = 0; -- -- if (strchr(cmd, '/') != NULL) { -- if (unveil(cmd, "x") != -1) -- unveils++; -- goto done; -- } -- -- if (!ipath) { -- errno = ENOENT; -- goto done; -- } -- path = strdup(ipath); -- if (!path) { -- errno = ENOENT; -- goto done; -- } -- for (p = path; p && *p; ) { -- char buf[PATH_MAX]; -- char *cp = strsep(&p, ":"); -- -- if (cp) { -- int r = snprintf(buf, sizeof buf, "%s/%s", cp, cmd); -- if (r >= 0 && r < sizeof buf) { -- if (unveil(buf, "x") != -1) -- unveils++; -- } -- } -- } --done: -- free(path); -- return (unveils); --} -- - int - main(int argc, char **argv) - { -- const char *safepath = "/bin:/sbin:/usr/bin:/usr/sbin:" -- "/usr/local/bin:/usr/local/sbin"; - const char *confpath = NULL; - char *shargv[] = { NULL, NULL }; - char *sh; -- const char *p; - const char *cmd; - char cmdline[LINE_MAX]; -- char mypwbuf[_PW_BUF_LEN], targpwbuf[_PW_BUF_LEN]; -+ char mypwbuf[1024], targpwbuf[1024]; - struct passwd mypwstore, targpwstore; - struct passwd *mypw, *targpw; - const struct rule *rule; -@@ -306,28 +282,20 @@ main(int argc, char **argv) - int nflag = 0; - char cwdpath[PATH_MAX]; - const char *cwd; -- char *login_style = NULL; - char **envp; - - setprogname("doas"); -- -- closefrom(STDERR_FILENO + 1); -+ openlog("doas", 0, LOG_AUTHPRIV); - - uid = getuid(); - -- while ((ch = getopt(argc, argv, "a:C:Lnsu:")) != -1) { -+ while ((ch = getopt(argc, argv, "C:Lnsu:")) != -1) { - switch (ch) { -- case 'a': -- login_style = optarg; -- break; - case 'C': - confpath = optarg; - break; - case 'L': -- i = open("/dev/tty", O_RDWR); -- if (i != -1) -- ioctl(i, TIOCCLRVERAUTH); -- exit(i == -1); -+ exit(clearpersist() != 0); - case 'u': - if (parseuid(optarg, &target) != 0) - errx(1, "unknown user"); -@@ -395,47 +363,30 @@ main(int argc, char **argv) - cmd = argv[0]; - if (!permit(uid, groups, ngroups, &rule, target, cmd, - (const char **)argv + 1)) { -- syslog(LOG_AUTHPRIV | LOG_NOTICE, -- "failed command for %s: %s", mypw->pw_name, cmdline); -- errc(1, EPERM, NULL); -+ syslog(LOG_NOTICE, "failed command for %s: %s", mypw->pw_name, cmdline); -+ errno = EPERM; -+ err(1, NULL); - } - - if (!(rule->options & NOPASS)) { - if (nflag) - errx(1, "Authorization required"); - -- authuser(mypw->pw_name, login_style, rule->options & PERSIST); -+ authuser(mypw->pw_name, rule->options & PERSIST); - } - -- if ((p = getenv("PATH")) != NULL) -- formerpath = strdup(p); -- if (formerpath == NULL) -- formerpath = ""; -- -- if (unveil(_PATH_LOGIN_CONF, "r") == -1 || -- unveil(_PATH_LOGIN_CONF ".db", "r") == -1) -- err(1, "unveil"); -- if (rule->cmd) { -- if (setenv("PATH", safepath, 1) == -1) -- err(1, "failed to set PATH '%s'", safepath); -- } -- if (unveilcommands(getenv("PATH"), cmd) == 0) -- goto fail; -- -- if (pledge("stdio rpath getpw exec id", NULL) == -1) -- err(1, "pledge"); -- - rv = getpwuid_r(target, &targpwstore, targpwbuf, sizeof(targpwbuf), &targpw); - if (rv != 0) - err(1, "getpwuid_r failed"); - if (targpw == NULL) - errx(1, "no passwd entry for target"); - -- if (setusercontext(NULL, targpw, target, LOGIN_SETGROUP | -- LOGIN_SETPATH | -- LOGIN_SETPRIORITY | LOGIN_SETRESOURCES | LOGIN_SETUMASK | -- LOGIN_SETUSER) != 0) -- errx(1, "failed to set user context for target"); -+ if (initgroups(targpw->pw_name, targpw->pw_gid) == -1) -+ err(1, "initgroups"); -+ if (setgid(targpw->pw_gid) == -1) -+ err(1, "setgid"); -+ if (setuid(targpw->pw_uid) == -1) -+ err(1, "setuid"); - - if (pledge("stdio rpath exec", NULL) == -1) - err(1, "pledge"); -@@ -448,21 +399,16 @@ main(int argc, char **argv) - if (pledge("stdio exec", NULL) == -1) - err(1, "pledge"); - -- syslog(LOG_AUTHPRIV | LOG_INFO, "%s ran command %s as %s from %s", -+ syslog(LOG_INFO, "%s ran command %s as %s from %s", - mypw->pw_name, cmdline, targpw->pw_name, cwd); - - envp = prepenv(rule, mypw, targpw); - -- /* setusercontext set path for the next process, so reset it for us */ - if (rule->cmd) { - if (setenv("PATH", safepath, 1) == -1) - err(1, "failed to set PATH '%s'", safepath); -- } else { -- if (setenv("PATH", formerpath, 1) == -1) -- err(1, "failed to set PATH '%s'", formerpath); - } - execvpe(cmd, argv, envp); --fail: - if (errno == ENOENT) - errx(1, "%s: command not found", cmd); - err(1, "%s", cmd); -diff --git a/usr.bin/doas/doas.h b/usr.bin/doas/doas.h -index 6f50fc22869..4e4e74476c1 100644 ---- a/usr.bin/doas/doas.h -+++ b/usr.bin/doas/doas.h -@@ -29,13 +29,17 @@ extern struct rule **rules; - extern int nrules; - extern int parse_errors; - --extern const char *formerpath; -+extern const char *safepath; - - struct passwd; - - char **prepenv(const struct rule *, const struct passwd *, - const struct passwd *); - -+int openpersist(int *valid); -+int setpersist(int fd); -+int clearpersist(void); -+ - #define PERMIT 1 - #define DENY 2 - -diff --git a/usr.bin/doas/env.c b/usr.bin/doas/env.c -index 2d93a4089b6..dc9be691955 100644 ---- a/usr.bin/doas/env.c -+++ b/usr.bin/doas/env.c -@@ -28,7 +28,7 @@ - - #include "doas.h" - --const char *formerpath; -+const char *safepath = "/bin"; - - struct envnode { - RB_ENTRY(envnode) node; -@@ -103,7 +103,7 @@ createenv(const struct rule *rule, const struct passwd *mypw, - addnode(env, "DOAS_USER", mypw->pw_name); - addnode(env, "HOME", targpw->pw_dir); - addnode(env, "LOGNAME", targpw->pw_name); -- addnode(env, "PATH", getenv("PATH")); -+ addnode(env, "PATH", safepath); - addnode(env, "SHELL", targpw->pw_shell); - addnode(env, "USER", targpw->pw_name); - -@@ -200,17 +200,10 @@ fillenv(struct env *env, const char **envlist) - /* assign value or inherit from environ */ - if (eq) { - val = eq + 1; -- if (*val == '$') { -- if (strcmp(val + 1, "PATH") == 0) -- val = formerpath; -- else -- val = getenv(val + 1); -- } -+ if (*val == '$') -+ val = getenv(val + 1); - } else { -- if (strcmp(name, "PATH") == 0) -- val = formerpath; -- else -- val = getenv(name); -+ val = getenv(name); - } - /* at last, we have something to insert */ - if (val) { -diff --git a/usr.bin/doas/parse.y b/usr.bin/doas/parse.y -index dd9466e5f13..d1f698c7679 100644 ---- a/usr.bin/doas/parse.y -+++ b/usr.bin/doas/parse.y -@@ -19,6 +19,7 @@ - #include - #include - #include -+#include - #include - #include - #include -diff --git a/usr.bin/doas/persist.c b/usr.bin/doas/persist.c -new file mode 100644 -index 00000000000..4ad1bf1efbf ---- /dev/null -+++ b/usr.bin/doas/persist.c -@@ -0,0 +1,133 @@ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "doas.h" -+ -+#define PERSIST_DIR "/run/doas" -+#define PERSIST_TIMEOUT 5 * 60 -+ -+static int -+ttyid(dev_t *tty) -+{ -+ int fd, i; -+ char buf[BUFSIZ], *p; -+ ssize_t n; -+ -+ fd = open("/proc/self/stat", O_RDONLY); -+ if (fd == -1) -+ return -1; -+ n = read(fd, buf, sizeof(buf) - 1); -+ if (n >= 0) -+ buf[n] = '\0'; -+ /* check that we read the whole file */ -+ n = read(fd, buf, 1); -+ close(fd); -+ if (n != 0) -+ return -1; -+ p = strrchr(buf, ')'); -+ if (!p) -+ return -1; -+ ++p; -+ /* ttr_nr is the 5th field after executable name, so skip the next 4 */ -+ for (i = 0; i < 4; ++i) { -+ p = strchr(++p, ' '); -+ if (!p) -+ return -1; -+ } -+ *tty = strtol(p, &p, 10); -+ if (*p != ' ') -+ return -1; -+ return 0; -+} -+ -+static int -+persistpath(char *buf, size_t len) -+{ -+ dev_t tty; -+ int n; -+ -+ if (ttyid(&tty) < 0) -+ return -1; -+ n = snprintf(buf, len, PERSIST_DIR "/%ju-%ju", (uintmax_t)getuid(), (uintmax_t)tty); -+ if (n < 0 || n >= (int)len) -+ return -1; -+ return 0; -+} -+ -+int -+openpersist(int *valid) -+{ -+ char path[256]; -+ struct stat st; -+ struct timespec ts; -+ int fd; -+ -+ if (stat(PERSIST_DIR, &st) < 0) { -+ if (errno != ENOENT) -+ return -1; -+ if (mkdir(PERSIST_DIR, 0700) < 0) -+ return -1; -+ } else if (st.st_uid != 0 || st.st_mode != (S_IFDIR | 0700)) { -+ return -1; -+ } -+ if (persistpath(path, sizeof(path)) < 0) -+ return -1; -+ fd = open(path, O_RDONLY); -+ if (fd == -1) { -+ char tmp[256]; -+ struct timespec ts[2] = { { .tv_nsec = UTIME_OMIT }, { 0 } }; -+ int n; -+ -+ n = snprintf(tmp, sizeof(tmp), PERSIST_DIR "/.tmp-%d", getpid()); -+ if (n < 0 || n >= (int)sizeof(tmp)) -+ return -1; -+ fd = open(tmp, O_RDONLY | O_CREAT | O_EXCL, 0); -+ if (fd == -1) -+ return -1; -+ if (futimens(fd, ts) < 0 || rename(tmp, path) < 0) { -+ close(fd); -+ unlink(tmp); -+ return -1; -+ } -+ *valid = 0; -+ } else { -+ *valid = clock_gettime(CLOCK_BOOTTIME, &ts) == 0 && -+ fstat(fd, &st) == 0 && -+ (ts.tv_sec < st.st_mtim.tv_sec || -+ (ts.tv_sec == st.st_mtim.tv_sec && ts.tv_nsec < st.st_mtim.tv_nsec)) && -+ st.st_mtime - ts.tv_sec <= PERSIST_TIMEOUT; -+ } -+ return fd; -+} -+ -+int -+setpersist(int fd) -+{ -+ struct timespec times[2]; -+ -+ if (clock_gettime(CLOCK_BOOTTIME, ×[1]) < 0) -+ return -1; -+ times[0].tv_nsec = UTIME_OMIT; -+ times[1].tv_sec += PERSIST_TIMEOUT; -+ return futimens(fd, times); -+} -+ -+int -+clearpersist(void) -+{ -+ char path[256]; -+ -+ if (persistpath(path, sizeof(path)) < 0) -+ return -1; -+ if (unlink(path) < 0 && errno != ENOENT) -+ return -1; -+ return 0; -+} --- -2.30.1 - diff --git a/pkg/openbsd/patch/0016-pwcache-Don-t-use-fixed-buffer-sizes.patch b/pkg/openbsd/patch/0016-pwcache-Don-t-use-fixed-buffer-sizes.patch new file mode 100644 index 00000000..3b7896ba --- /dev/null +++ b/pkg/openbsd/patch/0016-pwcache-Don-t-use-fixed-buffer-sizes.patch @@ -0,0 +1,92 @@ +From ab480e176692b91f2fb6fb9ea2e1725d980d805d Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Fri, 14 Apr 2017 11:25:01 -0700 +Subject: [PATCH] pwcache: Don't use fixed buffer sizes + +--- + lib/libc/gen/pwcache.c | 20 ++++++++------------ + 1 file changed, 8 insertions(+), 12 deletions(-) + +diff --git a/lib/libc/gen/pwcache.c b/lib/libc/gen/pwcache.c +index d54daa08cc7..2f30f4b966b 100644 +--- a/lib/libc/gen/pwcache.c ++++ b/lib/libc/gen/pwcache.c +@@ -202,8 +202,7 @@ grptb_start(void) + const char * + user_from_uid(uid_t uid, int noname) + { +- struct passwd pwstore, *pw = NULL; +- char pwbuf[_PW_BUF_LEN]; ++ struct passwd *pw; + UIDC **pptr, *ptr = NULL; + + if ((uidtb != NULL) || (uidtb_start() == 0)) { +@@ -226,7 +225,7 @@ user_from_uid(uid_t uid, int noname) + *pptr = ptr = malloc(sizeof(UIDC)); + } + +- getpwuid_r(uid, &pwstore, pwbuf, sizeof(pwbuf), &pw); ++ pw = getpwuid(uid); + if (pw == NULL) { + /* + * no match for this uid in the local password file +@@ -263,8 +262,7 @@ user_from_uid(uid_t uid, int noname) + const char * + group_from_gid(gid_t gid, int noname) + { +- struct group grstore, *gr = NULL; +- char grbuf[_GR_BUF_LEN]; ++ struct group *gr; + GIDC **pptr, *ptr = NULL; + + if ((gidtb != NULL) || (gidtb_start() == 0)) { +@@ -287,7 +285,7 @@ group_from_gid(gid_t gid, int noname) + *pptr = ptr = malloc(sizeof(GIDC)); + } + +- getgrgid_r(gid, &grstore, grbuf, sizeof(grbuf), &gr); ++ gr = getgrgid(gid); + if (gr == NULL) { + /* + * no match for this gid in the local group file, put in +@@ -322,8 +320,7 @@ group_from_gid(gid_t gid, int noname) + int + uid_from_user(const char *name, uid_t *uid) + { +- struct passwd pwstore, *pw = NULL; +- char pwbuf[_PW_BUF_LEN]; ++ struct passwd *pw; + UIDC **pptr, *ptr = NULL; + size_t namelen; + +@@ -357,7 +354,7 @@ uid_from_user(const char *name, uid_t *uid) + * no match, look it up, if no match store it as an invalid entry, + * or store the matching uid + */ +- getpwnam_r(name, &pwstore, pwbuf, sizeof(pwbuf), &pw); ++ pw = getpwnam(name); + if (ptr == NULL) { + if (pw == NULL) + return -1; +@@ -383,8 +380,7 @@ uid_from_user(const char *name, uid_t *uid) + int + gid_from_group(const char *name, gid_t *gid) + { +- struct group grstore, *gr = NULL; +- char grbuf[_GR_BUF_LEN]; ++ struct group *gr; + GIDC **pptr, *ptr = NULL; + size_t namelen; + +@@ -418,7 +414,7 @@ gid_from_group(const char *name, gid_t *gid) + * no match, look it up, if no match store it as an invalid entry, + * or store the matching gid + */ +- getgrnam_r(name, &grstore, grbuf, sizeof(grbuf), &gr); ++ gr = getgrnam(name); + if (ptr == NULL) { + if (gr == NULL) + return -1; +-- +2.19.0 + diff --git a/pkg/openbsd/patch/0017-Add-standalone-freezero.patch b/pkg/openbsd/patch/0017-Add-standalone-freezero.patch new file mode 100644 index 00000000..249a3e4d --- /dev/null +++ b/pkg/openbsd/patch/0017-Add-standalone-freezero.patch @@ -0,0 +1,51 @@ +From 98a3b77cfa775c87010159d49f5b17d84fe1aa7b Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Tue, 10 Oct 2017 03:07:56 -0700 +Subject: [PATCH] Add standalone freezero + +--- + lib/libc/stdlib/freezero.c | 32 ++++++++++++++++++++++++++++++++ + 1 file changed, 32 insertions(+) + create mode 100644 lib/libc/stdlib/freezero.c + +diff --git a/lib/libc/stdlib/freezero.c b/lib/libc/stdlib/freezero.c +new file mode 100644 +index 00000000000..31face3828b +--- /dev/null ++++ b/lib/libc/stdlib/freezero.c +@@ -0,0 +1,32 @@ ++/* ++ * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek ++ * Copyright (c) 2012 Matthew Dempsky ++ * Copyright (c) 2008 Damien Miller ++ * Copyright (c) 2000 Poul-Henning Kamp ++ * ++ * Permission to use, copy, modify, and distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#include ++#include ++ ++void ++freezero(void *ptr, size_t sz) ++{ ++ /* This is legal. */ ++ if (ptr == NULL) ++ return; ++ ++ explicit_bzero(ptr, sz); ++ free(ptr); ++} +-- +2.14.2 + diff --git a/pkg/openbsd/patch/0017-pwcache-Don-t-use-fixed-buffer-sizes.patch b/pkg/openbsd/patch/0017-pwcache-Don-t-use-fixed-buffer-sizes.patch deleted file mode 100644 index 3b7896ba..00000000 --- a/pkg/openbsd/patch/0017-pwcache-Don-t-use-fixed-buffer-sizes.patch +++ /dev/null @@ -1,92 +0,0 @@ -From ab480e176692b91f2fb6fb9ea2e1725d980d805d Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Fri, 14 Apr 2017 11:25:01 -0700 -Subject: [PATCH] pwcache: Don't use fixed buffer sizes - ---- - lib/libc/gen/pwcache.c | 20 ++++++++------------ - 1 file changed, 8 insertions(+), 12 deletions(-) - -diff --git a/lib/libc/gen/pwcache.c b/lib/libc/gen/pwcache.c -index d54daa08cc7..2f30f4b966b 100644 ---- a/lib/libc/gen/pwcache.c -+++ b/lib/libc/gen/pwcache.c -@@ -202,8 +202,7 @@ grptb_start(void) - const char * - user_from_uid(uid_t uid, int noname) - { -- struct passwd pwstore, *pw = NULL; -- char pwbuf[_PW_BUF_LEN]; -+ struct passwd *pw; - UIDC **pptr, *ptr = NULL; - - if ((uidtb != NULL) || (uidtb_start() == 0)) { -@@ -226,7 +225,7 @@ user_from_uid(uid_t uid, int noname) - *pptr = ptr = malloc(sizeof(UIDC)); - } - -- getpwuid_r(uid, &pwstore, pwbuf, sizeof(pwbuf), &pw); -+ pw = getpwuid(uid); - if (pw == NULL) { - /* - * no match for this uid in the local password file -@@ -263,8 +262,7 @@ user_from_uid(uid_t uid, int noname) - const char * - group_from_gid(gid_t gid, int noname) - { -- struct group grstore, *gr = NULL; -- char grbuf[_GR_BUF_LEN]; -+ struct group *gr; - GIDC **pptr, *ptr = NULL; - - if ((gidtb != NULL) || (gidtb_start() == 0)) { -@@ -287,7 +285,7 @@ group_from_gid(gid_t gid, int noname) - *pptr = ptr = malloc(sizeof(GIDC)); - } - -- getgrgid_r(gid, &grstore, grbuf, sizeof(grbuf), &gr); -+ gr = getgrgid(gid); - if (gr == NULL) { - /* - * no match for this gid in the local group file, put in -@@ -322,8 +320,7 @@ group_from_gid(gid_t gid, int noname) - int - uid_from_user(const char *name, uid_t *uid) - { -- struct passwd pwstore, *pw = NULL; -- char pwbuf[_PW_BUF_LEN]; -+ struct passwd *pw; - UIDC **pptr, *ptr = NULL; - size_t namelen; - -@@ -357,7 +354,7 @@ uid_from_user(const char *name, uid_t *uid) - * no match, look it up, if no match store it as an invalid entry, - * or store the matching uid - */ -- getpwnam_r(name, &pwstore, pwbuf, sizeof(pwbuf), &pw); -+ pw = getpwnam(name); - if (ptr == NULL) { - if (pw == NULL) - return -1; -@@ -383,8 +380,7 @@ uid_from_user(const char *name, uid_t *uid) - int - gid_from_group(const char *name, gid_t *gid) - { -- struct group grstore, *gr = NULL; -- char grbuf[_GR_BUF_LEN]; -+ struct group *gr; - GIDC **pptr, *ptr = NULL; - size_t namelen; - -@@ -418,7 +414,7 @@ gid_from_group(const char *name, gid_t *gid) - * no match, look it up, if no match store it as an invalid entry, - * or store the matching gid - */ -- getgrnam_r(name, &grstore, grbuf, sizeof(grbuf), &gr); -+ gr = getgrnam(name); - if (ptr == NULL) { - if (gr == NULL) - return -1; --- -2.19.0 - diff --git a/pkg/openbsd/patch/0018-Add-standalone-freezero.patch b/pkg/openbsd/patch/0018-Add-standalone-freezero.patch deleted file mode 100644 index 249a3e4d..00000000 --- a/pkg/openbsd/patch/0018-Add-standalone-freezero.patch +++ /dev/null @@ -1,51 +0,0 @@ -From 98a3b77cfa775c87010159d49f5b17d84fe1aa7b Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Tue, 10 Oct 2017 03:07:56 -0700 -Subject: [PATCH] Add standalone freezero - ---- - lib/libc/stdlib/freezero.c | 32 ++++++++++++++++++++++++++++++++ - 1 file changed, 32 insertions(+) - create mode 100644 lib/libc/stdlib/freezero.c - -diff --git a/lib/libc/stdlib/freezero.c b/lib/libc/stdlib/freezero.c -new file mode 100644 -index 00000000000..31face3828b ---- /dev/null -+++ b/lib/libc/stdlib/freezero.c -@@ -0,0 +1,32 @@ -+/* -+ * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek -+ * Copyright (c) 2012 Matthew Dempsky -+ * Copyright (c) 2008 Damien Miller -+ * Copyright (c) 2000 Poul-Henning Kamp -+ * -+ * Permission to use, copy, modify, and distribute this software for any -+ * purpose with or without fee is hereby granted, provided that the above -+ * copyright notice and this permission notice appear in all copies. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -+ */ -+ -+#include -+#include -+ -+void -+freezero(void *ptr, size_t sz) -+{ -+ /* This is legal. */ -+ if (ptr == NULL) -+ return; -+ -+ explicit_bzero(ptr, sz); -+ free(ptr); -+} --- -2.14.2 - diff --git a/pkg/openbsd/patch/0018-m4-Use-hand-written-lexer-to-avoid-cycle-in-bootstra.patch b/pkg/openbsd/patch/0018-m4-Use-hand-written-lexer-to-avoid-cycle-in-bootstra.patch new file mode 100644 index 00000000..f58f366f --- /dev/null +++ b/pkg/openbsd/patch/0018-m4-Use-hand-written-lexer-to-avoid-cycle-in-bootstra.patch @@ -0,0 +1,327 @@ +From edf250c633bef40e7e37dafc9fc393dd2ad9074f Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Tue, 10 Apr 2018 13:37:14 -0700 +Subject: [PATCH] m4: Use hand-written lexer to avoid cycle in bootstrap + +--- + usr.bin/m4/tokenizer.c | 191 +++++++++++++++++++++++++++++++++++++++++ + usr.bin/m4/tokenizer.l | 109 ----------------------- + 2 files changed, 191 insertions(+), 109 deletions(-) + create mode 100644 usr.bin/m4/tokenizer.c + delete mode 100644 usr.bin/m4/tokenizer.l + +diff --git a/usr.bin/m4/tokenizer.c b/usr.bin/m4/tokenizer.c +new file mode 100644 +index 00000000000..fa19fc65035 +--- /dev/null ++++ b/usr.bin/m4/tokenizer.c +@@ -0,0 +1,191 @@ ++/* $OpenBSD: tokenizer.l,v 1.10 2017/06/17 01:55:16 bcallah Exp $ */ ++/* ++ * Copyright (c) 2004 Marc Espie ++ * ++ * Permission to use, copy, modify, and distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++#include "parser.tab.h" ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++extern void m4_warnx(const char *, ...); ++extern int mimic_gnu; ++extern int32_t yylval; ++static const char *yypos; ++ ++void ++yy_scan_string(const char *s) ++{ ++ yypos = s; ++} ++ ++static int32_t ++number(const char *yytext, size_t yylen) ++{ ++ long l; ++ ++ errno = 0; ++ l = strtol(yytext, NULL, 0); ++ if (((l == LONG_MAX || l == LONG_MIN) && errno == ERANGE) || ++ l > INT32_MAX || l < INT32_MIN) ++ m4_warnx("numeric overflow in expr: %.*s", (int)yylen, yytext); ++ return l; ++} ++ ++static int32_t ++parse_radix(const char *yytext, size_t yylen) ++{ ++ long base; ++ char *next; ++ long l; ++ int d; ++ ++ l = 0; ++ base = strtol(yytext+2, &next, 0); ++ if (base > 36 || next == NULL) { ++ m4_warnx("error in number %.*s", (int)yylen, yytext); ++ } else { ++ next++; ++ while (*next != 0) { ++ if (*next >= '0' && *next <= '9') ++ d = *next - '0'; ++ else if (*next >= 'a' && *next <= 'z') ++ d = *next - 'a' + 10; ++ else { ++ assert(*next >= 'A' && *next <= 'Z'); ++ d = *next - 'A' + 10; ++ } ++ if (d >= base) { ++ m4_warnx("error in number %.*s", (int)yylen, yytext); ++ return 0; ++ } ++ l = base * l + d; ++ next++; ++ } ++ } ++ return l; ++} ++ ++static int ++isodigit(int c) ++{ ++ return c >= '0' && c <= '7'; ++} ++ ++int yylex(void) ++{ ++ const char *start; ++ ++next: ++ start = yypos; ++ switch (*yypos) { ++ case ' ': ++ case '\t': ++ case '\n': ++ ++yypos; ++ goto next; ++ case '<': ++ switch (yypos[1]) { ++ case '=': ++ yypos += 2; ++ return LE; ++ case '<': ++ yypos += 2; ++ return LSHIFT; ++ } ++ break; ++ case '>': ++ switch (yypos[1]) { ++ case '=': ++ yypos += 2; ++ return GE; ++ case '>': ++ yypos += 2; ++ return RSHIFT; ++ } ++ break; ++ case '=': ++ if (yypos[1] != '=') ++ break; ++ yypos += 2; ++ return EQ; ++ case '!': ++ if (yypos[1] != '=') ++ break; ++ yypos += 2; ++ return NE; ++ case '&': ++ if (yypos[1] != '&') ++ break; ++ yypos += 2; ++ return LAND; ++ case '|': ++ if (yypos[1] != '|') ++ break; ++ yypos += 2; ++ return LOR; ++ case '*': ++ if (!mimic_gnu || yypos[1] != '*') ++ break; ++ yypos += 2; ++ return EXPONENT; ++ case '0': ++ switch (*++yypos) { ++ case 'x': ++ case 'X': ++ if (!isxdigit(*++yypos)) ++ return ERROR; ++ do ++yypos; ++ while (isxdigit(*yypos)); ++ break; ++ case 'r': ++ case 'R': ++ if (!mimic_gnu) ++ break; ++ if (!isdigit(*++yypos)) ++ return ERROR; ++ do ++yypos; ++ while (isdigit(*yypos)); ++ if (*yypos != ':') ++ return ERROR; ++ if (!isalnum(*++yypos)) ++ return ERROR; ++ do ++yypos; ++ while (isalnum(*yypos)); ++ yylval = parse_radix(start, yypos - start); ++ return NUMBER; ++ default: ++ do ++yypos; ++ while (isodigit(*yypos)); ++ break; ++ } ++ yylval = number(start, yypos - start); ++ return NUMBER; ++ case '\0': ++ return '\0'; ++ } ++ if (isdigit(*yypos)) { ++ do ++yypos; ++ while (isdigit(*yypos)); ++ yylval = number(start, yypos - start); ++ return NUMBER; ++ } ++ ++ return *yypos++; ++} +diff --git a/usr.bin/m4/tokenizer.l b/usr.bin/m4/tokenizer.l +deleted file mode 100644 +index 94f02fb6085..00000000000 +--- a/usr.bin/m4/tokenizer.l ++++ /dev/null +@@ -1,109 +0,0 @@ +-%{ +-/* $OpenBSD: tokenizer.l,v 1.10 2017/06/17 01:55:16 bcallah Exp $ */ +-/* +- * Copyright (c) 2004 Marc Espie +- * +- * Permission to use, copy, modify, and distribute this software for any +- * purpose with or without fee is hereby granted, provided that the above +- * copyright notice and this permission notice appear in all copies. +- * +- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +- */ +-#include "parser.h" +-#include +-#include +-#include +-#include +-#include +- +-extern void m4_warnx(const char *, ...); +-extern int mimic_gnu; +-extern int32_t yylval; +- +-int32_t number(void); +-int32_t parse_radix(void); +-%} +- +-delim [ \t\n] +-ws {delim}+ +-hex 0[xX][0-9a-fA-F]+ +-oct 0[0-7]* +-dec [1-9][0-9]* +-radix 0[rR][0-9]+:[0-9a-zA-Z]+ +- +-%option noyywrap +- +-%% +-{ws} {/* just skip it */} +-{hex}|{oct}|{dec} { yylval = number(); return(NUMBER); } +-{radix} { if (mimic_gnu) { +- yylval = parse_radix(); return(NUMBER); +- } else { +- return(ERROR); +- } +- } +-"<=" { return(LE); } +-">=" { return(GE); } +-"<<" { return(LSHIFT); } +-">>" { return(RSHIFT); } +-"==" { return(EQ); } +-"!=" { return(NE); } +-"&&" { return(LAND); } +-"||" { return(LOR); } +-"**" { if (mimic_gnu) { return (EXPONENT); } } +-. { return yytext[0]; } +-%% +- +-int32_t +-number() +-{ +- long l; +- +- errno = 0; +- l = strtol(yytext, NULL, 0); +- if (((l == LONG_MAX || l == LONG_MIN) && errno == ERANGE) || +- l > INT32_MAX || l < INT32_MIN) +- m4_warnx("numeric overflow in expr: %s", yytext); +- return l; +-} +- +-int32_t +-parse_radix() +-{ +- long base; +- char *next; +- long l; +- int d; +- +- l = 0; +- base = strtol(yytext+2, &next, 0); +- if (base > 36 || next == NULL) { +- m4_warnx("error in number %s", yytext); +- } else { +- next++; +- while (*next != 0) { +- if (*next >= '0' && *next <= '9') +- d = *next - '0'; +- else if (*next >= 'a' && *next <= 'z') +- d = *next - 'a' + 10; +- else { +- assert(*next >= 'A' && *next <= 'Z'); +- d = *next - 'A' + 10; +- } +- if (d >= base) { +- m4_warnx("error in number %s", yytext); +- return 0; +- } +- l = base * l + d; +- next++; +- } +- } +- return l; +-} +- +-- +2.17.0 + diff --git a/pkg/openbsd/patch/0019-m4-Use-_Noreturn-instead-of-__dead.patch b/pkg/openbsd/patch/0019-m4-Use-_Noreturn-instead-of-__dead.patch new file mode 100644 index 00000000..c78d504e --- /dev/null +++ b/pkg/openbsd/patch/0019-m4-Use-_Noreturn-instead-of-__dead.patch @@ -0,0 +1,25 @@ +From 0f0eb43f3d6fb749fac229e3d6c8f74b2c40ece2 Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Tue, 10 Apr 2018 16:03:44 -0700 +Subject: [PATCH] m4: Use _Noreturn instead of __dead + +--- + usr.bin/m4/extern.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/usr.bin/m4/extern.h b/usr.bin/m4/extern.h +index ea8406b8540..0c07599777d 100644 +--- a/usr.bin/m4/extern.h ++++ b/usr.bin/m4/extern.h +@@ -113,7 +113,7 @@ extern void usage(void); + extern void resizedivs(int); + extern size_t buffer_mark(void); + extern void dump_buffer(FILE *, size_t); +-extern void __dead m4errx(int, const char *, ...); ++extern void _Noreturn m4errx(int, const char *, ...); + + extern int obtain_char(struct input_file *); + extern void set_input(struct input_file *, FILE *, const char *); +-- +2.17.0 + diff --git a/pkg/openbsd/patch/0019-m4-Use-hand-written-lexer-to-avoid-cycle-in-bootstra.patch b/pkg/openbsd/patch/0019-m4-Use-hand-written-lexer-to-avoid-cycle-in-bootstra.patch deleted file mode 100644 index f58f366f..00000000 --- a/pkg/openbsd/patch/0019-m4-Use-hand-written-lexer-to-avoid-cycle-in-bootstra.patch +++ /dev/null @@ -1,327 +0,0 @@ -From edf250c633bef40e7e37dafc9fc393dd2ad9074f Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Tue, 10 Apr 2018 13:37:14 -0700 -Subject: [PATCH] m4: Use hand-written lexer to avoid cycle in bootstrap - ---- - usr.bin/m4/tokenizer.c | 191 +++++++++++++++++++++++++++++++++++++++++ - usr.bin/m4/tokenizer.l | 109 ----------------------- - 2 files changed, 191 insertions(+), 109 deletions(-) - create mode 100644 usr.bin/m4/tokenizer.c - delete mode 100644 usr.bin/m4/tokenizer.l - -diff --git a/usr.bin/m4/tokenizer.c b/usr.bin/m4/tokenizer.c -new file mode 100644 -index 00000000000..fa19fc65035 ---- /dev/null -+++ b/usr.bin/m4/tokenizer.c -@@ -0,0 +1,191 @@ -+/* $OpenBSD: tokenizer.l,v 1.10 2017/06/17 01:55:16 bcallah Exp $ */ -+/* -+ * Copyright (c) 2004 Marc Espie -+ * -+ * Permission to use, copy, modify, and distribute this software for any -+ * purpose with or without fee is hereby granted, provided that the above -+ * copyright notice and this permission notice appear in all copies. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -+ */ -+#include "parser.tab.h" -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+extern void m4_warnx(const char *, ...); -+extern int mimic_gnu; -+extern int32_t yylval; -+static const char *yypos; -+ -+void -+yy_scan_string(const char *s) -+{ -+ yypos = s; -+} -+ -+static int32_t -+number(const char *yytext, size_t yylen) -+{ -+ long l; -+ -+ errno = 0; -+ l = strtol(yytext, NULL, 0); -+ if (((l == LONG_MAX || l == LONG_MIN) && errno == ERANGE) || -+ l > INT32_MAX || l < INT32_MIN) -+ m4_warnx("numeric overflow in expr: %.*s", (int)yylen, yytext); -+ return l; -+} -+ -+static int32_t -+parse_radix(const char *yytext, size_t yylen) -+{ -+ long base; -+ char *next; -+ long l; -+ int d; -+ -+ l = 0; -+ base = strtol(yytext+2, &next, 0); -+ if (base > 36 || next == NULL) { -+ m4_warnx("error in number %.*s", (int)yylen, yytext); -+ } else { -+ next++; -+ while (*next != 0) { -+ if (*next >= '0' && *next <= '9') -+ d = *next - '0'; -+ else if (*next >= 'a' && *next <= 'z') -+ d = *next - 'a' + 10; -+ else { -+ assert(*next >= 'A' && *next <= 'Z'); -+ d = *next - 'A' + 10; -+ } -+ if (d >= base) { -+ m4_warnx("error in number %.*s", (int)yylen, yytext); -+ return 0; -+ } -+ l = base * l + d; -+ next++; -+ } -+ } -+ return l; -+} -+ -+static int -+isodigit(int c) -+{ -+ return c >= '0' && c <= '7'; -+} -+ -+int yylex(void) -+{ -+ const char *start; -+ -+next: -+ start = yypos; -+ switch (*yypos) { -+ case ' ': -+ case '\t': -+ case '\n': -+ ++yypos; -+ goto next; -+ case '<': -+ switch (yypos[1]) { -+ case '=': -+ yypos += 2; -+ return LE; -+ case '<': -+ yypos += 2; -+ return LSHIFT; -+ } -+ break; -+ case '>': -+ switch (yypos[1]) { -+ case '=': -+ yypos += 2; -+ return GE; -+ case '>': -+ yypos += 2; -+ return RSHIFT; -+ } -+ break; -+ case '=': -+ if (yypos[1] != '=') -+ break; -+ yypos += 2; -+ return EQ; -+ case '!': -+ if (yypos[1] != '=') -+ break; -+ yypos += 2; -+ return NE; -+ case '&': -+ if (yypos[1] != '&') -+ break; -+ yypos += 2; -+ return LAND; -+ case '|': -+ if (yypos[1] != '|') -+ break; -+ yypos += 2; -+ return LOR; -+ case '*': -+ if (!mimic_gnu || yypos[1] != '*') -+ break; -+ yypos += 2; -+ return EXPONENT; -+ case '0': -+ switch (*++yypos) { -+ case 'x': -+ case 'X': -+ if (!isxdigit(*++yypos)) -+ return ERROR; -+ do ++yypos; -+ while (isxdigit(*yypos)); -+ break; -+ case 'r': -+ case 'R': -+ if (!mimic_gnu) -+ break; -+ if (!isdigit(*++yypos)) -+ return ERROR; -+ do ++yypos; -+ while (isdigit(*yypos)); -+ if (*yypos != ':') -+ return ERROR; -+ if (!isalnum(*++yypos)) -+ return ERROR; -+ do ++yypos; -+ while (isalnum(*yypos)); -+ yylval = parse_radix(start, yypos - start); -+ return NUMBER; -+ default: -+ do ++yypos; -+ while (isodigit(*yypos)); -+ break; -+ } -+ yylval = number(start, yypos - start); -+ return NUMBER; -+ case '\0': -+ return '\0'; -+ } -+ if (isdigit(*yypos)) { -+ do ++yypos; -+ while (isdigit(*yypos)); -+ yylval = number(start, yypos - start); -+ return NUMBER; -+ } -+ -+ return *yypos++; -+} -diff --git a/usr.bin/m4/tokenizer.l b/usr.bin/m4/tokenizer.l -deleted file mode 100644 -index 94f02fb6085..00000000000 ---- a/usr.bin/m4/tokenizer.l -+++ /dev/null -@@ -1,109 +0,0 @@ --%{ --/* $OpenBSD: tokenizer.l,v 1.10 2017/06/17 01:55:16 bcallah Exp $ */ --/* -- * Copyright (c) 2004 Marc Espie -- * -- * Permission to use, copy, modify, and distribute this software for any -- * purpose with or without fee is hereby granted, provided that the above -- * copyright notice and this permission notice appear in all copies. -- * -- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- */ --#include "parser.h" --#include --#include --#include --#include --#include -- --extern void m4_warnx(const char *, ...); --extern int mimic_gnu; --extern int32_t yylval; -- --int32_t number(void); --int32_t parse_radix(void); --%} -- --delim [ \t\n] --ws {delim}+ --hex 0[xX][0-9a-fA-F]+ --oct 0[0-7]* --dec [1-9][0-9]* --radix 0[rR][0-9]+:[0-9a-zA-Z]+ -- --%option noyywrap -- --%% --{ws} {/* just skip it */} --{hex}|{oct}|{dec} { yylval = number(); return(NUMBER); } --{radix} { if (mimic_gnu) { -- yylval = parse_radix(); return(NUMBER); -- } else { -- return(ERROR); -- } -- } --"<=" { return(LE); } --">=" { return(GE); } --"<<" { return(LSHIFT); } --">>" { return(RSHIFT); } --"==" { return(EQ); } --"!=" { return(NE); } --"&&" { return(LAND); } --"||" { return(LOR); } --"**" { if (mimic_gnu) { return (EXPONENT); } } --. { return yytext[0]; } --%% -- --int32_t --number() --{ -- long l; -- -- errno = 0; -- l = strtol(yytext, NULL, 0); -- if (((l == LONG_MAX || l == LONG_MIN) && errno == ERANGE) || -- l > INT32_MAX || l < INT32_MIN) -- m4_warnx("numeric overflow in expr: %s", yytext); -- return l; --} -- --int32_t --parse_radix() --{ -- long base; -- char *next; -- long l; -- int d; -- -- l = 0; -- base = strtol(yytext+2, &next, 0); -- if (base > 36 || next == NULL) { -- m4_warnx("error in number %s", yytext); -- } else { -- next++; -- while (*next != 0) { -- if (*next >= '0' && *next <= '9') -- d = *next - '0'; -- else if (*next >= 'a' && *next <= 'z') -- d = *next - 'a' + 10; -- else { -- assert(*next >= 'A' && *next <= 'Z'); -- d = *next - 'A' + 10; -- } -- if (d >= base) { -- m4_warnx("error in number %s", yytext); -- return 0; -- } -- l = base * l + d; -- next++; -- } -- } -- return l; --} -- --- -2.17.0 - diff --git a/pkg/openbsd/patch/0020-m4-Add-missing-includes.patch b/pkg/openbsd/patch/0020-m4-Add-missing-includes.patch new file mode 100644 index 00000000..d647009b --- /dev/null +++ b/pkg/openbsd/patch/0020-m4-Add-missing-includes.patch @@ -0,0 +1,50 @@ +From 3cc2a61c553d138778a6ec1dd84cd042ce834b4e Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Tue, 10 Apr 2018 16:24:12 -0700 +Subject: [PATCH] m4: Add missing includes + +--- + usr.bin/m4/look.c | 1 + + usr.bin/m4/main.c | 1 + + usr.bin/m4/parser.y | 1 + + 3 files changed, 3 insertions(+) + +diff --git a/usr.bin/m4/look.c b/usr.bin/m4/look.c +index ac504570a9f..5feb0413cd6 100644 +--- a/usr.bin/m4/look.c ++++ b/usr.bin/m4/look.c +@@ -38,6 +38,7 @@ + * by: oz + */ + ++#include + #include + #include + #include +diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c +index f1b8fa5a55b..4e664c0a50b 100644 +--- a/usr.bin/m4/main.c ++++ b/usr.bin/m4/main.c +@@ -39,6 +39,7 @@ + * by: oz + */ + ++#include + #include + #include + #include +diff --git a/usr.bin/m4/parser.y b/usr.bin/m4/parser.y +index 5b46d261a9a..fedded1e44c 100644 +--- a/usr.bin/m4/parser.y ++++ b/usr.bin/m4/parser.y +@@ -17,6 +17,7 @@ + */ + #include + #include ++#include + #define YYSTYPE int32_t + extern int32_t end_result; + extern int yylex(void); +-- +2.22.0 + diff --git a/pkg/openbsd/patch/0020-m4-Use-_Noreturn-instead-of-__dead.patch b/pkg/openbsd/patch/0020-m4-Use-_Noreturn-instead-of-__dead.patch deleted file mode 100644 index c78d504e..00000000 --- a/pkg/openbsd/patch/0020-m4-Use-_Noreturn-instead-of-__dead.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0f0eb43f3d6fb749fac229e3d6c8f74b2c40ece2 Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Tue, 10 Apr 2018 16:03:44 -0700 -Subject: [PATCH] m4: Use _Noreturn instead of __dead - ---- - usr.bin/m4/extern.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/usr.bin/m4/extern.h b/usr.bin/m4/extern.h -index ea8406b8540..0c07599777d 100644 ---- a/usr.bin/m4/extern.h -+++ b/usr.bin/m4/extern.h -@@ -113,7 +113,7 @@ extern void usage(void); - extern void resizedivs(int); - extern size_t buffer_mark(void); - extern void dump_buffer(FILE *, size_t); --extern void __dead m4errx(int, const char *, ...); -+extern void _Noreturn m4errx(int, const char *, ...); - - extern int obtain_char(struct input_file *); - extern void set_input(struct input_file *, FILE *, const char *); --- -2.17.0 - diff --git a/pkg/openbsd/patch/0021-libutil-Add-missing-includes.patch b/pkg/openbsd/patch/0021-libutil-Add-missing-includes.patch new file mode 100644 index 00000000..c441c199 --- /dev/null +++ b/pkg/openbsd/patch/0021-libutil-Add-missing-includes.patch @@ -0,0 +1,24 @@ +From 72cfeec702c7b76cce88be4c411ce40a8abb628c Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Tue, 10 Apr 2018 16:23:22 -0700 +Subject: [PATCH] libutil: Add missing includes + +--- + lib/libutil/ohash.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/lib/libutil/ohash.c b/lib/libutil/ohash.c +index 74ca4fafd9c..9537c60eac4 100644 +--- a/lib/libutil/ohash.c ++++ b/lib/libutil/ohash.c +@@ -15,6 +15,7 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++#include + #include + #include + #include +-- +2.17.0 + diff --git a/pkg/openbsd/patch/0021-m4-Add-missing-includes.patch b/pkg/openbsd/patch/0021-m4-Add-missing-includes.patch deleted file mode 100644 index d647009b..00000000 --- a/pkg/openbsd/patch/0021-m4-Add-missing-includes.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 3cc2a61c553d138778a6ec1dd84cd042ce834b4e Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Tue, 10 Apr 2018 16:24:12 -0700 -Subject: [PATCH] m4: Add missing includes - ---- - usr.bin/m4/look.c | 1 + - usr.bin/m4/main.c | 1 + - usr.bin/m4/parser.y | 1 + - 3 files changed, 3 insertions(+) - -diff --git a/usr.bin/m4/look.c b/usr.bin/m4/look.c -index ac504570a9f..5feb0413cd6 100644 ---- a/usr.bin/m4/look.c -+++ b/usr.bin/m4/look.c -@@ -38,6 +38,7 @@ - * by: oz - */ - -+#include - #include - #include - #include -diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c -index f1b8fa5a55b..4e664c0a50b 100644 ---- a/usr.bin/m4/main.c -+++ b/usr.bin/m4/main.c -@@ -39,6 +39,7 @@ - * by: oz - */ - -+#include - #include - #include - #include -diff --git a/usr.bin/m4/parser.y b/usr.bin/m4/parser.y -index 5b46d261a9a..fedded1e44c 100644 ---- a/usr.bin/m4/parser.y -+++ b/usr.bin/m4/parser.y -@@ -17,6 +17,7 @@ - */ - #include - #include -+#include - #define YYSTYPE int32_t - extern int32_t end_result; - extern int yylex(void); --- -2.22.0 - diff --git a/pkg/openbsd/patch/0022-acme-client-Add-missing-includes.patch b/pkg/openbsd/patch/0022-acme-client-Add-missing-includes.patch new file mode 100644 index 00000000..31f034c6 --- /dev/null +++ b/pkg/openbsd/patch/0022-acme-client-Add-missing-includes.patch @@ -0,0 +1,25 @@ +From 7ea4349d2ed8afd672348a7d2f3534007e5dc442 Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Mon, 18 Mar 2019 14:52:31 -0700 +Subject: [PATCH] acme-client: Add missing includes + +--- + usr.sbin/acme-client/extern.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/usr.sbin/acme-client/extern.h b/usr.sbin/acme-client/extern.h +index dda2edde4..d83ead634 100644 +--- a/usr.sbin/acme-client/extern.h ++++ b/usr.sbin/acme-client/extern.h +@@ -17,6 +17,8 @@ + #ifndef EXTERN_H + #define EXTERN_H + ++#include ++#include + #include "parse.h" + + #define MAX_SERVERS_DNS 8 +-- +2.21.0 + diff --git a/pkg/openbsd/patch/0022-libutil-Add-missing-includes.patch b/pkg/openbsd/patch/0022-libutil-Add-missing-includes.patch deleted file mode 100644 index c441c199..00000000 --- a/pkg/openbsd/patch/0022-libutil-Add-missing-includes.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 72cfeec702c7b76cce88be4c411ce40a8abb628c Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Tue, 10 Apr 2018 16:23:22 -0700 -Subject: [PATCH] libutil: Add missing includes - ---- - lib/libutil/ohash.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/lib/libutil/ohash.c b/lib/libutil/ohash.c -index 74ca4fafd9c..9537c60eac4 100644 ---- a/lib/libutil/ohash.c -+++ b/lib/libutil/ohash.c -@@ -15,6 +15,7 @@ - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -+#include - #include - #include - #include --- -2.17.0 - diff --git a/pkg/openbsd/patch/0023-acme-client-Add-missing-includes.patch b/pkg/openbsd/patch/0023-acme-client-Add-missing-includes.patch deleted file mode 100644 index 31f034c6..00000000 --- a/pkg/openbsd/patch/0023-acme-client-Add-missing-includes.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 7ea4349d2ed8afd672348a7d2f3534007e5dc442 Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Mon, 18 Mar 2019 14:52:31 -0700 -Subject: [PATCH] acme-client: Add missing includes - ---- - usr.sbin/acme-client/extern.h | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/usr.sbin/acme-client/extern.h b/usr.sbin/acme-client/extern.h -index dda2edde4..d83ead634 100644 ---- a/usr.sbin/acme-client/extern.h -+++ b/usr.sbin/acme-client/extern.h -@@ -17,6 +17,8 @@ - #ifndef EXTERN_H - #define EXTERN_H - -+#include -+#include - #include "parse.h" - - #define MAX_SERVERS_DNS 8 --- -2.21.0 - diff --git a/pkg/openbsd/patch/0023-rsync-Add-missing-includes.patch b/pkg/openbsd/patch/0023-rsync-Add-missing-includes.patch new file mode 100644 index 00000000..2f632cb3 --- /dev/null +++ b/pkg/openbsd/patch/0023-rsync-Add-missing-includes.patch @@ -0,0 +1,40 @@ +From ca34590e5d0065db581b3b4c05c9c7aea0015dff Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Fri, 14 Jun 2019 12:40:56 -0700 +Subject: [PATCH] rsync: Add missing includes + +- stdio.h in socket.c for sscanf +- sys/types.h in extern.h for various type definitions +--- + usr.bin/rsync/extern.h | 2 ++ + usr.bin/rsync/socket.c | 1 + + 2 files changed, 3 insertions(+) + +diff --git a/usr.bin/rsync/extern.h b/usr.bin/rsync/extern.h +index 305821be579..040588003a4 100644 +--- a/usr.bin/rsync/extern.h ++++ b/usr.bin/rsync/extern.h +@@ -17,6 +17,8 @@ + #ifndef EXTERN_H + #define EXTERN_H + ++#include ++ + /* + * This is the rsync protocol version that we support. + */ +diff --git a/usr.bin/rsync/socket.c b/usr.bin/rsync/socket.c +index 36384d063a0..43d8d7d01af 100644 +--- a/usr.bin/rsync/socket.c ++++ b/usr.bin/rsync/socket.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + #include + #include + #include +-- +2.22.0 + diff --git a/pkg/openbsd/patch/0024-rsync-Add-missing-includes.patch b/pkg/openbsd/patch/0024-rsync-Add-missing-includes.patch deleted file mode 100644 index 2f632cb3..00000000 --- a/pkg/openbsd/patch/0024-rsync-Add-missing-includes.patch +++ /dev/null @@ -1,40 +0,0 @@ -From ca34590e5d0065db581b3b4c05c9c7aea0015dff Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Fri, 14 Jun 2019 12:40:56 -0700 -Subject: [PATCH] rsync: Add missing includes - -- stdio.h in socket.c for sscanf -- sys/types.h in extern.h for various type definitions ---- - usr.bin/rsync/extern.h | 2 ++ - usr.bin/rsync/socket.c | 1 + - 2 files changed, 3 insertions(+) - -diff --git a/usr.bin/rsync/extern.h b/usr.bin/rsync/extern.h -index 305821be579..040588003a4 100644 ---- a/usr.bin/rsync/extern.h -+++ b/usr.bin/rsync/extern.h -@@ -17,6 +17,8 @@ - #ifndef EXTERN_H - #define EXTERN_H - -+#include -+ - /* - * This is the rsync protocol version that we support. - */ -diff --git a/usr.bin/rsync/socket.c b/usr.bin/rsync/socket.c -index 36384d063a0..43d8d7d01af 100644 ---- a/usr.bin/rsync/socket.c -+++ b/usr.bin/rsync/socket.c -@@ -28,6 +28,7 @@ - #include - #include - #include -+#include - #include - #include - #include --- -2.22.0 - diff --git a/pkg/openbsd/patch/0024-rsync-Use-standard-S_ISVTX-instead-of-S_ISTXT.patch b/pkg/openbsd/patch/0024-rsync-Use-standard-S_ISVTX-instead-of-S_ISTXT.patch new file mode 100644 index 00000000..39bc6502 --- /dev/null +++ b/pkg/openbsd/patch/0024-rsync-Use-standard-S_ISVTX-instead-of-S_ISTXT.patch @@ -0,0 +1,34 @@ +From b8ea0a7fc75f79d89f9f225da1112f477419d0bd Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Fri, 14 Jun 2019 12:42:15 -0700 +Subject: [PATCH] rsync: Use standard S_ISVTX instead of S_ISTXT + +--- + usr.bin/rsync/receiver.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/usr.bin/rsync/receiver.c b/usr.bin/rsync/receiver.c +index 5ffd3458b74..51f9ddf6a5c 100644 +--- a/usr.bin/rsync/receiver.c ++++ b/usr.bin/rsync/receiver.c +@@ -86,7 +86,7 @@ rsync_set_metadata(struct sess *sess, int newfile, + "to user.group: %u.%u", f->path, uid, gid); + } else + LOG4("%s: updated uid and/or gid", f->path); +- mode &= ~(S_ISTXT | S_ISUID | S_ISGID); ++ mode &= ~(S_ISVTX | S_ISUID | S_ISGID); + } + + /* Conditionally adjust file permissions. */ +@@ -147,7 +147,7 @@ rsync_set_metadata_at(struct sess *sess, int newfile, int rootfd, + "to user.group: %u.%u", f->path, uid, gid); + } else + LOG4("%s: updated uid and/or gid", f->path); +- mode &= ~(S_ISTXT | S_ISUID | S_ISGID); ++ mode &= ~(S_ISVTX | S_ISUID | S_ISGID); + } + + /* Conditionally adjust file permissions. */ +-- +2.23.0 + diff --git a/pkg/openbsd/patch/0025-rsync-Avoid-pointer-arithmetic-on-void.patch b/pkg/openbsd/patch/0025-rsync-Avoid-pointer-arithmetic-on-void.patch new file mode 100644 index 00000000..12abaa7d --- /dev/null +++ b/pkg/openbsd/patch/0025-rsync-Avoid-pointer-arithmetic-on-void.patch @@ -0,0 +1,149 @@ +From 56fcd604ca9bf0ae936307c3e56d232a3daef919 Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Sat, 15 Jun 2019 20:06:13 -0700 +Subject: [PATCH] rsync: Avoid pointer arithmetic on `void *` + +--- + usr.bin/rsync/blocks.c | 8 ++++---- + usr.bin/rsync/downloader.c | 2 +- + usr.bin/rsync/io.c | 12 ++++++------ + usr.bin/rsync/sender.c | 5 +++-- + 4 files changed, 14 insertions(+), 13 deletions(-) + +diff --git a/usr.bin/rsync/blocks.c b/usr.bin/rsync/blocks.c +index 4f21a41833d..242590e5bae 100644 +--- a/usr.bin/rsync/blocks.c ++++ b/usr.bin/rsync/blocks.c +@@ -157,7 +157,7 @@ blk_find(struct sess *sess, struct blkstat *st, + if (!recomp) { + fhash = (st->s1 & 0xFFFF) | (st->s2 << 16); + } else { +- fhash = hash_fast(st->map + st->offs, (size_t)osz); ++ fhash = hash_fast((char *)st->map + st->offs, (size_t)osz); + st->s1 = fhash & 0xFFFF; + st->s2 = fhash >> 16; + } +@@ -170,7 +170,7 @@ blk_find(struct sess *sess, struct blkstat *st, + if (st->hint < blks->blksz && + fhash == blks->blks[st->hint].chksum_short && + (size_t)osz == blks->blks[st->hint].len) { +- hash_slow(st->map + st->offs, (size_t)osz, md, sess); ++ hash_slow((char *)st->map + st->offs, (size_t)osz, md, sess); + have_md = 1; + if (memcmp(md, blks->blks[st->hint].chksum_long, blks->csum) == 0) { + LOG4("%s: found matching hinted match: " +@@ -203,7 +203,7 @@ blk_find(struct sess *sess, struct blkstat *st, + (intmax_t)ent->blk->offs, ent->blk->len); + + if (have_md == 0) { +- hash_slow(st->map + st->offs, (size_t)osz, md, sess); ++ hash_slow((char *)st->map + st->offs, (size_t)osz, md, sess); + have_md = 1; + } + +@@ -221,7 +221,7 @@ blk_find(struct sess *sess, struct blkstat *st, + * block in the sequence. + */ + +- map = st->map + st->offs; ++ map = (char *)st->map + st->offs; + st->s1 -= map[0]; + st->s2 -= osz * map[0]; + +diff --git a/usr.bin/rsync/downloader.c b/usr.bin/rsync/downloader.c +index 9ddb8600a73..36b086f74c8 100644 +--- a/usr.bin/rsync/downloader.c ++++ b/usr.bin/rsync/downloader.c +@@ -495,7 +495,7 @@ again: + sz = tok == p->blk.blksz - 1 ? p->blk.rem : p->blk.len; + assert(sz); + assert(p->map != MAP_FAILED); +- buf = p->map + (tok * p->blk.len); ++ buf = (char *)p->map + (tok * p->blk.len); + + /* + * Now we read from our block. +diff --git a/usr.bin/rsync/io.c b/usr.bin/rsync/io.c +index 27beba693d4..847af4c4c1b 100644 +--- a/usr.bin/rsync/io.c ++++ b/usr.bin/rsync/io.c +@@ -117,7 +117,7 @@ io_write_blocking(int fd, const void *buf, size_t sz) + ERRX("io_write_nonblocking: short write"); + return 0; + } +- buf += wsz; ++ buf = (char *)buf + wsz; + sz -= wsz; + } + +@@ -156,7 +156,7 @@ io_write_buf(struct sess *sess, int fd, const void *buf, size_t sz) + } + sess->total_write += wsz; + sz -= wsz; +- buf += wsz; ++ buf = (char *)buf + wsz; + } + + return 1; +@@ -250,7 +250,7 @@ io_read_blocking(int fd, void *buf, size_t sz) + ERRX("io_read_nonblocking: short read"); + return 0; + } +- buf += rsz; ++ buf = (char *)buf + rsz; + sz -= rsz; + } + +@@ -367,7 +367,7 @@ io_read_buf(struct sess *sess, int fd, void *buf, size_t sz) + } + sz -= rsz; + sess->mplex_read_remain -= rsz; +- buf += rsz; ++ buf = (char *)buf + rsz; + sess->total_read += rsz; + continue; + } +@@ -463,7 +463,7 @@ io_buffer_buf(void *buf, size_t *bufpos, size_t buflen, const void *val, + { + + assert(*bufpos + valsz <= buflen); +- memcpy(buf + *bufpos, val, valsz); ++ memcpy((char *)buf + *bufpos, val, valsz); + *bufpos += valsz; + } + +@@ -661,7 +661,7 @@ io_unbuffer_buf(const void *buf, size_t *bufpos, size_t bufsz, void *val, + { + + assert(*bufpos + valsz <= bufsz); +- memcpy(val, buf + *bufpos, valsz); ++ memcpy(val, (char *)buf + *bufpos, valsz); + *bufpos += valsz; + } + +diff --git a/usr.bin/rsync/sender.c b/usr.bin/rsync/sender.c +index 00add6b4e6c..0ac8226816f 100644 +--- a/usr.bin/rsync/sender.c ++++ b/usr.bin/rsync/sender.c +@@ -128,7 +128,7 @@ send_up_fsm(struct sess *sess, size_t *phase, + return 0; + } + io_lowbuffer_buf(sess, *wb, &pos, *wbsz, +- up->stat.map + up->stat.curpos, sz); ++ (char *)up->stat.map + up->stat.curpos, sz); + + up->stat.curpos += sz; + if (up->stat.curpos == up->stat.curlen) +@@ -568,7 +568,8 @@ rsync_sender(struct sess *sess, int fdin, + if ((pfd[1].revents & POLLOUT) && wbufsz > 0) { + assert(pfd[2].fd == -1); + assert(wbufsz - wbufpos); +- ssz = write(fdout, wbuf + wbufpos, wbufsz - wbufpos); ++ ssz = write(fdout, ++ (char *)wbuf + wbufpos, wbufsz - wbufpos); + if (ssz == -1) { + ERR("write"); + goto out; +-- +2.31.1 + diff --git a/pkg/openbsd/patch/0025-rsync-Use-standard-S_ISVTX-instead-of-S_ISTXT.patch b/pkg/openbsd/patch/0025-rsync-Use-standard-S_ISVTX-instead-of-S_ISTXT.patch deleted file mode 100644 index 39bc6502..00000000 --- a/pkg/openbsd/patch/0025-rsync-Use-standard-S_ISVTX-instead-of-S_ISTXT.patch +++ /dev/null @@ -1,34 +0,0 @@ -From b8ea0a7fc75f79d89f9f225da1112f477419d0bd Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Fri, 14 Jun 2019 12:42:15 -0700 -Subject: [PATCH] rsync: Use standard S_ISVTX instead of S_ISTXT - ---- - usr.bin/rsync/receiver.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/usr.bin/rsync/receiver.c b/usr.bin/rsync/receiver.c -index 5ffd3458b74..51f9ddf6a5c 100644 ---- a/usr.bin/rsync/receiver.c -+++ b/usr.bin/rsync/receiver.c -@@ -86,7 +86,7 @@ rsync_set_metadata(struct sess *sess, int newfile, - "to user.group: %u.%u", f->path, uid, gid); - } else - LOG4("%s: updated uid and/or gid", f->path); -- mode &= ~(S_ISTXT | S_ISUID | S_ISGID); -+ mode &= ~(S_ISVTX | S_ISUID | S_ISGID); - } - - /* Conditionally adjust file permissions. */ -@@ -147,7 +147,7 @@ rsync_set_metadata_at(struct sess *sess, int newfile, int rootfd, - "to user.group: %u.%u", f->path, uid, gid); - } else - LOG4("%s: updated uid and/or gid", f->path); -- mode &= ~(S_ISTXT | S_ISUID | S_ISGID); -+ mode &= ~(S_ISVTX | S_ISUID | S_ISGID); - } - - /* Conditionally adjust file permissions. */ --- -2.23.0 - diff --git a/pkg/openbsd/patch/0026-Include-sys-sysmacros.h-if-necessary.patch b/pkg/openbsd/patch/0026-Include-sys-sysmacros.h-if-necessary.patch new file mode 100644 index 00000000..6b64a048 --- /dev/null +++ b/pkg/openbsd/patch/0026-Include-sys-sysmacros.h-if-necessary.patch @@ -0,0 +1,73 @@ +From a8d547a2cf005a00a111394464fc2692f426ceed Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Mon, 5 Aug 2019 21:42:54 -0700 +Subject: [PATCH] Include sys/sysmacros.h if necessary + +--- + bin/pax/cpio.c | 4 ++++ + bin/pax/gen_subs.c | 3 +++ + bin/pax/tar.c | 3 +++ + usr.bin/rsync/flist.c | 4 ++++ + 4 files changed, 14 insertions(+) + +diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c +index 92fe965163a..3832b1e87aa 100644 +--- a/bin/pax/cpio.c ++++ b/bin/pax/cpio.c +@@ -41,6 +41,10 @@ + #include + #include + #include ++#ifndef major ++#include ++#endif ++ + #include "pax.h" + #include "cpio.h" + #include "extern.h" +diff --git a/bin/pax/gen_subs.c b/bin/pax/gen_subs.c +index 42c70804fb7..405dd2c24ed 100644 +--- a/bin/pax/gen_subs.c ++++ b/bin/pax/gen_subs.c +@@ -45,6 +45,9 @@ + #include + #include + #include ++#ifndef major ++#include ++#endif + + #include "pax.h" + #include "extern.h" +diff --git a/bin/pax/tar.c b/bin/pax/tar.c +index a49a5e885fb..3bfa9444dd5 100644 +--- a/bin/pax/tar.c ++++ b/bin/pax/tar.c +@@ -45,6 +45,9 @@ + #include + #include + #include ++#ifndef major ++#include ++#endif + + #include "pax.h" + #include "extern.h" +diff --git a/usr.bin/rsync/flist.c b/usr.bin/rsync/flist.c +index ac29ad47098..9680883ca77 100644 +--- a/usr.bin/rsync/flist.c ++++ b/usr.bin/rsync/flist.c +@@ -17,6 +17,10 @@ + */ + #include + #include ++#include ++#ifndef major ++#include ++#endif + + #include + #include +-- +2.22.0 + diff --git a/pkg/openbsd/patch/0026-rsync-Use-1-instead-of-INFTIM-for-poll-timeout.patch b/pkg/openbsd/patch/0026-rsync-Use-1-instead-of-INFTIM-for-poll-timeout.patch deleted file mode 100644 index 6169131f..00000000 --- a/pkg/openbsd/patch/0026-rsync-Use-1-instead-of-INFTIM-for-poll-timeout.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 588522657724047a2e4c838e62dfff5db41bd506 Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Fri, 14 Jun 2019 12:44:02 -0700 -Subject: [PATCH] rsync: Use -1 instead of INFTIM for poll timeout - ---- - usr.bin/rsync/extern.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/usr.bin/rsync/extern.h b/usr.bin/rsync/extern.h -index 040588003a4..64a02349adc 100644 ---- a/usr.bin/rsync/extern.h -+++ b/usr.bin/rsync/extern.h -@@ -47,7 +47,7 @@ - * Use this for debugging deadlocks. - * All poll events will use it and catch time-outs. - */ --#define POLL_TIMEOUT (INFTIM) -+#define POLL_TIMEOUT (-1) - - /* - * Operating mode for a client or a server. --- -2.22.0 - diff --git a/pkg/openbsd/patch/0027-nc-Portability-fixes-from-libressl-portable.patch b/pkg/openbsd/patch/0027-nc-Portability-fixes-from-libressl-portable.patch new file mode 100644 index 00000000..2c3cb23d --- /dev/null +++ b/pkg/openbsd/patch/0027-nc-Portability-fixes-from-libressl-portable.patch @@ -0,0 +1,194 @@ +From 074f2b35512b16c9644c8bd878fa9ace208c17a6 Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Mon, 2 Dec 2019 21:11:04 -0800 +Subject: [PATCH] nc: Portability fixes from libressl-portable + +--- + usr.bin/nc/netcat.c | 55 +++++++++++++++++++++++++++++++++++++++------ + 1 file changed, 48 insertions(+), 7 deletions(-) + +diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c +index 503095584ad..f052766213e 100644 +--- a/usr.bin/nc/netcat.c ++++ b/usr.bin/nc/netcat.c +@@ -93,9 +93,13 @@ int zflag; /* Port Scan Flag */ + int Dflag; /* sodebug */ + int Iflag; /* TCP receive buffer size */ + int Oflag; /* TCP send buffer size */ ++#ifdef TCP_MD5SIG + int Sflag; /* TCP MD5 signature option */ ++#endif + int Tflag = -1; /* IP Type of Service */ ++#ifdef SO_RTABLE + int rtableid = -1; ++#endif + + int usetls; /* use TLS */ + const char *Cflag; /* Public cert file */ +@@ -269,12 +273,14 @@ main(int argc, char *argv[]) + case 'u': + uflag = 1; + break; ++#ifdef SO_RTABLE + case 'V': + rtableid = (int)strtonum(optarg, 0, + RT_TABLEID_MAX, &errstr); + if (errstr) + errx(1, "rtable %s: %s", errstr, optarg); + break; ++#endif + case 'v': + vflag = 1; + break; +@@ -321,9 +327,11 @@ main(int argc, char *argv[]) + case 'o': + oflag = optarg; + break; ++#ifdef TCP_MD5SIG + case 'S': + Sflag = 1; + break; ++#endif + case 'T': + errstr = NULL; + errno = 0; +@@ -347,9 +355,11 @@ main(int argc, char *argv[]) + argc -= optind; + argv += optind; + ++#ifdef SO_RTABLE + if (rtableid >= 0) + if (setrtable(rtableid) == -1) + err(1, "setrtable"); ++#endif + + /* Cruft to make sure options are clean, and used properly. */ + if (argc == 1 && family == AF_UNIX) { +@@ -947,7 +957,10 @@ remote_connect(const char *host, const char *port, struct addrinfo hints, + char *ipaddr) + { + struct addrinfo *res, *res0; +- int s = -1, error, herr, on = 1, save_errno; ++ int s = -1, error, herr, save_errno; ++#ifdef SO_BINDANY ++ int on = 1; ++#endif + + if ((error = getaddrinfo(host, port, &hints, &res0))) + errx(1, "getaddrinfo for host \"%s\" port %s: %s", host, +@@ -962,8 +975,10 @@ remote_connect(const char *host, const char *port, struct addrinfo hints, + if (sflag || pflag) { + struct addrinfo ahints, *ares; + ++#ifdef SO_BINDANY + /* try SO_BINDANY, but don't insist */ + setsockopt(s, SOL_SOCKET, SO_BINDANY, &on, sizeof(on)); ++#endif + memset(&ahints, 0, sizeof(struct addrinfo)); + ahints.ai_family = res->ai_family; + ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; +@@ -1055,8 +1070,11 @@ int + local_listen(const char *host, const char *port, struct addrinfo hints) + { + struct addrinfo *res, *res0; +- int s = -1, ret, x = 1, save_errno; ++ int s = -1, save_errno; + int error; ++#ifdef SO_REUSEPORT ++ int ret, x = 1; ++#endif + + /* Allow nodename to be null. */ + hints.ai_flags |= AI_PASSIVE; +@@ -1076,9 +1094,11 @@ local_listen(const char *host, const char *port, struct addrinfo hints) + res->ai_protocol)) == -1) + continue; + ++#ifdef SO_REUSEPORT + ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); + if (ret == -1) + err(1, NULL); ++#endif + + set_common_sockopts(s, res->ai_family); + +@@ -1548,11 +1568,13 @@ set_common_sockopts(int s, int af) + { + int x = 1; + ++#ifdef TCP_MD5SIG + if (Sflag) { + if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG, + &x, sizeof(x)) == -1) + err(1, NULL); + } ++#endif + if (Dflag) { + if (setsockopt(s, SOL_SOCKET, SO_DEBUG, + &x, sizeof(x)) == -1) +@@ -1563,9 +1585,16 @@ set_common_sockopts(int s, int af) + IP_TOS, &Tflag, sizeof(Tflag)) == -1) + err(1, "set IP ToS"); + ++#ifdef IPV6_TCLASS + else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, + IPV6_TCLASS, &Tflag, sizeof(Tflag)) == -1) + err(1, "set IPv6 traffic class"); ++#else ++ else if (af == AF_INET6) { ++ errno = ENOPROTOOPT; ++ err(1, "set IPv6 traffic class not supported"); ++ } ++#endif + } + if (Iflag) { + if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, +@@ -1589,13 +1618,17 @@ set_common_sockopts(int s, int af) + } + + if (minttl != -1) { ++#ifdef IP_MINTTL + if (af == AF_INET && setsockopt(s, IPPROTO_IP, + IP_MINTTL, &minttl, sizeof(minttl))) + err(1, "set IP min TTL"); ++#endif + +- else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, ++#ifdef IPV6_MINHOPCOUNT ++ if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, + IPV6_MINHOPCOUNT, &minttl, sizeof(minttl))) + err(1, "set IPv6 min hop count"); ++#endif + } + } + +@@ -1820,14 +1853,22 @@ help(void) + \t-P proxyuser\tUsername for proxy authentication\n\ + \t-p port\t Specify local port for remote connects\n\ + \t-R CAfile CA bundle\n\ +- \t-r Randomize remote ports\n\ +- \t-S Enable the TCP MD5 signature option\n\ ++ \t-r Randomize remote ports\n" ++#ifdef TCP_MD5SIG ++ "\ ++ \t-S Enable the TCP MD5 signature option\n" ++#endif ++ "\ + \t-s sourceaddr Local source address\n\ + \t-T keyword TOS value or TLS options\n\ + \t-t Answer TELNET negotiation\n\ + \t-U Use UNIX domain socket\n\ +- \t-u UDP mode\n\ +- \t-V rtable Specify alternate routing table\n\ ++ \t-u UDP mode\n" ++#ifdef SO_RTABLE ++ "\ ++ \t-V rtable Specify alternate routing table\n" ++#endif ++ "\ + \t-v Verbose\n\ + \t-W recvlimit Terminate after receiving a number of packets\n\ + \t-w timeout Timeout for connects and final net reads\n\ +-- +2.26.2 + diff --git a/pkg/openbsd/patch/0027-rsync-Avoid-pointer-arithmetic-on-void.patch b/pkg/openbsd/patch/0027-rsync-Avoid-pointer-arithmetic-on-void.patch deleted file mode 100644 index 885ce499..00000000 --- a/pkg/openbsd/patch/0027-rsync-Avoid-pointer-arithmetic-on-void.patch +++ /dev/null @@ -1,148 +0,0 @@ -From bae6ab2cb50b4c5784dcd17207f145707c77f317 Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Sat, 15 Jun 2019 20:06:13 -0700 -Subject: [PATCH] rsync: Avoid pointer arithmetic on `void *` - ---- - usr.bin/rsync/blocks.c | 8 ++++---- - usr.bin/rsync/downloader.c | 2 +- - usr.bin/rsync/io.c | 12 ++++++------ - usr.bin/rsync/sender.c | 4 ++-- - 4 files changed, 13 insertions(+), 13 deletions(-) - -diff --git a/usr.bin/rsync/blocks.c b/usr.bin/rsync/blocks.c -index 4f21a41833d..242590e5bae 100644 ---- a/usr.bin/rsync/blocks.c -+++ b/usr.bin/rsync/blocks.c -@@ -157,7 +157,7 @@ blk_find(struct sess *sess, struct blkstat *st, - if (!recomp) { - fhash = (st->s1 & 0xFFFF) | (st->s2 << 16); - } else { -- fhash = hash_fast(st->map + st->offs, (size_t)osz); -+ fhash = hash_fast((char *)st->map + st->offs, (size_t)osz); - st->s1 = fhash & 0xFFFF; - st->s2 = fhash >> 16; - } -@@ -170,7 +170,7 @@ blk_find(struct sess *sess, struct blkstat *st, - if (st->hint < blks->blksz && - fhash == blks->blks[st->hint].chksum_short && - (size_t)osz == blks->blks[st->hint].len) { -- hash_slow(st->map + st->offs, (size_t)osz, md, sess); -+ hash_slow((char *)st->map + st->offs, (size_t)osz, md, sess); - have_md = 1; - if (memcmp(md, blks->blks[st->hint].chksum_long, blks->csum) == 0) { - LOG4("%s: found matching hinted match: " -@@ -203,7 +203,7 @@ blk_find(struct sess *sess, struct blkstat *st, - (intmax_t)ent->blk->offs, ent->blk->len); - - if (have_md == 0) { -- hash_slow(st->map + st->offs, (size_t)osz, md, sess); -+ hash_slow((char *)st->map + st->offs, (size_t)osz, md, sess); - have_md = 1; - } - -@@ -221,7 +221,7 @@ blk_find(struct sess *sess, struct blkstat *st, - * block in the sequence. - */ - -- map = st->map + st->offs; -+ map = (char *)st->map + st->offs; - st->s1 -= map[0]; - st->s2 -= osz * map[0]; - -diff --git a/usr.bin/rsync/downloader.c b/usr.bin/rsync/downloader.c -index 9ddb8600a73..36b086f74c8 100644 ---- a/usr.bin/rsync/downloader.c -+++ b/usr.bin/rsync/downloader.c -@@ -495,7 +495,7 @@ again: - sz = tok == p->blk.blksz - 1 ? p->blk.rem : p->blk.len; - assert(sz); - assert(p->map != MAP_FAILED); -- buf = p->map + (tok * p->blk.len); -+ buf = (char *)p->map + (tok * p->blk.len); - - /* - * Now we read from our block. -diff --git a/usr.bin/rsync/io.c b/usr.bin/rsync/io.c -index 8d113d6d013..181458ced08 100644 ---- a/usr.bin/rsync/io.c -+++ b/usr.bin/rsync/io.c -@@ -117,7 +117,7 @@ io_write_blocking(int fd, const void *buf, size_t sz) - ERRX("io_write_nonblocking: short write"); - return 0; - } -- buf += wsz; -+ buf = (char *)buf + wsz; - sz -= wsz; - } - -@@ -156,7 +156,7 @@ io_write_buf(struct sess *sess, int fd, const void *buf, size_t sz) - } - sess->total_write += wsz; - sz -= wsz; -- buf += wsz; -+ buf = (char *)buf + wsz; - } - - return 1; -@@ -250,7 +250,7 @@ io_read_blocking(int fd, void *buf, size_t sz) - ERRX("io_read_nonblocking: short read"); - return 0; - } -- buf += rsz; -+ buf = (char *)buf + rsz; - sz -= rsz; - } - -@@ -367,7 +367,7 @@ io_read_buf(struct sess *sess, int fd, void *buf, size_t sz) - } - sz -= rsz; - sess->mplex_read_remain -= rsz; -- buf += rsz; -+ buf = (char *)buf + rsz; - sess->total_read += rsz; - continue; - } -@@ -463,7 +463,7 @@ io_buffer_buf(void *buf, size_t *bufpos, size_t buflen, const void *val, - { - - assert(*bufpos + valsz <= buflen); -- memcpy(buf + *bufpos, val, valsz); -+ memcpy((char *)buf + *bufpos, val, valsz); - *bufpos += valsz; - } - -@@ -661,7 +661,7 @@ io_unbuffer_buf(const void *buf, size_t *bufpos, size_t bufsz, void *val, - { - - assert(*bufpos + valsz <= bufsz); -- memcpy(val, buf + *bufpos, valsz); -+ memcpy(val, (char *)buf + *bufpos, valsz); - *bufpos += valsz; - } - -diff --git a/usr.bin/rsync/sender.c b/usr.bin/rsync/sender.c -index 5f9850ee9d2..d6a1f55d1a9 100644 ---- a/usr.bin/rsync/sender.c -+++ b/usr.bin/rsync/sender.c -@@ -128,7 +128,7 @@ send_up_fsm(struct sess *sess, size_t *phase, - return 0; - } - io_lowbuffer_buf(sess, *wb, &pos, *wbsz, -- up->stat.map + up->stat.curpos, sz); -+ (char *)up->stat.map + up->stat.curpos, sz); - - up->stat.curpos += sz; - if (up->stat.curpos == up->stat.curlen) -@@ -569,7 +569,7 @@ rsync_sender(struct sess *sess, int fdin, - assert(pfd[2].fd == -1); - assert(wbufsz - wbufpos); - ssz = write(fdout, -- wbuf + wbufpos, wbufsz - wbufpos); -+ (char *)wbuf + wbufpos, wbufsz - wbufpos); - if (ssz == -1) { - ERR("write"); - goto out; --- -2.23.0 - diff --git a/pkg/openbsd/patch/0028-Include-sys-sysmacros.h-if-necessary.patch b/pkg/openbsd/patch/0028-Include-sys-sysmacros.h-if-necessary.patch deleted file mode 100644 index 6b64a048..00000000 --- a/pkg/openbsd/patch/0028-Include-sys-sysmacros.h-if-necessary.patch +++ /dev/null @@ -1,73 +0,0 @@ -From a8d547a2cf005a00a111394464fc2692f426ceed Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Mon, 5 Aug 2019 21:42:54 -0700 -Subject: [PATCH] Include sys/sysmacros.h if necessary - ---- - bin/pax/cpio.c | 4 ++++ - bin/pax/gen_subs.c | 3 +++ - bin/pax/tar.c | 3 +++ - usr.bin/rsync/flist.c | 4 ++++ - 4 files changed, 14 insertions(+) - -diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c -index 92fe965163a..3832b1e87aa 100644 ---- a/bin/pax/cpio.c -+++ b/bin/pax/cpio.c -@@ -41,6 +41,10 @@ - #include - #include - #include -+#ifndef major -+#include -+#endif -+ - #include "pax.h" - #include "cpio.h" - #include "extern.h" -diff --git a/bin/pax/gen_subs.c b/bin/pax/gen_subs.c -index 42c70804fb7..405dd2c24ed 100644 ---- a/bin/pax/gen_subs.c -+++ b/bin/pax/gen_subs.c -@@ -45,6 +45,9 @@ - #include - #include - #include -+#ifndef major -+#include -+#endif - - #include "pax.h" - #include "extern.h" -diff --git a/bin/pax/tar.c b/bin/pax/tar.c -index a49a5e885fb..3bfa9444dd5 100644 ---- a/bin/pax/tar.c -+++ b/bin/pax/tar.c -@@ -45,6 +45,9 @@ - #include - #include - #include -+#ifndef major -+#include -+#endif - - #include "pax.h" - #include "extern.h" -diff --git a/usr.bin/rsync/flist.c b/usr.bin/rsync/flist.c -index ac29ad47098..9680883ca77 100644 ---- a/usr.bin/rsync/flist.c -+++ b/usr.bin/rsync/flist.c -@@ -17,6 +17,10 @@ - */ - #include - #include -+#include -+#ifndef major -+#include -+#endif - - #include - #include --- -2.22.0 - diff --git a/pkg/openbsd/patch/0028-pax-Ignore-EOPNOTSUPP-from-fchmodat.patch b/pkg/openbsd/patch/0028-pax-Ignore-EOPNOTSUPP-from-fchmodat.patch new file mode 100644 index 00000000..2b0a5f22 --- /dev/null +++ b/pkg/openbsd/patch/0028-pax-Ignore-EOPNOTSUPP-from-fchmodat.patch @@ -0,0 +1,26 @@ +From 0f49ae38698a163f7954d28bbaba473b6bf28239 Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Fri, 10 Jan 2020 21:40:03 -0800 +Subject: [PATCH] pax: Ignore EOPNOTSUPP from fchmodat + +Linux does not support changing the mode of symlinks. +--- + bin/pax/file_subs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c +index 8aa3d249923..2c0994feca6 100644 +--- a/bin/pax/file_subs.c ++++ b/bin/pax/file_subs.c +@@ -795,7 +795,7 @@ void + set_pmode(char *fnm, mode_t mode) + { + mode &= ABITS; +- if (fchmodat(AT_FDCWD, fnm, mode, AT_SYMLINK_NOFOLLOW) == -1) ++ if (fchmodat(AT_FDCWD, fnm, mode, AT_SYMLINK_NOFOLLOW) == -1 && errno != EOPNOTSUPP) + syswarn(1, errno, "Could not set permissions on %s", fnm); + } + +-- +2.26.2 + diff --git a/pkg/openbsd/patch/0029-acme-client-Fix-build-with-old-bison-versions.patch b/pkg/openbsd/patch/0029-acme-client-Fix-build-with-old-bison-versions.patch new file mode 100644 index 00000000..50639203 --- /dev/null +++ b/pkg/openbsd/patch/0029-acme-client-Fix-build-with-old-bison-versions.patch @@ -0,0 +1,24 @@ +From c3aab43559f17feb64a29f8b0d395532cb423e8b Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Wed, 15 Apr 2020 20:26:16 -0700 +Subject: [PATCH] acme-client: Fix build with old bison versions + +--- + usr.sbin/acme-client/parse.y | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/usr.sbin/acme-client/parse.y b/usr.sbin/acme-client/parse.y +index 20818328d92..f392e516b63 100644 +--- a/usr.sbin/acme-client/parse.y ++++ b/usr.sbin/acme-client/parse.y +@@ -97,6 +97,7 @@ typedef struct { + } v; + int lineno; + } YYSTYPE; ++#define YYSTYPE_IS_DECLARED 1 + + %} + +-- +2.26.1 + diff --git a/pkg/openbsd/patch/0029-nc-Portability-fixes-from-libressl-portable.patch b/pkg/openbsd/patch/0029-nc-Portability-fixes-from-libressl-portable.patch deleted file mode 100644 index 2c3cb23d..00000000 --- a/pkg/openbsd/patch/0029-nc-Portability-fixes-from-libressl-portable.patch +++ /dev/null @@ -1,194 +0,0 @@ -From 074f2b35512b16c9644c8bd878fa9ace208c17a6 Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Mon, 2 Dec 2019 21:11:04 -0800 -Subject: [PATCH] nc: Portability fixes from libressl-portable - ---- - usr.bin/nc/netcat.c | 55 +++++++++++++++++++++++++++++++++++++++------ - 1 file changed, 48 insertions(+), 7 deletions(-) - -diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c -index 503095584ad..f052766213e 100644 ---- a/usr.bin/nc/netcat.c -+++ b/usr.bin/nc/netcat.c -@@ -93,9 +93,13 @@ int zflag; /* Port Scan Flag */ - int Dflag; /* sodebug */ - int Iflag; /* TCP receive buffer size */ - int Oflag; /* TCP send buffer size */ -+#ifdef TCP_MD5SIG - int Sflag; /* TCP MD5 signature option */ -+#endif - int Tflag = -1; /* IP Type of Service */ -+#ifdef SO_RTABLE - int rtableid = -1; -+#endif - - int usetls; /* use TLS */ - const char *Cflag; /* Public cert file */ -@@ -269,12 +273,14 @@ main(int argc, char *argv[]) - case 'u': - uflag = 1; - break; -+#ifdef SO_RTABLE - case 'V': - rtableid = (int)strtonum(optarg, 0, - RT_TABLEID_MAX, &errstr); - if (errstr) - errx(1, "rtable %s: %s", errstr, optarg); - break; -+#endif - case 'v': - vflag = 1; - break; -@@ -321,9 +327,11 @@ main(int argc, char *argv[]) - case 'o': - oflag = optarg; - break; -+#ifdef TCP_MD5SIG - case 'S': - Sflag = 1; - break; -+#endif - case 'T': - errstr = NULL; - errno = 0; -@@ -347,9 +355,11 @@ main(int argc, char *argv[]) - argc -= optind; - argv += optind; - -+#ifdef SO_RTABLE - if (rtableid >= 0) - if (setrtable(rtableid) == -1) - err(1, "setrtable"); -+#endif - - /* Cruft to make sure options are clean, and used properly. */ - if (argc == 1 && family == AF_UNIX) { -@@ -947,7 +957,10 @@ remote_connect(const char *host, const char *port, struct addrinfo hints, - char *ipaddr) - { - struct addrinfo *res, *res0; -- int s = -1, error, herr, on = 1, save_errno; -+ int s = -1, error, herr, save_errno; -+#ifdef SO_BINDANY -+ int on = 1; -+#endif - - if ((error = getaddrinfo(host, port, &hints, &res0))) - errx(1, "getaddrinfo for host \"%s\" port %s: %s", host, -@@ -962,8 +975,10 @@ remote_connect(const char *host, const char *port, struct addrinfo hints, - if (sflag || pflag) { - struct addrinfo ahints, *ares; - -+#ifdef SO_BINDANY - /* try SO_BINDANY, but don't insist */ - setsockopt(s, SOL_SOCKET, SO_BINDANY, &on, sizeof(on)); -+#endif - memset(&ahints, 0, sizeof(struct addrinfo)); - ahints.ai_family = res->ai_family; - ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; -@@ -1055,8 +1070,11 @@ int - local_listen(const char *host, const char *port, struct addrinfo hints) - { - struct addrinfo *res, *res0; -- int s = -1, ret, x = 1, save_errno; -+ int s = -1, save_errno; - int error; -+#ifdef SO_REUSEPORT -+ int ret, x = 1; -+#endif - - /* Allow nodename to be null. */ - hints.ai_flags |= AI_PASSIVE; -@@ -1076,9 +1094,11 @@ local_listen(const char *host, const char *port, struct addrinfo hints) - res->ai_protocol)) == -1) - continue; - -+#ifdef SO_REUSEPORT - ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); - if (ret == -1) - err(1, NULL); -+#endif - - set_common_sockopts(s, res->ai_family); - -@@ -1548,11 +1568,13 @@ set_common_sockopts(int s, int af) - { - int x = 1; - -+#ifdef TCP_MD5SIG - if (Sflag) { - if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG, - &x, sizeof(x)) == -1) - err(1, NULL); - } -+#endif - if (Dflag) { - if (setsockopt(s, SOL_SOCKET, SO_DEBUG, - &x, sizeof(x)) == -1) -@@ -1563,9 +1585,16 @@ set_common_sockopts(int s, int af) - IP_TOS, &Tflag, sizeof(Tflag)) == -1) - err(1, "set IP ToS"); - -+#ifdef IPV6_TCLASS - else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, - IPV6_TCLASS, &Tflag, sizeof(Tflag)) == -1) - err(1, "set IPv6 traffic class"); -+#else -+ else if (af == AF_INET6) { -+ errno = ENOPROTOOPT; -+ err(1, "set IPv6 traffic class not supported"); -+ } -+#endif - } - if (Iflag) { - if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, -@@ -1589,13 +1618,17 @@ set_common_sockopts(int s, int af) - } - - if (minttl != -1) { -+#ifdef IP_MINTTL - if (af == AF_INET && setsockopt(s, IPPROTO_IP, - IP_MINTTL, &minttl, sizeof(minttl))) - err(1, "set IP min TTL"); -+#endif - -- else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, -+#ifdef IPV6_MINHOPCOUNT -+ if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, - IPV6_MINHOPCOUNT, &minttl, sizeof(minttl))) - err(1, "set IPv6 min hop count"); -+#endif - } - } - -@@ -1820,14 +1853,22 @@ help(void) - \t-P proxyuser\tUsername for proxy authentication\n\ - \t-p port\t Specify local port for remote connects\n\ - \t-R CAfile CA bundle\n\ -- \t-r Randomize remote ports\n\ -- \t-S Enable the TCP MD5 signature option\n\ -+ \t-r Randomize remote ports\n" -+#ifdef TCP_MD5SIG -+ "\ -+ \t-S Enable the TCP MD5 signature option\n" -+#endif -+ "\ - \t-s sourceaddr Local source address\n\ - \t-T keyword TOS value or TLS options\n\ - \t-t Answer TELNET negotiation\n\ - \t-U Use UNIX domain socket\n\ -- \t-u UDP mode\n\ -- \t-V rtable Specify alternate routing table\n\ -+ \t-u UDP mode\n" -+#ifdef SO_RTABLE -+ "\ -+ \t-V rtable Specify alternate routing table\n" -+#endif -+ "\ - \t-v Verbose\n\ - \t-W recvlimit Terminate after receiving a number of packets\n\ - \t-w timeout Timeout for connects and final net reads\n\ --- -2.26.2 - diff --git a/pkg/openbsd/patch/0030-pax-Ignore-EOPNOTSUPP-from-fchmodat.patch b/pkg/openbsd/patch/0030-pax-Ignore-EOPNOTSUPP-from-fchmodat.patch deleted file mode 100644 index 2b0a5f22..00000000 --- a/pkg/openbsd/patch/0030-pax-Ignore-EOPNOTSUPP-from-fchmodat.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 0f49ae38698a163f7954d28bbaba473b6bf28239 Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Fri, 10 Jan 2020 21:40:03 -0800 -Subject: [PATCH] pax: Ignore EOPNOTSUPP from fchmodat - -Linux does not support changing the mode of symlinks. ---- - bin/pax/file_subs.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c -index 8aa3d249923..2c0994feca6 100644 ---- a/bin/pax/file_subs.c -+++ b/bin/pax/file_subs.c -@@ -795,7 +795,7 @@ void - set_pmode(char *fnm, mode_t mode) - { - mode &= ABITS; -- if (fchmodat(AT_FDCWD, fnm, mode, AT_SYMLINK_NOFOLLOW) == -1) -+ if (fchmodat(AT_FDCWD, fnm, mode, AT_SYMLINK_NOFOLLOW) == -1 && errno != EOPNOTSUPP) - syswarn(1, errno, "Could not set permissions on %s", fnm); - } - --- -2.26.2 - diff --git a/pkg/openbsd/patch/0030-rsync-Add-implementation-of-MD4.patch b/pkg/openbsd/patch/0030-rsync-Add-implementation-of-MD4.patch new file mode 100644 index 00000000..fc02ee8a --- /dev/null +++ b/pkg/openbsd/patch/0030-rsync-Add-implementation-of-MD4.patch @@ -0,0 +1,414 @@ +From 7fd1cb22e4d028d19ae1a02e50a6fac2c8e26773 Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Wed, 15 Apr 2020 22:10:06 -0700 +Subject: [PATCH] rsync: Add implementation of MD4 + +--- + usr.bin/rsync/Makefile | 6 +- + usr.bin/rsync/blocks.c | 2 +- + usr.bin/rsync/downloader.c | 2 +- + usr.bin/rsync/hash.c | 2 +- + usr.bin/rsync/md4.c | 266 +++++++++++++++++++++++++++++++++++++ + usr.bin/rsync/md4.h | 47 +++++++ + usr.bin/rsync/sender.c | 2 +- + 7 files changed, 320 insertions(+), 7 deletions(-) + create mode 100644 usr.bin/rsync/md4.c + create mode 100644 usr.bin/rsync/md4.h + +diff --git a/usr.bin/rsync/Makefile b/usr.bin/rsync/Makefile +index d7af8bd0a87..e04a0268392 100644 +--- a/usr.bin/rsync/Makefile ++++ b/usr.bin/rsync/Makefile +@@ -3,9 +3,9 @@ + PROG= openrsync + SRCS= blocks.c client.c downloader.c fargs.c flist.c hash.c ids.c \ + io.c log.c mkpath.c mktemp.c receiver.c sender.c server.c session.c \ +- socket.c symlinks.c uploader.c main.c misc.c +-LDADD+= -lcrypto -lm +-DPADD+= ${LIBCRYPTO} ${LIBM} ++ socket.c symlinks.c uploader.c main.c misc.c md4.c ++LDADD+= -lm ++DPADD+= ${LIBM} + MAN= openrsync.1 + + CFLAGS+=-g -W -Wall -Wextra +diff --git a/usr.bin/rsync/blocks.c b/usr.bin/rsync/blocks.c +index 242590e5bae..8c1564005e2 100644 +--- a/usr.bin/rsync/blocks.c ++++ b/usr.bin/rsync/blocks.c +@@ -26,7 +26,7 @@ + #include + #include + +-#include ++#include "md4.h" + + #include "extern.h" + +diff --git a/usr.bin/rsync/downloader.c b/usr.bin/rsync/downloader.c +index 36b086f74c8..26d1b531f85 100644 +--- a/usr.bin/rsync/downloader.c ++++ b/usr.bin/rsync/downloader.c +@@ -28,7 +28,7 @@ + #include + #include + +-#include ++#include "md4.h" + + #include "extern.h" + +diff --git a/usr.bin/rsync/hash.c b/usr.bin/rsync/hash.c +index edad21f13a6..6cb131b4b3e 100644 +--- a/usr.bin/rsync/hash.c ++++ b/usr.bin/rsync/hash.c +@@ -21,7 +21,7 @@ + #include + #include + +-#include ++#include "md4.h" + + #include "extern.h" + +diff --git a/usr.bin/rsync/md4.c b/usr.bin/rsync/md4.c +new file mode 100644 +index 00000000000..528f985563f +--- /dev/null ++++ b/usr.bin/rsync/md4.c +@@ -0,0 +1,266 @@ ++/* ++ * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. ++ * MD4 Message-Digest Algorithm (RFC 1320). ++ * ++ * Homepage: ++ * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md4 ++ * ++ * Author: ++ * Alexander Peslyak, better known as Solar Designer ++ * ++ * This software was written by Alexander Peslyak in 2001. No copyright is ++ * claimed, and the software is hereby placed in the public domain. ++ * In case this attempt to disclaim copyright and place the software in the ++ * public domain is deemed null and void, then the software is ++ * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the ++ * general public under the following terms: ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted. ++ * ++ * There's ABSOLUTELY NO WARRANTY, express or implied. ++ * ++ * (This is a heavily cut-down "BSD license".) ++ * ++ * This differs from Colin Plumb's older public domain implementation in that ++ * no exactly 32-bit integer data type is required (any 32-bit or wider ++ * unsigned integer data type will do), there's no compile-time endianness ++ * configuration, and the function prototypes match OpenSSL's. No code from ++ * Colin Plumb's implementation has been reused; this comment merely compares ++ * the properties of the two independent implementations. ++ * ++ * The primary goals of this implementation are portability and ease of use. ++ * It is meant to be fast, but not as fast as possible. Some known ++ * optimizations are not included to reduce source code size and avoid ++ * compile-time configuration. ++ */ ++ ++#include ++ ++#include "md4.h" ++ ++/* ++ * The basic MD4 functions. ++ * ++ * F and G are optimized compared to their RFC 1320 definitions, with the ++ * optimization for F borrowed from Colin Plumb's MD5 implementation. ++ */ ++#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) ++#define G(x, y, z) (((x) & ((y) | (z))) | ((y) & (z))) ++#define H(x, y, z) ((x) ^ (y) ^ (z)) ++ ++/* ++ * The MD4 transformation for all three rounds. ++ */ ++#define STEP(f, a, b, c, d, x, s) \ ++ (a) += f((b), (c), (d)) + (x); \ ++ (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); ++ ++/* ++ * SET reads 4 input bytes in little-endian byte order and stores them in a ++ * properly aligned word in host byte order. ++ * ++ * The check for little-endian architectures that tolerate unaligned memory ++ * accesses is just an optimization. Nothing will break if it fails to detect ++ * a suitable architecture. ++ * ++ * Unfortunately, this optimization may be a C strict aliasing rules violation ++ * if the caller's data buffer has effective type that cannot be aliased by ++ * MD4_u32plus. In practice, this problem may occur if these MD4 routines are ++ * inlined into a calling function, or with future and dangerously advanced ++ * link-time optimizations. For the time being, keeping these MD4 routines in ++ * their own translation unit avoids the problem. ++ */ ++#if defined(__i386__) || defined(__x86_64__) || defined(__vax__) ++#define SET(n) \ ++ (*(MD4_u32plus *)&ptr[(n) * 4]) ++#define GET(n) \ ++ SET(n) ++#else ++#define SET(n) \ ++ (ctx->block[(n)] = \ ++ (MD4_u32plus)ptr[(n) * 4] | \ ++ ((MD4_u32plus)ptr[(n) * 4 + 1] << 8) | \ ++ ((MD4_u32plus)ptr[(n) * 4 + 2] << 16) | \ ++ ((MD4_u32plus)ptr[(n) * 4 + 3] << 24)) ++#define GET(n) \ ++ (ctx->block[(n)]) ++#endif ++ ++/* ++ * This processes one or more 64-byte data blocks, but does NOT update the bit ++ * counters. There are no alignment requirements. ++ */ ++static const void *body(MD4_CTX *ctx, const void *data, unsigned long size) ++{ ++ const unsigned char *ptr; ++ MD4_u32plus a, b, c, d; ++ MD4_u32plus saved_a, saved_b, saved_c, saved_d; ++ const MD4_u32plus ac1 = 0x5a827999, ac2 = 0x6ed9eba1; ++ ++ ptr = (const unsigned char *)data; ++ ++ a = ctx->a; ++ b = ctx->b; ++ c = ctx->c; ++ d = ctx->d; ++ ++ do { ++ saved_a = a; ++ saved_b = b; ++ saved_c = c; ++ saved_d = d; ++ ++/* Round 1 */ ++ STEP(F, a, b, c, d, SET(0), 3) ++ STEP(F, d, a, b, c, SET(1), 7) ++ STEP(F, c, d, a, b, SET(2), 11) ++ STEP(F, b, c, d, a, SET(3), 19) ++ STEP(F, a, b, c, d, SET(4), 3) ++ STEP(F, d, a, b, c, SET(5), 7) ++ STEP(F, c, d, a, b, SET(6), 11) ++ STEP(F, b, c, d, a, SET(7), 19) ++ STEP(F, a, b, c, d, SET(8), 3) ++ STEP(F, d, a, b, c, SET(9), 7) ++ STEP(F, c, d, a, b, SET(10), 11) ++ STEP(F, b, c, d, a, SET(11), 19) ++ STEP(F, a, b, c, d, SET(12), 3) ++ STEP(F, d, a, b, c, SET(13), 7) ++ STEP(F, c, d, a, b, SET(14), 11) ++ STEP(F, b, c, d, a, SET(15), 19) ++ ++/* Round 2 */ ++ STEP(G, a, b, c, d, GET(0) + ac1, 3) ++ STEP(G, d, a, b, c, GET(4) + ac1, 5) ++ STEP(G, c, d, a, b, GET(8) + ac1, 9) ++ STEP(G, b, c, d, a, GET(12) + ac1, 13) ++ STEP(G, a, b, c, d, GET(1) + ac1, 3) ++ STEP(G, d, a, b, c, GET(5) + ac1, 5) ++ STEP(G, c, d, a, b, GET(9) + ac1, 9) ++ STEP(G, b, c, d, a, GET(13) + ac1, 13) ++ STEP(G, a, b, c, d, GET(2) + ac1, 3) ++ STEP(G, d, a, b, c, GET(6) + ac1, 5) ++ STEP(G, c, d, a, b, GET(10) + ac1, 9) ++ STEP(G, b, c, d, a, GET(14) + ac1, 13) ++ STEP(G, a, b, c, d, GET(3) + ac1, 3) ++ STEP(G, d, a, b, c, GET(7) + ac1, 5) ++ STEP(G, c, d, a, b, GET(11) + ac1, 9) ++ STEP(G, b, c, d, a, GET(15) + ac1, 13) ++ ++/* Round 3 */ ++ STEP(H, a, b, c, d, GET(0) + ac2, 3) ++ STEP(H, d, a, b, c, GET(8) + ac2, 9) ++ STEP(H, c, d, a, b, GET(4) + ac2, 11) ++ STEP(H, b, c, d, a, GET(12) + ac2, 15) ++ STEP(H, a, b, c, d, GET(2) + ac2, 3) ++ STEP(H, d, a, b, c, GET(10) + ac2, 9) ++ STEP(H, c, d, a, b, GET(6) + ac2, 11) ++ STEP(H, b, c, d, a, GET(14) + ac2, 15) ++ STEP(H, a, b, c, d, GET(1) + ac2, 3) ++ STEP(H, d, a, b, c, GET(9) + ac2, 9) ++ STEP(H, c, d, a, b, GET(5) + ac2, 11) ++ STEP(H, b, c, d, a, GET(13) + ac2, 15) ++ STEP(H, a, b, c, d, GET(3) + ac2, 3) ++ STEP(H, d, a, b, c, GET(11) + ac2, 9) ++ STEP(H, c, d, a, b, GET(7) + ac2, 11) ++ STEP(H, b, c, d, a, GET(15) + ac2, 15) ++ ++ a += saved_a; ++ b += saved_b; ++ c += saved_c; ++ d += saved_d; ++ ++ ptr += 64; ++ } while (size -= 64); ++ ++ ctx->a = a; ++ ctx->b = b; ++ ctx->c = c; ++ ctx->d = d; ++ ++ return ptr; ++} ++ ++void MD4_Init(MD4_CTX *ctx) ++{ ++ ctx->a = 0x67452301; ++ ctx->b = 0xefcdab89; ++ ctx->c = 0x98badcfe; ++ ctx->d = 0x10325476; ++ ++ ctx->lo = 0; ++ ctx->hi = 0; ++} ++ ++void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size) ++{ ++ MD4_u32plus saved_lo; ++ unsigned long used, available; ++ ++ saved_lo = ctx->lo; ++ if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) ++ ctx->hi++; ++ ctx->hi += size >> 29; ++ ++ used = saved_lo & 0x3f; ++ ++ if (used) { ++ available = 64 - used; ++ ++ if (size < available) { ++ memcpy(&ctx->buffer[used], data, size); ++ return; ++ } ++ ++ memcpy(&ctx->buffer[used], data, available); ++ data = (const unsigned char *)data + available; ++ size -= available; ++ body(ctx, ctx->buffer, 64); ++ } ++ ++ if (size >= 64) { ++ data = body(ctx, data, size & ~(unsigned long)0x3f); ++ size &= 0x3f; ++ } ++ ++ memcpy(ctx->buffer, data, size); ++} ++ ++#define OUT(dst, src) \ ++ (dst)[0] = (unsigned char)(src); \ ++ (dst)[1] = (unsigned char)((src) >> 8); \ ++ (dst)[2] = (unsigned char)((src) >> 16); \ ++ (dst)[3] = (unsigned char)((src) >> 24); ++ ++void MD4_Final(unsigned char *result, MD4_CTX *ctx) ++{ ++ unsigned long used, available; ++ ++ used = ctx->lo & 0x3f; ++ ++ ctx->buffer[used++] = 0x80; ++ ++ available = 64 - used; ++ ++ if (available < 8) { ++ memset(&ctx->buffer[used], 0, available); ++ body(ctx, ctx->buffer, 64); ++ used = 0; ++ available = 64; ++ } ++ ++ memset(&ctx->buffer[used], 0, available - 8); ++ ++ ctx->lo <<= 3; ++ OUT(&ctx->buffer[56], ctx->lo) ++ OUT(&ctx->buffer[60], ctx->hi) ++ ++ body(ctx, ctx->buffer, 64); ++ ++ OUT(&result[0], ctx->a) ++ OUT(&result[4], ctx->b) ++ OUT(&result[8], ctx->c) ++ OUT(&result[12], ctx->d) ++ ++ memset(ctx, 0, sizeof(*ctx)); ++} +diff --git a/usr.bin/rsync/md4.h b/usr.bin/rsync/md4.h +new file mode 100644 +index 00000000000..ebf5bb555a0 +--- /dev/null ++++ b/usr.bin/rsync/md4.h +@@ -0,0 +1,47 @@ ++/* ++ * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. ++ * MD4 Message-Digest Algorithm (RFC 1320). ++ * ++ * Homepage: ++ * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md4 ++ * ++ * Author: ++ * Alexander Peslyak, better known as Solar Designer ++ * ++ * This software was written by Alexander Peslyak in 2001. No copyright is ++ * claimed, and the software is hereby placed in the public domain. ++ * In case this attempt to disclaim copyright and place the software in the ++ * public domain is deemed null and void, then the software is ++ * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the ++ * general public under the following terms: ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted. ++ * ++ * There's ABSOLUTELY NO WARRANTY, express or implied. ++ * ++ * See md4.c for more information. ++ */ ++ ++#ifndef _MD4_H ++#define _MD4_H ++ ++#include ++ ++#define MD4_DIGEST_LENGTH 16 ++ ++/* Any 32-bit or wider unsigned integer data type will do */ ++typedef uint_fast32_t MD4_u32plus; ++ ++typedef struct { ++ MD4_u32plus lo, hi; ++ MD4_u32plus a, b, c, d; ++ unsigned char buffer[64]; ++ MD4_u32plus block[16]; ++} MD4_CTX; ++ ++extern void MD4_Init(MD4_CTX *ctx); ++extern void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size); ++extern void MD4_Final(unsigned char *result, MD4_CTX *ctx); ++ ++#endif +diff --git a/usr.bin/rsync/sender.c b/usr.bin/rsync/sender.c +index d6a1f55d1a9..3dacfc3709d 100644 +--- a/usr.bin/rsync/sender.c ++++ b/usr.bin/rsync/sender.c +@@ -26,7 +26,7 @@ + #include + #include + +-#include ++#include "md4.h" + + #include "extern.h" + +-- +2.26.1 + diff --git a/pkg/openbsd/patch/0031-acme-client-Fix-build-with-old-bison-versions.patch b/pkg/openbsd/patch/0031-acme-client-Fix-build-with-old-bison-versions.patch deleted file mode 100644 index 50639203..00000000 --- a/pkg/openbsd/patch/0031-acme-client-Fix-build-with-old-bison-versions.patch +++ /dev/null @@ -1,24 +0,0 @@ -From c3aab43559f17feb64a29f8b0d395532cb423e8b Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Wed, 15 Apr 2020 20:26:16 -0700 -Subject: [PATCH] acme-client: Fix build with old bison versions - ---- - usr.sbin/acme-client/parse.y | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/usr.sbin/acme-client/parse.y b/usr.sbin/acme-client/parse.y -index 20818328d92..f392e516b63 100644 ---- a/usr.sbin/acme-client/parse.y -+++ b/usr.sbin/acme-client/parse.y -@@ -97,6 +97,7 @@ typedef struct { - } v; - int lineno; - } YYSTYPE; -+#define YYSTYPE_IS_DECLARED 1 - - %} - --- -2.26.1 - diff --git a/pkg/openbsd/patch/0031-pax-Fix-some-incorrect-format-specifiers.patch b/pkg/openbsd/patch/0031-pax-Fix-some-incorrect-format-specifiers.patch new file mode 100644 index 00000000..05dd7d3a --- /dev/null +++ b/pkg/openbsd/patch/0031-pax-Fix-some-incorrect-format-specifiers.patch @@ -0,0 +1,48 @@ +From f855b534ca2c34c3691a0c89d1be482a33a3610c Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Thu, 4 Jun 2020 21:36:11 -0700 +Subject: [PATCH] pax: Fix some incorrect format specifiers + +--- + bin/pax/cpio.c | 2 +- + bin/pax/gen_subs.c | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c +index 3832b1e87aa..769a9dfb990 100644 +--- a/bin/pax/cpio.c ++++ b/bin/pax/cpio.c +@@ -214,7 +214,7 @@ rd_ln_nm(ARCHD *arcn) + */ + if ((arcn->sb.st_size <= 0) || + (arcn->sb.st_size >= (off_t)sizeof(arcn->ln_name))) { +- paxwarn(1, "Cpio link name length is invalid: %lld", ++ paxwarn(1, "Cpio link name length is invalid: %zu", + arcn->sb.st_size); + return(-1); + } +diff --git a/bin/pax/gen_subs.c b/bin/pax/gen_subs.c +index 405dd2c24ed..7eb82007e3b 100644 +--- a/bin/pax/gen_subs.c ++++ b/bin/pax/gen_subs.c +@@ -109,7 +109,7 @@ ls_list(ARCHD *arcn, time_t now, FILE *fp) + if (strftime(f_date, sizeof(f_date), TIMEFMT(sbp->st_mtime, now), + localtime(&(sbp->st_mtime))) == 0) + f_date[0] = '\0'; +- (void)fprintf(fp, "%s%2u %-*.*s %-*.*s ", f_mode, sbp->st_nlink, ++ (void)fprintf(fp, "%s%2u %-*.*s %-*.*s ", f_mode, (unsigned)sbp->st_nlink, + NAME_WIDTH, UT_NAMESIZE, user_from_uid(sbp->st_uid, 0), + NAME_WIDTH, UT_NAMESIZE, group_from_gid(sbp->st_gid, 0)); + +@@ -121,7 +121,7 @@ ls_list(ARCHD *arcn, time_t now, FILE *fp) + (unsigned long)MAJOR(sbp->st_rdev), + (unsigned long)MINOR(sbp->st_rdev)); + else { +- (void)fprintf(fp, "%9llu ", sbp->st_size); ++ (void)fprintf(fp, "%9zu ", sbp->st_size); + } + + /* +-- +2.27.0 + diff --git a/pkg/openbsd/patch/0032-pax-Use-memcpy-to-set-TMAGIC-and-TVERSION-to-avoid-w.patch b/pkg/openbsd/patch/0032-pax-Use-memcpy-to-set-TMAGIC-and-TVERSION-to-avoid-w.patch new file mode 100644 index 00000000..ecf17adb --- /dev/null +++ b/pkg/openbsd/patch/0032-pax-Use-memcpy-to-set-TMAGIC-and-TVERSION-to-avoid-w.patch @@ -0,0 +1,27 @@ +From b6eaf185d9a9c39e31c638ac162ec5f5a364e94d Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Thu, 4 Jun 2020 21:44:26 -0700 +Subject: [PATCH] pax: Use memcpy to set TMAGIC and TVERSION to avoid warning + +--- + bin/pax/tar.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/bin/pax/tar.c b/bin/pax/tar.c +index 8c9e4baea9c..c62705b2199 100644 +--- a/bin/pax/tar.c ++++ b/bin/pax/tar.c +@@ -1030,8 +1030,8 @@ ustar_wr(ARCHD *arcn) + break; + } + +- strncpy(hd->magic, TMAGIC, TMAGLEN); +- strncpy(hd->version, TVERSION, TVERSLEN); ++ memcpy(hd->magic, TMAGIC, TMAGLEN); ++ memcpy(hd->version, TVERSION, TVERSLEN); + + /* + * set the remaining fields. Some versions want all 16 bits of mode +-- +2.27.0 + diff --git a/pkg/openbsd/patch/0032-rsync-Add-implementation-of-MD4.patch b/pkg/openbsd/patch/0032-rsync-Add-implementation-of-MD4.patch deleted file mode 100644 index fc02ee8a..00000000 --- a/pkg/openbsd/patch/0032-rsync-Add-implementation-of-MD4.patch +++ /dev/null @@ -1,414 +0,0 @@ -From 7fd1cb22e4d028d19ae1a02e50a6fac2c8e26773 Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Wed, 15 Apr 2020 22:10:06 -0700 -Subject: [PATCH] rsync: Add implementation of MD4 - ---- - usr.bin/rsync/Makefile | 6 +- - usr.bin/rsync/blocks.c | 2 +- - usr.bin/rsync/downloader.c | 2 +- - usr.bin/rsync/hash.c | 2 +- - usr.bin/rsync/md4.c | 266 +++++++++++++++++++++++++++++++++++++ - usr.bin/rsync/md4.h | 47 +++++++ - usr.bin/rsync/sender.c | 2 +- - 7 files changed, 320 insertions(+), 7 deletions(-) - create mode 100644 usr.bin/rsync/md4.c - create mode 100644 usr.bin/rsync/md4.h - -diff --git a/usr.bin/rsync/Makefile b/usr.bin/rsync/Makefile -index d7af8bd0a87..e04a0268392 100644 ---- a/usr.bin/rsync/Makefile -+++ b/usr.bin/rsync/Makefile -@@ -3,9 +3,9 @@ - PROG= openrsync - SRCS= blocks.c client.c downloader.c fargs.c flist.c hash.c ids.c \ - io.c log.c mkpath.c mktemp.c receiver.c sender.c server.c session.c \ -- socket.c symlinks.c uploader.c main.c misc.c --LDADD+= -lcrypto -lm --DPADD+= ${LIBCRYPTO} ${LIBM} -+ socket.c symlinks.c uploader.c main.c misc.c md4.c -+LDADD+= -lm -+DPADD+= ${LIBM} - MAN= openrsync.1 - - CFLAGS+=-g -W -Wall -Wextra -diff --git a/usr.bin/rsync/blocks.c b/usr.bin/rsync/blocks.c -index 242590e5bae..8c1564005e2 100644 ---- a/usr.bin/rsync/blocks.c -+++ b/usr.bin/rsync/blocks.c -@@ -26,7 +26,7 @@ - #include - #include - --#include -+#include "md4.h" - - #include "extern.h" - -diff --git a/usr.bin/rsync/downloader.c b/usr.bin/rsync/downloader.c -index 36b086f74c8..26d1b531f85 100644 ---- a/usr.bin/rsync/downloader.c -+++ b/usr.bin/rsync/downloader.c -@@ -28,7 +28,7 @@ - #include - #include - --#include -+#include "md4.h" - - #include "extern.h" - -diff --git a/usr.bin/rsync/hash.c b/usr.bin/rsync/hash.c -index edad21f13a6..6cb131b4b3e 100644 ---- a/usr.bin/rsync/hash.c -+++ b/usr.bin/rsync/hash.c -@@ -21,7 +21,7 @@ - #include - #include - --#include -+#include "md4.h" - - #include "extern.h" - -diff --git a/usr.bin/rsync/md4.c b/usr.bin/rsync/md4.c -new file mode 100644 -index 00000000000..528f985563f ---- /dev/null -+++ b/usr.bin/rsync/md4.c -@@ -0,0 +1,266 @@ -+/* -+ * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. -+ * MD4 Message-Digest Algorithm (RFC 1320). -+ * -+ * Homepage: -+ * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md4 -+ * -+ * Author: -+ * Alexander Peslyak, better known as Solar Designer -+ * -+ * This software was written by Alexander Peslyak in 2001. No copyright is -+ * claimed, and the software is hereby placed in the public domain. -+ * In case this attempt to disclaim copyright and place the software in the -+ * public domain is deemed null and void, then the software is -+ * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the -+ * general public under the following terms: -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted. -+ * -+ * There's ABSOLUTELY NO WARRANTY, express or implied. -+ * -+ * (This is a heavily cut-down "BSD license".) -+ * -+ * This differs from Colin Plumb's older public domain implementation in that -+ * no exactly 32-bit integer data type is required (any 32-bit or wider -+ * unsigned integer data type will do), there's no compile-time endianness -+ * configuration, and the function prototypes match OpenSSL's. No code from -+ * Colin Plumb's implementation has been reused; this comment merely compares -+ * the properties of the two independent implementations. -+ * -+ * The primary goals of this implementation are portability and ease of use. -+ * It is meant to be fast, but not as fast as possible. Some known -+ * optimizations are not included to reduce source code size and avoid -+ * compile-time configuration. -+ */ -+ -+#include -+ -+#include "md4.h" -+ -+/* -+ * The basic MD4 functions. -+ * -+ * F and G are optimized compared to their RFC 1320 definitions, with the -+ * optimization for F borrowed from Colin Plumb's MD5 implementation. -+ */ -+#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) -+#define G(x, y, z) (((x) & ((y) | (z))) | ((y) & (z))) -+#define H(x, y, z) ((x) ^ (y) ^ (z)) -+ -+/* -+ * The MD4 transformation for all three rounds. -+ */ -+#define STEP(f, a, b, c, d, x, s) \ -+ (a) += f((b), (c), (d)) + (x); \ -+ (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); -+ -+/* -+ * SET reads 4 input bytes in little-endian byte order and stores them in a -+ * properly aligned word in host byte order. -+ * -+ * The check for little-endian architectures that tolerate unaligned memory -+ * accesses is just an optimization. Nothing will break if it fails to detect -+ * a suitable architecture. -+ * -+ * Unfortunately, this optimization may be a C strict aliasing rules violation -+ * if the caller's data buffer has effective type that cannot be aliased by -+ * MD4_u32plus. In practice, this problem may occur if these MD4 routines are -+ * inlined into a calling function, or with future and dangerously advanced -+ * link-time optimizations. For the time being, keeping these MD4 routines in -+ * their own translation unit avoids the problem. -+ */ -+#if defined(__i386__) || defined(__x86_64__) || defined(__vax__) -+#define SET(n) \ -+ (*(MD4_u32plus *)&ptr[(n) * 4]) -+#define GET(n) \ -+ SET(n) -+#else -+#define SET(n) \ -+ (ctx->block[(n)] = \ -+ (MD4_u32plus)ptr[(n) * 4] | \ -+ ((MD4_u32plus)ptr[(n) * 4 + 1] << 8) | \ -+ ((MD4_u32plus)ptr[(n) * 4 + 2] << 16) | \ -+ ((MD4_u32plus)ptr[(n) * 4 + 3] << 24)) -+#define GET(n) \ -+ (ctx->block[(n)]) -+#endif -+ -+/* -+ * This processes one or more 64-byte data blocks, but does NOT update the bit -+ * counters. There are no alignment requirements. -+ */ -+static const void *body(MD4_CTX *ctx, const void *data, unsigned long size) -+{ -+ const unsigned char *ptr; -+ MD4_u32plus a, b, c, d; -+ MD4_u32plus saved_a, saved_b, saved_c, saved_d; -+ const MD4_u32plus ac1 = 0x5a827999, ac2 = 0x6ed9eba1; -+ -+ ptr = (const unsigned char *)data; -+ -+ a = ctx->a; -+ b = ctx->b; -+ c = ctx->c; -+ d = ctx->d; -+ -+ do { -+ saved_a = a; -+ saved_b = b; -+ saved_c = c; -+ saved_d = d; -+ -+/* Round 1 */ -+ STEP(F, a, b, c, d, SET(0), 3) -+ STEP(F, d, a, b, c, SET(1), 7) -+ STEP(F, c, d, a, b, SET(2), 11) -+ STEP(F, b, c, d, a, SET(3), 19) -+ STEP(F, a, b, c, d, SET(4), 3) -+ STEP(F, d, a, b, c, SET(5), 7) -+ STEP(F, c, d, a, b, SET(6), 11) -+ STEP(F, b, c, d, a, SET(7), 19) -+ STEP(F, a, b, c, d, SET(8), 3) -+ STEP(F, d, a, b, c, SET(9), 7) -+ STEP(F, c, d, a, b, SET(10), 11) -+ STEP(F, b, c, d, a, SET(11), 19) -+ STEP(F, a, b, c, d, SET(12), 3) -+ STEP(F, d, a, b, c, SET(13), 7) -+ STEP(F, c, d, a, b, SET(14), 11) -+ STEP(F, b, c, d, a, SET(15), 19) -+ -+/* Round 2 */ -+ STEP(G, a, b, c, d, GET(0) + ac1, 3) -+ STEP(G, d, a, b, c, GET(4) + ac1, 5) -+ STEP(G, c, d, a, b, GET(8) + ac1, 9) -+ STEP(G, b, c, d, a, GET(12) + ac1, 13) -+ STEP(G, a, b, c, d, GET(1) + ac1, 3) -+ STEP(G, d, a, b, c, GET(5) + ac1, 5) -+ STEP(G, c, d, a, b, GET(9) + ac1, 9) -+ STEP(G, b, c, d, a, GET(13) + ac1, 13) -+ STEP(G, a, b, c, d, GET(2) + ac1, 3) -+ STEP(G, d, a, b, c, GET(6) + ac1, 5) -+ STEP(G, c, d, a, b, GET(10) + ac1, 9) -+ STEP(G, b, c, d, a, GET(14) + ac1, 13) -+ STEP(G, a, b, c, d, GET(3) + ac1, 3) -+ STEP(G, d, a, b, c, GET(7) + ac1, 5) -+ STEP(G, c, d, a, b, GET(11) + ac1, 9) -+ STEP(G, b, c, d, a, GET(15) + ac1, 13) -+ -+/* Round 3 */ -+ STEP(H, a, b, c, d, GET(0) + ac2, 3) -+ STEP(H, d, a, b, c, GET(8) + ac2, 9) -+ STEP(H, c, d, a, b, GET(4) + ac2, 11) -+ STEP(H, b, c, d, a, GET(12) + ac2, 15) -+ STEP(H, a, b, c, d, GET(2) + ac2, 3) -+ STEP(H, d, a, b, c, GET(10) + ac2, 9) -+ STEP(H, c, d, a, b, GET(6) + ac2, 11) -+ STEP(H, b, c, d, a, GET(14) + ac2, 15) -+ STEP(H, a, b, c, d, GET(1) + ac2, 3) -+ STEP(H, d, a, b, c, GET(9) + ac2, 9) -+ STEP(H, c, d, a, b, GET(5) + ac2, 11) -+ STEP(H, b, c, d, a, GET(13) + ac2, 15) -+ STEP(H, a, b, c, d, GET(3) + ac2, 3) -+ STEP(H, d, a, b, c, GET(11) + ac2, 9) -+ STEP(H, c, d, a, b, GET(7) + ac2, 11) -+ STEP(H, b, c, d, a, GET(15) + ac2, 15) -+ -+ a += saved_a; -+ b += saved_b; -+ c += saved_c; -+ d += saved_d; -+ -+ ptr += 64; -+ } while (size -= 64); -+ -+ ctx->a = a; -+ ctx->b = b; -+ ctx->c = c; -+ ctx->d = d; -+ -+ return ptr; -+} -+ -+void MD4_Init(MD4_CTX *ctx) -+{ -+ ctx->a = 0x67452301; -+ ctx->b = 0xefcdab89; -+ ctx->c = 0x98badcfe; -+ ctx->d = 0x10325476; -+ -+ ctx->lo = 0; -+ ctx->hi = 0; -+} -+ -+void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size) -+{ -+ MD4_u32plus saved_lo; -+ unsigned long used, available; -+ -+ saved_lo = ctx->lo; -+ if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) -+ ctx->hi++; -+ ctx->hi += size >> 29; -+ -+ used = saved_lo & 0x3f; -+ -+ if (used) { -+ available = 64 - used; -+ -+ if (size < available) { -+ memcpy(&ctx->buffer[used], data, size); -+ return; -+ } -+ -+ memcpy(&ctx->buffer[used], data, available); -+ data = (const unsigned char *)data + available; -+ size -= available; -+ body(ctx, ctx->buffer, 64); -+ } -+ -+ if (size >= 64) { -+ data = body(ctx, data, size & ~(unsigned long)0x3f); -+ size &= 0x3f; -+ } -+ -+ memcpy(ctx->buffer, data, size); -+} -+ -+#define OUT(dst, src) \ -+ (dst)[0] = (unsigned char)(src); \ -+ (dst)[1] = (unsigned char)((src) >> 8); \ -+ (dst)[2] = (unsigned char)((src) >> 16); \ -+ (dst)[3] = (unsigned char)((src) >> 24); -+ -+void MD4_Final(unsigned char *result, MD4_CTX *ctx) -+{ -+ unsigned long used, available; -+ -+ used = ctx->lo & 0x3f; -+ -+ ctx->buffer[used++] = 0x80; -+ -+ available = 64 - used; -+ -+ if (available < 8) { -+ memset(&ctx->buffer[used], 0, available); -+ body(ctx, ctx->buffer, 64); -+ used = 0; -+ available = 64; -+ } -+ -+ memset(&ctx->buffer[used], 0, available - 8); -+ -+ ctx->lo <<= 3; -+ OUT(&ctx->buffer[56], ctx->lo) -+ OUT(&ctx->buffer[60], ctx->hi) -+ -+ body(ctx, ctx->buffer, 64); -+ -+ OUT(&result[0], ctx->a) -+ OUT(&result[4], ctx->b) -+ OUT(&result[8], ctx->c) -+ OUT(&result[12], ctx->d) -+ -+ memset(ctx, 0, sizeof(*ctx)); -+} -diff --git a/usr.bin/rsync/md4.h b/usr.bin/rsync/md4.h -new file mode 100644 -index 00000000000..ebf5bb555a0 ---- /dev/null -+++ b/usr.bin/rsync/md4.h -@@ -0,0 +1,47 @@ -+/* -+ * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. -+ * MD4 Message-Digest Algorithm (RFC 1320). -+ * -+ * Homepage: -+ * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md4 -+ * -+ * Author: -+ * Alexander Peslyak, better known as Solar Designer -+ * -+ * This software was written by Alexander Peslyak in 2001. No copyright is -+ * claimed, and the software is hereby placed in the public domain. -+ * In case this attempt to disclaim copyright and place the software in the -+ * public domain is deemed null and void, then the software is -+ * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the -+ * general public under the following terms: -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted. -+ * -+ * There's ABSOLUTELY NO WARRANTY, express or implied. -+ * -+ * See md4.c for more information. -+ */ -+ -+#ifndef _MD4_H -+#define _MD4_H -+ -+#include -+ -+#define MD4_DIGEST_LENGTH 16 -+ -+/* Any 32-bit or wider unsigned integer data type will do */ -+typedef uint_fast32_t MD4_u32plus; -+ -+typedef struct { -+ MD4_u32plus lo, hi; -+ MD4_u32plus a, b, c, d; -+ unsigned char buffer[64]; -+ MD4_u32plus block[16]; -+} MD4_CTX; -+ -+extern void MD4_Init(MD4_CTX *ctx); -+extern void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size); -+extern void MD4_Final(unsigned char *result, MD4_CTX *ctx); -+ -+#endif -diff --git a/usr.bin/rsync/sender.c b/usr.bin/rsync/sender.c -index d6a1f55d1a9..3dacfc3709d 100644 ---- a/usr.bin/rsync/sender.c -+++ b/usr.bin/rsync/sender.c -@@ -26,7 +26,7 @@ - #include - #include - --#include -+#include "md4.h" - - #include "extern.h" - --- -2.26.1 - diff --git a/pkg/openbsd/patch/0033-pax-Fix-some-incorrect-format-specifiers.patch b/pkg/openbsd/patch/0033-pax-Fix-some-incorrect-format-specifiers.patch deleted file mode 100644 index 05dd7d3a..00000000 --- a/pkg/openbsd/patch/0033-pax-Fix-some-incorrect-format-specifiers.patch +++ /dev/null @@ -1,48 +0,0 @@ -From f855b534ca2c34c3691a0c89d1be482a33a3610c Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Thu, 4 Jun 2020 21:36:11 -0700 -Subject: [PATCH] pax: Fix some incorrect format specifiers - ---- - bin/pax/cpio.c | 2 +- - bin/pax/gen_subs.c | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c -index 3832b1e87aa..769a9dfb990 100644 ---- a/bin/pax/cpio.c -+++ b/bin/pax/cpio.c -@@ -214,7 +214,7 @@ rd_ln_nm(ARCHD *arcn) - */ - if ((arcn->sb.st_size <= 0) || - (arcn->sb.st_size >= (off_t)sizeof(arcn->ln_name))) { -- paxwarn(1, "Cpio link name length is invalid: %lld", -+ paxwarn(1, "Cpio link name length is invalid: %zu", - arcn->sb.st_size); - return(-1); - } -diff --git a/bin/pax/gen_subs.c b/bin/pax/gen_subs.c -index 405dd2c24ed..7eb82007e3b 100644 ---- a/bin/pax/gen_subs.c -+++ b/bin/pax/gen_subs.c -@@ -109,7 +109,7 @@ ls_list(ARCHD *arcn, time_t now, FILE *fp) - if (strftime(f_date, sizeof(f_date), TIMEFMT(sbp->st_mtime, now), - localtime(&(sbp->st_mtime))) == 0) - f_date[0] = '\0'; -- (void)fprintf(fp, "%s%2u %-*.*s %-*.*s ", f_mode, sbp->st_nlink, -+ (void)fprintf(fp, "%s%2u %-*.*s %-*.*s ", f_mode, (unsigned)sbp->st_nlink, - NAME_WIDTH, UT_NAMESIZE, user_from_uid(sbp->st_uid, 0), - NAME_WIDTH, UT_NAMESIZE, group_from_gid(sbp->st_gid, 0)); - -@@ -121,7 +121,7 @@ ls_list(ARCHD *arcn, time_t now, FILE *fp) - (unsigned long)MAJOR(sbp->st_rdev), - (unsigned long)MINOR(sbp->st_rdev)); - else { -- (void)fprintf(fp, "%9llu ", sbp->st_size); -+ (void)fprintf(fp, "%9zu ", sbp->st_size); - } - - /* --- -2.27.0 - diff --git a/pkg/openbsd/patch/0033-rsync-Fix-some-incorrect-format-specifiers.patch b/pkg/openbsd/patch/0033-rsync-Fix-some-incorrect-format-specifiers.patch new file mode 100644 index 00000000..278aabbd --- /dev/null +++ b/pkg/openbsd/patch/0033-rsync-Fix-some-incorrect-format-specifiers.patch @@ -0,0 +1,25 @@ +From 02cf1f8b022fd8c27eeb312ee3d649f4157899d6 Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Thu, 4 Jun 2020 21:36:24 -0700 +Subject: [PATCH] rsync: Fix some incorrect format specifiers + +--- + usr.bin/rsync/uploader.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/usr.bin/rsync/uploader.c b/usr.bin/rsync/uploader.c +index db8bc626ae2..d1ebb7bcf1b 100644 +--- a/usr.bin/rsync/uploader.c ++++ b/usr.bin/rsync/uploader.c +@@ -942,7 +942,7 @@ rsync_uploader(struct upload *u, int *fileinfd, + init_blk(&blk.blks[i], &blk, offs, i, mbuf, sess); + offs += blk.len; + LOG3( +- "i=%ld, offs=%lld, msz=%ld, blk.len=%lu, blk.rem=%lu", ++ "i=%zu, offs=%td, msz=%zd, blk.len=%zu, blk.rem=%zu", + i, offs, msz, blk.len, blk.rem); + i++; + } while (i < blk.blksz); +-- +2.31.1 + diff --git a/pkg/openbsd/patch/0034-m4-Declare-dopaste-only-when-it-s-used.patch b/pkg/openbsd/patch/0034-m4-Declare-dopaste-only-when-it-s-used.patch new file mode 100644 index 00000000..3d3ccfd2 --- /dev/null +++ b/pkg/openbsd/patch/0034-m4-Declare-dopaste-only-when-it-s-used.patch @@ -0,0 +1,26 @@ +From 666a050e706230ba5b0316a316100d8c7e86c93c Mon Sep 17 00:00:00 2001 +From: Michael Forney +Date: Thu, 4 Jun 2020 21:42:18 -0700 +Subject: [PATCH] m4: Declare dopaste only when it's used + +--- + usr.bin/m4/eval.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c +index d226505cab3..fe9fbde3d9c 100644 +--- a/usr.bin/m4/eval.c ++++ b/usr.bin/m4/eval.c +@@ -61,7 +61,9 @@ static void dodump(const char *[], int); + static void dotrace(const char *[], int, int); + static void doifelse(const char *[], int); + static int doincl(const char *); ++#ifdef EXTENDED + static int dopaste(const char *); ++#endif + static void dochq(const char *[], int); + static void dochc(const char *[], int); + static void dom4wrap(const char *); +-- +2.27.0 + diff --git a/pkg/openbsd/patch/0034-pax-Use-memcpy-to-set-TMAGIC-and-TVERSION-to-avoid-w.patch b/pkg/openbsd/patch/0034-pax-Use-memcpy-to-set-TMAGIC-and-TVERSION-to-avoid-w.patch deleted file mode 100644 index ecf17adb..00000000 --- a/pkg/openbsd/patch/0034-pax-Use-memcpy-to-set-TMAGIC-and-TVERSION-to-avoid-w.patch +++ /dev/null @@ -1,27 +0,0 @@ -From b6eaf185d9a9c39e31c638ac162ec5f5a364e94d Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Thu, 4 Jun 2020 21:44:26 -0700 -Subject: [PATCH] pax: Use memcpy to set TMAGIC and TVERSION to avoid warning - ---- - bin/pax/tar.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/bin/pax/tar.c b/bin/pax/tar.c -index 8c9e4baea9c..c62705b2199 100644 ---- a/bin/pax/tar.c -+++ b/bin/pax/tar.c -@@ -1030,8 +1030,8 @@ ustar_wr(ARCHD *arcn) - break; - } - -- strncpy(hd->magic, TMAGIC, TMAGLEN); -- strncpy(hd->version, TVERSION, TVERSLEN); -+ memcpy(hd->magic, TMAGIC, TMAGLEN); -+ memcpy(hd->version, TVERSION, TVERSLEN); - - /* - * set the remaining fields. Some versions want all 16 bits of mode --- -2.27.0 - diff --git a/pkg/openbsd/patch/0035-rsync-Fix-some-incorrect-format-specifiers.patch b/pkg/openbsd/patch/0035-rsync-Fix-some-incorrect-format-specifiers.patch deleted file mode 100644 index 14d9a008..00000000 --- a/pkg/openbsd/patch/0035-rsync-Fix-some-incorrect-format-specifiers.patch +++ /dev/null @@ -1,25 +0,0 @@ -From dbec208559b72489671f119e695a4c340a288803 Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Thu, 4 Jun 2020 21:36:24 -0700 -Subject: [PATCH] rsync: Fix some incorrect format specifiers - ---- - usr.bin/rsync/uploader.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/usr.bin/rsync/uploader.c b/usr.bin/rsync/uploader.c -index 38d5d24fcc7..bf82896d221 100644 ---- a/usr.bin/rsync/uploader.c -+++ b/usr.bin/rsync/uploader.c -@@ -945,7 +945,7 @@ rsync_uploader(struct upload *u, int *fileinfd, - init_blk(&blk.blks[i], &blk, offs, i, mbuf, sess); - offs += blk.len; - LOG3( -- "i=%ld, offs=%lld, msz=%ld, blk.len=%lu, blk.rem=%lu", -+ "i=%zu, offs=%td, msz=%zd, blk.len=%zu, blk.rem=%zu", - i, offs, msz, blk.len, blk.rem); - i++; - } while (i < blk.blksz); --- -2.27.0 - diff --git a/pkg/openbsd/patch/0036-m4-Declare-dopaste-only-when-it-s-used.patch b/pkg/openbsd/patch/0036-m4-Declare-dopaste-only-when-it-s-used.patch deleted file mode 100644 index 3d3ccfd2..00000000 --- a/pkg/openbsd/patch/0036-m4-Declare-dopaste-only-when-it-s-used.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 666a050e706230ba5b0316a316100d8c7e86c93c Mon Sep 17 00:00:00 2001 -From: Michael Forney -Date: Thu, 4 Jun 2020 21:42:18 -0700 -Subject: [PATCH] m4: Declare dopaste only when it's used - ---- - usr.bin/m4/eval.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c -index d226505cab3..fe9fbde3d9c 100644 ---- a/usr.bin/m4/eval.c -+++ b/usr.bin/m4/eval.c -@@ -61,7 +61,9 @@ static void dodump(const char *[], int); - static void dotrace(const char *[], int, int); - static void doifelse(const char *[], int); - static int doincl(const char *); -+#ifdef EXTENDED - static int dopaste(const char *); -+#endif - static void dochq(const char *[], int); - static void dochc(const char *[], int); - static void dom4wrap(const char *); --- -2.27.0 - diff --git a/pkg/openbsd/sha256 b/pkg/openbsd/sha256 index c2c2230a..219071ee 100644 --- a/pkg/openbsd/sha256 +++ b/pkg/openbsd/sha256 @@ -1,2 +1,2 @@ -90b76b58040f0ec9a9d08a5c979720d5d91a46f3e69fd710abd1a21b9960c226 src.tar.gz -e2bf77273a99c8ed4030806c8546bf8dc8ece0cf31e784aed2001e8e8227a8ab sys.tar.gz +eb06c8c1e0edf003af279ec31f7b67692dbf80aabd99dccde557be523e41761b src.tar.gz +e1a41a8290a68ff1ffb0851606ce8edf96093b44824136b1d131d0f3a81f4993 sys.tar.gz diff --git a/pkg/openbsd/url b/pkg/openbsd/url index c529035a..2d2daf4a 100644 --- a/pkg/openbsd/url +++ b/pkg/openbsd/url @@ -1,5 +1,5 @@ remote-name -url = "https://fastly.cdn.openbsd.org/pub/OpenBSD/6.8/src.tar.gz" +url = "https://fastly.cdn.openbsd.org/pub/OpenBSD/6.9/src.tar.gz" remote-name -url = "https://fastly.cdn.openbsd.org/pub/OpenBSD/6.8/sys.tar.gz" +url = "https://fastly.cdn.openbsd.org/pub/OpenBSD/6.9/sys.tar.gz" diff --git a/pkg/openbsd/ver b/pkg/openbsd/ver index c5038090..1d694169 100644 --- a/pkg/openbsd/ver +++ b/pkg/openbsd/ver @@ -1 +1 @@ -6.8 r2 +6.9 r0 -- cgit v1.2.3