From: Lennart Poettering Date: Thu, 21 Aug 2025 09:26:43 +0000 (+0200) Subject: export-tar: refuse to write tar to a TTY X-Git-Tag: v259-rc1~505^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ba1d9f6db03429e73cb5b9a298dc173e8211754;p=thirdparty%2Fsystemd.git export-tar: refuse to write tar to a TTY --- diff --git a/src/import/export.c b/src/import/export.c index 6f035bf96ed..b3edc1a787e 100644 --- a/src/import/export.c +++ b/src/import/export.c @@ -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);