diff options
-rw-r--r-- | src/cmdline.opt | 3 | ||||
-rw-r--r-- | src/process.c | 8 | ||||
-rw-r--r-- | src/wydawca.c | 47 | ||||
-rw-r--r-- | src/wydawca.h | 2 |
4 files changed, 57 insertions, 3 deletions
diff --git a/src/cmdline.opt b/src/cmdline.opt index 153199b..ec457de 100644 --- a/src/cmdline.opt +++ b/src/cmdline.opt | |||
@@ -18,7 +18,8 @@ static struct obstack pp_cmd_stack; | |||
18 | static int pp_cmd_stack_init; | 18 | static int pp_cmd_stack_init; |
19 | 19 | ||
20 | OPTIONS_BEGIN(gnu, "wydawca", | 20 | OPTIONS_BEGIN(gnu, "wydawca", |
21 | [<wydawca synchronizes files from a set of upload directories with the corresponding distribution sites>]) | 21 | [<wydawca synchronizes files from a set of upload directories with the corresponding distribution sites>], |
22 | [<UID [UID...]>]) | ||
22 | 23 | ||
23 | GROUP(Selecting program mode) | 24 | GROUP(Selecting program mode) |
24 | 25 | ||
diff --git a/src/process.c b/src/process.c index dd499bd..c019a65 100644 --- a/src/process.c +++ b/src/process.c | |||
@@ -152,6 +152,14 @@ scan_directory_pair (struct directory_pair *dpair) | |||
152 | continue; | 152 | continue; |
153 | } | 153 | } |
154 | 154 | ||
155 | if (!match_uid (st.st_uid)) | ||
156 | { | ||
157 | if (debug_level) | ||
158 | logmsg (LOG_DEBUG, "ignoring file: %s/%s", | ||
159 | dpair->source_dir, ent->d_name); | ||
160 | continue; | ||
161 | } | ||
162 | |||
155 | finfo.sb = st; | 163 | finfo.sb = st; |
156 | parse_file_name (ent->d_name, &finfo); | 164 | parse_file_name (ent->d_name, &finfo); |
157 | 165 | ||
diff --git a/src/wydawca.c b/src/wydawca.c index 26b240d..8dd7c98 100644 --- a/src/wydawca.c +++ b/src/wydawca.c | |||
@@ -243,6 +243,46 @@ gconf_print_diag (gconf_locus_t *locus, int err, int errcode, const char *msg) | |||
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | |||
247 | static int uidc; | ||
248 | static char **uidv; | ||
249 | |||
250 | static int | ||
251 | collect_uids (int argc, char **argv) | ||
252 | { | ||
253 | int i; | ||
254 | |||
255 | uidc = argc; | ||
256 | uidv = xcalloc (uidc, sizeof (uidv[0])); | ||
257 | for (i = 0; i < argc; i++) | ||
258 | { | ||
259 | struct passwd *pw = getpwnam (argv[i]); | ||
260 | if (!pw) | ||
261 | { | ||
262 | char *p; | ||
263 | unsigned n = strtoul (argv[i], &p, 10); | ||
264 | if (*p) | ||
265 | error (1, 0, "no such user: %s", argv[i]); | ||
266 | uidv[i] = n; | ||
267 | } | ||
268 | else | ||
269 | uidv[i] = pw->pw_uid; | ||
270 | } | ||
271 | } | ||
272 | |||
273 | int | ||
274 | match_uid (uid_t uid) | ||
275 | { | ||
276 | int i; | ||
277 | if (!uidv) | ||
278 | return 1; | ||
279 | for (i = 0; i < uidc; i++) | ||
280 | if (uidv[i] == uid) | ||
281 | return 1; | ||
282 | return 0; | ||
283 | } | ||
284 | |||
285 | |||
246 | #include "cmdline.h" | 286 | #include "cmdline.h" |
247 | 287 | ||
248 | int | 288 | int |
@@ -254,8 +294,11 @@ main (int argc, char **argv) | |||
254 | 294 | ||
255 | parse_options (argc, argv); | 295 | parse_options (argc, argv); |
256 | 296 | ||
257 | if (argc != optind) | 297 | argv += optind; |
258 | error (1, 0, "extra command line arguments"); | 298 | argc -= optind; |
299 | |||
300 | if (argc) | ||
301 | collect_uids (argc, argv); | ||
259 | 302 | ||
260 | if (preprocess_only) | 303 | if (preprocess_only) |
261 | exit (gconf_preproc_run (conffile, gconf_preprocessor)); | 304 | exit (gconf_preproc_run (conffile, gconf_preprocessor)); |
diff --git a/src/wydawca.h b/src/wydawca.h index 2ba065b..5b57ed0 100644 --- a/src/wydawca.h +++ b/src/wydawca.h | |||
@@ -393,6 +393,8 @@ int directive_next (struct file_triplet *trp, int n, | |||
393 | int process_directives (struct file_triplet *trp, | 393 | int process_directives (struct file_triplet *trp, |
394 | struct directory_pair *dpair); | 394 | struct directory_pair *dpair); |
395 | 395 | ||
396 | int match_uid (uid_t uid); | ||
397 | |||
396 | 398 | ||
397 | int parse_time_interval (const char *str, time_t *pint, const char **endp); | 399 | int parse_time_interval (const char *str, time_t *pint, const char **endp); |
398 | 400 | ||