Commit Graph

30 Commits

Author SHA1 Message Date
Kyle Evans
c816aea7ab Revert "grep: remove tautological condition"
This reverts commit f6d6c66889.

Gremlins snuck into my tree and injected some WIP.
2023-03-08 23:52:23 -06:00
Kyle Evans
f6d6c66889 grep: remove tautological condition
st_size is an off_t, it cannot hold values larger than OFF_MAX.

CID:		1008931
2023-03-08 23:34:22 -06:00
Baptiste Daroussin
cc9a8a116d pkg(7): replace usage of sbuf(9) with open_memstream(3)
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
2021-04-29 06:41:59 +02:00
Baptiste Daroussin
f648d757b7 pkg(7): indentation fixes
Non functional changes
2021-04-29 06:41:34 +02:00
Moritz Schmitt
e869d3c601 Make pkg(7) use environment variables specified in pkg.conf
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.

MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D29820
2021-04-27 04:01:49 +02:00
Kyle Evans
18418e1936 pkg(7): add an -r reponame option for bootstrap and add
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.

Reviewed by:	bapt, manu
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28524
2021-02-11 18:58:26 -06:00
Alex Richardson
9a0a48b12d usr.sbin/pkg: Don't re-define roundup2
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
2021-01-28 17:25:53 +00:00
Stefan Eßer
56d11d4a37 Make use of the getlocalbase() function for run-time adjustment of the
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
2020-11-18 20:00:55 +00:00
Stefan Eßer
1f474190fc Replace literal uses of /usr/local in C sources with _PATH_LOCALBASE
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
2020-10-27 11:29:11 +00:00
Baptiste Daroussin
ae659caa0a Use asprintf instead of sbuf 2020-10-19 07:26:42 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
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.
2017-11-27 15:37:16 +00:00
Baptiste Daroussin
1da56163f2 Remove some unneeded headers 2016-01-13 17:59:12 +00:00
Baptiste Daroussin
61acb4582f Implement pubkey support for the bootstrap
Note that to not interfer with finger print it expects a signature on pkg itself
which is named pkg.txz.pubkeysign

To genrate it:
echo -n "$(sha256 -q pkg.txz)" | openssl dgst -sha256 -sign /thekey \
    -binary -out ./pkg.txz.pubkeysig

Note the "echo -n" which prevent signing the '\n' one would get otherwise

PR:		202622
MFC after:	1 week
2015-09-08 21:25:36 +00:00
Nathan Whitehorn
60b9a1fcf3 Use pkg-1.4-style platform identifiers based on MACHINE_ARCH (e.g.
FreeBSD:11:amd64 instead of freebsd:11:x86:64) when bootstrapping pkg.
Thanks to portmgr for providing symlinks so both styles work.

Reviewed by:	bapt
MFC after:	3 weeks
2014-10-27 23:19:51 +00:00
Baptiste Daroussin
b04a7a0baf Import libucl 0.4.0
Adapt pkg(7) to the new libucl API
2014-04-22 22:02:06 +00:00
Bryan Drewery
197372c28d Fix ASSUME_ALWAYS_YES not being parsed properly from config after UCL conversion.
Sponsored by:	EMC / Isilon Storage Division
MFC after:	1 week
2014-03-14 17:37:38 +00:00
Bryan Drewery
97c3a76638 Fix ABI from /usr/local/etc/pkg.conf not being respected.
Regression from r259266.

Sponsored by:	EMC / Isilon Storage Division
MFC after:	1 week
2014-03-14 17:20:45 +00:00
Baptiste Daroussin
0ad5dbac61 Update my copyright 2014-02-23 22:04:03 +00:00
Baptiste Daroussin
8a7d859ebf Switch pkg(7) from libyaml to libucl 2014-02-23 21:55:07 +00:00
Baptiste Daroussin
a351c93d95 Implicit include of sys/queue.h instead of relying on gelf.h/libelf.h to bring it
Newer version of gelf.h and libelf.h does not include sys/queue.h anymore

Submitted by:	kaiw
MFC after:	3 days
2014-01-20 22:54:11 +00:00
Bryan Drewery
eb31a57474 Fix multi-repository support by properly respecting 'enabled' flag.
This will read the REPOS_DIR env/config setting (default is /etc/pkg
and /usr/local/etc/pkg/repos) and use the last enabled repository.

This can be changed in the environment using a comma-separated list,
or in /usr/local/etc/pkg.conf with JSON array syntax of:
    REPOS_DIR: ["/etc/pkg", "/usr/local/etc/pkg/repos"]

Approved by:	bapt
MFC after:	1 week
2013-12-12 17:59:09 +00:00
Bryan Drewery
f12db248e7 Support checking signature for pkg bootstrap.
If the pkg.conf is configured with SIGNATURE_TYPE: FINGERPRINTS,
and FINGERPRINTS: /etc/keys/pkg then a pkg.sig file is fetched along
with pkg.txz. The signature contains the signature provided by the
signing server, and the public key. The .sig is the exact output
from the signing server in the following format:

  SIGNATURE
  <openssl signed>
  CERT
  <rsa public key>
  END

The signature is verified with the following logic:

 - If the .sig file is missing, it fails.
 - If the .sig doesn't validate, it fails.
 - If the public key in the .sig is not in the known trusted fingerprints,
   it fails.
 - If the public key is in the revoked key list, it fails.

Approved by:	bapt
MFC after:	2 days
Discussed by:	bapt with des, jonathan, gavin
2013-10-26 03:43:02 +00:00
Bryan Drewery
bc5e9ac08d Add support for reading configuration files from /etc/pkg.
For now only /etc/pkg/FreeBSD.conf is supported. Its style is:

Repo: {
   URL: "...",
   MIRROR_TYPE: "...",
   ...
}

The configuration will be read from /usr/local/etc/pkg.conf if exists,
otherwise /etc/pkg/FreeBSD.conf

Approved by:	bapt
MFC after: 	2 days
2013-10-26 03:31:05 +00:00
Bryan Drewery
4ff9a7ef08 Wrap long lines
Approved by:	bapt
MFC after:	2 days
2013-10-26 03:21:08 +00:00
Bryan Drewery
62940ea951 Add support for using "pkg+http://" for the PACKAGESITE.
pkg 1.2 is adding this support as well. This should help
lessen the confusion on why the default SRV PACKAGESITE
does not load in a browser.

Adapated from:	matthew's upstream pkg change
Approved by:	bapt
MFC after:	2 days
2013-10-24 10:49:55 +00:00
Bryan Drewery
e3ededfa24 Rename libbsdyml to libyaml, make private, and bump
SHLIB_MAJOR to 1.0

Suggested by:	des
Approved by:	bapt
MFC after:	1 week
2013-10-14 18:31:15 +00:00
Baptiste Daroussin
40274a2d65 Add support to detect arm vs armv6
There are two different versions of the ARM ABI depending on the
TARGET_ARCH. As these are sligntly different a package built for
one may not work on another. We need to detect which one we are on
by parsing the .ARM.attributes section.

This will only work on the ARM EABI as this section is part of the
ABI definition. As armv6 only supports the ARM EABI this is not a
problem for the oabi.

Older versions of libelf in FreeBSD fail to read the
.ARM.attributes section needed. As armv6 is unsupported on these
versions we can assume we are running on arm.

Submitted by:	andrew
Approved by:	re (delphij)
Obtained from:	pkgng git
2013-09-10 20:56:01 +00:00
Baptiste Daroussin
4b5ef056f1 Fix detection of arm ABIs
Submitted by:	andrew
Obtained from:	pkg git
2013-07-28 20:11:31 +00:00
Baptiste Daroussin
d5bf8a8b57 choose in priority the allocated ABI if any to do the ${ABI} substitution in PACKAGESITE
Reviewed by:	bdrewery
2013-03-05 14:08:36 +00:00
Baptiste Daroussin
9950eceee6 Add the ability to correctly read pkg.conf is exists.
Only look for boostrap useful options:
 - PACKAGESITE
 - ABI
 - MIRROR_TYPE
 - ASSUME_ALWAYS_YES

While here makes PACKAGESITE expand the ${ABI} variable.
Allow to deactivate any SRV record look up (MIRROR_TYPE=none)
Use the same mechanism as for pkgng itself: first get configuration out of
environment variable and fallback on pkg.conf if exists.

Reviewed by:	bdrewery
2013-03-05 13:31:06 +00:00