Commit Graph

51 Commits

Author SHA1 Message Date
bapt
8204e4e32a Remove usage of _WITH_GETLINE from usr.sbin 2016-07-30 01:10:05 +00:00
bapt
390f3fc8ff Remove extra debug that crept in 2015-09-08 22:24:20 +00:00
bapt
57a6813e1e 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
bapt
7519c8e26a Fix indentation, no functional changes 2015-09-08 19:25:15 +00:00
delphij
671f0b94de 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
bapt
89080383fe Allow fetching pkg(8) even if servers/proxies are not passing Content-length 2015-04-03 17:35:30 +00:00
bapt
79fa39eaca Test the return of fetchParseURL(3)
CID:		1125811
MFC after:	1 week
2015-02-04 00:18:06 +00:00
bapt
5c21fe0178 Plug resources leak
CID:		1125813
CID:		1125807
CID:		1125808
MFC after:	1 week
2015-02-04 00:10:57 +00:00
gavin
7a4991b943 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
bapt
8286a6069a Import libucl 0.4.0
Adapt pkg(7) to the new libucl API
2014-04-22 22:02:06 +00:00
bapt
2440481666 Remove a useless newline, warnx already appends a newline 2014-02-23 23:49:10 +00:00
bapt
0f16562aeb Update my copyright 2014-02-23 22:04:03 +00:00
bapt
21c1fff027 Switch pkg(7) from libyaml to libucl 2014-02-23 21:55:07 +00:00
bapt
01497249f1 Fix yet another typo
Reported by:	kib
2013-12-23 17:47:04 +00:00
bapt
470e15c3e0 Fix typos
Reported by:	bryanv
2013-12-23 17:26:56 +00:00
bapt
06960fae5f 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
bapt
d88ffcbc99 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
bapt
5437f77c61 argc is now used
MFC after:	2 days
2013-11-16 15:48:49 +00:00
bdrewery
f0bfa091d0 Remove useless checks for NULL pointer before free(3)
Reported by:		eadler
Approved by:		eadler
2013-11-11 21:42:31 +00:00
glebius
e31e1e9372 Do not use just freed memory.
Sponsored by:	Nginx, Inc.
2013-11-11 07:44:09 +00:00
bdrewery
e6d38ec2e5 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
bdrewery
1ccf91520f 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
bdrewery
e863fdbd6f 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
bdrewery
177593dc9c 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
bdrewery
e7d4775169 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
bdrewery
c81b2b9710 Tell which fingerprint pkg is being validated against.
Approved by:	bapt
MFC after:	2 days
2013-10-26 03:44:08 +00:00
bdrewery
bd4bf7cc91 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
bdrewery
bc3991ef1d 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
bdrewery
607606f251 Wrap long lines
Approved by:	bapt
MFC after:	2 days
2013-10-26 03:21:08 +00:00
bdrewery
01c7972332 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
bapt
b4d70471e7 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
bapt
f6a0d91c0d 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
de14fff186 Improve bootstrapping message
MFC after:	3 days
2013-10-19 15:36:21 +00:00
bapt
6438218c14 Fix bootstrapping pkgng by not appending "/latest/" to PACKAGESITE.
Reporter by :	Alexander Yerenkow (via irc)
2013-03-08 10:43:03 +00:00
bapt
94bcfee7d0 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
bapt
f4e406048b Do not use deprecated functions from libarchive 2013-02-20 22:51:42 +00:00
bapt
efbce5fcea 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
7653472013 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
2fa689448c 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
45679ebc7b 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
0a2c07efd7 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
bapt
aa139cc58e 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
bapt
160bf30663 Fix confirmation logic when detecting a tty
Reported by:	mjg
2012-08-24 21:45:52 +00:00
bapt
c01de85820 - 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
kan
ee2618962b 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
bapt
f165b50eeb 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
bapt
8f1960d6cc - 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
bapt
10552859c1 - Use _PATH_TMP instead of hardcoded /tmp
- more style(9) fixes
- some refactoring
- better error detection
- Add the DPADD to Makefile

Submitted by:	Garrett Cooper <yanegomi@gmail.com>
Approved by:	des (mentor)
2012-04-16 20:41:25 +00:00
bapt
c8f7bbe987 - Fix style(9) bugs + inconsistencies
Submitted by:	marius
Approved by:	des (mentor)
2012-04-15 18:32:14 +00:00
bapt
008e190698 Do not do double initialisation
style(9) says for (;;) not while (1)

Reported by:	culot
Approved by:	des
2012-04-15 16:00:32 +00:00