Hi all, as previously threatened, here are some git patches. Hope that helps.
Ciao, Markus
>From dfe485c4298aa8572f7534e19336b682239d0879 Mon Sep 17 00:00:00 2001 From: Markus Wichmann <nullp...@gmx.net> Date: Sun, 20 Oct 2013 10:49:59 +0200 Subject: [PATCH 1/4] Make mkdir read mode argument as octal. --- mkdir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdir.c b/mkdir.c index 8080797..781654a 100644 --- a/mkdir.c +++ b/mkdir.c @@ -30,7 +30,7 @@ main(int argc, char *argv[]) break; case 'm': mflag = true; - mode = estrtol(EARGF(usage()), 10); + mode = estrtol(EARGF(usage()), 8); break; default: usage(); -- 1.8.4.rc3
>From 40cf23698c688972e072f5352af7def861caa327 Mon Sep 17 00:00:00 2001 From: Markus Wichmann <nullp...@gmx.net> Date: Sun, 20 Oct 2013 10:50:58 +0200 Subject: [PATCH 2/4] Make chmod honor S_ISVTX. --- chmod.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chmod.c b/chmod.c index 6d0f8a7..1af3f45 100644 --- a/chmod.c +++ b/chmod.c @@ -95,6 +95,7 @@ parsemode(const char *str) if(*end == '\0') { if(octal & 04000) mode |= S_ISUID; if(octal & 02000) mode |= S_ISGID; + if(octal & 01000) mode |= S_ISVTX; if(octal & 00400) mode |= S_IRUSR; if(octal & 00200) mode |= S_IWUSR; if(octal & 00100) mode |= S_IXUSR; @@ -140,6 +141,9 @@ parsemode(const char *str) case 's': mode |= S_ISUID|S_ISGID; break; + case 't': + mode |= S_ISVTX; + break; /* error */ default: eprintf("%s: invalid mode\n", str); -- 1.8.4.rc3
>From cd2c8a254aa18b020fa499c509d981a49401ee65 Mon Sep 17 00:00:00 2001 From: Markus Wichmann <nullp...@gmx.net> Date: Sun, 20 Oct 2013 10:53:43 +0200 Subject: [PATCH 3/4] Make chmod and ls recognize sticky bit (S_ISVTX). --- chmod.c | 4 ++-- ls.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/chmod.c b/chmod.c index 1af3f45..74c8700 100644 --- a/chmod.c +++ b/chmod.c @@ -31,9 +31,9 @@ main(int argc, char *argv[]) case 'R': rflag = true; break; - case 'r': case 'w': case 'x': case 's': + case 'r': case 'w': case 'x': case 's': case 't': /* - * -[rwxs] are valid modes so do not interpret + * -[rwxst] are valid modes so do not interpret * them as options - in any case we are done if * we hit this case */ diff --git a/ls.c b/ls.c index af1336d..c5eae89 100644 --- a/ls.c +++ b/ls.c @@ -228,6 +228,7 @@ output(Entry *ent) if(ent->mode & S_ISUID) mode[3] = (mode[3] == 'x') ? 's' : 'S'; if(ent->mode & S_ISGID) mode[6] = (mode[6] == 'x') ? 's' : 'S'; + if(ent->mode & S_ISVTX) mode[9] = (mode[9] == 'x') ? 't' : 'T'; errno = 0; pw = getpwuid(ent->uid); -- 1.8.4.rc3
>From a0749cdc82e5fc55e7feba70c081ad3a42684beb Mon Sep 17 00:00:00 2001 From: Markus Wichmann <nullp...@gmx.net> Date: Sun, 20 Oct 2013 10:56:49 +0200 Subject: [PATCH 4/4] Add sticky bit to documentation. --- chmod.1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/chmod.1 b/chmod.1 index 579aa68..4deb792 100644 --- a/chmod.1 +++ b/chmod.1 @@ -9,7 +9,7 @@ chmod \- change file mode .P .B chmod .RB [ \-r ] -.RB [ ugoa ]*[ +-= ][ rwxs ]* +.RB [ ugoa ]*[ +-= ][ rwxst ]* .RI [ file ...] .SH DESCRIPTION .B chmod @@ -18,7 +18,7 @@ changes the file mode for the given files. If the mode is an .I octal number, the modes are set according to that number's comprising bits. The first -digit defines the setuid (4) and setgid (2) attributes. The second digit +digit defines the setuid (4), setgid (2), and sticky (1) attributes. The second digit defines the owner's permissions: read (4), write (2), and execute (1); the third defines permissions for others in the file's group; and the fourth for all other users. Leading zeroes may be omitted. @@ -62,6 +62,9 @@ execute permissions. .TP .B s setuid and setgid attributes. +.TP +.B t +sticky attribute. .PD .SH OPTIONS .TP -- 1.8.4.rc3