rshdriver

Nobuyuki Tsuchimura <[email protected]>
Newsgroups gmane.comp.web.sitecopy
Message-ID <[email protected]>
Hi, Joe

  I'm very glad that my patch for rshdriver is adopted
in release 0.14.0. I thank you very much.
I have some suggestions for rshdriver;
- bug fix for c compiler other than gcc,
- small memory leak? (I'm not sure),
- ad-hock modification against filename containing white space.

-- Regards,
Nobuyuki Tsuchimura

_______________________________________________
sitecopy maillist  -  [email protected]
http://dav.lyra.org/mailman/listinfo/sitecopy
sitecopy-0.14.2-rsh.patch (text/plain, 2.4 KB)
diff -uNr sitecopy-0.14.2/src/rshdriver.c sitecopy-0.14.2-sftp/src/rshdriver.c
--- sitecopy-0.14.2/src/rshdriver.c	2004-09-11 08:32:27.000000000 +0900
+++ sitecopy-0.14.2-sftp/src/rshdriver.c	2004-10-05 19:50:30.000000000 +0900
@@ -58,8 +58,9 @@
 static int run_rcmd(enum rcommand rcmd,
                     rsh_session *sess, const char *template, ...) 
 #ifdef __GNUC__
-    __attribute__ ((format (printf, 3, 4)));
+    __attribute__ ((format (printf, 3, 4)))
 #endif /* __GNUC__ */
+     ;
 
 static int run_rcmd(enum rcommand rcmd,
                     rsh_session *sess, const char *template, ...) 
@@ -84,14 +85,14 @@
     }
 
     NE_DEBUG(DEBUG_RSH, "rcmd: %s\n", cmd);
-    
+
     if (rcmd == RSH_PIPE_READ || rcmd == RSH_PIPE_WRITE) {
         sess->fp = popen(cmd, rcmd == RSH_PIPE_READ ? "r" : "w");
         return sess->fp != NULL ? SITE_OK : SITE_FAILED;
     } else {
         return system(cmd) == 0 ? SITE_OK : SITE_FAILED;
     }
-    
+    /* why not free(cmd)? */
 }
 
 static int run_finish(rsh_session *sess)
@@ -177,22 +178,22 @@
 
 static int file_delete(void *session, const char *filename) {
     rsh_session *sess = session;
-    return run_rcmd(RSH, sess, "rm %s", filename);
+    return run_rcmd(RSH, sess, "rm '%s'", filename);
 }
 
 static int file_chmod(void *session, const char *fname, const mode_t mode) {
     rsh_session *sess = session;
-    return run_rcmd(RSH, sess, "chmod %03o %s", mode, fname);
+    return run_rcmd(RSH, sess, "chmod %03o '%s'", mode, fname);
 }
 
 static int dir_create(void *session, const char *dirname) {
     rsh_session *sess = session;
-    return run_rcmd(RSH, sess, "mkdir %s", dirname);
+    return run_rcmd(RSH, sess, "mkdir '%s'", dirname);
 }
 
 static int dir_remove(void *session, const char *dirname) {
     rsh_session *sess = session;
-    return run_rcmd(RSH, sess, "rmdir %s", dirname);
+    return run_rcmd(RSH, sess, "rmdir '%s'", dirname);
 }
 
 static const char *error(void *session) {
@@ -234,7 +235,7 @@
     ls_destroy(lsctx);
 
     NE_DEBUG(DEBUG_RSH, "Fetch finished successfully.\n");
-    return run_finish(sess);
+    return success;
 }
 
 static int fetch_list(void *session, const char *dirname, int need_modtimes,
@@ -244,7 +245,8 @@
 
     ret = run_rcmd(RSH_PIPE_READ, sess, "ls -laR '%s'", dirname);
     if (ret == SITE_OK) {
-        ret = rsh_fetch(sess, dirname, files);
+        rsh_fetch(sess, dirname, files);
+        ret = run_finish(sess);
     }
 
     return ret;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.