- /* chown may have turned off some permission bits we wanted. */
- if ((mode & 07000) != 0 && chmod (basename_dir, mode))
- {
- error (0, errno, _("cannot chmod %s"), dirpath);
- retval = 1;
- }
+ }
+
+ /* 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 (basename_dir, mode))
+ {
+ error (0, errno, _("cannot chmod %s"), dirpath);
+ retval = 1;