@@ -2591,6 +2591,50 @@ 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 ( $log. out . logs . any? { |log | log . include? ( "Skip #{ path } because '#{ fname } ' lacks execute permission.\n " ) } )
2612+ end
2613+ ensure
2614+ d . instance_shutdown if d && d . instance
2615+ end
2616+
2617+ def test_no_warn_with_directory_permission
2618+ omit "Cannot test with root user" if Process ::UID . eid == 0
2619+ omit "NTFS doesn't support UNIX like permissions" if Fluent . windows?
2620+ path = "#{ @tmp_dir } /noaccess/tail.txt"
2621+ begin
2622+ FileUtils . mkdir_p ( "#{ @tmp_dir } /noaccess" )
2623+ FileUtils . chmod ( 0100 , "#{ @tmp_dir } /noaccess" )
2624+ config = config_element ( '' , '' , {
2625+ 'tag' => "tail" ,
2626+ 'path' => path ,
2627+ 'format' => 'none' ,
2628+ "pos_file" => "#{ @tmp_dir } /tail.pos" ,
2629+ } )
2630+ d = create_driver ( config , false )
2631+ fname = File . expand_path ( "#{ @tmp_dir } /noaccess" )
2632+ assert ( $log. out . logs . all? { |log | !log . include? ( "Skip #{ path } because '#{ fname } ' lacks execute permission.\n " ) } )
2633+ end
2634+ ensure
2635+ d . instance_shutdown if d && d . instance
2636+ end
2637+
25942638 def test_shutdown_timeout
25952639 Fluent ::FileWrapper . open ( "#{ @tmp_dir } /tail.txt" , "wb" ) do |f |
25962640 # Should be large enough to take too long time to consume
0 commit comments