Commit | Line | Data |
---|---|---|
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); | |
47 | --- orig/rsync.c 2005-03-16 02:19:30 | |
48 | +++ rsync.c 2005-03-31 08:28:41 | |
49 | @@ -56,6 +56,8 @@ int set_perms(char *fname,struct file_st | |
50 | int updated = 0; | |
51 | STRUCT_STAT st2; | |
52 | int change_uid, change_gid; | |
53 | + extern int am_daemon; | |
54 | + extern int module_id; | |
55 | ||
56 | if (!st) { | |
57 | if (dry_run) | |
58 | @@ -126,9 +128,19 @@ int set_perms(char *fname,struct file_st | |
59 | ||
60 | #ifdef HAVE_CHMOD | |
61 | if (!S_ISLNK(st->st_mode)) { | |
62 | - if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) { | |
63 | + mode_t mode = file->mode; /* file->mode shouldn't be modified */ | |
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 | + } | |
73 | + if ((st->st_mode & CHMOD_BITS) != (mode & CHMOD_BITS)) { | |
74 | updated = 1; | |
75 | - if (do_chmod(fname,(file->mode & CHMOD_BITS)) != 0) { | |
76 | + if (do_chmod(fname, (mode & CHMOD_BITS)) != 0) { | |
77 | rsyserr(FERROR, errno, "failed to set permissions on %s", | |
78 | full_fname(fname)); | |
79 | return 0; | |
e65e0121 | 80 | --- orig/rsyncd.conf.yo 2005-06-03 08:32:34 |
f5e69f56 WD |
81 | +++ rsyncd.conf.yo 2005-03-31 08:28:41 |
82 | @@ -221,6 +221,70 @@ file transfers to and from that module s | |
83 | was run as root. This complements the "uid" option. The default is gid -2, | |
84 | which is normally the group "nobody". | |
85 | ||
86 | +dit(bf(create mask)) When a file is created (or touched) by rsyncd the | |
87 | +permissions will be taken from the source file bit-wise 'AND'ed with this | |
88 | +parameter. This parameter may be thought of as a bit-wise MASK for the UNIX | |
89 | +modes of a file. Any bit not set here will be removed from the modes set | |
90 | +on a file when it is created. | |
91 | + | |
92 | +The default value of this parameter is set to 07777 to be provide the | |
93 | +default behaviour of older versions. | |
94 | + | |
95 | +Following this rsync will bit-wise 'OR' the UNIX mode created from this | |
96 | +parameter with the value of the force create mode parameter which is set | |
97 | +to 000 by default. | |
98 | + | |
99 | +This parameter does not affect directory modes. See the parameter | |
100 | +"directory mask" for details. | |
101 | + | |
102 | +See also the "force create mode" parameter for forcing particular mode bits | |
103 | +to be set on created files. See also the "directory mask" parameter for | |
104 | +masking mode bits on created directories. | |
105 | + | |
106 | +dit(bf(force create mode)) This parameter specifies a set of UNIX | |
107 | +mode bit permissions that will always be set on a file created by | |
108 | +rsyncd. This is done by bitwise 'OR'ing these bits onto the mode | |
109 | +bits of a file that is being created or having its permissions changed. | |
110 | + | |
111 | +The default for this parameter is (in octal) 000. The modes in this | |
112 | +parameter are bitwise 'OR'ed onto the file mode after the mask set in | |
113 | +the "create mask" parameter is applied. | |
114 | + | |
115 | +See also the parameter "create mask" for details on | |
116 | +masking mode bits on files. | |
117 | + | |
118 | + | |
119 | +dit(bf(directory mask)) When a directory is created (or touched) by | |
120 | +rsyncd the permissions will be taken from the source directory | |
121 | +bit-wise 'AND'ed with this parameter. This parameter may be thought | |
122 | +of as a bit-wise MASK for the UNIX modes of a file. Any bit not set | |
123 | +here will be removed from the modes set on a file when it is created. | |
124 | + | |
125 | +The default value of this parameter is set to 07777 to be provide the | |
126 | +default behaviour of older versions. | |
127 | + | |
128 | +Following this rsync will bit-wise 'OR' the UNIX mode created from this | |
129 | +parameter with the value of the "force directory mode" parameter which | |
130 | +is set to 000 by default. | |
131 | + | |
132 | +This parameter does not affect file modes. See the parameter "create mask" | |
133 | +for details. | |
134 | + | |
135 | +See also the "force directory mode" parameter for forcing particular | |
136 | +mode bits to be set on created directories. See also the "create mask" | |
137 | +parameter for masking mode bits on created files. | |
138 | + | |
139 | +dit(bf(force directory mode)) This parameter specifies a set of UNIX mode | |
140 | +bit permissions that will always be set on a directory created by rsyncd. | |
141 | +This is done by bitwise 'OR'ing these bits onto the mode bits of a directory | |
142 | +that is being created. The default for this parameter is (in octal) 0000 | |
143 | +which will not add any extra permission bits to a created directory. This | |
144 | +operation is done after the mode mask in the parameter "directory mask" | |
145 | +is applied. | |
146 | + | |
147 | +See also the parameter directory mask for details on masking mode bits on | |
148 | +created directories. | |
149 | + | |
150 | dit(bf(filter)) The "filter" option allows you to specify a space-separated | |
e33d747e | 151 | list of filter rules that the daemon will not allow to be read or written. |
f5e69f56 | 152 | This is only superficially equivalent to the client specifying these |