@@ -469,7 +469,7 @@ static int reftable_stack_init_addition(struct reftable_addition *add,
469
469
strbuf_addstr (& add -> lock_file_name , ".lock" );
470
470
471
471
add -> lock_file_fd = open (add -> lock_file_name .buf ,
472
- O_EXCL | O_CREAT | O_WRONLY , 0644 );
472
+ O_EXCL | O_CREAT | O_WRONLY , 0666 );
473
473
if (add -> lock_file_fd < 0 ) {
474
474
if (errno == EEXIST ) {
475
475
err = REFTABLE_LOCK_ERROR ;
@@ -478,6 +478,13 @@ static int reftable_stack_init_addition(struct reftable_addition *add,
478
478
}
479
479
goto done ;
480
480
}
481
+ if (st -> config .default_permissions ) {
482
+ if (chmod (add -> lock_file_name .buf , st -> config .default_permissions ) < 0 ) {
483
+ err = REFTABLE_IO_ERROR ;
484
+ goto done ;
485
+ }
486
+ }
487
+
481
488
err = stack_uptodate (st );
482
489
if (err < 0 )
483
490
goto done ;
@@ -644,7 +651,12 @@ int reftable_addition_add(struct reftable_addition *add,
644
651
err = REFTABLE_IO_ERROR ;
645
652
goto done ;
646
653
}
647
-
654
+ if (add -> stack -> config .default_permissions ) {
655
+ if (chmod (temp_tab_file_name .buf , add -> stack -> config .default_permissions )) {
656
+ err = REFTABLE_IO_ERROR ;
657
+ goto done ;
658
+ }
659
+ }
648
660
wr = reftable_new_writer (reftable_fd_write , & tab_fd ,
649
661
& add -> stack -> config );
650
662
err = write_table (wr , arg );
@@ -900,7 +912,7 @@ static int stack_compact_range(struct reftable_stack *st, int first, int last,
900
912
strbuf_addstr (& lock_file_name , ".lock" );
901
913
902
914
lock_file_fd =
903
- open (lock_file_name .buf , O_EXCL | O_CREAT | O_WRONLY , 0644 );
915
+ open (lock_file_name .buf , O_EXCL | O_CREAT | O_WRONLY , 0666 );
904
916
if (lock_file_fd < 0 ) {
905
917
if (errno == EEXIST ) {
906
918
err = 1 ;
@@ -931,8 +943,8 @@ static int stack_compact_range(struct reftable_stack *st, int first, int last,
931
943
strbuf_addstr (& subtab_lock , ".lock" );
932
944
933
945
sublock_file_fd = open (subtab_lock .buf ,
934
- O_EXCL | O_CREAT | O_WRONLY , 0644 );
935
- if (sublock_file_fd > 0 ) {
946
+ O_EXCL | O_CREAT | O_WRONLY , 0666 );
947
+ if (sublock_file_fd >= 0 ) {
936
948
close (sublock_file_fd );
937
949
} else if (sublock_file_fd < 0 ) {
938
950
if (errno == EEXIST ) {
@@ -967,7 +979,7 @@ static int stack_compact_range(struct reftable_stack *st, int first, int last,
967
979
goto done ;
968
980
969
981
lock_file_fd =
970
- open (lock_file_name .buf , O_EXCL | O_CREAT | O_WRONLY , 0644 );
982
+ open (lock_file_name .buf , O_EXCL | O_CREAT | O_WRONLY , 0666 );
971
983
if (lock_file_fd < 0 ) {
972
984
if (errno == EEXIST ) {
973
985
err = 1 ;
@@ -977,6 +989,12 @@ static int stack_compact_range(struct reftable_stack *st, int first, int last,
977
989
goto done ;
978
990
}
979
991
have_lock = 1 ;
992
+ if (st -> config .default_permissions ) {
993
+ if (chmod (lock_file_name .buf , st -> config .default_permissions ) < 0 ) {
994
+ err = REFTABLE_IO_ERROR ;
995
+ goto done ;
996
+ }
997
+ }
980
998
981
999
format_name (& new_table_name , st -> readers [first ]-> min_update_index ,
982
1000
st -> readers [last ]-> max_update_index );
0 commit comments