@@ -2591,6 +2591,46 @@ def test_EACCES
25912591 d . instance_shutdown if d && d . instance
25922592 end
25932593
2594+ def test_warn_without_directory_permission
2595+ omit "Cannot test with root user" if Process ::UID . eid == 0
2596+ omit "NTFS doesn't support UNIX like permissions" if Fluent . windows?
2597+ path = "#{ @tmp_dir } /noaccess/tail.txt"
2598+ begin
2599+ FileUtils . mkdir_p ( "#{ @tmp_dir } /noaccess" )
2600+ FileUtils . touch ( path )
2601+ FileUtils . chmod ( 0400 , path )
2602+ FileUtils . chmod ( 0600 , "#{ @tmp_dir } /noaccess" )
2603+ config = config_element ( '' , '' , {
2604+ 'tag' => "tail" ,
2605+ 'path' => path ,
2606+ 'format' => 'none' ,
2607+ "pos_file" => "#{ @tmp_dir } /tail.pos" ,
2608+ } )
2609+ d = create_driver ( config , false )
2610+ fname = File . expand_path ( "#{ @tmp_dir } /noaccess" )
2611+ assert ( d . logs . any? { |log | log . include? ( "Skip #{ path } because '#{ fname } ' lacks execute permission.\n " ) } )
2612+ end
2613+ end
2614+
2615+ def test_no_warn_with_directory_permission
2616+ omit "Cannot test with root user" if Process ::UID . eid == 0
2617+ omit "NTFS doesn't support UNIX like permissions" if Fluent . windows?
2618+ path = "#{ @tmp_dir } /noaccess/tail.txt"
2619+ begin
2620+ FileUtils . mkdir_p ( "#{ @tmp_dir } /noaccess" )
2621+ FileUtils . chmod ( 0100 , "#{ @tmp_dir } /noaccess" )
2622+ config = config_element ( '' , '' , {
2623+ 'tag' => "tail" ,
2624+ 'path' => path ,
2625+ 'format' => 'none' ,
2626+ "pos_file" => "#{ @tmp_dir } /tail.pos" ,
2627+ } )
2628+ d = create_driver ( config , false )
2629+ fname = File . expand_path ( "#{ @tmp_dir } /noaccess" )
2630+ assert ( d . logs . all? { |log | !log . include? ( "Skip #{ path } because '#{ fname } ' lacks execute permission.\n " ) } )
2631+ end
2632+ end
2633+
25942634 def test_shutdown_timeout
25952635 Fluent ::FileWrapper . open ( "#{ @tmp_dir } /tail.txt" , "wb" ) do |f |
25962636 # Should be large enough to take too long time to consume
0 commit comments