snprintf (filename, len, "%s/checksum", cachedir);
(void) mkdir (cachedir, 0755);
snprintf (filename, len, "%s/checksum", cachedir);
(void) mkdir (cachedir, 0755);
/* See if the cache directory exists and passes some simple checks
* to make sure it has not been tampered with.
/* See if the cache directory exists and passes some simple checks
* to make sure it has not been tampered with.
if (lstat (cachedir, &statbuf) == -1)
return 0;
if (statbuf.st_uid != uid) {
if (lstat (cachedir, &statbuf) == -1)
return 0;
if (statbuf.st_uid != uid) {
filename, statbuf.st_mode);
return -1;
}
if ((statbuf.st_mode & 0022) != 0) {
filename, statbuf.st_mode);
return -1;
}
if ((statbuf.st_mode & 0022) != 0) {
perrorf (g, "link: %s %s", filename, *kernel);
goto error;
}
perrorf (g, "link: %s %s", filename, *kernel);
goto error;
}
snprintf (filename, len, "%s/initrd", cachedir);
(void) unlink (*initrd);
if (link (filename, *initrd) == -1) {
perrorf (g, "link: %s %s", filename, *initrd);
goto error;
}
snprintf (filename, len, "%s/initrd", cachedir);
(void) unlink (*initrd);
if (link (filename, *initrd) == -1) {
perrorf (g, "link: %s %s", filename, *initrd);
goto error;
}
snprintf (filename, len, "%s/root", cachedir);
(void) unlink (*appliance);
if (link (filename, *appliance) == -1) {
perrorf (g, "link: %s %s", filename, *appliance);
goto error;
}
snprintf (filename, len, "%s/root", cachedir);
(void) unlink (*appliance);
if (link (filename, *appliance) == -1) {
perrorf (g, "link: %s %s", filename, *appliance);
goto error;
}