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
@@ -33,6 +33,41 @@ register_spool (struct spool *spool)
33 spool_list = sp; 33 spool_list = sp;
34} 34}
35 35
36static int
37spool_check_alias (struct spool *spool, const char *name)
38{
39 int rc = 0;
40
41 if (spool->aliases)
42 {
43 gl_list_iterator_t itr = gl_list_iterator (spool->aliases);
44 const void *p;
45
46 while (gl_list_iterator_next (&itr, &p, NULL))
47 if (strcmp (name, p) == 0)
48 {
49 rc = 1;
50 break;
51 }
52 gl_list_iterator_free (&itr);
53 }
54 return rc;
55}
56
57struct spool *
58wydawca_find_spool (const char *name)
59{
60 struct spool_list *sp;
61
62 for (sp = spool_list; sp; sp = sp->next)
63 {
64 if (strcmp (sp->spool.tag, name) == 0
65 || spool_check_alias (&sp->spool, name))
66 return &sp->spool;
67 }
68 return NULL;
69}
70
36/* Return true if NAME is a directory. If stat fails, return the error 71/* Return true if NAME is a directory. If stat fails, return the error
37 code in EC */ 72 code in EC */
38int 73int
@@ -100,10 +135,22 @@ parse_file_name (const char *name, struct file_info *finfo)
100 abort (); /* should not happen */ 135 abort (); /* should not happen */
101} 136}
102 137
138int
139match_uid_p (uid_t uid, int uc, uid_t *uv)
140{
141 int i;
142 if (!uv)
143 return 1;
144 for (i = 0; i < uc; i++)
145 if (uv[i] == uid)
146 return 1;
147 return 0;
148}
149
103/* Scan upload directory from the DPAIR and register all files found 150/* Scan upload directory from the DPAIR and register all files found
104 there, forming triplets when possible */ 151 there, forming triplets when possible */
105void 152void
106scan_spool (struct spool *spool) 153scan_spool (const struct spool *spool, int uc, uid_t *uv)
107{ 154{
108 DIR *dir; 155 DIR *dir;
109 struct dirent *ent; 156 struct dirent *ent;
@@ -127,8 +174,9 @@ scan_spool (struct spool *spool)
127 return; 174 return;
128 } 175 }
129 176
130 timer_start ("directory"); 177 timer_start ("spool");
131 timer_start (spool->url); 178 /* FIXME: prefix spool tag with something */
179 timer_start (spool->tag);
132 while ((ent = readdir (dir))) 180 while ((ent = readdir (dir)))
133 { 181 {
134 struct stat st; 182 struct stat st;
@@ -152,7 +200,7 @@ scan_spool (struct spool *spool)
152 continue; 200 continue;
153 } 201 }
154 202
155 if (!match_uid_p (st.st_uid)) 203 if (!match_uid_p (st.st_uid, uc, uv))
156 { 204 {
157 if (debug_level) 205 if (debug_level)
158 logmsg (LOG_DEBUG, _("ignoring file: %s/%s"), 206 logmsg (LOG_DEBUG, _("ignoring file: %s/%s"),
@@ -164,7 +212,7 @@ scan_spool (struct spool *spool)
164 parse_file_name (ent->d_name, &finfo); 212 parse_file_name (ent->d_name, &finfo);
165 213
166 if (debug_level) 214 if (debug_level)
167 logmsg (LOG_DEBUG, _("file %s: %s, root %.*s"), ent->d_name, 215 logmsg (LOG_DEBUG, _("found file %s: %s, stem: %.*s"), ent->d_name,
168 file_type_str (finfo.type), finfo.root_len, finfo.name); 216 file_type_str (finfo.type), finfo.root_len, finfo.name);
169 217
170 register_file (&finfo); 218 register_file (&finfo);
@@ -186,8 +234,8 @@ scan_spool (struct spool *spool)
186 } 234 }
187 enumerate_triplets (spool); 235 enumerate_triplets (spool);
188 } 236 }
189 timer_stop (spool->url); 237 timer_stop (spool->tag);
190 timer_stop ("directory"); 238 timer_stop ("spool");
191} 239}
192 240
193static void 241static void
@@ -200,7 +248,7 @@ close_methods (struct spool *spool)
200 248
201/* Scan all configured update directories */ 249/* Scan all configured update directories */
202void 250void
203scan_directories () 251scan_directories (int uidc, uid_t *uidv)
204{ 252{
205 struct spool_list *sp; 253 struct spool_list *sp;
206 254
@@ -208,7 +256,7 @@ scan_directories ()
208 256
209 for (sp = spool_list; sp; sp = sp->next) 257 for (sp = spool_list; sp; sp = sp->next)
210 if (enabled_spool_p (&sp->spool)) 258 if (enabled_spool_p (&sp->spool))
211 scan_spool (&sp->spool); 259 scan_spool (&sp->spool, uidc, uidv);
212 260
213 for (sp = spool_list; sp; sp = sp->next) 261 for (sp = spool_list; sp; sp = sp->next)
214 close_methods (&sp->spool); 262 close_methods (&sp->spool);

Return to:

Send suggestions and report system problems to the System administrator.