... | ... |
@@ -331,10 +331,6 @@ void mloop() |
331 | 331 |
fd_set rfds; |
332 | 332 |
fd_set wfds; |
333 | 333 |
while(loop_flag){ |
334 |
- if(log_level != moption.loglevel){ |
|
335 |
- lprintf(0,"%s: loglevel set %d to %d\n", __func__, moption.loglevel, log_level); |
|
336 |
- moption.loglevel = log_level; |
|
337 |
- } |
|
338 | 334 |
FD_ZERO(&rfds); |
339 | 335 |
FD_ZERO(&wfds); |
340 | 336 |
rfdset(moption.mcsocket, &rfds); |
... | ... |
@@ -351,6 +347,10 @@ void mloop() |
351 | 351 |
do_comexe(moption.comm, &rfds); |
352 | 352 |
do_exechk(moption.comm); |
353 | 353 |
} |
354 |
+ if(log_level != moption.loglevel){ |
|
355 |
+ lprintf(0, "%s: loglevel change %d to %d\n", __func__, moption.loglevel, log_level); |
|
356 |
+ moption.loglevel = log_level; |
|
357 |
+ } |
|
354 | 358 |
} |
355 | 359 |
} |
356 | 360 |
|
... | ... |
@@ -406,8 +406,9 @@ int is_dir(char *path); |
406 | 406 |
int is_reg(char *path); |
407 | 407 |
int mcreatenode(char *base, char *name, mode_t mode, dev_t dev); |
408 | 408 |
int mrename(char *base, char *oldname, char *newname); |
409 |
+int mexec(mcomm *c, int n); |
|
409 | 410 |
void mtempname(char *base, char *fn, char *tn); |
410 | 411 |
void minit(int argc, char *argv[]); |
411 | 412 |
void mexit(); |
412 |
-int mexec(mcomm *c, int n); |
|
413 | 413 |
void mrecv_gc(); |
414 |
+ |
... | ... |
@@ -152,31 +152,32 @@ int mexec_scan_dir(int fd, char *base, char *sendhost, int mode, mcomm *c, int b |
152 | 152 |
|
153 | 153 |
d = opendir(base); |
154 | 154 |
if(!d){ |
155 |
- /* directory open error */ |
|
156 | 155 |
mexec_scan_echo(fd, "directory open error %s", base); |
157 |
- }else{ |
|
158 |
- while((dent=readdir(d))){ |
|
159 |
- if(!loop_flag){ |
|
160 |
- return(1); |
|
161 |
- } |
|
162 |
- if(!strcmp(dent->d_name, ".")){ |
|
163 |
- continue; |
|
164 |
- } |
|
165 |
- if(!strcmp(dent->d_name, "..")){ |
|
166 |
- continue; |
|
167 |
- } |
|
168 |
- if(baseflag){ |
|
169 |
- sprintf(path, "%s/%s", base, dent->d_name); |
|
170 |
- }else{ |
|
171 |
- strcpy(path, dent->d_name); |
|
172 |
- } |
|
173 |
- space_escape(path); |
|
174 |
- if((r = mexec_scan_child(fd, path, sendhost, mode, c, gid))){ |
|
175 |
- return(r); |
|
176 |
- } |
|
156 |
+ return(0); |
|
157 |
+ } |
|
158 |
+ while((dent=readdir(d))){ |
|
159 |
+ if(!loop_flag){ |
|
160 |
+ closedir(d); |
|
161 |
+ return(1); |
|
162 |
+ } |
|
163 |
+ if(!strcmp(dent->d_name, ".")){ |
|
164 |
+ continue; |
|
165 |
+ } |
|
166 |
+ if(!strcmp(dent->d_name, "..")){ |
|
167 |
+ continue; |
|
168 |
+ } |
|
169 |
+ if(baseflag){ |
|
170 |
+ sprintf(path, "%s/%s", base, dent->d_name); |
|
171 |
+ }else{ |
|
172 |
+ strcpy(path, dent->d_name); |
|
173 |
+ } |
|
174 |
+ space_escape(path); |
|
175 |
+ if((r = mexec_scan_child(fd, path, sendhost, mode, c, gid))){ |
|
176 |
+ closedir(d); |
|
177 |
+ return(r); |
|
177 | 178 |
} |
178 |
- closedir(d); |
|
179 | 179 |
} |
180 |
+ closedir(d); |
|
180 | 181 |
return(0); |
181 | 182 |
} |
182 | 183 |
|
... | ... |
@@ -190,23 +191,23 @@ int mexec_scan_child(int fd, char *base, char *sendhost, int mode, mcomm *c, gid |
190 | 190 |
} |
191 | 191 |
/*----- exclude -----*/ |
192 | 192 |
sprintf(path, "%s/%s", moption.real_dir, base); |
193 |
- if(!mfnmatch(path, c->exclude)){ |
|
194 |
- if(!is_dir(base)){ |
|
195 |
- return(mexec_scan_send(fd, base, sendhost, mode, gid)); |
|
196 |
- }else{ |
|
197 |
- /*----- exclude dir -----*/ |
|
198 |
- strcat(path, "/"); |
|
199 |
- if(mfnmatch(path, c->exclude)){ |
|
200 |
- return(0); |
|
201 |
- } |
|
202 |
- /*----- scan dir -----*/ |
|
203 |
- if((r = mexec_scan_dir(fd, base, sendhost, mode, c, 1, gid))){ |
|
204 |
- return(r); |
|
205 |
- } |
|
206 |
- if(loop_flag && (mode != MAKUO_MEXEC_MD5)){ |
|
207 |
- return(mexec_scan_send(fd, base, sendhost, mode, gid)); |
|
208 |
- } |
|
209 |
- } |
|
193 |
+ if(mfnmatch(path, c->exclude)){ |
|
194 |
+ return(0); |
|
195 |
+ } |
|
196 |
+ if(!is_dir(base)){ |
|
197 |
+ return(mexec_scan_send(fd, base, sendhost, mode, gid)); |
|
198 |
+ } |
|
199 |
+ /*----- exclude dir -----*/ |
|
200 |
+ strcat(path, "/"); |
|
201 |
+ if(mfnmatch(path, c->exclude)){ |
|
202 |
+ return(0); |
|
203 |
+ } |
|
204 |
+ /*----- scan dir -----*/ |
|
205 |
+ if((r = mexec_scan_dir(fd, base, sendhost, mode, c, 1, gid))){ |
|
206 |
+ return(r); |
|
207 |
+ } |
|
208 |
+ if(loop_flag && (mode != MAKUO_MEXEC_MD5)){ |
|
209 |
+ return(mexec_scan_send(fd, base, sendhost, mode, gid)); |
|
210 | 210 |
} |
211 | 211 |
return(0); |
212 | 212 |
} |
... | ... |
@@ -224,12 +225,14 @@ int mexec_scan(mcomm *c, char *fn, mhost *h, int mode, gid_t gid) |
224 | 224 |
return(-1); |
225 | 225 |
} |
226 | 226 |
|
227 |
- base[0] = 0; |
|
227 |
+ base[0] = 0; |
|
228 | 228 |
sendhost[0] = 0; |
229 |
- if(h) |
|
229 |
+ if(h){ |
|
230 | 230 |
strcpy(sendhost, h->hostname); |
231 |
- if(fn) |
|
231 |
+ } |
|
232 |
+ if(fn){ |
|
232 | 233 |
strcpy(base, fn); |
234 |
+ } |
|
233 | 235 |
|
234 | 236 |
pid=fork(); |
235 | 237 |
if(pid == -1){ |
... | ... |
@@ -152,6 +152,9 @@ void lprintf(int l, char *fmt, ...) |
152 | 152 |
char b[1024]; |
153 | 153 |
char d[2048]; |
154 | 154 |
static char m[2048]; |
155 |
+#ifdef MAKUO_DEBUG |
|
156 |
+ struct timeval tv; |
|
157 |
+#endif |
|
155 | 158 |
if(moption.loglevel < l){ |
156 | 159 |
return; |
157 | 160 |
} |
... | ... |
@@ -167,7 +170,6 @@ void lprintf(int l, char *fmt, ...) |
167 | 167 |
return; |
168 | 168 |
} |
169 | 169 |
#ifdef MAKUO_DEBUG |
170 |
- struct timeval tv; |
|
171 | 170 |
gettimeofday(&tv, NULL); |
172 | 171 |
fprintf(stderr, "%02d.%06d %s", tv.tv_sec % 60, tv.tv_usec, m); |
173 | 172 |
#else |