test cookie perms

This commit is contained in:
Alexandre Ratchov 2011-04-27 09:45:58 +02:00
parent 369b2b9faf
commit 2e3fe03333
1 changed files with 13 additions and 0 deletions

View File

@ -222,6 +222,10 @@ aucat_gencookie(unsigned char *cookie)
close(fd);
return 0;
}
if (n == 0) {
close(fd);
return 0;
}
cookie += n;
len -= n;
}
@ -249,6 +253,7 @@ aucat_savecookie(char *path, unsigned char *cookie)
int
aucat_loadcookie(unsigned char *cookie)
{
struct stat sb;
char buf[PATH_MAX], *path;
int fd, len, res;
@ -266,6 +271,14 @@ aucat_loadcookie(unsigned char *cookie)
DPERROR(path);
goto bad_gen;
}
if (fstat(fd, &sb) < 0) {
DPERROR(path);
goto bad_close;
}
if (sb.st_mode & 0077) {
DPRINTF("%s has wrong permissions\n", path);
goto bad_close;
}
len = read(fd, cookie, AMSG_COOKIELEN);
if (len < 0) {
DPERROR(path);