BOOL read_only;
BOOL list;
BOOL use_chroot;
+ BOOL transfer_logging;
char *uid;
char *gid;
char *hosts_allow;
True, /* read only */
True, /* list */
True, /* use chroot */
+ False, /* transfer logging */
"nobody",/* uid */
"nobody",/* gid */
NULL, /* hosts allow */
{"secrets file", P_STRING, P_LOCAL, &sDefault.secrets_file,NULL, 0},
{"exclude", P_STRING, P_LOCAL, &sDefault.exclude, NULL, 0},
{"exclude from", P_STRING, P_LOCAL, &sDefault.exclude_from,NULL, 0},
+ {"transfer logging", P_BOOL, P_LOCAL, &sDefault.transfer_logging,NULL,0},
{NULL, P_BOOL, P_NONE, NULL, NULL, 0}
};
FN_LOCAL_BOOL(lp_read_only, read_only)
FN_LOCAL_BOOL(lp_list, list)
FN_LOCAL_BOOL(lp_use_chroot, use_chroot)
+FN_LOCAL_BOOL(lp_transfer_logging, transfer_logging)
FN_LOCAL_STRING(lp_uid, uid)
FN_LOCAL_STRING(lp_gid, gid)
FN_LOCAL_STRING(lp_hosts_allow, hosts_allow)
buf[len] = 0;
+ if (fd == FLOG) {
+ if (am_daemon) logit(LOG_INFO, buf);
+ depth--;
+ return;
+ }
+
if (am_daemon) {
int priority = LOG_INFO;
if (fd == FERROR) priority = LOG_WARNING;
fflush(f);
}
+
+/* log the outgoing transfer of a file */
+void log_send(struct file_struct *file)
+{
+ extern int module_id;
+ if (lp_transfer_logging(module_id)) {
+ rprintf(FLOG,"Sending %s [%s] %.0f %s\n",
+ client_name(0), client_addr(0),
+ (double)file->length, f_name(file));
+ }
+}
+
+/* log the incoming transfer of a file */
+void log_recv(struct file_struct *file)
+{
+ extern int module_id;
+ if (lp_transfer_logging(module_id)) {
+ rprintf(FLOG,"Receiving %s [%s] %.0f %s\n",
+ client_name(0), client_addr(0),
+ (double)file->length, f_name(file));
+ }
+}
+
+/* log the incoming transfer of a file for interactive use, this
+ will be called at the end where the client was run */
+void log_transfer(struct file_struct *file, char *fname)
+{
+ extern int verbose;
+
+ if (!verbose) return;
+
+ rprintf(FINFO,"%s\n", fname);
+}
extern int do_stats;
if (am_daemon) {
- syslog(LOG_INFO,"wrote %.0f bytes read %.0f bytes total size %.0f\n",
+ rprintf(FLOG,"wrote %.0f bytes read %.0f bytes total size %.0f\n",
(double)stats.total_written,
(double)stats.total_read,
(double)stats.total_size);
struct file_struct *file;
int phase=0;
int recv_ok;
-
+ extern int module_id;
+
if (verbose > 2) {
rprintf(FINFO,"recv_files(%d) starting\n",flist->count);
}
fname = local_name;
if (dry_run) {
- if (!am_server && verbose)
- rprintf(FINFO,"%s\n",fname);
+ if (!am_server) {
+ log_transfer(file, fname);
+ }
continue;
}
cleanup_set(fnametmp, fname, file, buf, fd1, fd2);
- if (!am_server && verbose)
- rprintf(FINFO,"%s\n",fname);
+ if (!am_server) {
+ log_transfer(file, fname);
+ }
+
+ log_recv(file);
/* recv file data */
recv_ok = receive_data(f_in,buf,fd2,fname,file->length);
#define MPLEX_BASE 7
#define FERROR 1
#define FINFO 2
+#define FLOG 3
#include "config.h"
local1, local2, local3, local4, local5, local6 and local7. The default
is daemon.
+dit(bf(transfer file)) The "transfer logging" option enables per-file
+logging of downloads and uploads in a format somewhat similar to that
+used by ftp daemons. If you want to customise the log formats look at
+log_send, log_recv and log_transfer in log.c
+
dit(bf(socket options)) This option can provide endless fun for people
who like to tune their systems to the utmost degree. You can set all
sorts of socket options which may make transfers faster (or
offset = strlen(file->basedir)+1;
}
strlcat(fname,f_name(file),MAXPATHLEN-strlen(fname));
+ clean_fname(fname);
if (verbose > 2)
rprintf(FINFO,"send_files(%d,%s)\n",i,fname);
if (dry_run) {
- if (!am_server && verbose)
- rprintf(FINFO,"%s\n",fname);
+ if (!am_server) {
+ log_transfer(file, fname+offset);
+ }
write_int(f_out,i);
continue;
}
if (verbose > 2)
rprintf(FINFO,"send_files mapped %s of size %d\n",
fname,(int)st.st_size);
+
+ log_send(file);
write_int(f_out,i);
if (verbose > 2)
rprintf(FINFO,"calling match_sums %s\n",fname);
- if (!am_server && verbose)
- rprintf(FINFO,"%s\n",fname+offset);
+ if (!am_server) {
+ log_transfer(file, fname+offset);
+ }
match_sums(f_out,s,buf,st.st_size);
struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
int length = sizeof(sa);
static char addr_buf[100];
+ static int initialised;
+
+ if (initialised) return addr_buf;
+
+ initialised = 1;
if (getpeername(fd, &sa, &length)) {
exit_cleanup(1);
}
-
+
strlcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr), sizeof(addr_buf)-1);
-
return addr_buf;
}
struct hostent *hp;
char **p;
char *def = "UNKNOWN";
+ static int initialised;
+
+ if (initialised) return name_buf;
+
+ initialised = 1;
strcpy(name_buf,def);