Commit graph

32 commits

Author SHA1 Message Date
Robin Elfrink
ebf9d9f6a6 Make apt_updates facts use /usr/bin/apt-get.
/usr/lib/update-notifier/apt-check is not available on all systems,
but /usr/bin/apt-get is.
2016-02-12 23:21:28 +01:00
Clayton O'Neill
ea6a84f336 Fix apt_key tempfile race condition
The Ruby Tempfile class has a finalizer that removes the file when the
GC runs.  It's not predictible when the GC will run, so you have to
ensure that the instance of the class stays in scope for as long as you
need it.

Unfortunately the tempfile method is returning just the filename of the
temporary file, which means it goes out of scope when that method
returns.  This allows the GC to reap it at any time after return.

In both CI and production environments we've seen this race fail,
causing apt-key add to fail a small (2-3%) amount of the time.

This changes the tempfile and source_to_file methods to return the
underlying Tempfile object, pushing it up into the caller's scope.  Both
of the callers immediately use the object to get its filename and then
open the file, eliminating the race.

Tested this by adding 'GC.start; sleep(1)' immediately before the
command is run, to give the GC plenty of time to remove the tempfile if
it was going to.
2015-11-12 14:09:52 +00:00
Dustin Lactin
6e51be76ea Added new apt_reboot_required fact, updated readme, and added unit tests 2015-04-29 11:36:51 -06:00
Morgan Haskel
2802868f96 Iterate through multiple keys 2015-04-20 12:44:42 -07:00
Morgan Haskel
dc746734f1 Merge remote-tracking branch 'upstream/master' into merge_master_to_next 2015-03-25 18:32:09 -04:00
Morgan Haskel
c7354b90fb Actually make it possible to use apt_key
The provider wasn't updated for a parameter rename.
2015-03-18 12:51:37 -07:00
Chris Boot
a24c41247f apt_key: fix some whitespace issues 2015-03-15 22:47:15 +00:00
Chris Boot
42ab470d00 apt_key: fix parsing invalid dates when using GnuPG 2.x
If one should happen to have redirected /usr/bin/gpg to run GnuPG 2.x
rather than the more usual GnuPG 1.x, the apt_key provider fails with
the following error:

Could not prefetch apt_key provider 'apt_key': invalid date

This is because the output of "--with-colons" defaults to using
"fixed-list-mode" in 2.x but did not do so for 1.x. This new format
gives much more information about keys and also uses timestamps in
seconds from 1970-01-01 (UNIX epoch) rather than dates in the format
YYYY-MM-DD.

This patch adds "--fixed-list-mode" when calling apt-key, and adjusts
the code to parse the timestamps instead. This actually has several
advantages:

- Works the same with GnuPG 1.x and 2.x.
- More accurate expiry time tracking, not just entire days.
- No need to require 'date' any longer.
- Will allow the provider to expose more key information in future.

Tested on:
- Debian Wheezy (Puppet 2.7.23, Ruby 1.8.7p358)
- Debian Jessie (Puppet 3.7.2, Ruby 2.1.5p273)
2015-03-15 22:33:22 +00:00
tphoney
f588f2651a initial commit for gpg key checking
better attempt at gpg version checking

adding in key length warning

removing version check, adding key check

adding tests

clean up the code

small changes

use commands

documentation updates
2015-03-12 18:25:26 +00:00
Daniele Sluijters
0f3bdcdf5a apt(::key|_key) Remove the key.*_ prefixes.
Remove a lot of the redundant `key_` prefixes on `apt::key` and the
`keyserver_` prefix on `apt_key`.
2015-03-01 14:20:46 +01:00
WolverineFan
e7fee16589 Fix apt_has_updates fact not parsing apt-check output correctly
The /usr/lib/update-notifier/apt-check script returns its output
to STDERR but a recent change to the script redirects STDERR to
/dev/null.  This will cause the array to always be empty.

Combined with that problem, while we were checking for the result
being nil, we never checked for an invalid array.  As a result,
the apt_has_updates was always true and the apt_updates and
apt_security_updates facts were trying to read from an empty array
and failing.
2015-01-16 17:45:55 -05:00
Travis Fields
18fae0a516 MODULES-1661 Fix to do delete with short key not long 2015-01-13 23:45:03 -08:00
Travis Fields
f1ca76dec5 MODULES-1661 Fix issue with apt_key destroy, also added mutliple deletes 2015-01-13 17:40:18 -08:00
rfkrocktk
445ad0b6fe Allow full length GPG key fingerprints.
Also add support for ECC and ECDSA key_types
2015-01-10 00:45:57 -05:00
Simon Kohlmeyer
b0e0024730
Allow ports that consist of 5 decimals 2015-01-08 05:26:53 +01:00
Morgan Haskel
e5338f2e53 Merge remote-tracking branch 'upstream/1.6.x' into merge_1.6.x
Conflicts:
	lib/facter/apt_package_updates.rb
	lib/facter/apt_security_updates.rb
	lib/facter/apt_updates.rb
2014-11-21 11:59:04 -05:00
Travis Fields
559787268a MODULES-1119 Fixed to now have username and passwords passed in again 2014-11-20 20:57:40 -05:00
Morgan Haskel
20ddb67714 Merge remote-tracking branch 'upstream/master' into 1.7.x-merge
Conflicts:
	lib/facter/apt_package_updates.rb
	lib/facter/apt_security_updates.rb
	lib/facter/apt_updates.rb
2014-10-27 09:57:46 -04:00
Hunter Haugen
97556124da Remove stderr from stdout
Sometimes there are lib errors on platforms with malformed packages.
This shouldn't cause the facts to completely fail.
2014-10-27 09:49:27 -04:00
Daniele Sluijters
5d96da0c6a Merge pull request #375 from raphink/dev/facts_perfs
Refactor facts to improve performance.
2014-10-16 10:07:25 +02:00
Raphaël Pinson
d090ae4ebb Refactor facts to improve performance:
* Add an apt_has_updates boolean fact
* Make other facts depend on it
2014-10-15 15:44:50 +02:00
Morgan Haskel
87f3f1023c Don't truncate to short keys in the type
You should be able to create/delete keys using the long key to avoid
collisions, and truncating in the type makes that not work.
2014-10-01 13:40:25 -05:00
Wolf Noble
7a192d7bea - add bits for updating apt
- fix spec tests to include osfamily fact
- add spec tests to verify current default behavior unimpacted.
- manage the update-stamp file in puppet via content rather than a served file.
- update custom fact to return -1 if the file doesn't exist
- add spec test for custom fact
- refactor to use a variable vs a collector/override
- document parameters a bit more verbosely
- remove empty unconstrained fact
- Add osfamily fact to backports tests to facilitate functional tests on non-debian hosts
2014-09-24 16:29:27 -07:00
Hunter Haugen
ea9f902543 Remove stderr from stdout
Sometimes there are lib errors on platforms with malformed packages.
This shouldn't cause the facts to completely fail.
2014-08-15 16:22:46 -07:00
Arkady Smirnov
f4ea10f4d8 MODULES-780 Don't blow up on unicode characters. 2014-07-09 14:06:40 +03:00
Daniele Sluijters
943be409bd Merge pull request #319 from cloudbuy/master
add facts showing available updates
2014-06-27 14:28:19 +02:00
Damien Churchill
7eb9d00360 add facts showing available updates
Making use of the apt-check command from the 'update-notifier-common'
package (if available) display the number of available updates, number of
security updates as well as the update package names.
2014-06-27 11:21:58 +01:00
Daniele Sluijters
14b3beda74 MODULES-780 Don't blow up on unicode characters.
Gotta love the difference between Ruby 1.8.7 not caring and every
subsequent version exploding.
2014-06-26 14:35:39 +02:00
innyso
3cbe24e18e Adding dash to key_server validate regex
Dashes should be allow when defining domain or url for key_server. Rspec
test cases are included to make sure no malform domain name or url are
used.
2014-06-10 01:07:04 +01:00
Daniele Sluijters
cc1f9c8bb9 Use File.expand_path with require.
For some reason, even though our own tests pass with `require
puppet_x/apt_key/patch_openuri` every other module that depends on
puppetlabs-apt is now breaking in tests claiming it can't load that
module.

Somewhere along the way something is probably messing with LOADPATH
causing this to trip up. This should fix the issues for everyone.

This commit affects:
 * puppetlabs/puppetlabs-apt#229
 * puppetlabs/puppetlabs-postgresql#391
2014-03-16 12:51:33 +01:00
Daniele Sluijters
c3b3f5bb42 apt_key: Support fetching keys over FTP. 2014-02-21 09:06:47 +01:00
Daniele Sluijters
374101612c Add a type and provider to manage apt keys.
This commits introduces:
 * The apt_key type;
 * The apt_key provider;
 * Unit tests for the type;
 * Beaker/acceptance tests for the type/provider.

The idea behind apt_key is that apt::key will simply become a wrapper
that uses apt_key. Being a native type/provider apt_key is a lot less
error prone than the current exec behaviour of apt::key and adds a few
nice bonuses like inventory capabilities for mcollective users.
2014-02-18 22:51:08 +01:00