Commit f7632fc6 authored by Andrew Tridgell's avatar Andrew Tridgell

if no local destination is provided for the transfer then provide

a "ls -l" style listing of the files that would be transferred
parent 2f098547
...@@ -51,6 +51,36 @@ static struct exclude_struct **local_exclude_list; ...@@ -51,6 +51,36 @@ static struct exclude_struct **local_exclude_list;
static void clean_flist(struct file_list *flist, int strip_root); static void clean_flist(struct file_list *flist, int strip_root);
static void list_file_entry(struct file_struct *f)
{
char perms[11] = "----------";
char *perm_map = "rwxrwxrwx";
int i;
for (i=0;i<9;i++) {
if (f->mode & (1<<i)) perms[9-i] = perm_map[8-i];
}
if (S_ISLNK(f->mode)) perms[0] = 'l';
if (S_ISDIR(f->mode)) perms[0] = 'd';
if (S_ISBLK(f->mode)) perms[0] = 'b';
if (S_ISCHR(f->mode)) perms[0] = 'c';
if (S_ISSOCK(f->mode)) perms[0] = 's';
if (S_ISFIFO(f->mode)) perms[0] = 'p';
if (preserve_links && S_ISLNK(f->mode)) {
rprintf(FINFO,"%s %11.0f %s %s -> %s\n",
perms,
(double)f->length, timestring(f->modtime),
f_name(f), f->link);
} else {
rprintf(FINFO,"%s %11.0f %s %s\n",
perms,
(double)f->length, timestring(f->modtime), f_name(f));
}
}
int link_stat(const char *Path, STRUCT_STAT *Buffer) int link_stat(const char *Path, STRUCT_STAT *Buffer)
{ {
#if SUPPORT_LINKS #if SUPPORT_LINKS
...@@ -699,6 +729,7 @@ struct file_list *recv_file_list(int f) ...@@ -699,6 +729,7 @@ struct file_list *recv_file_list(int f)
struct file_list *flist; struct file_list *flist;
unsigned char flags; unsigned char flags;
int64 start_read; int64 start_read;
extern int list_only;
if (verbose && recurse && !am_server) { if (verbose && recurse && !am_server) {
rprintf(FINFO,"receiving file list ... "); rprintf(FINFO,"receiving file list ... ");
...@@ -765,6 +796,14 @@ struct file_list *recv_file_list(int f) ...@@ -765,6 +796,14 @@ struct file_list *recv_file_list(int f)
io_error |= read_int(f); io_error |= read_int(f);
} }
if (list_only) {
int i;
for (i=0;i<flist->count;i++) {
list_file_entry(flist->files[i]);
}
}
if (verbose > 2) if (verbose > 2)
rprintf(FINFO,"recv_file_list done\n"); rprintf(FINFO,"recv_file_list done\n");
......
...@@ -165,6 +165,9 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out) ...@@ -165,6 +165,9 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
char *fnamecmp; char *fnamecmp;
char fnamecmpbuf[MAXPATHLEN]; char fnamecmpbuf[MAXPATHLEN];
extern char *compare_dest; extern char *compare_dest;
extern int list_only;
if (list_only) return;
if (verbose > 2) if (verbose > 2)
rprintf(FINFO,"recv_generator(%s,%d)\n",fname,i); rprintf(FINFO,"recv_generator(%s,%d)\n",fname,i);
......
...@@ -26,33 +26,11 @@ ...@@ -26,33 +26,11 @@
static FILE *logfile; static FILE *logfile;
/****************************************************************************
return the date and time as a string
****************************************************************************/
static char *timestring(void )
{
static char TimeBuf[200];
time_t t = time(NULL);
struct tm *tm = localtime(&t);
#ifdef HAVE_STRFTIME
strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %T",tm);
#else
strlcpy(TimeBuf, asctime(tm), sizeof(TimeBuf)-1);
#endif
if (TimeBuf[strlen(TimeBuf)-1] == '\n') {
TimeBuf[strlen(TimeBuf)-1] = 0;
}
return(TimeBuf);
}
static void logit(int priority, char *buf) static void logit(int priority, char *buf)
{ {
if (logfile) { if (logfile) {
fprintf(logfile,"%s [%d] %s", fprintf(logfile,"%s [%d] %s",
timestring(), (int)getpid(), buf); timestring(time(NULL)), (int)getpid(), buf);
fflush(logfile); fflush(logfile);
} else { } else {
syslog(priority, "%s", buf); syslog(priority, "%s", buf);
......
...@@ -384,6 +384,7 @@ int client_run(int f_in, int f_out, int pid, int argc, char *argv[]) ...@@ -384,6 +384,7 @@ int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
int status = 0, status2 = 0; int status = 0, status2 = 0;
char *local_name = NULL; char *local_name = NULL;
extern int am_sender; extern int am_sender;
extern int list_only;
setup_protocol(f_out,f_in); setup_protocol(f_out,f_in);
...@@ -412,6 +413,8 @@ int client_run(int f_in, int f_out, int pid, int argc, char *argv[]) ...@@ -412,6 +413,8 @@ int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
report(-1); report(-1);
exit_cleanup(status); exit_cleanup(status);
} }
if (argc == 0) list_only = 1;
send_exclude_list(f_out); send_exclude_list(f_out);
...@@ -462,6 +465,20 @@ static int start_client(int argc, char *argv[]) ...@@ -462,6 +465,20 @@ static int start_client(int argc, char *argv[])
extern int am_sender; extern int am_sender;
extern char *shell_cmd; extern char *shell_cmd;
if (strncasecmp(URL_PREFIX, argv[0], strlen(URL_PREFIX)) == 0) {
char *host, *path;
host = argv[0] + strlen(URL_PREFIX);
p = strchr(host,'/');
if (p) {
*p = 0;
path = p+1;
} else {
path="";
}
return start_socket_client(host, path, argc-1, argv+1);
}
p = find_colon(argv[0]); p = find_colon(argv[0]);
if (p) { if (p) {
...@@ -470,7 +487,7 @@ static int start_client(int argc, char *argv[]) ...@@ -470,7 +487,7 @@ static int start_client(int argc, char *argv[])
return start_socket_client(argv[0], p+2, argc-1, argv+1); return start_socket_client(argv[0], p+2, argc-1, argv+1);
} }
if (argc < 2) { if (argc < 1) {
usage(FERROR); usage(FERROR);
exit_cleanup(1); exit_cleanup(1);
} }
...@@ -525,7 +542,7 @@ static int start_client(int argc, char *argv[]) ...@@ -525,7 +542,7 @@ static int start_client(int argc, char *argv[])
shell_path?shell_path:""); shell_path?shell_path:"");
} }
if (!am_sender && argc != 1) { if (!am_sender && argc > 1) {
usage(FERROR); usage(FERROR);
exit_cleanup(1); exit_cleanup(1);
} }
......
...@@ -73,7 +73,7 @@ int rsync_port = RSYNC_PORT; ...@@ -73,7 +73,7 @@ int rsync_port = RSYNC_PORT;
int verbose = 0; int verbose = 0;
int always_checksum = 0; int always_checksum = 0;
int list_only = 0;
void usage(int F) void usage(int F)
{ {
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#define RSYNC_NAME "rsync" #define RSYNC_NAME "rsync"
#define RSYNCD_CONF "/etc/rsyncd.conf" #define RSYNCD_CONF "/etc/rsyncd.conf"
#define URL_PREFIX "rsync://"
#define BACKUP_SUFFIX "~" #define BACKUP_SUFFIX "~"
/* a non-zero CHAR_OFFSET makes the rolling sum stronger, but is /* a non-zero CHAR_OFFSET makes the rolling sum stronger, but is
......
...@@ -140,6 +140,9 @@ itemize( ...@@ -140,6 +140,9 @@ itemize(
it() if you specify no path name on the remote server then the it() if you specify no path name on the remote server then the
list of accessible paths on the server will be shown. list of accessible paths on the server will be shown.
it() if you specify no local destination then a listing of the
specified files on the remote server is provided
) )
Some paths on the remote server may require authentication. If so then Some paths on the remote server may require authentication. If so then
......
...@@ -762,3 +762,25 @@ char *sanitize_path(char *p) ...@@ -762,3 +762,25 @@ char *sanitize_path(char *p)
return(copy); return(copy);
} }
/****************************************************************************
return the date and time as a string
****************************************************************************/
char *timestring(time_t t)
{
static char TimeBuf[200];
struct tm *tm = localtime(&t);
#ifdef HAVE_STRFTIME
strftime(TimeBuf,sizeof(TimeBuf)-1,"%Y/%m/%d %T",tm);
#else
strlcpy(TimeBuf, asctime(tm), sizeof(TimeBuf)-1);
#endif
if (TimeBuf[strlen(TimeBuf)-1] == '\n') {
TimeBuf[strlen(TimeBuf)-1] = 0;
}
return(TimeBuf);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment