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