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; static int pp_cmd_stack_init; OPTIONS_BEGIN(gnu, "wydawca", - [<wydawca synchronizes files from a set of upload directories with the corresponding distribution sites>]) + [<wydawca synchronizes files from a set of upload directories with the corresponding distribution sites>], + [<UID [UID...]>]) GROUP(Selecting program mode) 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) continue; } + if (!match_uid (st.st_uid)) + { + if (debug_level) + logmsg (LOG_DEBUG, "ignoring file: %s/%s", + dpair->source_dir, ent->d_name); + continue; + } + finfo.sb = st; parse_file_name (ent->d_name, &finfo); 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) } } + +static int uidc; +static char **uidv; + +static int +collect_uids (int argc, char **argv) +{ + int i; + + uidc = argc; + uidv = xcalloc (uidc, sizeof (uidv[0])); + for (i = 0; i < argc; i++) + { + struct passwd *pw = getpwnam (argv[i]); + if (!pw) + { + char *p; + unsigned n = strtoul (argv[i], &p, 10); + if (*p) + error (1, 0, "no such user: %s", argv[i]); + uidv[i] = n; + } + else + uidv[i] = pw->pw_uid; + } +} + +int +match_uid (uid_t uid) +{ + int i; + if (!uidv) + return 1; + for (i = 0; i < uidc; i++) + if (uidv[i] == uid) + return 1; + return 0; +} + + #include "cmdline.h" int @@ -254,8 +294,11 @@ main (int argc, char **argv) parse_options (argc, argv); - if (argc != optind) - error (1, 0, "extra command line arguments"); + argv += optind; + argc -= optind; + + if (argc) + collect_uids (argc, argv); if (preprocess_only) 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, int process_directives (struct file_triplet *trp, struct directory_pair *dpair); +int match_uid (uid_t uid); + int parse_time_interval (const char *str, time_t *pint, const char **endp); |