]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_filestore_dump: Fail import/export with a tty for stdin/stdout
authorDavid Zafman <david.zafman@inktank.com>
Tue, 20 May 2014 01:16:52 +0000 (18:16 -0700)
committerDavid Zafman <dzafman@redhat.com>
Tue, 3 Mar 2015 17:51:30 +0000 (09:51 -0800)
Signed-off-by: David Zafman <david.zafman@inktank.com>
(cherry picked from commit 7520e504cf2cdd3de2f236acb2cbf8a5016e6698)

src/tools/ceph_filestore_dump.cc

index 4fa1c6ad5459209792768c3b1b5c69e43cb48024..cabd55890f3be75385b77ad224922d7de60f05d8 100644 (file)
@@ -1174,12 +1174,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);