ntdll: Refuse to create the .wine directory if the parent belongs to a different user.

This commit is contained in:
Alexandre Julliard 2008-03-21 11:28:31 +01:00
parent 4754eb0b20
commit 3e8532779f

View file

@ -886,13 +886,24 @@ done:
*/
static void create_config_dir(void)
{
const char *config_dir = wine_get_config_dir();
const char *p, *config_dir = wine_get_config_dir();
char *tmp_dir;
int fd;
pid_t pid, wret;
if (!(tmp_dir = malloc( strlen(config_dir) + sizeof("-XXXXXX") )))
fatal_error( "out of memory\n" );
if ((p = strrchr( config_dir, '/' )) && p != config_dir)
{
struct stat st;
memcpy( tmp_dir, config_dir, p - config_dir );
tmp_dir[p - config_dir] = 0;
if (!stat( tmp_dir, &st ) && st.st_uid != getuid())
fatal_error( "'%s' is not owned by you, refusing to create a configuration directory there\n",
tmp_dir );
}
strcpy( tmp_dir, config_dir );
strcat( tmp_dir, "-XXXXXX" );
if ((fd = mkstemps( tmp_dir, 0 )) == -1)