| 760 | } |
| 761 | |
| 762 | int adjust_shared_perm(struct repository *repo, |
| 763 | const char *path) |
| 764 | { |
| 765 | int old_mode, new_mode; |
| 766 | |
| 767 | if (!repo_settings_get_shared_repository(repo)) |
| 768 | return 0; |
| 769 | if (get_st_mode_bits(path, &old_mode) < 0) |
| 770 | return -1; |
| 771 | |
| 772 | new_mode = calc_shared_perm(repo, old_mode); |
| 773 | if (S_ISDIR(old_mode)) { |
| 774 | /* Copy read bits to execute bits */ |
| 775 | new_mode |= (new_mode & 0444) >> 2; |
| 776 | |
| 777 | /* |
| 778 | * g+s matters only if any extra access is granted |
| 779 | * based on group membership. |
| 780 | */ |
| 781 | if (FORCE_DIR_SET_GID && (new_mode & 060)) |
| 782 | new_mode |= FORCE_DIR_SET_GID; |
| 783 | } |
| 784 | |
| 785 | if (((old_mode ^ new_mode) & ~S_IFMT) && |
| 786 | chmod(path, (new_mode & ~S_IFMT)) < 0) |
| 787 | return -2; |
| 788 | return 0; |
| 789 | } |
| 790 | |
| 791 | void safe_create_dir(struct repository *repo, const char *dir, int share) |
| 792 | { |
no test coverage detected