export-tar: refuse to write tar to a TTY

This commit is contained in:
Lennart Poettering
2025-09-18 15:40:41 +02:00
parent f20508da71
commit 0ba1d9f6db
+4
View File
@@ -18,6 +18,7 @@
#include "runtime-scope.h"
#include "signal-util.h"
#include "string-util.h"
#include "terminal-util.h"
#include "verbs.h"
static ImportCompressType arg_compress = IMPORT_COMPRESS_UNKNOWN;
@@ -93,6 +94,9 @@ static int export_tar(int argc, char *argv[], void *userdata) {
} else {
_cleanup_free_ char *pretty = NULL;
if (isatty_safe(STDOUT_FILENO))
return log_error_errno(SYNTHETIC_ERRNO(EBADF), "Refusing to write archive to TTY.");
fd = STDOUT_FILENO;
(void) fd_get_path(fd, &pretty);