Refer to an rsync daemon as a "daemon", not a "server".
[rsync/rsync-patches.git] / rsyncd-perm.diff
CommitLineData
f5e69f56
WD
1--- orig/loadparm.c 2005-02-19 17:38:51
2+++ loadparm.c 2005-03-31 08:28:41
3@@ -144,6 +144,10 @@ typedef struct
4 int timeout;
5 int max_connections;
6 BOOL ignore_nonreadable;
7+ int create_mask;
8+ int force_create_mode;
9+ int directory_mask;
10+ int force_directory_mode;
11 } service;
12
13
14@@ -186,7 +190,11 @@ static service sDefault =
15 "*.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz", /* dont compress */
16 0, /* timeout */
17 0, /* max connections */
18- False /* ignore nonreadable */
19+ False, /* ignore nonreadable */
20+ CHMOD_BITS, /* create mask */
21+ 0, /* force create mode */
22+ CHMOD_BITS, /* directory mask */
23+ 0 /* force directory mode */
24 };
25
26
27@@ -306,6 +314,10 @@ static struct parm_struct parm_table[] =
28 {"log format", P_STRING, P_LOCAL, &sDefault.log_format, NULL, 0},
29 {"refuse options", P_STRING, P_LOCAL, &sDefault.refuse_options,NULL, 0},
30 {"dont compress", P_STRING, P_LOCAL, &sDefault.dont_compress,NULL, 0},
31+ {"create mask", P_OCTAL, P_LOCAL, &sDefault.create_mask, NULL, 0},
32+ {"force create mode",P_OCTAL, P_LOCAL, &sDefault.force_create_mode, NULL, 0},
33+ {"directory mask", P_OCTAL, P_LOCAL, &sDefault.directory_mask, NULL, 0},
34+ {"force directory mode",P_OCTAL,P_LOCAL, &sDefault.force_directory_mode, NULL, 0},
35 {NULL, P_BOOL, P_NONE, NULL, NULL, 0}
36 };
37
38@@ -391,6 +403,10 @@ FN_LOCAL_STRING(lp_refuse_options, refus
39 FN_LOCAL_STRING(lp_dont_compress, dont_compress)
40 FN_LOCAL_INTEGER(lp_timeout, timeout)
41 FN_LOCAL_INTEGER(lp_max_connections, max_connections)
42+FN_LOCAL_INTEGER(lp_create_mask, create_mask)
43+FN_LOCAL_INTEGER(lp_force_create_mode, force_create_mode)
44+FN_LOCAL_INTEGER(lp_directory_mask, directory_mask)
45+FN_LOCAL_INTEGER(lp_force_directory_mode, force_directory_mode)
46
47 /* local prototypes */
48 static int strwicmp(char *psz1, char *psz2);
49--- orig/rsync.c 2005-03-16 02:19:30
50+++ rsync.c 2005-03-31 08:28:41
51@@ -56,6 +56,8 @@ int set_perms(char *fname,struct file_st
52 int updated = 0;
53 STRUCT_STAT st2;
54 int change_uid, change_gid;
55+ extern int am_daemon;
56+ extern int module_id;
57
58 if (!st) {
59 if (dry_run)
60@@ -126,9 +128,19 @@ int set_perms(char *fname,struct file_st
61
62 #ifdef HAVE_CHMOD
63 if (!S_ISLNK(st->st_mode)) {
64- if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) {
65+ mode_t mode = file->mode; /* file->mode shouldn't be modified */
66+ if (am_daemon) {
67+ if (S_ISDIR(st->st_mode)) {
68+ mode = (mode & lp_directory_mask(module_id))
69+ | lp_force_directory_mode(module_id);
70+ } else {
71+ mode = (mode & lp_create_mask(module_id))
72+ | lp_force_create_mode(module_id);
73+ }
74+ }
75+ if ((st->st_mode & CHMOD_BITS) != (mode & CHMOD_BITS)) {
76 updated = 1;
77- if (do_chmod(fname,(file->mode & CHMOD_BITS)) != 0) {
78+ if (do_chmod(fname, (mode & CHMOD_BITS)) != 0) {
79 rsyserr(FERROR, errno, "failed to set permissions on %s",
80 full_fname(fname));
81 return 0;
82--- orig/rsyncd.conf.yo 2005-04-23 17:50:12
83+++ rsyncd.conf.yo 2005-03-31 08:28:41
84@@ -221,6 +221,70 @@ file transfers to and from that module s
85 was run as root. This complements the "uid" option. The default is gid -2,
86 which is normally the group "nobody".
87
88+dit(bf(create mask)) When a file is created (or touched) by rsyncd the
89+permissions will be taken from the source file bit-wise 'AND'ed with this
90+parameter. This parameter may be thought of as a bit-wise MASK for the UNIX
91+modes of a file. Any bit not set here will be removed from the modes set
92+on a file when it is created.
93+
94+The default value of this parameter is set to 07777 to be provide the
95+default behaviour of older versions.
96+
97+Following this rsync will bit-wise 'OR' the UNIX mode created from this
98+parameter with the value of the force create mode parameter which is set
99+to 000 by default.
100+
101+This parameter does not affect directory modes. See the parameter
102+"directory mask" for details.
103+
104+See also the "force create mode" parameter for forcing particular mode bits
105+to be set on created files. See also the "directory mask" parameter for
106+masking mode bits on created directories.
107+
108+dit(bf(force create mode)) This parameter specifies a set of UNIX
109+mode bit permissions that will always be set on a file created by
110+rsyncd. This is done by bitwise 'OR'ing these bits onto the mode
111+bits of a file that is being created or having its permissions changed.
112+
113+The default for this parameter is (in octal) 000. The modes in this
114+parameter are bitwise 'OR'ed onto the file mode after the mask set in
115+the "create mask" parameter is applied.
116+
117+See also the parameter "create mask" for details on
118+masking mode bits on files.
119+
120+
121+dit(bf(directory mask)) When a directory is created (or touched) by
122+rsyncd the permissions will be taken from the source directory
123+bit-wise 'AND'ed with this parameter. This parameter may be thought
124+of as a bit-wise MASK for the UNIX modes of a file. Any bit not set
125+here will be removed from the modes set on a file when it is created.
126+
127+The default value of this parameter is set to 07777 to be provide the
128+default behaviour of older versions.
129+
130+Following this rsync will bit-wise 'OR' the UNIX mode created from this
131+parameter with the value of the "force directory mode" parameter which
132+is set to 000 by default.
133+
134+This parameter does not affect file modes. See the parameter "create mask"
135+for details.
136+
137+See also the "force directory mode" parameter for forcing particular
138+mode bits to be set on created directories. See also the "create mask"
139+parameter for masking mode bits on created files.
140+
141+dit(bf(force directory mode)) This parameter specifies a set of UNIX mode
142+bit permissions that will always be set on a directory created by rsyncd.
143+This is done by bitwise 'OR'ing these bits onto the mode bits of a directory
144+that is being created. The default for this parameter is (in octal) 0000
145+which will not add any extra permission bits to a created directory. This
146+operation is done after the mode mask in the parameter "directory mask"
147+is applied.
148+
149+See also the parameter directory mask for details on masking mode bits on
150+created directories.
151+
152 dit(bf(filter)) The "filter" option allows you to specify a space-separated
153 list of filter rules that the server will not allow to be read or written.
154 This is only superficially equivalent to the client specifying these