]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
export-tar: refuse to write tar to a TTY
authorLennart Poettering <lennart@poettering.net>
Thu, 21 Aug 2025 09:26:43 +0000 (11:26 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 18 Sep 2025 13:40:41 +0000 (15:40 +0200)
src/import/export.c

index 6f035bf96ed91078ba5512f8e9febe74faf00569..b3edc1a787ea517b6c831def9f735a8467af8a1d 100644 (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);