aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pkg
Commit message (Collapse)AuthorAgeFilesLines
* pkg: include missing <string.h>Kyle Evans2025-01-121-0/+1
| | | | | | | | | | My local environment seems to be seeing some pollution; we need <string.h> for strlen. PR: 284021 Fixes: 2e065d74a5b0e ("pkg: add a pkgsign_verify_data [...]") (cherry picked from commit b8770ce1dfed52fcb7249cdf3cf4d4d16357b9fd)
* pkg: finish adding the ECC signer and signature type bitsKyle Evans2025-01-114-20/+711
| | | | | | | | | | | | | Signature types need to be parsed out of the key/signature information that we are presented with from the files we download. We use that to understand whicher signer we need to dispatch to. The ECC signer is more-or-less lifted from pkg(8), with some changes to slim it down for pkg(7). Reviewed by: bapt (cherry picked from commit 3d0a0dda3a7d57bbd4eaf65ba8da0f2a36089c0e)
* pkg: add a pkgsign_verify_data callbackKyle Evans2025-01-113-19/+65
| | | | | | | | | | | | | This will be used to verify raw payloads, as if signed by pkg-key(8). It will be used specifically in pkg(7) to verify .pubkeysig as published by poudriere. Amend verify_pubsignature() now to use it. For the RSA signer, we need to verify using a sha256 of the data instead of the data itself. Reviewed by: bapt (cherry picked from commit 2e065d74a5b0ea32db7d4f6e3f78eaa17ee7685e)
* pkg: abstract rsa out behind a pkgsign APIKyle Evans2025-01-113-9/+110
| | | | | | | | | This mirrors a change we made in pkg(8), and will be used to next add another signer that does ECC. Reviewed by: bapt, emaste (cherry picked from commit 5862580ded35e23581291a2e1052f04428369ead)
* pkg: refactor out a pkg_read_fd()Kyle Evans2025-01-112-13/+29
| | | | | | | | | | We already have to do this for reading the pubkey, just pull it out for other uses. The ECC signer will use this to verify the bootstrap if the PUBKEY mechanism is used. Reviewed by: bapt, emaste (cherry picked from commit 2ecfc040a09f8c42f67bbfdcc4bd02ef84dac8b7)
* pkg: pull rsa bits out of pkg.cKyle Evans2025-01-114-130/+207
| | | | | | | | | We'll eventually add a pkgsign abstraction over these similar to how we do in pkg(8), but start by isolating these parts. Reviewed by: bapt, emaste (cherry picked from commit 2629e90dd05fb69d767525f960101d7d055ffae0)
* pkg: Allocate a suitably-sized string for the local ABIJohn Baldwin2024-11-301-9/+12
| | | | | | | | | | | | | | | | | | Previously the local ABI string was written to an on-stack buffer and the pointer to that buffer was saved in a global before the function returned. This had two issues: c[ABI].val pointed to a no-longer-valid on-stack buffer after config_init returned, and the string could potentially be truncated. Fix both of those by changing pkg_get_myabi to return a pointer to a string allocated by asprintf. Note that the allocated string is left in the global config array until it is implicitly freed on process exit. Reported by: GCC 13 -Wdangling-pointer Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D42623 (cherry picked from commit fd9ae9ac04edf9acef4a2ffbf663698a2b8e7ced)
* pkg: improve error messageEd Maste2024-10-111-1/+5
| | | | | | | | | | | Print the complete list of url that have failed PR: 281924 Co-authored-by: Baptiste Daroussin <bapt@FreeBSD.org> Differential Revision: https://reviews.freebsd.org/D46983 (cherry picked from commit be9243409d6be99f5d7815b6d074a85a6e84f7ce) (cherry picked from commit 2f29060f46138bbfc52c5944825293d598cc68de)
* pkg: prefer .pkg extensionEd Maste2024-10-111-2/+2
| | | | | | | | | | | | | | | .pkg is the default extension as of commit c244b1d8a387, falling back to .txz if not found. PR: 281924 Reviewed by: bapt Fixes: a2aac2f5e564 ("pkg(7): when bootstrapping first search for pkg.bsd file then pkg.txz") Fixes: c244b1d8a387 ("pkg: settle the uniq extension to .pkg instead of .bsd") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46977 (cherry picked from commit f5c847ae849aab9354d0956afd683f1c90bfd91e) (cherry picked from commit fef1f3fecd5b6e7bf040f6dd2e31177332c3c0ec)
* Remove $FreeBSD$: two-line nroff patternWarner Losh2023-08-231-2/+0
| | | | | | | Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/ Similar commit in main: (cherry picked from commit fa9896e082a1)
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-234-4/+0
| | | | | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/ Similar commit in main: (cherry picked from commit d0b2dbfa0ecf)
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-233-6/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in main: (cherry picked from commit 1d386b48a555)
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-232-4/+0
| | | | | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/ Similar commit in main: (cherry picked from commit b3e7694832e8)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-257-7/+7
| | | | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* pkg(7): now that we do use libmd, use it completlyBaptiste Daroussin2023-05-193-77/+16
| | | | | | | | | | Use SHA256_Fd and SHA256_Data instead of home made equivalent. wrap those functions into hash.c to avoid header collition between openssl and libmd Suggested by: kevans (cherry picked from commit e5dd5bfa55dc82686870330f547932486ba48db2)
* pkg(7): use libmd for sha256 instead of opensslBaptiste Daroussin2023-05-194-79/+147
| | | | | | | | | | | | | | OpenSSL 3.0 has deprecated the sha256 api, let's use libmd which has the same API instead. In order to avoid the collision in definitions (sha256.h cannot be included in the same file as a file where openssl headers has been included) let's move the sha256 related code in its own file PR: 270023 Reported by: ngie (cherry picked from commit b2654064c2d11a1ee36667b3ff8b0f4d2536af74)
* /usr/sbin/pkg: don't sleep on fetch failureJohn Hood2022-10-121-3/+1
| | | | | PR: 263458 (cherry picked from commit 60b92ba9323c2dd249ba3a3349b207c2d0b9d212)
* pkg(8): Remove a double word in a source code commentGordon Bergling2022-09-071-2/+2
| | | | | | - s/that that/that/ (cherry picked from commit 990878b07f4a452d3e4c01e98001f94e3a868fb1)
* pkg.7: Clean up mdocMateusz Piotrowski2022-07-071-18/+16
| | | | | | MFC after: 1 week (cherry picked from commit 3beedc3840c29f3f728ed28cbc1450e1b9999f61)
* pkg-bootstrap: use latest package set on arm64 stable branchesEd Maste2022-06-201-1/+1
| | | | | | | | | | | | As with i386 and amd64, "latest" packages are available on stable branches for arm64/aarch64. Reviewed by: manu MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35445 (cherry picked from commit f92e0d6acda3abd16c6d411bf90ef26c4e3c40c4)
* pkgbase: Add a FreeBSD-pkg-bootstrap packageEmmanuel Vadot2022-01-051-0/+2
| | | | | | | | | | | | And put pkg and its keys in it. It's easier for small image to depend on this package rather than the larger utilities one. MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D33458 (cherry picked from commit ec0ea6efa1ad229d75c394c1a9b9cac33af2b1d3)
* pkg: use specific CONFSNAME_${file} for FreeBSD.confKyle Evans2021-08-261-2/+3
| | | | | | | | | | | | | | | | | | Setting CONFSNAME directly is a little more complicated for downstream consumers, as any additional CONFS that are added here will inherit the group name by default. This is perhaps arguably a design flaw in CONFS because inheriting NAME will never give a good result when additional files are added, but this is a low-effort change. While we're here, pull FreeBSD.conf.${branch} out into a PKGCONF variable so one can just drop a new repo config in entirely with a new naming scheme. CONFSNAME gets set based on chopping anything off after ".conf", so that, e.g.: - FooBSD.conf => FooBSD.conf - FooBSD.conf.internal => FooBSD.conf (cherry picked from commit d35164539b14a6d14fb587e58a0c7a1668d7643a)
* pkg: allow multiple add arguments againKyle Evans2021-08-261-4/+50
| | | | | | | | | | | | | | | | While pkg(7) add only handles a single 'add' argument, pkg-add(8) fully handles multiple arguments. Stop rejecting it, just turn off local-bootstrap mode and proceed to remote bootstrap if we need it. While we're here, check if the first argument to pkg add is even a pkg package. If it's not, also do remote bootstrap instead. Future work could improve this altogether by picking out a pkg package out of many and local bootstrap then pass the rest through to the newly installed pkg. (cherry picked from commit 40b9f924b189ce8fa871db600b4abc99b03c6a65)
* usr.sbin/pkg: Don't re-define roundup2Alex Richardson2021-07-051-2/+0
| | | | | | | | | | The file already includes sys/param.h and should use that definition. I found this while testing D28332. Reviewed By: bapt Differential Revision: https://reviews.freebsd.org/D28331 (cherry picked from commit 9a0a48b12d3d85f0f00b99439e6a8779f5f1abb6)
* pkg(7): replace usage of sbuf(9) with open_memstream(3)Baptiste Daroussin2021-05-053-46/+56
| | | | | | | | | | | open_memstream(3) is a standard way to obtain the same feature we do get by using sbuf(9) (aka dynamic size buffer), switching to using it makes pkg(7) more portable, and reduces its number of dependencies. Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D30005 (cherry picked from commit cc9a8a116d19daf224222506441e91a3d329160e)
* pkg(7): indentation fixesBaptiste Daroussin2021-05-051-2/+2
| | | | | | Non functional changes (cherry picked from commit f648d757b76d70d58bbda7c3ed3ff79261d24d0f)
* pkg(7): when bootstrapping first search for pkg.pkg file then pkg.txzBaptiste Daroussin2021-05-051-14/+29
| | | | | | | | | | | | | | The package extension is going to be changed to .pkg to be among other things resilient to the change of compression format used and reduce the impact of all third party tool of that change. Ensure the bootstrap knows about it Reviewed by: manu Differential revision: https://reviews.freebsd.org/D29232 (cherry picked from commit a2aac2f5e5642740507a3cadb98046f3dd434ce4) (cherry picked from commit c244b1d8a38731041d0f3ff4191192a85dd8608b)
* Make pkg(7) use environment variables specified in pkg.confMoritz Schmitt2021-05-052-4/+27
| | | | | | | | | | Modify /usr/sbin/pkg to use environment variables specified in pkg.conf. This allows control over underlying libraries like fetch(3), which can be configured by setting HTTP_PROXY. Differential Revision: https://reviews.freebsd.org/D29820 (cherry picked from commit e869d3c60147bbb226b5ad97d2ef73391aeebafa)
* pkg(7): address minor nits (mostly clang-analyze complaints)Kyle Evans2021-02-202-5/+3
| | | | | | | | | | | | | | - One (1) spurious whitespace. - One (1) occurrence of "random(3) bad, arc4random(3)" good. - Three (3) writes that will never be seen. The latter two points are complaints from clang-analyze. Switching to arc4random(3) is decidedly a good idea because we weren't doing any kind of PRNG seeding anyways. The discarded assignments are arguably good for future-proofing, but it's better to improve the S/N ratio from clang-analyze. (cherry picked from commit b2c4ca8d2872bc4410626f2b1ceafa49de5828ce)
* pkg(7): add an -r reponame option for bootstrap and addKyle Evans2021-02-204-19/+91
| | | | | | | | | | | | | | | This is limited to bootstrap/add because some real pkg(8) commands have -r flags with an incompatible meaning/usage, e.g., pkg-audit. pkg(7) will still commence the search as it has, but it will ignore any repo objects without the given name so that overrides and whatnot still work as expected. The use of it for add is noted in the manpage; notably, that the signature config for that repository will be used over global config if it's specified. i.e., pkg(7) should assume that the given pkg did come from that repository and treat it appropriately. (cherry picked from commit 18418e1936b59c34a9c4a02a1ba5fe0d00dde1b3)
* pkg(7): rework the arguments handlingBaptiste Daroussin2021-01-062-40/+102
| | | | | | | | | | | | | | Rework the arguments handling around using getopt_long: * add long option support * add -4 and -6 support to enforce ipv4 or ipv6 While here fix a regression which occured between FreeBSD 12.1 and FreeBSD 12.2 where pkg bootstrap -y stopped working PR: 252270 MFC after: 2 weeks Submitted by: evilham <contact@evilham.com> Differential Revision: https://reviews.freebsd.org/D27860
* Make use of the getlocalbase() function for run-time adjustment of theStefan Eßer2020-11-183-7/+6
| | | | | | | | | | | | | | | | | | local software base directory, as committed in SVN rev. 367813. The pkg and mailwrapper programs used the LOCALBASE environment variable for this purpose and this functionality is preserved by getlocalbase(). After this change, the value of the user.localbase sysctl variable is used if present (and not overridden in the environment). The nvmecontrol program gains support of a dynamic path to its plugin directory with this update. Differential Revision: https://reviews.freebsd.org/D27237 Notes: svn path=/head/; revision=367816
* Revert the whole getlocalbase() set of changes while a different design isScott Long2020-11-152-8/+3
| | | | | | | hashed out. Notes: svn path=/head/; revision=367711
* Fix the previous revision, it suffered from an incomplete change to theScott Long2020-11-151-2/+2
| | | | | | | | getlocalbase API. Also don't erroneously subtract the lenth from the buffer a second time. Notes: svn path=/head/; revision=367702
* Replace hardcoded references to _PATH_LOCALBASE with calls to getlocalbase.3Scott Long2020-11-142-3/+8
| | | | | | | Reviewed by: imp, se Notes: svn path=/head/; revision=367687
* fix up docs, if signature checking is enabled, the file MUST exist...John-Mark Gurney2020-11-061-6/+3
| | | | Notes: svn path=/head/; revision=367434
* Replace literal uses of /usr/local in C sources with _PATH_LOCALBASEStefan Eßer2020-10-273-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Literal references to /usr/local exist in a large number of files in the FreeBSD base system. Many are in contributed software, in configuration files, or in the documentation, but 19 uses have been identified in C source files or headers outside the contrib and sys/contrib directories. This commit makes it possible to set _PATH_LOCALBASE in paths.h to use a different prefix for locally installed software. In order to avoid changes to openssh source files, LOCALBASE is passed to the build via Makefiles under src/secure. While _PATH_LOCALBASE could have been used here, there is precedent in the construction of the path used to a xauth program which depends on the LOCALBASE value passed on the compiler command line to select a non-default directory. This could be changed in a later commit to make the openssh build consistently use _PATH_LOCALBASE. It is considered out-of-scope for this commit. Reviewed by: imp MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D26942 Notes: svn path=/head/; revision=367075
* Use asprintf instead of sbufBaptiste Daroussin2020-10-191-8/+8
| | | | Notes: svn path=/head/; revision=366828
* pkg-bootstrap: complain on improper `pkg bootstrap` usageKyle Evans2020-07-221-1/+9
| | | | | | | | | | | | | | Right now, the bootstrap will gloss over things like pkg bootstrap -x or pkg bootstrap -f pkg. Make it more clear that this is incorrect, and hint at the correct formatting. Reported by: jhb (IIRC via IRC) Approved by: bapt, jhb, manu MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D24750 Notes: svn path=/head/; revision=363421
* pkg: Provide a friendlier message when bootstrap fails due to address resolutionTom Jones2020-06-231-4/+9
| | | | | | | | | | | | | | The current message when bootstapping pkg fails for any reason implies that pkg is not available. We have the error code from fetch so if bootstrap failed due to address resolution say so. Reviewed by: bapt, bz Approved by: bz (co-mentor) MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D25323 Notes: svn path=/head/; revision=362541
* Rework the logic for installing the pkg(8) configuration.Glen Barber2019-10-081-3/+7
| | | | | | | | | | | | | | | | 'quarterly' package sets do not exist for head, so explicitly install the 'latest' configuration file there. Otherwise, fall back to the original conditional evaluation to determine if the 'latest' or 'quarterly' configuration file should be installed. Reported by: manu Reviewed by: manu MFC after: 3 days Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=353320
* Apply r346792 (cperciva) from stable/12 to head. The original commitGlen Barber2019-09-191-0/+10
| | | | | | | | | | | | | | | | | | | | | | message: On non-x86 systems, use "quarterly" packages. x86 architectures have "latest" package builds on stable/*, so keep using those (they'll get switched over to "quarterly" during releases). The original commit was a direct commit to stable/12, as at the time it was presumed it would not be necessary for head. However, when it is time to create a releng branch or switch from PRERELEASE/STABLE to BETA/RC, the pkg(7) Makefile needs further adjusting. This commit includes those further adjustments, evaluating the BRANCH variable from release/Makefile to determine the pkg(7) repository to use. MFC after: immediate (if possible) Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=352520
* Keep two versions of the FreeBSD.conf pkg configuration file; one whichColin Percival2019-04-243-1/+19
| | | | | | | | | | | | | | | | | | points at the "latest" branch and one which points at the "quarterly" branch. Install the "latest" version unless overridden via the newly added PKGCONFBRANCH variable. This does not change user-visible behaviour (assuming said vairable is not set) but will make it easier to change the defaults in the future -- on stable branches we will want "latest" on x86 but "quarterly" elsewhere. Discussed with: gjb MFC after: 3 days X-MFC: After MFCing this I'll make a direct commit to stable/* to switch non-x86 architectures to "quarterly". Notes: svn path=/head/; revision=346628
* Move pkg/FreeBSD.conf to usr.sbin/pkg/Brad Davis2018-07-312-0/+19
| | | | | | | | Approved by: bapt (mentor) Differential Revision: https://reviews.freebsd.org/D16491 Notes: svn path=/head/; revision=336978
* pkg: accept -y and --yes from argumentsBaptiste Daroussin2018-04-131-0/+10
| | | | | | | | | | | | By popular demand, pkg now walks thought the arguments passed and if it finds -y or --yes it does accept those as equivalent of ASSUME_ALWAYS_YES env var. Requested by: many MFC after: 1 week Notes: svn path=/head/; revision=332484
* various: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-275-0/+10
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326276
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Flush stdout before yes/no confirmations, to force questionPoul-Henning Kamp2017-05-031-0/+1
| | | | | | | through pipes/tee(1)/whatever Notes: svn path=/head/; revision=317771
* usr.sbin: normalize paths using SRCTOP-relative paths or :H when possibleEnji Cooper2017-03-041-2/+2
| | | | | | | | | | This simplifies make logic/output MFC after: 1 month Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=314659
* Remove usage of _WITH_GETLINE from usr.sbinBaptiste Daroussin2016-07-301-1/+0
| | | | Notes: svn path=/head/; revision=303527