[Saga-devel] saga SVN commit 3275: /trunk/adaptors/ssh/ssh_context/

amerzky at cct.lsu.edu amerzky at cct.lsu.edu
Wed Jan 14 09:40:46 CST 2009


User: amerzky
Date: 2009/01/14 09:40 AM

Modified:
 /trunk/adaptors/ssh/ssh_context/
  Makefile, ssh_context_adaptor.cpp

Log:
 fixes

File Changes:

Directory: /trunk/adaptors/ssh/ssh_context/
===========================================

File [modified]: Makefile
Delta lines: +3 -0
===================================================================
--- trunk/adaptors/ssh/ssh_context/Makefile	2009-01-14 15:09:47 UTC (rev 3274)
+++ trunk/adaptors/ssh/ssh_context/Makefile	2009-01-14 15:40:34 UTC (rev 3275)
@@ -14,6 +14,9 @@
 SAGA_ADAPTOR_INI  = ssh_context_adaptor.ini
 SAGA_ADAPTOR_OBJ  = $(SAGA_OBJ)
 
+# we use saga::filesystem
+SAGA_ADAPTOR_PACKAGES = file 
+
 -include $(SAGA_MAKE_INCLUDE_ROOT)/saga.adaptor.mk
 
 distclean::

File [modified]: ssh_context_adaptor.cpp
Delta lines: +41 -5
===================================================================
--- trunk/adaptors/ssh/ssh_context/ssh_context_adaptor.cpp	2009-01-14 15:09:47 UTC (rev 3274)
+++ trunk/adaptors/ssh/ssh_context/ssh_context_adaptor.cpp	2009-01-14 15:40:34 UTC (rev 3275)
@@ -5,6 +5,8 @@
 
 #include "ssh_context_adaptor.hpp"
 
+#include <saga/saga.hpp>
+
 #include <saga/saga/adaptors/config.hpp>
 #include <saga/saga/adaptors/adaptor.hpp>
 #include <saga/saga/adaptors/attribute.hpp>
@@ -166,15 +168,49 @@
       return ci;
     }
 
-    path = home;
-    path += "/.ssh/id_dsa"; 
-    
-    // FIXME: look for id_rsa as fallback, and also look in ~/.ssh2/
+    saga::filesystem::directory d (std::string ("file://localhost/") + home);
+
+    if ( d.exists (".ssh") &&
+         d.is_dir (".ssh") )
+    {
+      d.change_dir (".ssh");
+    }
+    else
+    if ( d.exists (".ssh2") &&
+         d.is_dir (".ssh2") )
+    {
+      d.change_dir (".ssh2");
+    }
+    else
+    {
+      ci.errormessage = "Cannot access private ssh key";
+      ci.success      = false;
+      return ci;
+    }
+
+    if ( d.exists  ("id.dsa") &&
+         d.is_file ("id.dsa") )
+    {
+      path = d.get_cwd ().get_path () + "/id.dsa"; 
+    }
+    else
+    if ( d.exists  ("id.rsa") &&
+         d.is_file ("id.rsa") )
+    {
+      path = d.get_cwd ().get_path () + "/id.rsa"; 
+    }
+    else
+    {
+      ci.errormessage = "Cannot access private ssh key";
+      ci.success      = false;
+      return ci;
+    }
   }
 
 
 
-  // check if given [private key, and related public-key, exist
+  // check if given private key, and related public-key, exist
+  // FIXME: use saga::filesystem!
   struct stat buf;
 
   ci.private_key = path;



More information about the saga-devel mailing list