redmine

Started support of "--modification-signature" option

... ... @@ -116,6 +116,7 @@ enum flags_enum {
CG_GROUPNAME = 40|OPTION_LONGOPTONLY,
PERMIT_MPROTECT = 41|OPTION_LONGOPTONLY,
SHM_MPROTECT = 42|OPTION_LONGOPTONLY,
MODSIGN = 43|OPTION_LONGOPTONLY,
};
typedef enum flags_enum flags_t;
... ...
... ... @@ -130,6 +130,7 @@ static const struct option long_options[] =
#endif
{"max-iterations", required_argument, NULL, MAXITERATIONS},
{"standby-file", required_argument, NULL, STANDBYFILE},
{"modification-signature",required_argument, NULL, MODSIGN},
{"timeout-sync", required_argument, NULL, SYNCTIMEOUT},
{"delay-sync", required_argument, NULL, SYNCDELAY},
{"delay-collect", required_argument, NULL, DELAY},
... ... @@ -183,6 +184,43 @@ static char *const pivotrootways[] = {
#ifdef CAPABILITIES_SUPPORT
enum stat_fields {
STAT_FIELD_RESET = 0x0000,
STAT_FIELD_DEV = 0x0001,
STAT_FIELD_INO = 0x0002,
STAT_FIELD_MODE = 0x0004,
STAT_FIELD_NLINK = 0x0008,
STAT_FIELD_UID = 0x0010,
STAT_FIELD_GID = 0x0020,
STAT_FIELD_RDEV = 0x0040,
STAT_FIELD_SIZE = 0x0080,
STAT_FIELD_BLKSIZE = 0x0100,
STAT_FIELD_BLOCKS = 0x0200,
STAT_FIELD_ATIME = 0x0400,
STAT_FIELD_MTIME = 0x0800,
STAT_FIELD_CTIME = 0x1000,
STAT_FIELD_ALL = 0x1ff7,
};
static char *const stat_fields[] = {
[STAT_FIELD_RESET] = "",
[STAT_FIELD_DEV] = "dev",
[STAT_FIELD_INO] = "ino",
[STAT_FIELD_MODE] = "mode",
[STAT_FIELD_NLINK] = "nlink",
[STAT_FIELD_UID] = "uid",
[STAT_FIELD_GID] = "gid",
[STAT_FIELD_RDEV] = "rdev",
[STAT_FIELD_SIZE] = "size",
[STAT_FIELD_BLKSIZE] = "blksize",
[STAT_FIELD_BLOCKS] = "blocks",
[STAT_FIELD_ATIME] = "atime",
[STAT_FIELD_MTIME] = "mtime",
[STAT_FIELD_CTIME] = "ctime",
NULL
};
enum x_capabilities {
X_CAP_RESET = 0,
X_CAP_DAC_READ_SEARCH,
... ... @@ -1212,6 +1250,21 @@ int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsource_t pa
ctx_p->flags[STANDBYFILE] = 0;
}
break;
case MODSIGN: {
char *subopts = arg;
ctx_p->flags[MODSIGN] = 0;
while (*subopts != 0) {
char *value;
typeof(ctx_p->flags[MODSIGN]) field = getsubopt(&subopts, stat_fields, &value);
debug(4, "field == 0x%x", field);
if (field != STAT_FIELD_RESET)
ctx_p->flags[MODSIGN] |= field;
}
break;
}
case SYNCDELAY:
ctx_p->syncdelay = (unsigned int)atol(arg);
break;
... ...
... ... @@ -618,14 +618,63 @@ to prevent infinite sync-up processes.
The default value is "0".
.RE
.B \-\-modification\-signature
.I signature\-mask
.RS
Sets file/dir modification recheck signature.
See
.I "struct stat"
in
.BR lstat (2)
for possible fields.
For example reasonable
.IR signature\-mask \-s
can be "dev,ino,mode,uid,gid,rdev,size,atime,mtime,ctime" (there's an alias for that — "*") or "uid,gid".
Examples of use cases:
.RS
.B chown/chmod
.RS
If you're using clsync for fixing file/dir privileges [using
.BR chown (1)
and/or
.BR chmod (1)]
than reasonable signature will be "uid,gid".
Full example: clsync \-w5 \-t5 \-T5 \-x1 \-W /var/www/site.example.org/root \-Mdirect \-Schown \-\-uid 0 \-\-gid 0 \-Ysyslog \-b1 \-\-modification\-signature uid,gid \-\- \-\-from=root www\-data:www\-data %INCLUDE\-LIST%
.RE
.B "bi\-directional syncing"
.RS
If you're going to setup bi\-directional syncing then you may use \-\-modification\-signature "*" to prevent sync loop between servers.
.RE
.B Not enough CPU
.RS
If rsync eats to many CPU with rechecking hashsums of files on their dry open()/close() due to some hacky script (for example "chown -R www-data:www-data" in cron) then you can use \-\-modification\-signature "dev,ino,mode,uid,gid,rdev,size,atime,mtime" (without "blksize", "blocks", "nlink" and "ctime")
.RE
.RE
.B Warning!
This option requires a
.BR lstat (2)
syscall on every file and directory. This may essentially reduce the
.B clsync
performance.
To disable file/dir modification rechecking use empty value — "".
The default value is "".
.RE
.PP
.B \-k, \-\-timeout\-sync
.I sync-timeout
.I sync\-timeout
.RS
Sets timeout for syncing processes.
.B clsync
will die if syncing process alive more than
.I sync-timeout
.I sync\-timeout
seconds.
Set "0" to disable the timeout.
... ...