Commit aabcab59 aabcab593f3cead42f4d6a9d113bb9c6245780d7 by Wojciech Polak

Moved stat() (checking the file permissions) to wicket_create().

1 parent d10f29bb
......@@ -52,9 +52,19 @@ static int get_user __P ((url_t, const char *, char **));
int
wicket_create (wicket_t *pwicket, const char *filename)
{
struct stat st;
if (pwicket == NULL)
return EINVAL;
if (filename)
{
if (stat (filename, &st) == -1)
return errno;
if ((st.st_mode & S_IRWXG) || (st.st_mode & S_IRWXO))
return MU_ERR_UNSAFE_PERMS;
}
*pwicket = calloc (1, sizeof (**pwicket));
if (*pwicket == NULL)
return ENOMEM;
......@@ -249,16 +259,10 @@ get_ticket (url_t url, const char *user, const char *filename, url_t * ticket)
FILE *fp = NULL;
size_t buflen = 128;
char *buf = NULL;
struct stat st;
if (!filename || !url)
return EINVAL;
if (stat (filename, &st) == -1)
return errno;
if ((st.st_mode & S_IRWXG) || (st.st_mode & S_IRWXO))
return MU_ERR_UNSAFE_PERMS;
fp = fopen (filename, "r");
if (!fp)
......