Fixed failing hunks.
[rsync/rsync-patches.git] / rsyncd-perm.diff
1 --- orig/loadparm.c     2005-09-16 20:36:31
2 +++ loadparm.c  2005-09-16 20:41:11
3 @@ -140,6 +140,10 @@ typedef struct
4         char *temp_dir;
5         char *uid;
6  
7 +       int create_mask;
8 +       int directory_mask;
9 +       int force_create_mode;
10 +       int force_directory_mode;
11         int max_connections;
12         int max_verbosity;
13         int timeout;
14 @@ -180,6 +184,10 @@ static service sDefault =
15   /* temp_dir */                NULL,
16   /* uid */                     NOBODY_USER,
17  
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 @@ -284,10 +292,14 @@ static struct parm_struct parm_table[] =
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},
40 @@ -394,6 +406,10 @@ FN_LOCAL_STRING(lp_secrets_file, secrets
41  FN_LOCAL_STRING(lp_temp_dir, temp_dir)
42  FN_LOCAL_STRING(lp_uid, uid)
43  
44 +FN_LOCAL_INTEGER(lp_create_mask, create_mask)
45 +FN_LOCAL_INTEGER(lp_directory_mask, directory_mask)
46 +FN_LOCAL_INTEGER(lp_force_create_mode, force_create_mode)
47 +FN_LOCAL_INTEGER(lp_force_directory_mode, force_directory_mode)
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)
51 --- orig/rsync.c        2005-07-27 23:31:12
52 +++ rsync.c     2005-07-28 00:54:53
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;
62 @@ -56,6 +58,7 @@ int set_perms(char *fname,struct file_st
63         int updated = 0;
64         STRUCT_STAT st2;
65         int change_uid, change_gid;
66 +       mode_t mode = file->mode; /* file->mode shouldn't be modified */
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  
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 +       }
83 +
84  #ifdef HAVE_CHMOD
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",
92 --- orig/rsyncd.conf.yo 2005-07-29 02:47:20
93 +++ rsyncd.conf.yo      2005-03-31 08:28:41
94 @@ -218,6 +218,70 @@ file transfers to and from that module s
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
163  list of filter rules that the daemon will not allow to be read or written.
164  This is only superficially equivalent to the client specifying these