]> 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>
Thu, 28 Aug 2014 23:21:28 +0000 (16:21 -0700)
Signed-off-by: David Zafman <david.zafman@inktank.com>
src/tools/ceph_filestore_dump.cc

index 949042f14b952744d567f94657693eddc14bc02a..dc94ec72bba661fef93a6c367f29171b7903b431 100644 (file)
@@ -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);