| 434 | Return true if successful. */ |
| 435 | |
| 436 | static bool |
| 437 | change_attributes (char const *name, int dirfd, char const *relname) |
| 438 | { |
| 439 | bool ok = false; |
| 440 | /* chown must precede chmod because on some systems, |
| 441 | chown clears the set[ug]id bits for non-superusers, |
| 442 | resulting in incorrect permissions. |
| 443 | On System V, users can give away files with chown and then not |
| 444 | be able to chmod them. So don't give files away. |
| 445 | |
| 446 | We don't normally ignore errors from chown because the idea of |
| 447 | the install command is that the file is supposed to end up with |
| 448 | precisely the attributes that the user specified (or defaulted). |
| 449 | If the file doesn't end up with the group they asked for, they'll |
| 450 | want to know. */ |
| 451 | |
| 452 | if (! (owner_id == (uid_t) -1 && group_id == (gid_t) -1) |
| 453 | && lchownat (dirfd, relname, owner_id, group_id) != 0) |
| 454 | error (0, errno, _("cannot change ownership of %s"), quoteaf (name)); |
| 455 | else if (chmodat (dirfd, relname, mode) != 0) |
| 456 | error (0, errno, _("cannot change permissions of %s"), quoteaf (name)); |
| 457 | else |
| 458 | ok = true; |
| 459 | |
| 460 | if (use_default_selinux_context) |
| 461 | setdefaultfilecon (name); |
| 462 | |
| 463 | return ok; |
| 464 | } |
| 465 | |
| 466 | /* Set the timestamps of file DEST aka DIRFD+RELNAME to match those of SRC_SB. |
| 467 | Return true if successful. */ |
no test coverage detected