-
- /* The above chown may have turned off some permission bits in MODE.
- Another reason we may have to use chmod here is that mkdir(2) is
- required to honor only the file permission bits. In particular,
- it need not honor the `special' bits, so if MODE includes any
- special bits, set them here. */
- if ((mode & ~S_IRWXUGO) && chmod (fixup_permissions_dir, mode) != 0)
- {
- error (0, errno, _("cannot change permissions of %s"),
- quote (full_dir));
- retval = false;
- }
- }
-
- if (do_chdir)
- {
- if (restore_cwd (&cwd) != 0)
- {
- *cwd_errno = errno;
- cwd_problem = true;
- }
- free_cwd (&cwd);
- }
-
- /* If the mode for leading directories didn't include owner "wx"
- privileges, reset their protections to the correct value. */
- for (; leading_dirs != NULL; leading_dirs = leading_dirs->next)
- {
- leading_dirs->dirname_end[0] = '\0';
- if ((cwd_problem && *full_dir != '/')
- || chmod (full_dir, parent_mode) != 0)
- {
- error (0, (cwd_problem ? 0 : errno),
- _("cannot change permissions of %s"), quote (full_dir));
- retval = false;
- }