From: David Zafman Date: Tue, 20 May 2014 01:16:52 +0000 (-0700) Subject: ceph_filestore_dump: Fail import/export with a tty for stdin/stdout X-Git-Tag: v0.86~180^2~28 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7520e504cf2cdd3de2f236acb2cbf8a5016e6698;p=ceph.git ceph_filestore_dump: Fail import/export with a tty for stdin/stdout Signed-off-by: David Zafman --- diff --git a/src/tools/ceph_filestore_dump.cc b/src/tools/ceph_filestore_dump.cc index 949042f14b95..dc94ec72bba6 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);