aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-02-22 12:50:12 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-02-22 12:50:12 +0200
commit5dd37baedfb74ad33fd7b785fe316e40e3b93551 (patch)
tree0a476dd669352bd851e0184def16cc7ac72e832c
parent79eeda2081f4cfccfb63eaec2e04cf206d4518a1 (diff)
downloadwydawca-5dd37baedfb74ad33fd7b785fe316e40e3b93551.tar.gz
wydawca-5dd37baedfb74ad33fd7b785fe316e40e3b93551.tar.bz2
Allow to specify UIDs of the users whose uploads are to be processed.
* src/process.c (scan_directory_pair): Ignore files with non-matching owner UIDs. * src/wydawca.c: Treat non-option arguments as a list of owner names or UIDs. * src/cmdline.opt: Update.
-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
@@ -20,3 +20,4 @@ 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...]>])
diff --git a/src/process.c b/src/process.c
index dd499bd..c019a65 100644
--- a/src/process.c
+++ b/src/process.c
@@ -154,2 +154,10 @@ scan_directory_pair (struct directory_pair *dpair)
+ 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;
diff --git a/src/wydawca.c b/src/wydawca.c
index 26b240d..8dd7c98 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -245,2 +245,42 @@ 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"
@@ -256,4 +296,7 @@ main (int argc, char **argv)
- if (argc != optind)
- error (1, 0, "extra command line arguments");
+ argv += optind;
+ argc -= optind;
+
+ if (argc)
+ collect_uids (argc, argv);
diff --git a/src/wydawca.h b/src/wydawca.h
index 2ba065b..5b57ed0 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -395,2 +395,4 @@ int process_directives (struct file_triplet *trp,
+int match_uid (uid_t uid);
+

Return to:

Send suggestions and report system problems to the System administrator.