[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
test branch
puppet-dev at googlegroups.com
Wed Jul 14 10:33:35 UTC 2010
The following commit has been merged in the upstream branch:
commit b10d35d0da8f630e004966a52ac3ecd01287d36c
Author: Sean Millichamp <sean at bruenor.org>
Date: Fri May 7 08:58:50 2010 -0400
Fixes #3745 Catch unhandled exception in ssh_authorized_key provider
If the target is not specified it is automatically set to the user's
home directory. If the user does not exist when the generation of
the target path occurs then an ArgumentError exception is raised
but not caught. This patch catches the ArgumentError and raises
a Puppet::Error instead to more gracefully notify the user and allow
any remaining resources to be applied.
Signed-off-by: Sean Millichamp <sean at bruenor.org>
diff --git a/lib/puppet/provider/ssh_authorized_key/parsed.rb b/lib/puppet/provider/ssh_authorized_key/parsed.rb
index fb4d095..b222e51 100644
--- a/lib/puppet/provider/ssh_authorized_key/parsed.rb
+++ b/lib/puppet/provider/ssh_authorized_key/parsed.rb
@@ -54,7 +54,11 @@ Puppet::Type.type(:ssh_authorized_key).provide(:parsed,
end
def target
- @resource.should(:target) || File.expand_path("~%s/.ssh/authorized_keys" % user)
+ begin
+ @resource.should(:target) || File.expand_path("~%s/.ssh/authorized_keys" % user)
+ rescue
+ raise Puppet::Error, "Target not defined and/or specified user does not exist yet"
+ end
end
def user
diff --git a/spec/unit/provider/ssh_authorized_key/parsed.rb b/spec/unit/provider/ssh_authorized_key/parsed.rb
index 0edf2b0..f8613e3 100755
--- a/spec/unit/provider/ssh_authorized_key/parsed.rb
+++ b/spec/unit/provider/ssh_authorized_key/parsed.rb
@@ -204,5 +204,17 @@ describe provider_class do
proc { @provider.flush }.should raise_error
end
end
+
+ describe "and a invalid user has been specified with no target" do
+ before :each do
+ @resource.stubs(:should).with(:user).returns "thisusershouldnotexist"
+ @resource.stubs(:should).with(:target).returns nil
+ end
+
+ it "should catch an exception and raise a Puppet error" do
+ lambda { @provider.flush }.should raise_error(Puppet::Error)
+ end
+ end
+
end
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list