hello! 2.6.4 is out -- I'm too late again :-(
I've posted an older version of this patch in the past and
this time I hope it will make it into the source tree.
Because loadparms.c and rsyncd.conf.yo have changed
`make proto' and `make man' have to be called.
rsyncd.conf options to handle file permissions
(stolen from samba)
This patch is made to provide more control on the
permissions of files and directories that are
uploaded to a rsyncd-server.
Normally when files and directories are uploaded to
a rsyncd they are created with the permissions of the
source. Especially in the case that user and group
are set to special values using the 'uid' and 'gid'
directives it does not much sense to use the source
permission pattern.
There is a patch introducing a new chmod command line
option but normally you may want to control the permissions
on server side. The patch below will allow you to modify
file and directory permissions by using 4 new rsyncd.conf
directives. I'm sure that those 2 patches will not break
each other and it really makes sense to use them both.
You may know this options from samba.
create mask
When a file is created (or touched) by rsyncd the
permissions will be taken from the source file
bit-wise 'AND'ed with this parameter. This
parameter may be thought of as a bit-wise MASK for
the UNIX modes of a file. Any bit not set here will
be removed from the modes set on a file when it is
created.
The default value of this parameter is set to 07777
to be provide the default behaviour of older versions.
Following this rsync will bit-wise 'OR' the UNIX
mode created from this parameter with the value of
the force create mode parameter which is set to 000
by default.
This parameter does not affect directory modes. See
the parameter "directory mask" for details.
See also the "force create mode" parameter for
forcing particular mode bits to be set on created
files. See also the "directory mask" parameter for
masking mode bits on created directories.
Default: create mask = 07777
Example: create mask = 0644
force create mode
This parameter specifies a set of UNIX mode bit
permissions that will always be set on a file created
by rsyncd. This is done by bitwise 'OR'ing these bits
onto the mode bits of a file that is being created or
having its permissions changed.
The default for this parameter is (in octal) 000.
The modes in this parameter are bitwise 'OR'ed onto
the file mode after the mask set in the "create mask"
parameter is applied.
See also the parameter "create mask" for details on
masking mode bits on files.
Default: force create mode = 000
Example: force create mode = 0644
directory mask
When a directory is created (or touched) by rsyncd the
permissions will be taken from the source directory
bit-wise 'AND'ed with this parameter. This
parameter may be thought of as a bit-wise MASK for
the UNIX modes of a file. Any bit not set here will
be removed from the modes set on a file when it is
created.
The default value of this parameter is set to 07777
to be provide the default behaviour of older versions.
Following this rsync will bit-wise 'OR' the UNIX
mode created from this parameter with the value of
the "force directory mode" parameter which is set to 000
by default.
This parameter does not affect file modes. See
the parameter "create mask" for details.
See also the "force directory mode" parameter for
forcing particular mode bits to be set on created
directories. See also the "create mask" parameter for
masking mode bits on created files.
Default: directory mask = 07777
Example: directory mask = 0755
force directory mode
This parameter specifies a set of UNIX mode bit
permissions that will always be set on a directory
created by rsyncd. This is done by bitwise 'OR'ing
these bits onto the mode bits of a directory that
is being created. The default for this parameter is
(in octal) 0000 which will not add any extra permission
bits to a created directory. This operation is done
after the mode mask in the parameter "directory mask"
is applied.
See also the parameter directory mask for details
on masking mode bits on created directories.
Default: force directory mode = 000
Example: force directory mode = 0755
cu, Stefan
--
Stefan Nehlsen | ParlaNet Administration | [EMAIL PROTECTED] | +49 431 988-1260
diff -u rsync-2.6.4/loadparm.c rsync-2.6.4-rsyncd-perm/loadparm.c
--- rsync-2.6.4/loadparm.c 2005-02-19 18:38:51.000000000 +0100
+++ rsync-2.6.4-rsyncd-perm/loadparm.c 2005-03-31 10:28:40.729525901 +0200
@@ -144,6 +144,10 @@
int timeout;
int max_connections;
BOOL ignore_nonreadable;
+ int create_mask;
+ int force_create_mode;
+ int directory_mask;
+ int force_directory_mode;
} service;
@@ -186,7 +190,11 @@
"*.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz", /* dont
compress */
0, /* timeout */
0, /* max connections */
- False /* ignore nonreadable */
+ False, /* ignore nonreadable */
+ CHMOD_BITS, /* create mask */
+ 0, /* force create mode */
+ CHMOD_BITS, /* directory mask */
+ 0 /* force directory mode */
};
@@ -306,6 +314,10 @@
{"log format", P_STRING, P_LOCAL, &sDefault.log_format, NULL, 0},
{"refuse options", P_STRING, P_LOCAL, &sDefault.refuse_options,NULL, 0},
{"dont compress", P_STRING, P_LOCAL, &sDefault.dont_compress,NULL, 0},
+ {"create mask", P_OCTAL, P_LOCAL, &sDefault.create_mask,
NULL, 0},
+ {"force create mode", P_OCTAL, P_LOCAL, &sDefault.force_create_mode,
NULL, 0},
+ {"directory mask", P_OCTAL, P_LOCAL, &sDefault.directory_mask,
NULL, 0},
+ {"force directory mode", P_OCTAL, P_LOCAL, &sDefault.force_directory_mode,
NULL, 0},
{NULL, P_BOOL, P_NONE, NULL, NULL, 0}
};
@@ -391,6 +403,10 @@
FN_LOCAL_STRING(lp_dont_compress, dont_compress)
FN_LOCAL_INTEGER(lp_timeout, timeout)
FN_LOCAL_INTEGER(lp_max_connections, max_connections)
+FN_LOCAL_INTEGER(lp_create_mask, create_mask)
+FN_LOCAL_INTEGER(lp_force_create_mode, force_create_mode)
+FN_LOCAL_INTEGER(lp_directory_mask, directory_mask)
+FN_LOCAL_INTEGER(lp_force_directory_mode, force_directory_mode)
/* local prototypes */
static int strwicmp(char *psz1, char *psz2);
diff -u rsync-2.6.4/rsync.c rsync-2.6.4-rsyncd-perm/rsync.c
--- rsync-2.6.4/rsync.c 2005-03-14 18:06:08.000000000 +0100
+++ rsync-2.6.4-rsyncd-perm/rsync.c 2005-03-31 10:28:40.736524282 +0200
@@ -56,6 +56,8 @@
int updated = 0;
STRUCT_STAT st2;
int change_uid, change_gid;
+ extern int am_daemon;
+ extern int module_id;
if (!st) {
if (dry_run)
@@ -126,9 +128,19 @@
#ifdef HAVE_CHMOD
if (!S_ISLNK(st->st_mode)) {
- if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) {
+ mode_t mode = file->mode; /* file->mode shouldn't be modified */
+ if (am_daemon) {
+ if(S_ISDIR(st->st_mode)) {
+ mode = ( mode & lp_directory_mask(module_id))
+ | lp_force_directory_mode(module_id);
+ } else {
+ mode = ( mode & lp_create_mask(module_id))
+ | lp_force_create_mode(module_id);
+ }
+ }
+ if ((st->st_mode & CHMOD_BITS) != (mode & CHMOD_BITS)) {
updated = 1;
- if (do_chmod(fname,(file->mode & CHMOD_BITS)) != 0) {
+ if (do_chmod(fname,(mode & CHMOD_BITS)) != 0) {
rsyserr(FERROR, errno, "failed to set
permissions on %s",
full_fname(fname));
return 0;
diff -u rsync-2.6.4/rsyncd.conf.yo rsync-2.6.4-rsyncd-perm/rsyncd.conf.yo
--- rsync-2.6.4/rsyncd.conf.yo 2005-03-31 05:14:09.000000000 +0200
+++ rsync-2.6.4-rsyncd-perm/rsyncd.conf.yo 2005-03-31 10:28:40.744522431
+0200
@@ -218,6 +218,70 @@
was run as root. This complements the "uid" option. The default is gid -2,
which is normally the group "nobody".
+dit(bf(create mask)) When a file is created (or touched) by rsyncd the
+permissions will be taken from the source file bit-wise 'AND'ed with this
+parameter. This parameter may be thought of as a bit-wise MASK for the UNIX
+modes of a file. Any bit not set here will be removed from the modes set
+on a file when it is created.
+
+The default value of this parameter is set to 07777 to be provide the
+default behaviour of older versions.
+
+Following this rsync will bit-wise 'OR' the UNIX mode created from this
+parameter with the value of the force create mode parameter which is set
+to 000 by default.
+
+This parameter does not affect directory modes. See the parameter
+"directory mask" for details.
+
+See also the "force create mode" parameter for forcing particular mode bits
+to be set on created files. See also the "directory mask" parameter for
+masking mode bits on created directories.
+
+dit(bf(force create mode)) This parameter specifies a set of UNIX
+mode bit permissions that will always be set on a file created by
+rsyncd. This is done by bitwise 'OR'ing these bits onto the mode
+bits of a file that is being created or having its permissions changed.
+
+The default for this parameter is (in octal) 000. The modes in this
+parameter are bitwise 'OR'ed onto the file mode after the mask set in
+the "create mask" parameter is applied.
+
+See also the parameter "create mask" for details on
+masking mode bits on files.
+
+
+dit(bf(directory mask)) When a directory is created (or touched) by
+rsyncd the permissions will be taken from the source directory
+bit-wise 'AND'ed with this parameter. This parameter may be thought
+of as a bit-wise MASK for the UNIX modes of a file. Any bit not set
+here will be removed from the modes set on a file when it is created.
+
+The default value of this parameter is set to 07777 to be provide the
+default behaviour of older versions.
+
+Following this rsync will bit-wise 'OR' the UNIX mode created from this
+parameter with the value of the "force directory mode" parameter which
+is set to 000 by default.
+
+This parameter does not affect file modes. See the parameter "create mask"
+for details.
+
+See also the "force directory mode" parameter for forcing particular
+mode bits to be set on created directories. See also the "create mask"
+parameter for masking mode bits on created files.
+
+dit(bf(force directory mode)) This parameter specifies a set of UNIX mode
+bit permissions that will always be set on a directory created by rsyncd.
+This is done by bitwise 'OR'ing these bits onto the mode bits of a directory
+that is being created. The default for this parameter is (in octal) 0000
+which will not add any extra permission bits to a created directory. This
+operation is done after the mode mask in the parameter "directory mask"
+is applied.
+
+See also the parameter directory mask for details on masking mode bits on
+created directories.
+
dit(bf(filter)) The "filter" option allows you to specify a space-separated
list of filter rules that the server will not allow to be read or written.
This is only superficially equivalent to the client specifying these
pgpFf78KWkI4Y.pgp
Description: PGP signature
-- To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
