Takes an existing file permission and a list of AND/OR changes, and * create a new permissions. */
| 216 | /* Takes an existing file permission and a list of AND/OR changes, and |
| 217 | * create a new permissions. */ |
| 218 | int tweak_mode(int mode, struct chmod_mode_struct *chmod_modes) |
| 219 | { |
| 220 | int IsX = mode & 0111; |
| 221 | int NonPerm = mode & ~CHMOD_BITS; |
| 222 | |
| 223 | for ( ; chmod_modes; chmod_modes = chmod_modes->next) { |
| 224 | if ((chmod_modes->flags & FLAG_DIRS_ONLY) && !S_ISDIR(NonPerm)) |
| 225 | continue; |
| 226 | if ((chmod_modes->flags & FLAG_FILES_ONLY) && S_ISDIR(NonPerm)) |
| 227 | continue; |
| 228 | mode &= chmod_modes->ModeAND; |
| 229 | if ((chmod_modes->flags & FLAG_X_KEEP) && !IsX && !S_ISDIR(NonPerm)) |
| 230 | mode |= chmod_modes->ModeOR & ~0111; |
| 231 | else |
| 232 | mode |= chmod_modes->ModeOR; |
| 233 | } |
| 234 | |
| 235 | return mode | NonPerm; |
| 236 | } |
| 237 | |
| 238 | /* Free the linked list created by parse_chmod. */ |
| 239 | int free_chmod_mode(struct chmod_mode_struct *chmod_modes) |
no outgoing calls
no test coverage detected