aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmdline.opt3
-rw-r--r--src/process.c8
-rw-r--r--src/wydawca.c47
-rw-r--r--src/wydawca.h2
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;
18static int pp_cmd_stack_init; 18static int pp_cmd_stack_init;
19 19
20OPTIONS_BEGIN(gnu, "wydawca", 20OPTIONS_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
23GROUP(Selecting program mode) 24GROUP(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
247static int uidc;
248static char **uidv;
249
250static int
251collect_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
273int
274match_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
248int 288int
@@ -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,
393int process_directives (struct file_triplet *trp, 393int process_directives (struct file_triplet *trp,
394 struct directory_pair *dpair); 394 struct directory_pair *dpair);
395 395
396int match_uid (uid_t uid);
397
396 398
397int parse_time_interval (const char *str, time_t *pint, const char **endp); 399int parse_time_interval (const char *str, time_t *pint, const char **endp);
398 400

Return to:

Send suggestions and report system problems to the System administrator.