logstash-output-file 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a764f6a8510cb8b185ca81ec48c9b893473e0313
4
- data.tar.gz: a525b4b6f8e3c998a44e4f0ed3d3a5857205a2ba
3
+ metadata.gz: 5b7121bdf41f7f33e90370360fcbd1156dfd9196
4
+ data.tar.gz: 26d8d1aaa831354979b9c315ca341bcd0ba438a7
5
5
  SHA512:
6
- metadata.gz: 1a06888dc105e4f66b6c1e844b547d43c52f65d1a3e478de4f259b00d820b3ad3d6be8530fe05312d43fa36a1d41a733149b16922fad097498f22fa3ddced6fb
7
- data.tar.gz: 897c0e4db7c8225958e82750b4fd6b9989ec7738ceca6da9caa63c084ef341fe5217a293ed505ea949f5f0b95af7661fff6e41a52fe2daaba70839852ce51229
6
+ metadata.gz: 772a0c1c148ab9cd9a9153fefc1dcdb425609a898d967260720c29620651b470ce488fcd1782021180abe241d174c38cefd1d55aa1a255bb1fc11361b10ae92e
7
+ data.tar.gz: f7bbca5b836c1a4ba89ae022b2ca5f02a510c8c2d4ec1a2fa1bcef6eae545e2b34b64e15c601d93f798b5f7781f9d72b0dc797cd0477f04cc8f0751cb1ad6bcb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.2.3
2
+ - Rename Dir.exists? to Dir.exist? to fix deprecation warning
3
+ - Allow setting dir and file permissions
4
+
1
5
  ## 2.2.1
2
6
  - Fixed specs to not depend on pipeline ordering
3
7
 
data/CONTRIBUTORS CHANGED
@@ -3,6 +3,7 @@ reports, or in general have helped logstash along its way.
3
3
 
4
4
  Contributors:
5
5
  * Colin Surprenant (colinsurprenant)
6
+ * Ivan Babrou (bobrik)
6
7
  * John E. Vincent (lusis)
7
8
  * Jordan Sissel (jordansissel)
8
9
  * Kayla Green (MixMuffins)
@@ -58,6 +58,18 @@ class LogStash::Outputs::File < LogStash::Outputs::Base
58
58
  # in such a file, the plugin will created a gain this file. Default => true
59
59
  config :create_if_deleted, :validate => :boolean, :default => true
60
60
 
61
+ # Dir access mode to use. Note that due to the bug in jruby system umask
62
+ # is ignored on linux: https://github.com/jruby/jruby/issues/3426
63
+ # Setting it to -1 uses default OS value.
64
+ # Example: `"dir_mode" => 0750`
65
+ config :dir_mode, :validate => :number, :default => -1
66
+
67
+ # File access mode to use. Note that due to the bug in jruby system umask
68
+ # is ignored on linux: https://github.com/jruby/jruby/issues/3426
69
+ # Setting it to -1 uses default OS value.
70
+ # Example: `"file_mode" => 0640`
71
+ config :file_mode, :validate => :number, :default => -1
72
+
61
73
  default :codec, "json_lines"
62
74
 
63
75
  public
@@ -233,16 +245,24 @@ class LogStash::Outputs::File < LogStash::Outputs::Base
233
245
  @logger.info("Opening file", :path => path)
234
246
 
235
247
  dir = File.dirname(path)
236
- if !Dir.exists?(dir)
248
+ if !Dir.exist?(dir)
237
249
  @logger.info("Creating directory", :directory => dir)
238
- FileUtils.mkdir_p(dir)
250
+ if @dir_mode != -1
251
+ FileUtils.mkdir_p(dir, :mode => @dir_mode)
252
+ else
253
+ FileUtils.mkdir_p(dir)
254
+ end
239
255
  end
240
256
  # work around a bug opening fifos (bug JRUBY-6280)
241
257
  stat = File.stat(path) rescue nil
242
258
  if stat && stat.ftype == "fifo" && LogStash::Environment.jruby?
243
259
  fd = java.io.FileWriter.new(java.io.File.new(path))
244
260
  else
245
- fd = File.new(path, "a+")
261
+ if @file_mode != -1
262
+ fd = File.new(path, "a+", @file_mode)
263
+ else
264
+ fd = File.new(path, "a+")
265
+ end
246
266
  end
247
267
  if gzip
248
268
  fd = Zlib::GzipWriter.new(fd)
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-file'
4
- s.version = '2.2.2'
4
+ s.version = '2.2.3'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "This output will write events to files on disk"
7
7
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
@@ -361,6 +361,35 @@ describe LogStash::Outputs::File do
361
361
  end
362
362
  end
363
363
  end
364
+ context "when using file and dir modes" do
365
+ it 'dirs and files are created with correct atypical permissions' do
366
+ good_event = LogStash::Event.new
367
+ good_event['message'] = "hello world"
368
+
369
+ Stud::Temporary.directory do |path|
370
+ config = {
371
+ "path" => "#{path}/is/nested/output.txt",
372
+ "dir_mode" => 0751,
373
+ "file_mode" => 0610,
374
+ }
375
+ output = LogStash::Outputs::File.new(config)
376
+ output.register
377
+ output.receive(good_event)
378
+ good_file = File.join(path, 'is/nested/output.txt')
379
+ expect(File.exist?(good_file)).to eq(true)
380
+ expect(File.stat(good_file).mode.to_s(8)[-3..-1]).to eq('610')
381
+ first_good_dir = File.join(path, 'is')
382
+ expect(File.stat(first_good_dir).mode.to_s(8)[-3..-1]).to eq('751')
383
+ second_good_dir = File.join(path, 'is/nested')
384
+ expect(File.stat(second_good_dir).mode.to_s(8)[-3..-1]).to eq('751')
385
+ output.close #teardown first to allow reading the file
386
+ File.open(good_file) {|f|
387
+ event = LogStash::Event.new(LogStash::Json.load(f.readline))
388
+ expect(event["message"]).to eq("hello world")
389
+ }
390
+ end
391
+ end
392
+ end
364
393
  end
365
394
  end
366
395
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-file
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-22 00:00:00.000000000 Z
11
+ date: 2016-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core