From 9e7f51724c4d7542648bc4872aa09f6c35b7e36f Mon Sep 17 00:00:00 2001 From: purplerain Date: Wed, 17 May 2023 13:56:02 +0000 Subject: [PATCH] sync --- lib/libcrypto/bn/bn_isqrt.c | 6 +- lib/libcrypto/crypto_internal.h | 55 ++++++-- lib/libcrypto/crypto_lock.c | 7 +- lib/libcrypto/sha/sha512.c | 121 +++++++----------- regress/usr.bin/ssh/Makefile | 10 +- sbin/fdisk/gpt.c | 4 +- sbin/fdisk/mbr.c | 8 +- sbin/fdisk/part.c | 6 +- sbin/fdisk/part.h | 6 +- sys/net/toeplitz.h | 6 +- usr.sbin/pkg_add/OpenBSD/Delete.pm | 4 +- usr.sbin/pkg_add/OpenBSD/Error.pm | 8 +- usr.sbin/pkg_add/OpenBSD/Getopt.pm | 4 +- usr.sbin/pkg_add/OpenBSD/PackageInfo.pm | 8 +- usr.sbin/pkg_add/OpenBSD/PackageName.pm | 4 +- usr.sbin/pkg_add/OpenBSD/PackageRepository.pm | 14 +- .../pkg_add/OpenBSD/PackageRepository/HTTP.pm | 8 +- .../OpenBSD/PackageRepository/Installed.pm | 4 +- .../pkg_add/OpenBSD/PackageRepository/SCP.pm | 6 +- usr.sbin/pkg_add/OpenBSD/Paths.pm | 100 +++++++-------- usr.sbin/pkg_add/OpenBSD/PkgCfl.pm | 10 +- usr.sbin/pkg_add/OpenBSD/PkgCreate.pm | 24 ++-- usr.sbin/pkg_add/OpenBSD/RequiredBy.pm | 6 +- usr.sbin/pkg_add/OpenBSD/Signer.pm | 4 +- 24 files changed, 225 insertions(+), 208 deletions(-) diff --git a/lib/libcrypto/bn/bn_isqrt.c b/lib/libcrypto/bn/bn_isqrt.c index 4a757b02c..1dff1b056 100644 --- a/lib/libcrypto/bn/bn_isqrt.c +++ b/lib/libcrypto/bn/bn_isqrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_isqrt.c,v 1.7 2023/03/27 10:25:02 tb Exp $ */ +/* $OpenBSD: bn_isqrt.c,v 1.8 2023/05/17 07:42:38 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler * @@ -22,9 +22,7 @@ #include #include "bn_local.h" - -#define CTASSERT(x) extern char _ctassert[(x) ? 1 : -1 ] \ - __attribute__((__unused__)) +#include "crypto_internal.h" /* * Calculate integer square root of |n| using a variant of Newton's method. diff --git a/lib/libcrypto/crypto_internal.h b/lib/libcrypto/crypto_internal.h index 24a06256d..2e6ab8269 100644 --- a/lib/libcrypto/crypto_internal.h +++ b/lib/libcrypto/crypto_internal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_internal.h,v 1.3 2023/04/14 10:42:51 jsing Exp $ */ +/* $OpenBSD: crypto_internal.h,v 1.4 2023/05/17 06:37:14 jsing Exp $ */ /* * Copyright (c) 2023 Joel Sing * @@ -22,14 +22,34 @@ #ifndef HEADER_CRYPTO_INTERNAL_H #define HEADER_CRYPTO_INTERNAL_H +#define CTASSERT(x) \ + extern char _ctassert[(x) ? 1 : -1] __attribute__((__unused__)) + /* - * crypto_store_htobe32() stores a 32 bit unsigned host endian value - * as a 32 bit unsigned big endian value, at the specified location in - * memory. The memory location may have any alignment. + * crypto_load_be32toh() loads a 32 bit unsigned big endian value as a 32 bit + * unsigned host endian value, from the specified address in memory. The memory + * address may have any alignment. + */ +#ifndef HAVE_CRYPTO_LOAD_BE32TOH +static inline uint32_t +crypto_load_be32toh(const void *src) +{ + uint32_t v; + + memcpy(&v, src, sizeof(v)); + + return be32toh(v); +} +#endif + +/* + * crypto_store_htobe32() stores a 32 bit unsigned host endian value as a 32 bit + * unsigned big endian value, at the specified address in memory. The memory + * address may have any alignment. */ #ifndef HAVE_CRYPTO_STORE_HTOBE32 static inline void -crypto_store_htobe32(uint8_t *dst, uint32_t v) +crypto_store_htobe32(void *dst, uint32_t v) { v = htobe32(v); memcpy(dst, &v, sizeof(v)); @@ -37,13 +57,30 @@ crypto_store_htobe32(uint8_t *dst, uint32_t v) #endif /* - * crypto_store_htobe64() stores a 64 bit unsigned host endian value - * as a 64 bit unsigned big endian value, at the specified location in - * memory. The memory location may have any alignment. + * crypto_load_be64toh() loads a 64 bit unsigned big endian value as a 64 bit + * unsigned host endian value, from the specified address in memory. The memory + * address may have any alignment. + */ +#ifndef HAVE_CRYPTO_LOAD_BE64TOH +static inline uint64_t +crypto_load_be64toh(const void *src) +{ + uint64_t v; + + memcpy(&v, src, sizeof(v)); + + return be64toh(v); +} +#endif + +/* + * crypto_store_htobe64() stores a 64 bit unsigned host endian value as a 64 bit + * unsigned big endian value, at the specified address in memory. The memory + * address may have any alignment. */ #ifndef HAVE_CRYPTO_STORE_HTOBE64 static inline void -crypto_store_htobe64(uint8_t *dst, uint64_t v) +crypto_store_htobe64(void *dst, uint64_t v) { v = htobe64(v); memcpy(dst, &v, sizeof(v)); diff --git a/lib/libcrypto/crypto_lock.c b/lib/libcrypto/crypto_lock.c index 5d317a81c..5b1d1b090 100644 --- a/lib/libcrypto/crypto_lock.c +++ b/lib/libcrypto/crypto_lock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_lock.c,v 1.2 2018/11/28 15:51:32 jsing Exp $ */ +/* $OpenBSD: crypto_lock.c,v 1.3 2023/05/17 07:42:38 tb Exp $ */ /* * Copyright (c) 2018 Brent Cook * @@ -19,6 +19,8 @@ #include +#include "crypto_internal.h" + static pthread_mutex_t locks[] = { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, @@ -63,9 +65,6 @@ static pthread_mutex_t locks[] = { PTHREAD_MUTEX_INITIALIZER, }; -#define CTASSERT(x) extern char _ctassert[(x) ? 1 : -1 ] \ - __attribute__((__unused__)) - CTASSERT((sizeof(locks) / sizeof(*locks)) == CRYPTO_NUM_LOCKS); void diff --git a/lib/libcrypto/sha/sha512.c b/lib/libcrypto/sha/sha512.c index c0752bd2c..c88ef057d 100644 --- a/lib/libcrypto/sha/sha512.c +++ b/lib/libcrypto/sha/sha512.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sha512.c,v 1.36 2023/05/16 07:04:57 jsing Exp $ */ +/* $OpenBSD: sha512.c,v 1.37 2023/05/17 06:37:14 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. * @@ -66,9 +66,8 @@ #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA512) -#if !defined(__STRICT_ALIGNMENT) || defined(SHA512_ASM) -#define SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA -#endif +/* Ensure that SHA_LONG64 and uint64_t are equivalent. */ +CTASSERT(sizeof(SHA_LONG64) == sizeof(uint64_t)); #ifdef SHA512_ASM void sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num); @@ -118,31 +117,6 @@ static const SHA_LONG64 K512[80] = { U64(0x5fcb6fab3ad6faec), U64(0x6c44198c4a475817), }; -#if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) -# if defined(__x86_64) || defined(__x86_64__) -# define PULL64(x) ({ SHA_LONG64 ret=*((const SHA_LONG64 *)(&(x))); \ - asm ("bswapq %0" \ - : "=r"(ret) \ - : "0"(ret)); ret; }) -# elif (defined(__i386) || defined(__i386__)) -# define PULL64(x) ({ const unsigned int *p=(const unsigned int *)(&(x));\ - unsigned int hi=p[0],lo=p[1]; \ - asm ("bswapl %0; bswapl %1;" \ - : "=r"(lo),"=r"(hi) \ - : "0"(lo),"1"(hi)); \ - ((SHA_LONG64)hi)<<32|lo; }) -# endif -#endif - -#ifndef PULL64 -#if BYTE_ORDER == BIG_ENDIAN -#define PULL64(x) (x) -#else -#define B(x, j) (((SHA_LONG64)(*(((const unsigned char *)(&x))+j)))<<((7-j)*8)) -#define PULL64(x) (B(x,0)|B(x,1)|B(x,2)|B(x,3)|B(x,4)|B(x,5)|B(x,6)|B(x,7)) -#endif -#endif - #define ROTR(x, s) crypto_ror_u64(x, s) #define Sigma0(x) (ROTR((x),28) ^ ROTR((x),34) ^ ROTR((x),39)) @@ -185,37 +159,60 @@ sha512_block_data_order(SHA512_CTX *ctx, const void *_in, size_t num) g = ctx->h[6]; h = ctx->h[7]; - X[0] = PULL64(in[0]); + if ((uintptr_t)in % sizeof(SHA_LONG64) == 0) { + /* Input is 64 bit aligned. */ + X[0] = be64toh(in[0]); + X[1] = be64toh(in[1]); + X[2] = be64toh(in[2]); + X[3] = be64toh(in[3]); + X[4] = be64toh(in[4]); + X[5] = be64toh(in[5]); + X[6] = be64toh(in[6]); + X[7] = be64toh(in[7]); + X[8] = be64toh(in[8]); + X[9] = be64toh(in[9]); + X[10] = be64toh(in[10]); + X[11] = be64toh(in[11]); + X[12] = be64toh(in[12]); + X[13] = be64toh(in[13]); + X[14] = be64toh(in[14]); + X[15] = be64toh(in[15]); + } else { + /* Input is not 64 bit aligned. */ + X[0] = crypto_load_be64toh(&in[0]); + X[1] = crypto_load_be64toh(&in[1]); + X[2] = crypto_load_be64toh(&in[2]); + X[3] = crypto_load_be64toh(&in[3]); + X[4] = crypto_load_be64toh(&in[4]); + X[5] = crypto_load_be64toh(&in[5]); + X[6] = crypto_load_be64toh(&in[6]); + X[7] = crypto_load_be64toh(&in[7]); + X[8] = crypto_load_be64toh(&in[8]); + X[9] = crypto_load_be64toh(&in[9]); + X[10] = crypto_load_be64toh(&in[10]); + X[11] = crypto_load_be64toh(&in[11]); + X[12] = crypto_load_be64toh(&in[12]); + X[13] = crypto_load_be64toh(&in[13]); + X[14] = crypto_load_be64toh(&in[14]); + X[15] = crypto_load_be64toh(&in[15]); + } + in += SHA_LBLOCK; + ROUND_00_15(0, a, b, c, d, e, f, g, h, X[0]); - X[1] = PULL64(in[1]); ROUND_00_15(1, h, a, b, c, d, e, f, g, X[1]); - X[2] = PULL64(in[2]); ROUND_00_15(2, g, h, a, b, c, d, e, f, X[2]); - X[3] = PULL64(in[3]); ROUND_00_15(3, f, g, h, a, b, c, d, e, X[3]); - X[4] = PULL64(in[4]); ROUND_00_15(4, e, f, g, h, a, b, c, d, X[4]); - X[5] = PULL64(in[5]); ROUND_00_15(5, d, e, f, g, h, a, b, c, X[5]); - X[6] = PULL64(in[6]); ROUND_00_15(6, c, d, e, f, g, h, a, b, X[6]); - X[7] = PULL64(in[7]); ROUND_00_15(7, b, c, d, e, f, g, h, a, X[7]); - X[8] = PULL64(in[8]); ROUND_00_15(8, a, b, c, d, e, f, g, h, X[8]); - X[9] = PULL64(in[9]); ROUND_00_15(9, h, a, b, c, d, e, f, g, X[9]); - X[10] = PULL64(in[10]); ROUND_00_15(10, g, h, a, b, c, d, e, f, X[10]); - X[11] = PULL64(in[11]); ROUND_00_15(11, f, g, h, a, b, c, d, e, X[11]); - X[12] = PULL64(in[12]); ROUND_00_15(12, e, f, g, h, a, b, c, d, X[12]); - X[13] = PULL64(in[13]); ROUND_00_15(13, d, e, f, g, h, a, b, c, X[13]); - X[14] = PULL64(in[14]); ROUND_00_15(14, c, d, e, f, g, h, a, b, X[14]); - X[15] = PULL64(in[15]); ROUND_00_15(15, b, c, d, e, f, g, h, a, X[15]); for (i = 16; i < 80; i += 16) { @@ -245,8 +242,6 @@ sha512_block_data_order(SHA512_CTX *ctx, const void *_in, size_t num) ctx->h[5] += f; ctx->h[6] += g; ctx->h[7] += h; - - in += SHA_LBLOCK; } } @@ -323,21 +318,15 @@ SHA512_Init(SHA512_CTX *c) void SHA512_Transform(SHA512_CTX *c, const unsigned char *data) { -#ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA - if ((size_t)data % sizeof(c->u.d[0]) != 0) { - memcpy(c->u.p, data, sizeof(c->u.p)); - data = c->u.p; - } -#endif sha512_block_data_order(c, data, 1); } int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len) { - SHA_LONG64 l; - unsigned char *p = c->u.p; - const unsigned char *data = (const unsigned char *)_data; + const unsigned char *data = _data; + unsigned char *p = c->u.p; + SHA_LONG64 l; if (len == 0) return 1; @@ -366,22 +355,10 @@ SHA512_Update(SHA512_CTX *c, const void *_data, size_t len) } if (len >= sizeof(c->u)) { -#ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA - if ((size_t)data % sizeof(c->u.d[0]) != 0) { - while (len >= sizeof(c->u)) { - memcpy(p, data, sizeof(c->u)); - sha512_block_data_order(c, p, 1); - len -= sizeof(c->u); - data += sizeof(c->u); - } - } else -#endif - { - sha512_block_data_order(c, data, len/sizeof(c->u)); - data += len; - len %= sizeof(c->u); - data -= len; - } + sha512_block_data_order(c, data, len/sizeof(c->u)); + data += len; + len %= sizeof(c->u); + data -= len; } if (len != 0) { diff --git a/regress/usr.bin/ssh/Makefile b/regress/usr.bin/ssh/Makefile index 8ae0d0dfc..006f79d9b 100644 --- a/regress/usr.bin/ssh/Makefile +++ b/regress/usr.bin/ssh/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.124 2023/03/01 09:29:32 dtucker Exp $ +# $OpenBSD: Makefile,v 1.125 2023/05/17 05:52:01 djm Exp $ OPENSSL?= yes @@ -13,7 +13,7 @@ REGRESS_SETUP_ONCE=misc # For sk-dummy.so REGRESS_FAIL_EARLY?= yes # Key conversion operations are not supported when built w/out OpenSSL. -.if ${OPENSSL:L} != no +.if !defined(LTESTS_FROM) && ${OPENSSL:L} != no REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 .endif @@ -221,8 +221,14 @@ t-${t}: timestamp sh ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/${t}.sh .endfor +.undef LTESTS_STARTED .for t in ${LTESTS} +.if defined(LTESTS_FROM) && ${LTESTS_FROM} == t-${t} +LTESTS_STARTED=yes +.endif +.if !defined(LTESTS_FROM) || defined(LTESTS_STARTED) REGRESS_TARGETS+=t-${t} +.endif .endfor .for t in ${INTEROP_TESTS} diff --git a/sbin/fdisk/gpt.c b/sbin/fdisk/gpt.c index e1f9aef26..ad7f44e49 100644 --- a/sbin/fdisk/gpt.c +++ b/sbin/fdisk/gpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gpt.c,v 1.90 2023/05/10 12:59:47 krw Exp $ */ +/* $OpenBSD: gpt.c,v 1.91 2023/05/17 12:59:37 krw Exp $ */ /* * Copyright (c) 2015 Markus Muller * Copyright (c) 2015 Kenneth R Westerback @@ -132,7 +132,7 @@ protective_mbr(const struct mbr *mbr) for (i = 0; i < nitems(dp); i++) { memset(&dos_partition, 0, sizeof(dos_partition)); if (i < nitems(mbr->mbr_prt)) - PRT_make(&mbr->mbr_prt[i], mbr->mbr_lba_self, + PRT_prt_to_dp(&mbr->mbr_prt[i], mbr->mbr_lba_self, mbr->mbr_lba_firstembr, &dos_partition); memcpy(&dp[i], &dos_partition, sizeof(dp[i])); } diff --git a/sbin/fdisk/mbr.c b/sbin/fdisk/mbr.c index b7aeea00d..4b6af10ff 100644 --- a/sbin/fdisk/mbr.c +++ b/sbin/fdisk/mbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbr.c,v 1.123 2023/03/06 13:24:40 krw Exp $ */ +/* $OpenBSD: mbr.c,v 1.124 2023/05/17 12:59:37 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -64,7 +64,7 @@ MBR_init(struct mbr *mbr) bootprt = disk.dk_bootprt; } else { memcpy(&dp, &default_dmbr.dmbr_parts[0], sizeof(dp)); - PRT_parse(&dp, 0, 0, &bootprt); + PRT_dp_to_prt(&dp, 0, 0, &bootprt); } if (bootprt.prt_ns > 0) { @@ -123,7 +123,7 @@ dos_mbr_to_mbr(const struct dos_mbr *dmbr, const uint64_t lba_self, for (i = 0; i < nitems(mbr->mbr_prt); i++) { memset(&mbr->mbr_prt[i], 0, sizeof(mbr->mbr_prt[i])); if (i < nitems(dmbr->dmbr_parts)) - PRT_parse(&dos_parts[i], lba_self, lba_firstembr, + PRT_dp_to_prt(&dos_parts[i], lba_self, lba_firstembr, &mbr->mbr_prt[i]); } } @@ -140,7 +140,7 @@ mbr_to_dos_mbr(const struct mbr *mbr, struct dos_mbr *dos_mbr) for (i = 0; i < nitems(dos_mbr->dmbr_parts); i++) { memset(&dos_partition, 0, sizeof(dos_partition)); if (i < nitems(mbr->mbr_prt)) { - PRT_make(&mbr->mbr_prt[i], mbr->mbr_lba_self, + PRT_prt_to_dp(&mbr->mbr_prt[i], mbr->mbr_lba_self, mbr->mbr_lba_firstembr, &dos_partition); } memcpy(&dos_mbr->dmbr_parts[i], &dos_partition, diff --git a/sbin/fdisk/part.c b/sbin/fdisk/part.c index bb9929aa8..ba0b9d46f 100644 --- a/sbin/fdisk/part.c +++ b/sbin/fdisk/part.c @@ -1,4 +1,4 @@ -/* $OpenBSD: part.c,v 1.161 2023/05/10 13:45:49 krw Exp $ */ +/* $OpenBSD: part.c,v 1.162 2023/05/17 12:59:37 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -951,7 +951,7 @@ PRT_print_gptmenu(char *lbuf, size_t lbuflen) } void -PRT_parse(const struct dos_partition *dp, const uint64_t lba_self, +PRT_dp_to_prt(const struct dos_partition *dp, const uint64_t lba_self, const uint64_t lba_firstembr, struct prt *prt) { off_t off; @@ -974,7 +974,7 @@ PRT_parse(const struct dos_partition *dp, const uint64_t lba_self, } void -PRT_make(const struct prt *prt, const uint64_t lba_self, +PRT_prt_to_dp(const struct prt *prt, const uint64_t lba_self, const uint64_t lba_firstembr, struct dos_partition *dp) { struct chs start, end; diff --git a/sbin/fdisk/part.h b/sbin/fdisk/part.h index a0c5e618b..f4fb574de 100644 --- a/sbin/fdisk/part.h +++ b/sbin/fdisk/part.h @@ -1,4 +1,4 @@ -/* $OpenBSD: part.h,v 1.45 2023/04/09 17:19:59 krw Exp $ */ +/* $OpenBSD: part.h,v 1.46 2023/05/17 12:59:37 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -31,9 +31,9 @@ struct prt { void PRT_print_mbrmenu(char *, size_t); void PRT_print_gptmenu(char *, size_t); -void PRT_parse(const struct dos_partition *, const uint64_t, +void PRT_dp_to_prt(const struct dos_partition *, const uint64_t, const uint64_t, struct prt *); -void PRT_make(const struct prt *,const uint64_t, const uint64_t, +void PRT_prt_to_dp(const struct prt *,const uint64_t, const uint64_t, struct dos_partition *); void PRT_print_part(const int, const struct prt *, const char *); void PRT_print_parthdr(void); diff --git a/sys/net/toeplitz.h b/sys/net/toeplitz.h index 030608284..52933eb30 100644 --- a/sys/net/toeplitz.h +++ b/sys/net/toeplitz.h @@ -1,4 +1,4 @@ -/* $OpenBSD: toeplitz.h,v 1.10 2022/12/27 20:13:03 patrick Exp $ */ +/* $OpenBSD: toeplitz.h,v 1.11 2023/05/17 10:22:17 dlg Exp $ */ /* * Copyright (c) 2019 David Gwynne @@ -92,9 +92,9 @@ stoeplitz_hash_h16(const struct stoeplitz_cache *scache, uint16_t h16) } static __unused inline uint16_t -stoeplitz_hash_h32(const struct stoeplitz_cache *scache, uint64_t h32) +stoeplitz_hash_h32(const struct stoeplitz_cache *scache, uint32_t h32) { - return (stoeplitz_hash_h16(scache, h32 & (h32 >> 16))); + return (stoeplitz_hash_h16(scache, h32 ^ (h32 >> 16))); } static __unused inline uint16_t diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm index 7b8a8924b..2b085fa76 100644 --- a/usr.sbin/pkg_add/OpenBSD/Delete.pm +++ b/usr.sbin/pkg_add/OpenBSD/Delete.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Delete.pm,v 1.165 2022/06/09 09:27:11 espie Exp $ +# $OpenBSD: Delete.pm,v 1.166 2023/05/17 15:51:58 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie # @@ -360,7 +360,7 @@ sub delete } } -sub should_run() { 1 } +sub should_run { 1 } package OpenBSD::PackingElement::UnexecDelete; sub should_run diff --git a/usr.sbin/pkg_add/OpenBSD/Error.pm b/usr.sbin/pkg_add/OpenBSD/Error.pm index 8ea48fc8a..0b9f16de1 100644 --- a/usr.sbin/pkg_add/OpenBSD/Error.pm +++ b/usr.sbin/pkg_add/OpenBSD/Error.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Error.pm,v 1.40 2019/07/24 18:05:26 espie Exp $ +# $OpenBSD: Error.pm,v 1.41 2023/05/17 15:51:58 espie Exp $ # # Copyright (c) 2004-2010 Marc Espie # @@ -20,7 +20,7 @@ use warnings; # this is a set of common classes related to error handling in pkg land package OpenBSD::Auto; -sub cache(*&) +sub cache :prototype(*&) { my ($sym, $code) = @_; my $callpkg = caller; @@ -170,7 +170,7 @@ sub dienow } } -sub try(&@) +sub try :prototype(&@) { my ($try, $catch) = @_; eval { &$try }; @@ -189,7 +189,7 @@ sub rethrow die $e if $e; } -sub catch(&) +sub catch :prototype(&) { bless $_[0], "OpenBSD::Error::catch"; } diff --git a/usr.sbin/pkg_add/OpenBSD/Getopt.pm b/usr.sbin/pkg_add/OpenBSD/Getopt.pm index 2de3b1f1a..d25bf2b58 100644 --- a/usr.sbin/pkg_add/OpenBSD/Getopt.pm +++ b/usr.sbin/pkg_add/OpenBSD/Getopt.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Getopt.pm,v 1.12 2012/04/10 16:57:12 espie Exp $ +# $OpenBSD: Getopt.pm,v 1.13 2023/05/17 15:51:58 espie Exp $ # # Copyright (c) 2006 Marc Espie # @@ -48,7 +48,7 @@ sub handle_option } } -sub getopts($;$) +sub getopts { my ($args, $hash) = @_; diff --git a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm index a79a216d1..b27b91068 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageInfo.pm,v 1.63 2022/02/15 07:35:35 espie Exp $ +# $OpenBSD: PackageInfo.pm,v 1.64 2023/05/17 15:51:58 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie # @@ -174,7 +174,7 @@ sub installed_name return $name; } -sub info_names() +sub info_names { return @info; } @@ -187,7 +187,7 @@ sub is_info_name my $dlock; -sub lock_db($;$) +sub lock_db { my ($shared, $state) = @_; my $mode = $shared ? LOCK_SH : LOCK_EX; @@ -206,7 +206,7 @@ sub lock_db($;$) return; } -sub unlock_db() +sub unlock_db { if (defined $dlock) { flock($dlock, LOCK_UN); diff --git a/usr.sbin/pkg_add/OpenBSD/PackageName.pm b/usr.sbin/pkg_add/OpenBSD/PackageName.pm index 58894c954..4cbe0b6bf 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageName.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageName.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageName.pm,v 1.56 2021/11/25 18:23:53 espie Exp $ +# $OpenBSD: PackageName.pm,v 1.57 2023/05/17 15:51:58 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie # @@ -20,7 +20,7 @@ use warnings; package OpenBSD::PackageName; -sub url2pkgname($) +sub url2pkgname { my $name = $_[0]; $name =~ s|.*/||; diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm index 97785d69a..1c62eb5cb 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageRepository.pm,v 1.172 2022/05/08 13:21:04 espie Exp $ +# $OpenBSD: PackageRepository.pm,v 1.173 2023/05/17 15:51:58 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie # @@ -101,12 +101,12 @@ sub dont_cleanup { } -sub ftp() { 'OpenBSD::PackageRepository::FTP' } -sub http() { 'OpenBSD::PackageRepository::HTTP' } -sub https() { 'OpenBSD::PackageRepository::HTTPS' } -sub scp() { 'OpenBSD::PackageRepository::SCP' } -sub file() { 'OpenBSD::PackageRepository::Local' } -sub installed() { 'OpenBSD::PackageRepository::Installed' } +sub ftp { 'OpenBSD::PackageRepository::FTP' } +sub http { 'OpenBSD::PackageRepository::HTTP' } +sub https { 'OpenBSD::PackageRepository::HTTPS' } +sub scp { 'OpenBSD::PackageRepository::SCP' } +sub file { 'OpenBSD::PackageRepository::Local' } +sub installed { 'OpenBSD::PackageRepository::Installed' } sub parse { diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository/HTTP.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository/HTTP.pm index 7f7e2be06..e57951dbe 100755 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository/HTTP.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository/HTTP.pm @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: HTTP.pm,v 1.13 2017/08/04 11:53:03 sthen Exp $ +# $OpenBSD: HTTP.pm,v 1.14 2023/05/17 15:51:58 espie Exp $ # # Copyright (c) 2011 Marc Espie # @@ -124,7 +124,7 @@ sub get_header $h->{'Transfer-Encoding'} eq 'chunked') { $h->{chunked} = 1; } - if (defined $h->{'Content-Range'} && + if (defined $h->{'Content-Range'} && $h->{'Content-Range'} =~ m/^bytes\s+(\d+)\-(\d+)\/(\d+)/) { ($h->{start}, $h->{end}, $h->{size}) = ($1, $2, $3); } @@ -232,7 +232,7 @@ package _Proxy; my $pid; my $token = 0; -sub batch(&) +sub batch { my $code = shift; if (defined $pid) { @@ -250,7 +250,7 @@ sub batch(&) } } -sub abort_batch() +sub abort_batch { if (defined $pid) { kill HUP => $pid; diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm index 5f2dc0fc9..31667b208 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Installed.pm,v 1.44 2022/05/08 13:21:04 espie Exp $ +# $OpenBSD: Installed.pm,v 1.45 2023/05/17 15:45:36 espie Exp $ # # Copyright (c) 2007-2014 Marc Espie # @@ -75,7 +75,7 @@ sub setup_cache # with the corresponding release if (defined $repo->{release}) { my $url = $repo->urlscheme."://$repo->{host}$repo->{release}"; - my $r2 = $repo->parse_url(\$url, $state); + my $r2 = OpenBSD::PackageRepository->parse(\$url, $state); $r2->{info_cache} = $repo->{info_cache}; } } diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm index 519f0fd88..adab12a74 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: SCP.pm,v 1.29 2014/08/27 18:40:03 kspillner Exp $ +# $OpenBSD: SCP.pm,v 1.30 2023/05/17 15:51:58 espie Exp $ # # Copyright (c) 2003-2006 Marc Espie # @@ -64,7 +64,7 @@ my $pid; my $token = 0; $|= 1; -sub batch(&) +sub batch { my $code = shift; if (defined $pid) { @@ -82,7 +82,7 @@ sub batch(&) } } -sub abort_batch() +sub abort_batch { if (defined $pid) { kill 1, $pid; diff --git a/usr.sbin/pkg_add/OpenBSD/Paths.pm b/usr.sbin/pkg_add/OpenBSD/Paths.pm index 7b7a59d92..1d673e088 100644 --- a/usr.sbin/pkg_add/OpenBSD/Paths.pm +++ b/usr.sbin/pkg_add/OpenBSD/Paths.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Paths.pm,v 1.37 2022/04/13 21:19:16 espie Exp $ +# $OpenBSD: Paths.pm,v 1.38 2023/05/17 15:51:58 espie Exp $ # # Copyright (c) 2007-2014 Marc Espie # @@ -21,61 +21,61 @@ use warnings; package OpenBSD::Paths; # Commands -sub ldconfig() { '/sbin/ldconfig' } -sub chroot() { '/usr/sbin/chroot' } -sub mkfontscale() { '/usr/X11R6/bin/mkfontscale' } -sub mkfontdir() { '/usr/X11R6/bin/mkfontdir' } -sub fc_cache() { '/usr/X11R6/bin/fc-cache' } -sub install_info() { '/usr/bin/install-info' } -sub useradd() { '/usr/sbin/useradd' } -sub groupadd() { '/usr/sbin/groupadd' } -sub sysctl() { '/sbin/sysctl' } -sub openssl() { '/usr/bin/openssl' } -sub pkgca() { '/etc/ssl/pkgca.pem' } -sub signify() { '/usr/bin/signify' } +sub ldconfig { '/sbin/ldconfig' } +sub chroot { '/usr/sbin/chroot' } +sub mkfontscale { '/usr/X11R6/bin/mkfontscale' } +sub mkfontdir { '/usr/X11R6/bin/mkfontdir' } +sub fc_cache { '/usr/X11R6/bin/fc-cache' } +sub install_info { '/usr/bin/install-info' } +sub useradd { '/usr/sbin/useradd' } +sub groupadd { '/usr/sbin/groupadd' } +sub sysctl { '/sbin/sysctl' } +sub openssl { '/usr/bin/openssl' } +sub pkgca { '/etc/ssl/pkgca.pem' } +sub signify { '/usr/bin/signify' } sub signifykey { my $s = $_[1]; "/etc/signify/$s.pub" } -sub pkg_add() { '/usr/sbin/pkg_add' } -sub chmod() { '/bin/chmod' } # external command is used for symbolic modes. -sub gzip() { '/usr/bin/gzip' } -sub ftp() { $ENV{'FETCH_CMD'} || '/usr/bin/ftp' } -sub groff() { '/usr/local/bin/groff' } -sub sh() { '/bin/sh' } -sub arch() { '/usr/bin/arch' } -sub uname() { '/usr/bin/uname' } -sub userdel() { '/usr/sbin/userdel' } -sub groupdel() { '/usr/sbin/groupdel' } -sub makewhatis() { '/usr/sbin/makewhatis' } -sub mknod() { '/sbin/mknod' } -sub mount() { '/sbin/mount' } -sub df() { '/bin/df' } -sub ssh() { '/usr/bin/ssh' } -sub make() { '/usr/bin/make' } -sub mklocatedb() { '/usr/libexec/locate.mklocatedb' } -sub locate() { '/usr/bin/locate' } -sub hostname() { '/bin/hostname' } -sub doas() { '/usr/bin/doas' } -sub env() { '/usr/bin/env' } -sub du() { '/usr/bin/du' } -sub diff() { '/usr/bin/diff' } -sub sha256() { '/bin/sha256' } +sub pkg_add { '/usr/sbin/pkg_add' } +sub chmod { '/bin/chmod' } # external command is used for symbolic modes. +sub gzip { '/usr/bin/gzip' } +sub ftp { $ENV{'FETCH_CMD'} || '/usr/bin/ftp' } +sub groff { '/usr/local/bin/groff' } +sub sh { '/bin/sh' } +sub arch { '/usr/bin/arch' } +sub uname { '/usr/bin/uname' } +sub userdel { '/usr/sbin/userdel' } +sub groupdel { '/usr/sbin/groupdel' } +sub makewhatis { '/usr/sbin/makewhatis' } +sub mknod { '/sbin/mknod' } +sub mount { '/sbin/mount' } +sub df { '/bin/df' } +sub ssh { '/usr/bin/ssh' } +sub make { '/usr/bin/make' } +sub mklocatedb { '/usr/libexec/locate.mklocatedb' } +sub locate { '/usr/bin/locate' } +sub hostname { '/bin/hostname' } +sub doas { '/usr/bin/doas' } +sub env { '/usr/bin/env' } +sub du { '/usr/bin/du' } +sub diff { '/usr/bin/diff' } +sub sha256 { '/bin/sha256' } # Various paths -sub shells() { '/etc/shells' } -sub pkgdb() { '/var/db/pkg' } -sub localbase() { '/usr/local' } -sub vartmp() { '/tmp' } -sub portsdir() { '/usr/ports' } +sub shells { '/etc/shells' } +sub pkgdb { '/var/db/pkg' } +sub localbase { '/usr/local' } +sub vartmp { '/tmp' } +sub portsdir { '/usr/ports' } -sub library_dirs() { ("/usr", "/usr/X11R6") } -sub master_keys() { ("/etc/master_key") } -sub installurl() { "/etc/installurl" } -sub srclocatedb() { "/usr/lib/locate/src.db" } -sub xlocatedb() { "/usr/X11R6/lib/locate/xorg.db" } +sub library_dirs { ("/usr", "/usr/X11R6") } +sub master_keys { ("/etc/master_key") } +sub installurl { "/etc/installurl" } +sub srclocatedb { "/usr/lib/locate/src.db" } +sub xlocatedb { "/usr/X11R6/lib/locate/xorg.db" } sub updateinfodb { '/usr/local/share/update.db' } -sub font_cruft() { ("fonts.alias", "fonts.dir", "fonts.cache-1", "fonts.scale") } -sub man_cruft() { ("whatis.db", "mandoc.db", "mandoc.index") } -sub info_cruft() { ("dir") } +sub font_cruft { ("fonts.alias", "fonts.dir", "fonts.cache-1", "fonts.scale") } +sub man_cruft { ("whatis.db", "mandoc.db", "mandoc.index") } +sub info_cruft { ("dir") } # a bit of code, OS-dependent stuff that's run-time detected and has no # home yet. diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm b/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm index bdc5c77e2..19b8c0958 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgCfl.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PkgCfl.pm,v 1.39 2014/02/01 10:53:17 espie Exp $ +# $OpenBSD: PkgCfl.pm,v 1.40 2023/05/17 15:51:58 espie Exp $ # # Copyright (c) 2003-2005 Marc Espie # @@ -68,20 +68,20 @@ sub conflicts_with } } -sub register($$) +sub register { my ($plist, $state) = @_; $state->{conflict_list}{$plist->pkgname} = $plist->conflict_list; } -sub unregister($$) +sub unregister { my ($plist, $state) = @_; delete $state->{conflict_list}{$plist->pkgname}; } -sub fill_conflict_lists($) +sub fill_conflict_lists { my $state = shift; for my $pkg (installed_packages()) { @@ -96,7 +96,7 @@ sub fill_conflict_lists($) } } -sub find($$) +sub find { my ($pkgname, $state) = @_; my @bad = (); diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm index 3149f3d6d..eebcd249e 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgCreate.pm,v 1.186 2023/05/16 14:30:55 espie Exp $ +# $OpenBSD: PkgCreate.pm,v 1.187 2023/05/17 15:51:58 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie # @@ -250,7 +250,7 @@ sub register_forbidden } } -sub is_forbidden() { 0 } +sub is_forbidden { 0 } sub resolve_link { my ($filename, $base, $level) = @_; @@ -507,7 +507,7 @@ sub prepare_for_archival return $o; } -sub forbidden() { 1 } +sub forbidden { 1 } sub register_for_archival { @@ -842,31 +842,31 @@ sub check_version } package OpenBSD::PackingElement::DigitalSignature; -sub is_forbidden() { 1 } +sub is_forbidden { 1 } package OpenBSD::PackingElement::Signer; -sub is_forbidden() { 1 } +sub is_forbidden { 1 } package OpenBSD::PackingElement::ExtraInfo; -sub is_forbidden() { 1 } +sub is_forbidden { 1 } package OpenBSD::PackingElement::ManualInstallation; -sub is_forbidden() { 1 } +sub is_forbidden { 1 } package OpenBSD::PackingElement::Firmware; -sub is_forbidden() { 1 } +sub is_forbidden { 1 } package OpenBSD::PackingElement::Url; -sub is_forbidden() { 1 } +sub is_forbidden { 1 } package OpenBSD::PackingElement::Arch; -sub is_forbidden() { 1 } +sub is_forbidden { 1 } package OpenBSD::PackingElement::LocalBase; -sub is_forbidden() { 1 } +sub is_forbidden { 1 } package OpenBSD::PackingElement::Version; -sub is_forbidden() { 1 } +sub is_forbidden { 1 } # put together file and filename, in order to handle fragments simply package MyFile; diff --git a/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm b/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm index 2937f8514..a109b91df 100644 --- a/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm +++ b/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: RequiredBy.pm,v 1.28 2023/05/04 14:02:44 espie Exp $ +# $OpenBSD: RequiredBy.pm,v 1.29 2023/05/17 15:51:58 espie Exp $ # # Copyright (c) 2003-2005 Marc Espie # @@ -166,12 +166,12 @@ package OpenBSD::RequiredBy; our @ISA=qw(OpenBSD::RequirementList); use OpenBSD::PackageInfo; -sub filename() { REQUIRED_BY }; +sub filename { REQUIRED_BY }; package OpenBSD::Requiring; our @ISA=qw(OpenBSD::RequirementList); use OpenBSD::PackageInfo; -sub filename() { REQUIRING }; +sub filename { REQUIRING }; 1; diff --git a/usr.sbin/pkg_add/OpenBSD/Signer.pm b/usr.sbin/pkg_add/OpenBSD/Signer.pm index 343035d9c..fa093ab81 100644 --- a/usr.sbin/pkg_add/OpenBSD/Signer.pm +++ b/usr.sbin/pkg_add/OpenBSD/Signer.pm @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: Signer.pm,v 1.10 2016/10/03 13:17:30 espie Exp $ +# $OpenBSD: Signer.pm,v 1.11 2023/05/17 15:51:58 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie # @@ -19,7 +19,7 @@ use strict; use warnings; -# code necessary to create signed package +# code necessary to create signed packages # the factory that chooses what method to use to sign things package OpenBSD::Signer;