chmod: Implement X perm symbol

Instead of clearing the format bits before calling parsemode, leave
them in so we can differentiate between directories and other files,
then clear the format bits in the result.
This commit is contained in:
Michael Forney
2020-01-06 13:08:38 -08:00
parent e5284b1537
commit f3d05ffd0a
3 changed files with 11 additions and 5 deletions

View File

@@ -113,6 +113,10 @@ next:
case 'x':
perm |= S_IXUSR|S_IXGRP|S_IXOTH;
break;
case 'X':
if (S_ISDIR(mode) || mode & (S_IXUSR|S_IXGRP|S_IXOTH))
perm |= S_IXUSR|S_IXGRP|S_IXOTH;
break;
case 's':
perm |= S_ISUID|S_ISGID;
break;
@@ -144,5 +148,5 @@ apply:
goto next;
}
}
return mode;
return mode & ~S_IFMT;
}