]> andersk Git - openssh.git/blobdiff - sftp-int.c
- (bal) Cygwin lacks setgroups() API. Patch by Corinna Vinschen
[openssh.git] / sftp-int.c
index 18f2e6c46f10c056b90f3fde282a30e7d10d8bde..46e405e0dfb31e8c4cfc336244d7767982a96af7 100644 (file)
@@ -26,7 +26,7 @@
 /* XXX: recursive operations */
 
 #include "includes.h"
-RCSID("$OpenBSD: sftp-int.c,v 1.33 2001/04/05 10:42:53 markus Exp $");
+RCSID("$OpenBSD: sftp-int.c,v 1.36 2001/04/15 08:43:46 markus Exp $");
 
 #include "buffer.h"
 #include "xmalloc.h"
@@ -86,6 +86,7 @@ const struct CMD cmds[] = {
        { "dir",        I_LS },
        { "exit",       I_QUIT },
        { "get",        I_GET },
+       { "mget",       I_GET },
        { "help",       I_HELP },
        { "lcd",        I_LCHDIR },
        { "lchdir",     I_LCHDIR },
@@ -97,6 +98,7 @@ const struct CMD cmds[] = {
        { "lumask",     I_LUMASK },
        { "mkdir",      I_MKDIR },
        { "put",        I_PUT },
+       { "mput",       I_PUT },
        { "pwd",        I_PWD },
        { "quit",       I_QUIT },
        { "rename",     I_RENAME },
@@ -144,7 +146,7 @@ help(void)
 void
 local_do_shell(const char *args)
 {
-       int ret, status;
+       int status;
        char *shell;
        pid_t pid;
 
@@ -161,10 +163,10 @@ local_do_shell(const char *args)
                /* XXX: child has pipe fds to ssh subproc open - issue? */
                if (args) {
                        debug3("Executing %s -c \"%s\"", shell, args);
-                       ret = execl(shell, shell, "-c", args, NULL);
+                       execl(shell, shell, "-c", args, NULL);
                } else {
                        debug3("Executing %s", shell);
-                       ret = execl(shell, shell, NULL);
+                       execl(shell, shell, NULL);
                }
                fprintf(stderr, "Couldn't execute \"%s\": %s\n", shell,
                    strerror(errno));
@@ -854,9 +856,10 @@ parse_dispatch_command(int in, int out, const char *cmd, char **pwd)
 }
 
 void
-interactive_loop(int fd_in, int fd_out)
+interactive_loop(int fd_in, int fd_out, char *file1, char *file2)
 {
        char *pwd;
+       char *dir = NULL;
        char cmd[2048];
 
        version = do_init(fd_in, fd_out);
@@ -867,6 +870,25 @@ interactive_loop(int fd_in, int fd_out)
        if (pwd == NULL)
                fatal("Need cwd");
 
+       if (file1 != NULL) {
+               dir = xstrdup(file1);
+               dir = make_absolute(dir, pwd);
+
+               if (remote_is_dir(fd_in, fd_out, dir) && file2 == NULL) {
+                       printf("Changing to: %s\n", dir);
+                       snprintf(cmd, sizeof cmd, "cd \"%s\"", dir);
+                       parse_dispatch_command(fd_in, fd_out, cmd, &pwd);
+               } else {
+                       if (file2 == NULL)
+                               snprintf(cmd, sizeof cmd, "get %s", dir);
+                       else
+                               snprintf(cmd, sizeof cmd, "get %s %s", dir,
+                                   file2);
+
+                       parse_dispatch_command(fd_in, fd_out, cmd, &pwd);
+                       return;
+               }
+       }
        setvbuf(stdout, NULL, _IOLBF, 0);
        setvbuf(infile, NULL, _IOLBF, 0);
 
This page took 0.59749 seconds and 4 git commands to generate.