From a84327d71be7df8848973cad0c6cdefd2962b3b4 Mon Sep 17 00:00:00 2001 From: Chris Dunlop Date: Tue, 13 Dec 2011 14:26:40 +1100 Subject: [PATCH 1/5] Add 'link by hash dir' to rsyncd.conf Expand upon link-by-hash.diff to enable configuring the option on the server side. Signed-off-by: Chris Dunlop --- clientserver.c | 5 +++++ loadparm.c | 4 ++++ options.c | 4 ++++ rsyncd.conf.yo | 8 ++++++++ 4 files changed, 21 insertions(+), 0 deletions(-) diff --git a/clientserver.c b/clientserver.c index 2294bb0..7d65733 100644 --- a/clientserver.c +++ b/clientserver.c @@ -50,6 +50,7 @@ extern int logfile_format_has_i; extern int logfile_format_has_o_or_i; extern char *bind_address; extern char *config_file; +extern char *link_by_hash_dir; extern char *logfile_format; extern char *files_from; extern char *tmpdir; @@ -551,6 +552,10 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char return -1; } + if (*lp_link_by_hash_dir(i)) { + link_by_hash_dir = lp_link_by_hash_dir(i); + } + if (am_daemon && am_server) { rprintf(FLOG, "rsync allowed access on module %s from %s (%s)\n", name, host, addr); diff --git a/loadparm.c b/loadparm.c index 965b771..5aed624 100644 --- a/loadparm.c +++ b/loadparm.c @@ -119,6 +119,7 @@ typedef struct { char *include; char *include_from; char *incoming_chmod; + char *link_by_hash_dir; char *lock_file; char *log_file; char *log_format; @@ -195,6 +196,7 @@ static const all_vars Defaults = { /* include; */ NULL, /* include_from; */ NULL, /* incoming_chmod; */ NULL, + /* link_by_hash_dir; */ NULL, /* lock_file; */ DEFAULT_LOCK_FILE, /* log_file; */ NULL, /* log_format; */ "%o %h [%a] %m (%u) %f %l", @@ -336,6 +338,7 @@ static struct parm_struct parm_table[] = {"include from", P_STRING, P_LOCAL, &Vars.l.include_from, NULL,0}, {"include", P_STRING, P_LOCAL, &Vars.l.include, NULL,0}, {"incoming chmod", P_STRING, P_LOCAL, &Vars.l.incoming_chmod, NULL,0}, + {"link by hash dir", P_STRING, P_LOCAL, &Vars.l.link_by_hash_dir, NULL,0}, {"list", P_BOOL, P_LOCAL, &Vars.l.list, NULL,0}, {"lock file", P_STRING, P_LOCAL, &Vars.l.lock_file, NULL,0}, {"log file", P_STRING, P_LOCAL, &Vars.l.log_file, NULL,0}, @@ -464,6 +467,7 @@ FN_LOCAL_STRING(lp_hosts_deny, hosts_deny) FN_LOCAL_STRING(lp_include, include) FN_LOCAL_STRING(lp_include_from, include_from) FN_LOCAL_STRING(lp_incoming_chmod, incoming_chmod) +FN_LOCAL_STRING(lp_link_by_hash_dir, link_by_hash_dir) FN_LOCAL_STRING(lp_lock_file, lock_file) FN_LOCAL_STRING(lp_log_file, log_file) FN_LOCAL_STRING(lp_log_format, log_format) diff --git a/options.c b/options.c index aeb7efe..f32b4d8 100644 --- a/options.c +++ b/options.c @@ -1302,6 +1302,10 @@ int parse_arguments(int *argc_p, const char ***argv_p) iconv_opt = strdup(arg); #endif + if (*lp_link_by_hash_dir(module_id)) { + set_refuse_options("link-by-hash"); + } + /* TODO: Call poptReadDefaultConfig; handle errors. */ /* The context leaks in case of an error, but if there's a diff --git a/rsyncd.conf.yo b/rsyncd.conf.yo index 29bb12f..f485695 100644 --- a/rsyncd.conf.yo +++ b/rsyncd.conf.yo @@ -283,6 +283,14 @@ message telling them to try later. The default is 0, which means no limit. A negative value disables the module. See also the "lock file" parameter. +dit(bf(link by hash dir)) When the "link by hash dir" parameter is set +to a non-empty string, received files will be hard linked into em(DIR), +a link farm arranged by MD4 file hash. The result is that the system +will only store one copy of the unique contents of each file, regardless +of the file's name. If this parameter is set it will disable the +bf(--link-by-hash) command-line option. The default is for this +parameter to be unset. + dit(bf(log file)) When the "log file" parameter is set to a non-empty string, the rsync daemon will log messages to the indicated file rather than using syslog. This is particularly useful on systems (such as AIX) -- 1.7.0.4