@@ -100,7 +100,11 @@ impl EncodeLabelValue for ErrorType {
100
100
101
101
pub fn check_ownership ( config : & Config , path : & Path , m : & Metadata , k : & FileKind ) -> bool {
102
102
let mut good = true ;
103
- if let Some ( owner) = config. raw_owner {
103
+ if * k == FileKind :: Editable {
104
+ if !config. editable_owners . is_empty ( ) {
105
+ good &= config. editable_owners . contains ( & m. uid ( ) ) ;
106
+ }
107
+ } else if let Some ( owner) = config. raw_owner {
104
108
good &= owner == m. uid ( ) ;
105
109
}
106
110
if let Some ( group) = config. group {
@@ -564,6 +568,39 @@ mod tests {
564
568
check_has_dir_with ( & backlog, ROOT_FILE_DIR , 1 ) ;
565
569
}
566
570
571
+ #[ rstest]
572
+ fn test_ownership_editable (
573
+ mut test_data : TestData ,
574
+ mut backlog : Backlog ,
575
+ #[ values( true , false ) ] do_fail : bool ,
576
+ #[ values( 0 , 1 , 2 , 5 ) ] extra_allowed : u32 ,
577
+ ) {
578
+ let _ = env_logger:: builder ( ) . is_test ( true ) . try_init ( ) ;
579
+
580
+ let fname = add_file ( test_data. temp_dir . path ( ) , "file.jpg" ) ;
581
+ let m = std:: fs:: metadata ( fname) . expect ( "Can't stat just created file!" ) ;
582
+ fn generate_check ( add_own : bool , id : u32 , extras : u32 ) -> Vec < u32 > {
583
+ let mut v = vec ! [ ] ;
584
+ if add_own {
585
+ v. push ( id) ;
586
+ } else {
587
+ v. push ( id + 1 ) ;
588
+ }
589
+ for e in 0 ..extras {
590
+ v. push ( id + e + 2 ) ;
591
+ }
592
+ v
593
+ }
594
+ test_data
595
+ . editable_owners
596
+ . extend ( generate_check ( !do_fail, m. uid ( ) , extra_allowed) ) ;
597
+ let config = test_data. build_config ( None , None , None , None , None ) ;
598
+ backlog. scan ( & config, test_data. now ) ;
599
+ let expected_errors = if do_fail { 1 } else { 0 } ;
600
+ check_backlog ( & backlog, 1 , 1 , 0 , expected_errors, 0 , 0 ) ;
601
+ check_has_dir_with ( & backlog, ROOT_FILE_DIR , 1 ) ;
602
+ }
603
+
567
604
#[ rstest]
568
605
fn test_permissions (
569
606
test_data : TestData ,
0 commit comments