parsemode: rework

- for octal input: reset mode to 0.
- take umask into account.
- make '=rwx' etc work.
- we wont support crazy but valid modes like "a+rw,g=x,o=g"
- uudecode: use parsemode, mask is 0.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
This commit is contained in:
Hiltjo Posthuma
2014-04-23 21:28:59 +02:00
committed by sin
parent a1b62b2282
commit bd99b92e91
4 changed files with 68 additions and 51 deletions

View File

@@ -107,7 +107,7 @@ parseheader(FILE *fp, const char *s, const char *header, mode_t *mode, char **fn
eprintf("malformed mode string in header\n");
*q++ = '\0';
/* now mode should be null terminated, q points to fname */
parsemode(p, mode, NULL);
*mode = parsemode(p, *mode, 0);
n = strlen(q);
while (n > 0 && (q[n - 1] == '\n' || q[n - 1] == '\r'))
q[--n] = '\0';