Sorry, ignore this; I sent a patch from the wrong branch. Pretty sure I emailed this patch already yesterday.
On Apr 21, 2009, at 5:41 PM, Luke Kanies wrote: > > We were already writing all specific files with > appropriate permissions; this change makes all of > the files that are part of a group (which largely > means files saved by puppetmasterd and puppetca) > are also written using the correct permissions. > > Signed-off-by: Luke Kanies <[email protected]> > --- > lib/puppet/indirector/key/file.rb | 4 ++-- > lib/puppet/indirector/ssl_file.rb | 8 +++++--- > spec/unit/indirector/key/file.rb | 4 ++-- > spec/unit/indirector/ssl_file.rb | 4 ++-- > 4 files changed, 11 insertions(+), 9 deletions(-) > > diff --git a/lib/puppet/indirector/key/file.rb b/lib/puppet/ > indirector/key/file.rb > index 4536f8a..a413ccf 100644 > --- a/lib/puppet/indirector/key/file.rb > +++ b/lib/puppet/indirector/key/file.rb > @@ -34,9 +34,9 @@ class Puppet::SSL::Key::File < > Puppet::Indirector::SslFile > super > > begin > - File.open(public_key_path(request.key), "w") { |f| > f.print request.instance.content.public_key.to_pem } > + Puppet.settings.writesub(:publickeydir, > public_key_path(request.key)) { |f| f.print > request.instance.content.public_key.to_pem } > rescue => detail > - raise Puppet::Error, "Could not write %s: %s" % [key, > detail] > + raise Puppet::Error, "Could not write %s: %s" % > [request.key, detail] > end > end > end > diff --git a/lib/puppet/indirector/ssl_file.rb b/lib/puppet/ > indirector/ssl_file.rb > index 4119a65..de71637 100644 > --- a/lib/puppet/indirector/ssl_file.rb > +++ b/lib/puppet/indirector/ssl_file.rb > @@ -156,12 +156,14 @@ class Puppet::Indirector::SslFile < > Puppet::Indirector::Terminus > Puppet.settings.write(self.class.ca_setting) { |f| yield > f } > elsif file_location > Puppet.settings.write(self.class.file_setting) { |f| > yield f } > - else > + elsif setting = self.class.directory_setting > begin > - File.open(path, "w") { |f| yield f } > + Puppet.settings.writesub(setting, path) { |f| yield > f } > rescue => detail > - raise Puppet::Error, "Could not write %s: %s" % > [path, detail] > + raise Puppet::Error, "Could not write %s to %s: %s" > % [path, setting, detail] > end > + else > + raise Puppet::DevError, "You must provide a setting to > determine where the files are stored" > end > end > end > diff --git a/spec/unit/indirector/key/file.rb b/spec/unit/indirector/ > key/file.rb > index 8a1cb04..f365bfd 100755 > --- a/spec/unit/indirector/key/file.rb > +++ b/spec/unit/indirector/key/file.rb > @@ -70,11 +70,11 @@ describe Puppet::SSL::Key::File do > end > > it "should save the public key when saving the private key" do > - File.stubs(:open).with(@private_key_path, "w") > + Puppet.settings.stubs(:writesub) > > fh = mock 'filehandle' > > - File.expects(:open).with(@public_key_path, "w").yields fh > + Puppet.settings.expects(:writesub).with(:publickeydir, > @public_key_path).yields fh > @public_key.expects(:to_pem).returns "my pem" > > fh.expects(:print).with "my pem" > diff --git a/spec/unit/indirector/ssl_file.rb b/spec/unit/indirector/ > ssl_file.rb > index 89f682f..559e2f9 100755 > --- a/spec/unit/indirector/ssl_file.rb > +++ b/spec/unit/indirector/ssl_file.rb > @@ -173,11 +173,11 @@ describe Puppet::Indirector::SslFile do > end > > describe "and a directory setting is set" do > - it "should open the file in write mode" do > + it "should use the Settings class to write the > file" do > @searcher.class.store_in @setting > fh = mock 'filehandle' > fh.stubs :print > - File.expects(:open).with(@certpath, > "w").yields(fh) > + > Puppet.settings.expects(:writesub).with(@setting, @certpath).yields fh > > @searcher.save(@request) > end > -- > 1.6.1 > > > > -- If you can't be a good example, then you'll just have to be a horrible warning. -- Catherine Aird --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---
