Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Drop encryption on localhost. Fixes #140
Browse files Browse the repository at this point in the history
  • Loading branch information
leoarnold committed Jun 16, 2019
1 parent c6578b8 commit afeea60
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 70 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 2019-06-16 - Release 2.2.2

Published at [Puppet Forge](https://forge.puppet.com/leoarnold/cups/2.2.2)
and [GitHub](https://github.com/leoarnold/puppet-cups/releases/tag/2.2.2).

### Summary

This release drops the use of encryption while talking to localhost via IPP.
On localhost, HTTPS technically isn't necessary and since some users experienced
CUPS SSL errors, we stop using it.

## 2019-06-13 - Release 2.2.1

Published at [Puppet Forge](https://forge.puppet.com/leoarnold/cups/2.2.1)
Expand Down
36 changes: 18 additions & 18 deletions lib/puppet/provider/cups_queue/cups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def create_class
destroy

resource.should(:members).each do |member|
lpadmin('-E', '-p', member, '-c', name)
lpadmin('-p', member, '-c', name)
end

run_property_setter(:access, :description, :location, :options, :shared,
Expand All @@ -68,7 +68,7 @@ def create_printer
destroy

# Create a minimal raw queue first, then adapt it
lpadmin('-E', '-p', name, '-v', 'file:///dev/null')
lpadmin('-p', name, '-v', 'file:///dev/null')

run_parameter_setter(:model, :ppd)

Expand Down Expand Up @@ -99,7 +99,7 @@ def run_attribute_setter(attribute, target_value)
private :run_attribute_setter

def destroy
lpadmin('-E', '-x', name) if queue_exists?
lpadmin('-x', name) if queue_exists?
end

### Property getters and setters
Expand All @@ -114,9 +114,9 @@ def accepting

def accepting=(value)
if value == :true
cupsaccept('-E', name)
cupsaccept(name)
else
cupsreject('-E', name)
cupsreject(name)
end
end

Expand All @@ -127,15 +127,15 @@ def access
end

def access=(value)
lpadmin('-E', '-p', name, '-u', value['policy'] + ':' + value['users'].join(','))
lpadmin('-p', name, '-u', value['policy'] + ':' + value['users'].join(','))
end

def description
query('printer-info')
end

def description=(value)
lpadmin('-E', '-p', name, '-D', value)
lpadmin('-p', name, '-D', value)
end

def enabled
Expand All @@ -144,9 +144,9 @@ def enabled

def enabled=(value)
if value == :true
while_root_allowed { cupsenable('-E', name) }
while_root_allowed { cupsenable(name) }
else
cupsdisable('-E', name)
cupsdisable(name)
end
end

Expand All @@ -156,9 +156,9 @@ def held

def held=(value)
if value == :true
cupsdisable('-E', '--hold', name)
cupsdisable('--hold', name)
else
cupsenable('-E', '--release', name)
cupsenable('--release', name)
end
end

Expand All @@ -167,7 +167,7 @@ def location
end

def location=(value)
lpadmin('-E', '-p', name, '-L', value)
lpadmin('-p', name, '-L', value)
end

def make_and_model
Expand All @@ -180,7 +180,7 @@ def make_and_model=(_value)
end

def model=(value)
lpadmin('-E', '-p', name, '-m', value)
lpadmin('-p', name, '-m', value)
end

def members
Expand All @@ -198,28 +198,28 @@ def options

def options=(options_should)
options_should.each do |key, value|
lpadmin('-E', '-p', name, '-o', "#{key}=#{value}")
lpadmin('-p', name, '-o', "#{key}=#{value}")
end
end

def ppd=(value)
lpadmin('-E', '-p', name, '-P', value)
lpadmin('-p', name, '-P', value)
end

def shared
query('printer-is-shared')
end

def shared=(value)
lpadmin('-E', '-p', name, '-o', "printer-is-shared=#{value}")
lpadmin('-p', name, '-o', "printer-is-shared=#{value}")
end

def uri
query('device-uri') if printer_exists?
end

def uri=(value)
lpadmin('-E', '-p', name, '-v', value)
lpadmin('-p', name, '-v', value)
end

private
Expand Down Expand Up @@ -310,7 +310,7 @@ def query_native_option(option)
def vendor_options_is
answer = {}

lpoptions('-E', '-p', name, '-l').each_line do |line|
lpoptions('-p', name, '-l').each_line do |line|
result = %r{\A(?<key>\w+)/(.*):(.*)\*(?<value>\w+)}.match(line)
answer[result[:key]] = result[:value] if result
end
Expand Down
2 changes: 1 addition & 1 deletion manifests/queues/default.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

if ($::cups::default_queue) {
exec { 'cups::queues::default':
command => "lpadmin -E -d '${::cups::default_queue}'",
command => "lpadmin -d '${::cups::default_queue}'",
unless => "lpstat -d | grep -w '${::cups::default_queue}'",
path => ['/usr/sbin/', '/usr/bin/', '/sbin/', '/bin/'],
require => Cups_queue[$::cups::default_queue]
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leoarnold-cups",
"version": "2.2.1",
"version": "2.2.2",
"author": "Leo Arnold",
"summary": "Puppet module for the Common Unix Printing System (CUPS)",
"license": "MIT",
Expand Down
28 changes: 14 additions & 14 deletions spec/acceptance/puppet/cups_issue_4781_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@
context "when the queue is present, disabled and restricted to user 'sshd'" do
context 'without specifying an ACL' do
before(:all) do
shell('lpadmin -E -p Office -v /dev/null -u allow:sshd')
shell('cupsdisable -E Office')
shell('lpadmin -p Office -v /dev/null -u allow:sshd')
shell('cupsdisable Office')
end

let(:manifest) do
Expand All @@ -150,8 +150,8 @@

context 'when admitting everybody' do
before(:all) do
shell('lpadmin -E -p Office -v /dev/null -u allow:sshd')
shell('cupsdisable -E Office')
shell('lpadmin -p Office -v /dev/null -u allow:sshd')
shell('cupsdisable Office')
end

let(:access) { "{ 'policy' => 'allow', users => ['all'] }" }
Expand All @@ -167,8 +167,8 @@

context 'when admitting just one specific user' do
before(:all) do
shell('lpadmin -E -p Office -v /dev/null -u allow:sshd')
shell('cupsdisable -E Office')
shell('lpadmin -p Office -v /dev/null -u allow:sshd')
shell('cupsdisable Office')
end

let(:access) { "{ 'policy' => 'allow', users => ['sshd'] }" }
Expand All @@ -184,8 +184,8 @@

context 'when denying several users' do
before(:all) do
shell('lpadmin -E -p Office -v /dev/null -u allow:sshd')
shell('cupsdisable -E Office')
shell('lpadmin -p Office -v /dev/null -u allow:sshd')
shell('cupsdisable Office')
end

let(:access) { "{ 'policy' => 'deny', users => ['root', 'sshd'] }" }
Expand All @@ -201,8 +201,8 @@

context 'when denying just one specific user' do
before(:all) do
shell('lpadmin -E -p Office -v /dev/null -u allow:sshd')
shell('cupsdisable -E Office')
shell('lpadmin -p Office -v /dev/null -u allow:sshd')
shell('cupsdisable Office')
end

let(:access) { "{ 'policy' => 'deny', users => ['sshd'] }" }
Expand All @@ -218,8 +218,8 @@

context 'when denying several users' do
before(:all) do
shell('lpadmin -E -p Office -v /dev/null -u allow:sshd')
shell('cupsdisable -E Office')
shell('lpadmin -p Office -v /dev/null -u allow:sshd')
shell('cupsdisable Office')
end

let(:access) { "{ 'policy' => 'deny', users => ['root', 'sshd'] }" }
Expand All @@ -235,8 +235,8 @@

context 'when denying everybody' do
before(:all) do
shell('lpadmin -E -p Office -v /dev/null -u allow:sshd')
shell('cupsdisable -E Office')
shell('lpadmin -p Office -v /dev/null -u allow:sshd')
shell('cupsdisable Office')
end

let(:access) { "{ 'policy' => 'deny', users => ['all'] }" }
Expand Down
18 changes: 9 additions & 9 deletions spec/acceptance/puppet/cups_queue_properties_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
context 'when changing only the property' do
describe 'access' do
before(:all) do
shell("lpadmin -E -p #{Shellwords.escape(name)} -u allow:all")
shell("lpadmin -p #{Shellwords.escape(name)} -u allow:all")
end

context 'with policy => allow' do
Expand Down Expand Up @@ -134,7 +134,7 @@

describe 'accepting' do
before(:all) do
shell("cupsreject -E #{Shellwords.escape(name)}")
shell("cupsreject #{Shellwords.escape(name)}")
end

context 'when set to true' do
Expand Down Expand Up @@ -186,7 +186,7 @@

describe 'description' do
before(:all) do
shell("lpadmin -E -p #{Shellwords.escape(name)} -D 'color'")
shell("lpadmin -p #{Shellwords.escape(name)} -D 'color'")
end

let(:manifest) do
Expand All @@ -213,7 +213,7 @@

describe 'enabled' do
before(:all) do
shell("cupsdisable -E #{Shellwords.escape(name)}")
shell("cupsdisable #{Shellwords.escape(name)}")
end

context 'when set to true' do
Expand Down Expand Up @@ -265,7 +265,7 @@

describe 'held' do
before(:all) do
shell("cupsenable -E --release #{Shellwords.escape(name)}")
shell("cupsenable --release #{Shellwords.escape(name)}")
end

context 'when set to true' do
Expand Down Expand Up @@ -317,7 +317,7 @@

describe 'location' do
before(:all) do
shell("lpadmin -E -p #{Shellwords.escape(name)} -L 'Room 451'")
shell("lpadmin -p #{Shellwords.escape(name)} -L 'Room 451'")
end

let(:manifest) do
Expand Down Expand Up @@ -345,7 +345,7 @@
describe 'options' do
context 'when using native options' do
before(:all) do
shell("lpadmin -E -p #{Shellwords.escape(name)}" \
shell("lpadmin -p #{Shellwords.escape(name)}" \
' -o auth-info-required=negotiate' \
' -o job-sheets-default=banner,banner' \
' -o printer-error-policy=retry-current-job')
Expand Down Expand Up @@ -375,7 +375,7 @@

context 'when using vendor options' do
before(:all) do
shell("lpadmin -E -p #{Shellwords.escape(name)} -o Duplex=None")
shell("lpadmin -p #{Shellwords.escape(name)} -o Duplex=None")
end

let(:manifest) do
Expand Down Expand Up @@ -407,7 +407,7 @@

describe 'shared' do
before(:all) do
shell("lpadmin -E -p #{Shellwords.escape(name)} -o printer-is-shared=false")
shell("lpadmin -p #{Shellwords.escape(name)} -o printer-is-shared=false")
end

context 'when set to true' do
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
context "when the catalog contains the corresponding 'cups_queue' resource" do
let(:pre_condition) { "cups_queue { 'Office': ensure => 'printer' }" }

it { is_expected.to contain_exec('cups::queues::default').with(command: "lpadmin -E -d 'Office'") }
it { is_expected.to contain_exec('cups::queues::default').with(command: "lpadmin -d 'Office'") }

it { is_expected.to contain_exec('cups::queues::default').with(unless: "lpstat -d | grep -w 'Office'") }

Expand Down
8 changes: 4 additions & 4 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def ensure_cups_is_running

def add_printers(*names)
names.each do |name|
shell("lpadmin -E -p #{Shellwords.escape(name)} -m drv:///sample.drv/generic.ppd -o printer-is-shared=false")
shell("lpadmin -p #{Shellwords.escape(name)} -m drv:///sample.drv/generic.ppd -o printer-is-shared=false")
end
end

Expand All @@ -39,16 +39,16 @@ def add_printers_to_classes(class_members)
members = class_members[classname]
members = %w[Dummy] if members.empty?
members.each do |printername|
shell("lpadmin -E -p #{Shellwords.escape(printername)} -c #{Shellwords.escape(classname)}")
shell("lpadmin -p #{Shellwords.escape(printername)} -c #{Shellwords.escape(classname)}")
end
shell("lpadmin -E -p #{Shellwords.escape(classname)} -o printer-is-shared=false")
shell("lpadmin -p #{Shellwords.escape(classname)} -o printer-is-shared=false")
end
remove_queues('Dummy')
end

def remove_queues(*names)
names.flatten.each do |name|
shell("lpadmin -E -x #{Shellwords.escape(name)}", acceptable_exit_codes: [0, 1])
shell("lpadmin -x #{Shellwords.escape(name)}", acceptable_exit_codes: [0, 1])
end
end

Expand Down
Loading

0 comments on commit afeea60

Please sign in to comment.