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