When listing a bare module name w/o -r, make sure we list the

contents of the module's root directory.
This commit is contained in:
Wayne Davison committed 2007-10-27 02:19:49 +00:00
1 parent 1d8638ce86
commit e844a4a8a8
2 files changed
+25 -11

No files matched your search

+24 -10
View File
@@ -192,21 +192,31 @@ static int exchange_protocols(int f_in, int f_out, char *buf, size_t bufsiz, int
int start_inband_exchange(int f_in, int f_out, const char *user, int argc, char *argv[])
{
int i;
int i, modlen;
char line[BIGPATHBUFLEN];
char *sargs[MAX_ARGS];
int sargc = 0;
char *p, *path = *argv;
char *p, *modname;
if (argc == 0 && !am_sender)
list_only |= 1;
assert(argc > 0);
if (*path == '/') {
if (**argv == '/') {
rprintf(FERROR,
"ERROR: The remote path must start with a module name\n");
return -1;
}
if (!(p = strchr(*argv, '/')))
modlen = strlen(*argv);
else
modlen = p - *argv;
if (!(modname = new_array(char, modlen+1+1))) /* room for '/' & '\0' */
out_of_memory("start_inband_exchange");
strlcpy(modname, *argv, modlen + 1);
modname[modlen] = '/';
modname[modlen+1] = '\0';
if (!user)
user = getenv("USER");
if (!user)
@@ -232,7 +242,12 @@ int start_inband_exchange(int f_in, int f_out, const char *user, int argc, char
rprintf(FERROR, "internal: args[] overflowed in do_cmd()\n");
exit_cleanup(RERR_SYNTAX);
}
sargs[sargc++] = *argv++;
if (list_only && strncmp(*argv, modname, modlen) == 0
&& argv[0][modlen] == '\0')
sargs[sargc++] = modname; /* we send "modname/" */
else
sargs[sargc++] = *argv;
argv++;
argc--;
}
@@ -241,10 +256,7 @@ int start_inband_exchange(int f_in, int f_out, const char *user, int argc, char
if (verbose > 1)
print_child_argv("sending daemon args:", sargs);
p = strchr(path, '/');
if (p) *p = '\0';
io_printf(f_out, "%s\n", path);
if (p) *p = '/';
io_printf(f_out, "%.*s\n", modlen, modname);
/* Old servers may just drop the connection here,
rather than sending a proper EXIT command. Yuck. */
@@ -303,6 +315,8 @@ int start_inband_exchange(int f_in, int f_out, const char *user, int argc, char
io_start_multiplex_in();
}
free(modname);
return 0;
}
+1 -1
View File
@@ -723,7 +723,7 @@ static void do_server_sender(int f_in, int f_out, int argc, char *argv[])
argc--;
argv++;
if (argc == 0 && (recurse || list_only)) {
if (argc == 0 && (recurse || xfer_dirs || list_only)) {
argc = 1;
argv--;
argv[0] = ".";