Commit 898925a6 authored by paz's avatar paz

Don't specify a keyserver if a blank value is configured.

This is useful on systems like Debian 9, which have a default keyserver
configured system-wide.
parent 8115c801
......@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added
* Internal footer: to be appended to each email that is sent to a subscribed address. Will not be included in messages to non-subscribed addresses. This change requires a change to the database, don't forget to run `schleuder install` after updating the code.
* Optionally use an OS-wide defined keyserver by configuring a blank value for the keyserver.
### Changed
......
......@@ -16,6 +16,9 @@ log_level: warn
#keyserver: hkps://hkps.pool.sks-keyservers.net
# If you have gnupg 2.1 and TOR running locally, use a onion-keyserver:
#keyserver: hkp://jirk5u4osbsr34t5.onion
# If you have an OS-wide defined keyserver, specify a blank value to have that
# one used:
#keyserver:
# The default works for all supported versions of gnupg:
keyserver: pool.sks-keyservers.net
......
......@@ -98,7 +98,7 @@ module GPGME
end
def refresh_key(fingerprint)
args = "--keyserver #{Conf.keyserver} --refresh-keys #{fingerprint}"
args = "#{keyserver_arg} --refresh-keys #{fingerprint}"
gpgerr, gpgout, exitcode = self.class.gpgcli(args)
if exitcode > 0
......@@ -135,13 +135,13 @@ module GPGME
def fetch_key_gpg_arguments_for(input)
case input
when Conf::FINGERPRINT_REGEXP
"--keyserver #{Conf.keyserver} --recv-key #{input}"
"#{keyserver_arg} --recv-key #{input}"
when /^http/
"--fetch-key #{input}"
when /@/
# --recv-key doesn't work with email-addresses, so we use --locate-key
# restricted to keyservers.
"--keyserver #{Conf.keyserver} --auto-key-locate keyserver --locate-key #{input}"
"#{keyserver_arg} --auto-key-locate keyserver --locate-key #{input}"
else
[nil, I18n.t("fetch_key.invalid_input")]
end
......@@ -248,5 +248,13 @@ module GPGME
File.delete(path)
end
end
def keyserver_arg
if Conf.keyserver.present?
"--keyserver #{Conf.keyserver}"
else
""
end
end
end
end
......@@ -168,4 +168,26 @@ describe GPGME::Ctx do
expect(out.class).to eql(NilClass)
expect(exitcode.class).to eql(Integer)
end
context "#keyserver_arg" do
it "returns keyserver-args if a keyserver is configured" do
list = create(:list)
keyserver_args = list.gpg.send(:keyserver_arg)
expect(keyserver_args).to eql("--keyserver #{Conf.keyserver}")
end
it "returns a blank string if the keyserver-option is set to a blank value" do
oldval = Conf.instance.config['keyserver']
Conf.instance.config['keyserver'] = ''
list = create(:list)
keyserver_args = list.gpg.send(:keyserver_arg)
expect(keyserver_args).to eql("")
Conf.instance.config['keyserver'] = oldval
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment