[INTERPRETER]

* NEW: Check at startup that temporary directories are really directories 
  and not symbolic links.


git-svn-id: svn://localhost/gambas/trunk@5464 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2012-12-22 19:51:30 +00:00
parent 388f35a0c6
commit dfcdd53552
2 changed files with 5 additions and 4 deletions

View file

@ -2248,8 +2248,6 @@ bool GB_StatFile(const char *path, GB_FILE_STAT *info, bool follow)
END_CATCH_ERROR
}
// TODO: don't accept directories!
char *GB_RealFileName(const char *name, int len)
{
char *path = STRING_conv_file_name(name, len);

View file

@ -180,15 +180,18 @@ void FILE_remove_temp_file(void)
void FILE_init(void)
{
struct stat info;
FILE_remove_temp_file();
snprintf(file_buffer, sizeof(file_buffer), FILE_TEMP_PREFIX, (int)getuid());
mkdir(file_buffer, S_IRWXU);
if (chown(file_buffer, getuid(), getgid()) || chmod(file_buffer, S_IRWXU) == 0)
if (lstat(file_buffer, &info) == 0 && S_ISDIR(info.st_mode) && chown(file_buffer, getuid(), getgid()) == 0 && chmod(file_buffer, S_IRWXU) == 0)
{
snprintf(file_buffer, sizeof(file_buffer), FILE_TEMP_DIR, (int)getuid(), (int)getpid());
mkdir(file_buffer, S_IRWXU);
if (chown(file_buffer, getuid(), getgid()) || chmod(file_buffer, S_IRWXU) == 0)
if (lstat(file_buffer, &info) == 0 && S_ISDIR(info.st_mode) && chown(file_buffer, getuid(), getgid()) == 0 && chmod(file_buffer, S_IRWXU) == 0)
return;
}