mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
zdtm/socket-ext: clean up test files
Reported-by: Dmitry Safonov <dima@arista.com> Cc: Dmitry Safonov <dima@arista.com> Signed-off-by: Andrei Vagin <avagin@openvz.org> Reviewed-by: Dmitry Safonov <dima@arista.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
061c21e6b8
commit
c971d7a97b
@@ -29,11 +29,26 @@ int main(int argc, char *argv[])
|
||||
char *path;
|
||||
pid_t pid;
|
||||
int ret, sk;
|
||||
char *val;
|
||||
|
||||
unsetenv("ZDTM_GROUPS");
|
||||
val = getenv("ZDTM_GID");
|
||||
if (val && (setgid(atoi(val)) == -1)) {
|
||||
fprintf(stderr, "Can't set gid: %m");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
val = getenv("ZDTM_UID");
|
||||
if (val && (setuid(atoi(val)) == -1)) {
|
||||
fprintf(stderr, "Can't set uid: %m");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (mkdtemp(dir) < 0) {
|
||||
pr_perror("mkdtemp(%s) failed", dir);
|
||||
return 1;
|
||||
}
|
||||
chmod(dir, 0777);
|
||||
addr.sun_family = AF_UNIX;
|
||||
snprintf(addr.sun_path, sizeof(addr.sun_path),
|
||||
"%s/%s", dir, "sock");
|
||||
@@ -92,8 +107,14 @@ int main(int argc, char *argv[])
|
||||
test_daemon();
|
||||
test_waitsig();
|
||||
|
||||
unlink(path);
|
||||
unlink(dir);
|
||||
if (unlink(path)) {
|
||||
pr_perror("Unable to remove %s\n", path);
|
||||
return 1;
|
||||
}
|
||||
if (rmdir(dir)) {
|
||||
pr_perror("Unable to remove %s", dir);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = send(sk, "H", 1, 0);
|
||||
if (ret != 1) {
|
||||
|
Reference in New Issue
Block a user