- {
- /* If at least one of the S_IXUGO bits are set, chown might
- clear the S_ISUID and S_SGID bits. Keep track of any
- file mode bits whose values are indeterminate due to this
- issue. */
- mode_t indeterminate = 0;
-
- /* On some systems, chown clears S_ISUID and S_ISGID, so do
- chown before chmod. On older System V hosts, ordinary
- users can give their files away via chown; don't worry
- about that here, since users shouldn't do that. */
-
- if ((owner != (uid_t) -1 && owner != st.st_uid)
- || (group != (gid_t) -1 && group != st.st_gid))
- {
- result = (0 <= fd
- ? fchown (fd, owner, group)
- : mkdir_mode != (mode_t) -1
- ? lchown (dir, owner, group)
- : chown (dir, owner, group));
-
- /* Either the user cares about an indeterminate bit and
- it'll be set properly by chmod below, or the user
- doesn't care and it's OK to use the bit's pre-chown
- value. So there's no need to re-stat DIR here. */
-
- if (result == 0 && (dir_mode & S_IXUGO))
- indeterminate = dir_mode & (S_ISUID | S_ISGID);
- }
-
- /* If the file mode bits might not be right, use chmod to
- change them. Don't change bits the user doesn't care
- about. */
- if (result == 0 && (((dir_mode ^ mode) | indeterminate) & mode_bits))
- {
- mode_t chmod_mode =
- mode | (dir_mode & CHMOD_MODE_BITS & ~mode_bits);
- result = (HAVE_FCHMOD && 0 <= fd
- ? fchmod (fd, chmod_mode)
- : mkdir_mode != (mode_t) -1
- ? lchmod (dir, chmod_mode)
- : chmod (dir, chmod_mode));
- }
- }
+ {
+ /* If at least one of the S_IXUGO bits are set, chown might
+ clear the S_ISUID and S_SGID bits. Keep track of any
+ file mode bits whose values are indeterminate due to this
+ issue. */
+ mode_t indeterminate = 0;
+
+ /* On some systems, chown clears S_ISUID and S_ISGID, so do
+ chown before chmod. On older System V hosts, ordinary
+ users can give their files away via chown; don't worry
+ about that here, since users shouldn't do that. */
+
+ if ((owner != (uid_t) -1 && owner != st.st_uid)
+ || (group != (gid_t) -1 && group != st.st_gid))
+ {
+ result = (0 <= fd
+ ? fchown (fd, owner, group)
+ : mkdir_mode != (mode_t) -1
+ ? lchown (dir, owner, group)
+ : chown (dir, owner, group));
+
+ /* Either the user cares about an indeterminate bit and
+ it'll be set properly by chmod below, or the user
+ doesn't care and it's OK to use the bit's pre-chown
+ value. So there's no need to re-stat DIR here. */
+
+ if (result == 0 && (dir_mode & S_IXUGO))
+ indeterminate = dir_mode & (S_ISUID | S_ISGID);
+ }
+
+ /* If the file mode bits might not be right, use chmod to
+ change them. Don't change bits the user doesn't care
+ about. */
+ if (result == 0 && (((dir_mode ^ mode) | indeterminate) & mode_bits))
+ {
+ mode_t chmod_mode =
+ mode | (dir_mode & CHMOD_MODE_BITS & ~mode_bits);
+ result = (HAVE_FCHMOD && 0 <= fd
+ ? fchmod (fd, chmod_mode)
+ : mkdir_mode != (mode_t) -1
+ ? lchmod (dir, chmod_mode)
+ : chmod (dir, chmod_mode));
+ }
+ }