links

lynx-like text mode web browser
git clone anongit@rnpnr.xyz:links.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 86cd1af5bf8a014a43ade98a43547f8100c6c352
Parent: 56ee8dbab37db5dd303e2d8d898fa3b6cdd7626e
Author: opask
Date:   Sat,  8 Dec 2018 00:50:04 -0700

Revert "file.c: never set execute bit or sticky bit"
It was a mistake.

This reverts commit 19e5302d9792cc057803889849f7155692f170f3.

Diffstat:
Mfile.c | 24++++++++++++++++++++++++
1 file changed, 24 insertions(+), 0 deletions(-)

diff --git a/file.c b/file.c @@ -11,6 +11,29 @@ static void setrwx(unsigned m, unsigned char *p) { if (m & S_IRUSR) p[0] = 'r'; if (m & S_IWUSR) p[1] = 'w'; + if (m & S_IXUSR) p[2] = 'x'; +} + +static void setst(unsigned m, unsigned char *p) +{ +#ifdef S_ISUID + if (m & S_ISUID) { + p[2] = 'S'; + if (m & S_IXUSR) p[2] = 's'; + } +#endif +#ifdef S_ISGID + if (m & S_ISGID) { + p[5] = 'S'; + if (m & S_IXGRP) p[5] = 's'; + } +#endif +#ifdef S_ISVTX + if (m & S_ISVTX) { + p[8] = 'T'; + if (m & S_IXOTH) p[8] = 't'; + } +#endif } static void stat_mode(unsigned char **p, int *l, struct stat *stp) @@ -46,6 +69,7 @@ static void stat_mode(unsigned char **p, int *l, struct stat *stp) setrwx(mode << 0, &rwx[0]); setrwx(mode << 3, &rwx[3]); setrwx(mode << 6, &rwx[6]); + setst(mode, rwx); } add_to_str(p, l, rwx); add_chr_to_str(p, l, ' ');