Commit Graph

54 Commits

Author SHA1 Message Date
Baptiste Daroussin
8e877d85dc pkg: accept -y and --yes from arguments
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
2018-04-13 18:25:00 +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
Poul-Henning Kamp
67c9f60e86 Flush stdout before yes/no confirmations, to force question
through pipes/tee(1)/whatever
2017-05-03 20:41:26 +00:00
Baptiste Daroussin
7556d9b06a Remove usage of _WITH_GETLINE from usr.sbin 2016-07-30 01:10:05 +00:00
Baptiste Daroussin
4c79e0d6c1 Remove extra debug that crept in 2015-09-08 22:24:20 +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
Baptiste Daroussin
b50756c759 Fix indentation, no functional changes 2015-09-08 19:25:15 +00:00
Xin LI
48f9270689 Issue warning and refuse to proceed further if the configured
repository signature_type is unsupported by bootstrap pkg(7).

Previously, when signature_type specified an unsupported method,
the bootstrap pkg(7) would proceed like when signature_type is
"none".  MITM attackers may be able to use this vulnerability and
bypass validation and install their own versions of pkg(8).

At this time, only fingerprint and none are supported by the
bootstrap pkg(7).

FreeBSD's official pkg(8) repository uses the fingerprint method
and is therefore unaffected.

Errata candidate.

Discussed with:	bapt@
Submitted by:	Fabian Keil
Obtained from:	ElectroBSD
2015-08-19 18:24:39 +00:00
Baptiste Daroussin
cc36fe4926 Allow fetching pkg(8) even if servers/proxies are not passing Content-length 2015-04-03 17:35:30 +00:00
Baptiste Daroussin
79fe80ef10 Test the return of fetchParseURL(3)
CID:		1125811
MFC after:	1 week
2015-02-04 00:18:06 +00:00
Baptiste Daroussin
92947daacf Plug resources leak
CID:		1125813
CID:		1125807
CID:		1125808
MFC after:	1 week
2015-02-04 00:10:57 +00:00
Gavin Atkinson
4622bc4e31 When we fail to extract the pkg binaries (for example, / is read-only),
give a more helpful error message.

MFC after:	1 week
2014-07-16 00:12:57 +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
Baptiste Daroussin
d8cfb94376 Remove a useless newline, warnx already appends a newline 2014-02-23 23:49:10 +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
1efc897026 Fix yet another typo
Reported by:	kib
2013-12-23 17:47:04 +00:00
Baptiste Daroussin
e9d9ee5218 Fix typos
Reported by:	bryanv
2013-12-23 17:26:56 +00:00
Baptiste Daroussin
575c4095bf Do not print a question in non-interractive mode but explain why boostrapping
has failed and how to allow it to happen

Reported by:	jmmv
2013-12-23 17:16:44 +00:00
Baptiste Daroussin
d8d2111e85 Do not create pkg.conf, as it is not necessary anymore and packagesite is deprecated
Reported by:	glebius
MFC after:	3 days
2013-11-25 11:31:42 +00:00
Baptiste Daroussin
46b67ede12 argc is now used
MFC after:	2 days
2013-11-16 15:48:49 +00:00
Bryan Drewery
0e088eec8f Remove useless checks for NULL pointer before free(3)
Reported by:		eadler
Approved by:		eadler
2013-11-11 21:42:31 +00:00
Gleb Smirnoff
d2201d13a7 Do not use just freed memory.
Sponsored by:	Nginx, Inc.
2013-11-11 07:44:09 +00:00
Bryan Drewery
5494cb5f12 Remove condition which can never be true as the previous loop
is never exited while remote == NULL.

Reported by:	Coverity
Approved by:	bapt
MFC after:	2 days
2013-11-05 13:36:05 +00:00
Bryan Drewery
5212e8bacf Add -f support to 'pkg bootstrap' and 'pkg add' to force installation
of pkg(8) even if already installed.

This is useful if you somehow messup pkg(8) and need to reinstall from
remote with it already being registered in the pkg(8) /var/db/pkg database.

Also add some sanity checks to 'pkg add'.

Approved by:	bapt
MFC after:	2 days
2013-11-01 12:37:36 +00:00
Bryan Drewery
c3e8a27aab Add a 'pkg bootstrap' command which will bootstrap pkg(8) without
forwarding any command to it after installation.

This is useful if the only goal is to install pkg(8) without any extra
output.

Requested by:	cperciva
Approved by:	bapt
MFC after:	2 days
2013-10-30 10:17:16 +00:00
Bryan Drewery
c2788c07bf Fix build with GCC.
BIO_new_mem_buf takes a void* buf, but internally it never modifies the
buf. It assigns the buffer to another pointer and then marks it as
read-only. So deconsting it should be safe here.

Also fix warning about 'buf' possibly being unused in parse_cert()

Approved by:	bapt
MFC after:	2 days
X-MFC-With:	r257147
2013-10-26 19:59:42 +00:00
Bryan Drewery
52cb76fe60 Add support to check the signature of a local pkg.txz file being
added with "pkg add". If the pkg.conf is configured to check for
signature, then the pkg.txz.sig file will be expected and validated
per r257147

Approved by:	bapt
MFC after:	2 days
2013-10-26 03:47:49 +00:00
Bryan Drewery
516aaf7cf8 Tell which fingerprint pkg is being validated against.
Approved by:	bapt
MFC after:	2 days
2013-10-26 03:44:08 +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
95073c2d2e Be verbose and tell where pkg(8) is being bootstrapped from.
Approved by:	bapt
MFC after:	2 days
2013-10-26 03:32:06 +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
Baptiste Daroussin
b70213b5c7 Allow to bootstrap by doing pkg add ./a/path/to/a/pkg_package.txz
Requested by:	many
MFC after:	3 days
2013-10-23 14:23:48 +00:00
Baptiste Daroussin
35e07a7a52 Improve SRV records support for the pkg(8) bootstrap:
- order srv records by priorities
- for all entries of the same priority, order randomly respect the weight
- select the port where to fetch from respect the port provided in the SRV record

Obtained from:	pkg git repo
MFC after:	3 days
2013-10-23 14:06:07 +00:00
Gavin Atkinson
65008e03e7 Improve bootstrapping message
MFC after:	3 days
2013-10-19 15:36:21 +00:00
Baptiste Daroussin
968d04c371 Fix bootstrapping pkgng by not appending "/latest/" to PACKAGESITE.
Reporter by :	Alexander Yerenkow (via irc)
2013-03-08 10:43:03 +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
Baptiste Daroussin
ff75c36ae1 Do not use deprecated functions from libarchive 2013-02-20 22:51:42 +00:00
Baptiste Daroussin
86e220abc9 In case of failure of the pkg boostrap advice the user to either change the
PACKAGESITE they use or install from ports directly indicating where the port
is localted in the port collection

Submitted by:	kientzle
2013-02-14 12:42:09 +00:00
Matthew Seaman
e41b8acbd5 Remove extraneous space and new-line.
Submitted by:	pjd, gcooper
Approved by:	bapt
MFC after:	2 weeks
2012-12-23 20:39:03 +00:00
Matthew Seaman
d8f9490c67 Third time's the charm. pkg -N output needs to go to stderr.
Approved by:	bapt
MFC after:	2 weeks
2012-12-23 11:22:18 +00:00
Matthew Seaman
d482e1f4a6 Switch from 'pkg -n' to 'pkg -N' as the test for pkgn activation
status. '-n' is already used extensively elsewhere in pkgng (to mean
'dry-run') and this reduces the potential confusion

Submitted by:	eadler
Approved by:	bapt
MFC after:	2 weeks
2012-12-22 15:13:16 +00:00
Matthew Seaman
ecfed9f2eb In preparation for making 'pkg -n' the one true method of determining
whether a system has been configured to use pkgng, cause /usr/sbin/pkg
recognise a -n option and exit with a failure code when the pkg port
is not installed.

Approved by:	bapt
MFC after:	2 weeks
2012-12-21 20:01:13 +00:00
Baptiste Daroussin
29aaa96159 if PACKAGESITE url scheme is not 'file://', always try to revolv SRV records and
use them if any. It allows the bootstrap to use directly pkg.FreeBSD.org instead
of pkgbeta.FreeBSD.org

MFC after:	1 month
2012-12-05 11:35:50 +00:00
Baptiste Daroussin
204ea792b3 Fix confirmation logic when detecting a tty
Reported by:	mjg
2012-08-24 21:45:52 +00:00
Baptiste Daroussin
3a480126c4 - change ALWAYS_ASSUME_YES to ASSUME_ALWAYS_YES for consistency with pkg(8)
- if not on a tty prompt about the missing pkg(8) but default on 'no' except if
  ASSUME_ALWAYS_YES is set

MFC after:	2 days
2012-08-24 21:08:56 +00:00
Alexander Kabaev
e18ad51c15 Make pkg bootstrap program ask for confirmation before proceeding.
The previous behaviour was to silently download and install the pkg
package, without ever telling user about what it was doing and why.

Discussed with:	bapt
Reviewed by: kib
2012-07-15 04:15:27 +00:00
Baptiste Daroussin
514ead92ea Add missing \n when generating pkg.conf
Reported by:	beat
Approved by:	des (mentor)
MFC after:	1 day
2012-05-21 15:45:18 +00:00
Baptiste Daroussin
2fe3761e69 - close the open file after fetching
- create a default /usr/local/etc/pkg.conf

Approved by:	des (mentor)
2012-05-01 10:16:12 +00:00