mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
Added O_TMPFILE support for uwac tempfile generation.
This commit is contained in:
@@ -212,11 +212,11 @@ static int create_tmpfile_cloexec(char* tmpname)
|
||||
int uwac_create_anonymous_file(off_t size)
|
||||
{
|
||||
static const char template[] = "/weston-shared-XXXXXX";
|
||||
const char* path;
|
||||
size_t length;
|
||||
char* name;
|
||||
const char* path;
|
||||
int fd;
|
||||
int ret;
|
||||
size_t length;
|
||||
path = getenv("XDG_RUNTIME_DIR");
|
||||
|
||||
if (!path)
|
||||
@@ -225,15 +225,20 @@ int uwac_create_anonymous_file(off_t size)
|
||||
return -1;
|
||||
}
|
||||
|
||||
length = strlen(path) + sizeof(template);
|
||||
name = malloc(length);
|
||||
fd = open(path, O_TMPFILE | O_RDWR | O_EXCL, 0600);
|
||||
|
||||
if (!name)
|
||||
return -1;
|
||||
if (fd < 0)
|
||||
{
|
||||
length = strlen(path) + sizeof(template);
|
||||
name = malloc(length);
|
||||
|
||||
snprintf(name, length, "%s%s", path, template);
|
||||
fd = create_tmpfile_cloexec(name);
|
||||
free(name);
|
||||
if (!name)
|
||||
return -1;
|
||||
|
||||
snprintf(name, length, "%s%s", path, template);
|
||||
fd = create_tmpfile_cloexec(name);
|
||||
free(name);
|
||||
}
|
||||
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user