aboutsummaryrefslogtreecommitdiff
path: root/src/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c66
1 files changed, 57 insertions, 9 deletions
diff --git a/src/process.c b/src/process.c
index 0d2bf5e..20bfd38 100644
--- a/src/process.c
+++ b/src/process.c
@@ -30,12 +30,47 @@ register_spool (struct spool *spool)
struct spool_list *sp = xmalloc (sizeof *sp);
sp->spool = *spool;
sp->next = spool_list;
spool_list = sp;
}
+static int
+spool_check_alias (struct spool *spool, const char *name)
+{
+ int rc = 0;
+
+ if (spool->aliases)
+ {
+ gl_list_iterator_t itr = gl_list_iterator (spool->aliases);
+ const void *p;
+
+ while (gl_list_iterator_next (&itr, &p, NULL))
+ if (strcmp (name, p) == 0)
+ {
+ rc = 1;
+ break;
+ }
+ gl_list_iterator_free (&itr);
+ }
+ return rc;
+}
+
+struct spool *
+wydawca_find_spool (const char *name)
+{
+ struct spool_list *sp;
+
+ for (sp = spool_list; sp; sp = sp->next)
+ {
+ if (strcmp (sp->spool.tag, name) == 0
+ || spool_check_alias (&sp->spool, name))
+ return &sp->spool;
+ }
+ return NULL;
+}
+
/* Return true if NAME is a directory. If stat fails, return the error
code in EC */
int
test_dir (const char *name, int *ec)
{
struct stat st;
@@ -97,16 +132,28 @@ parse_file_name (const char *name, struct file_info *finfo)
return;
}
}
abort (); /* should not happen */
}
+int
+match_uid_p (uid_t uid, int uc, uid_t *uv)
+{
+ int i;
+ if (!uv)
+ return 1;
+ for (i = 0; i < uc; i++)
+ if (uv[i] == uid)
+ return 1;
+ return 0;
+}
+
/* Scan upload directory from the DPAIR and register all files found
there, forming triplets when possible */
void
-scan_spool (struct spool *spool)
+scan_spool (const struct spool *spool, int uc, uid_t *uv)
{
DIR *dir;
struct dirent *ent;
if (debug_level)
logmsg (LOG_DEBUG, "%s -> %s", spool->source_dir,
@@ -124,14 +171,15 @@ scan_spool (struct spool *spool)
{
logmsg (LOG_ERR, _("cannot open directory %s: %s"), spool->source_dir,
strerror (errno));
return;
}
- timer_start ("directory");
- timer_start (spool->url);
+ timer_start ("spool");
+ /* FIXME: prefix spool tag with something */
+ timer_start (spool->tag);
while ((ent = readdir (dir)))
{
struct stat st;
struct file_info finfo;
if (strcmp (ent->d_name, ".") == 0 || strcmp (ent->d_name, "..") == 0)
@@ -149,25 +197,25 @@ scan_spool (struct spool *spool)
{
logmsg (LOG_NOTICE, _("not a regular file: %s/%s"),
spool->source_dir, ent->d_name);
continue;
}
- if (!match_uid_p (st.st_uid))
+ if (!match_uid_p (st.st_uid, uc, uv))
{
if (debug_level)
logmsg (LOG_DEBUG, _("ignoring file: %s/%s"),
spool->source_dir, ent->d_name);
continue;
}
finfo.sb = st;
parse_file_name (ent->d_name, &finfo);
if (debug_level)
- logmsg (LOG_DEBUG, _("file %s: %s, root %.*s"), ent->d_name,
+ logmsg (LOG_DEBUG, _("found file %s: %s, stem: %.*s"), ent->d_name,
file_type_str (finfo.type), finfo.root_len, finfo.name);
register_file (&finfo);
}
closedir (dir);
@@ -183,35 +231,35 @@ scan_spool (struct spool *spool)
logmsg (LOG_ERR, _("failed to initialize access method %d"), i);
return;
}
}
enumerate_triplets (spool);
}
- timer_stop (spool->url);
- timer_stop ("directory");
+ timer_stop (spool->tag);
+ timer_stop ("spool");
}
static void
close_methods (struct spool *spool)
{
int i;
for (i = 0; i < NITEMS (spool->access_method); i++)
method_done (spool->access_method[i]);
}
/* Scan all configured update directories */
void
-scan_directories ()
+scan_directories (int uidc, uid_t *uidv)
{
struct spool_list *sp;
timer_start ("wydawca");
for (sp = spool_list; sp; sp = sp->next)
if (enabled_spool_p (&sp->spool))
- scan_spool (&sp->spool);
+ scan_spool (&sp->spool, uidc, uidv);
for (sp = spool_list; sp; sp = sp->next)
close_methods (&sp->spool);
timer_stop ("wydawca");
}

Return to:

Send suggestions and report system problems to the System administrator.