Create a secure temp path instead of a predictable one (Thanks Han)

With this commit, i3 will now use either $XDG_RUNTIME_DIR/i3 (XDG_RUNTIME_DIR
is only writable by the user, so this is not a problem) or a secure temporary
location in /tmp, following the pattern /tmp/i3-<user>.XXXXXX
This commit is contained in:
Michael Stapelberg
2011-12-18 17:53:21 +00:00
parent 7eb2ca405e
commit c21172a6f6
5 changed files with 51 additions and 23 deletions

View File

@ -20,9 +20,20 @@ EOT
# ensure XDG_RUNTIME_DIR is not set
delete $ENV{XDG_RUNTIME_DIR};
# See which files exist in /tmp before to not mistakenly check an already
# existing tmpdir of another i3 instance.
my @files_before = </tmp/i3-*>;
my $pid = launch_with_config($config, 1);
my @files_after = </tmp/i3-*>;
@files_after = grep { !($_ ~~ @files_before) } @files_after;
is(@files_after, 1, 'one new temp directory');
my $folder = "/tmp/i3-" . getpwuid(getuid());
like($files_after[0], qr/^$folder/, 'temp directory matches expected pattern');
$folder = $files_after[0];
ok(-d $folder, "folder $folder exists");
my $socketpath = "$folder/ipc-socket." . $pid;
ok(-S $socketpath, "file $socketpath exists and is a socket");