From 7520e504cf2cdd3de2f236acb2cbf8a5016e6698 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Mon, 19 May 2014 18:16:52 -0700 Subject: [PATCH] ceph_filestore_dump: Fail import/export with a tty for stdin/stdout Signed-off-by: David Zafman --- src/tools/ceph_filestore_dump.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tools/ceph_filestore_dump.cc b/src/tools/ceph_filestore_dump.cc index 949042f14b9..dc94ec72bba 100644 --- a/src/tools/ceph_filestore_dump.cc +++ b/src/tools/ceph_filestore_dump.cc @@ -1176,12 +1176,20 @@ int main(int argc, char **argv) file_fd = fd_none; if (type == "export") { if (!vm.count("file")) { + if (outistty) { + cerr << "stdout is a tty and no --file option specified" << std::endl; + exit(1); + } file_fd = STDOUT_FILENO; } else { file_fd = open(file.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0666); } } else if (type == "import") { if (!vm.count("file")) { + if (isatty(STDIN_FILENO)) { + cerr << "stdin is a tty and no --file option specified" << std::endl; + exit(1); + } file_fd = STDIN_FILENO; } else { file_fd = open(file.c_str(), O_RDONLY); -- 2.47.3