Lines 33-42
Link Here
|
33 |
{ |
33 |
{ |
34 |
u_char *p,*q,buf[BUFSIZ]; |
34 |
u_char *p,*q,buf[BUFSIZ]; |
35 |
MD5_CTX ctx; |
35 |
MD5_CTX ctx; |
36 |
int i,j,sep,cnt; |
36 |
int i,j,sep; |
|
|
37 |
intmax_t cnt,rel; |
38 |
char *svn_command = NULL; |
37 |
u_char *md5=0,*md5before=0,*trash=0,*name=0,*uid=0,*gid=0,*mode=0; |
39 |
u_char *md5=0,*md5before=0,*trash=0,*name=0,*uid=0,*gid=0,*mode=0; |
38 |
struct CTM_Syntax *sp; |
40 |
struct CTM_Syntax *sp; |
39 |
FILE *ed=0; |
41 |
FILE *ed=0, *fd_to; |
40 |
struct stat st; |
42 |
struct stat st; |
41 |
char md5_1[33]; |
43 |
char md5_1[33]; |
42 |
int match=0; |
44 |
int match=0; |
Lines 129-135
Link Here
|
129 |
WRONG |
131 |
WRONG |
130 |
found: |
132 |
found: |
131 |
for(i=0;(j = sp->List[i]);i++) { |
133 |
for(i=0;(j = sp->List[i]);i++) { |
132 |
if (sp->List[i+1] && (sp->List[i+1] & CTM_F_MASK) != CTM_F_Bytes) |
134 |
if (sp->List[i+1] && (sp->List[i+1] & CTM_F_MASK) != CTM_F_Bytes && (sp->List[i+1] & CTM_F_MASK) != CTM_F_Forward) |
133 |
sep = ' '; |
135 |
sep = ' '; |
134 |
else |
136 |
else |
135 |
sep = '\n'; |
137 |
sep = '\n'; |
Lines 147-199
Link Here
|
147 |
break; |
149 |
break; |
148 |
case CTM_F_Count: GETBYTECNT(cnt,sep); break; |
150 |
case CTM_F_Count: GETBYTECNT(cnt,sep); break; |
149 |
case CTM_F_Bytes: GETDATA(trash,cnt); break; |
151 |
case CTM_F_Bytes: GETDATA(trash,cnt); break; |
|
|
152 |
case CTM_F_Release: GETBYTECNT(rel,sep); break; |
153 |
case CTM_F_Forward: |
154 |
if ((j & CTM_Q_MASK) == CTM_Q_Forward_Tar) { |
155 |
if (Verbose > 0) |
156 |
fd_to = popen("tar xvf -","w"); |
157 |
else |
158 |
fd_to = popen("tar xvf - >/dev/null 2>&1","w"); |
159 |
} else if ((j & CTM_Q_MASK) == CTM_Q_Forward_SVN) { |
160 |
svn_command = alloca(strlen(name)+128); |
161 |
if (Verbose > 0) |
162 |
snprintf(svn_command,strlen(name)+127,"svnadmin load %s\n", name); |
163 |
else |
164 |
snprintf(svn_command,strlen(name)+127,"svnadmin load %s > /dev/null 2>&1\n", name); |
165 |
fd_to = popen(svn_command,"w"); |
166 |
} else WRONG |
167 |
if (fd_to == NULL) { |
168 |
fprintf(stderr,"Cannot forward\n"); |
169 |
WRONG |
170 |
} |
171 |
if (Verbose > 0) { |
172 |
if (!strcmp(sp->Key,"TR")) |
173 |
fprintf(stderr,"> %s\n",sp->Key); |
174 |
else |
175 |
fprintf(stderr,"> %s %s\n",sp->Key,name); |
176 |
} |
177 |
GETFORWARD(cnt,fd_to); |
178 |
if (pclose(fd_to)) { |
179 |
if ((j & CTM_Q_MASK) == CTM_Q_Forward_Tar) |
180 |
fprintf(stderr,"Tar failed to close properly\n"); |
181 |
else if ((j & CTM_Q_MASK) == CTM_Q_Forward_SVN) |
182 |
fprintf(stderr,"Svnadmin failed to close properly\n"); |
183 |
WRONG |
184 |
} |
185 |
if ((j & CTM_Q_MASK) == CTM_Q_Forward_SVN) { |
186 |
snprintf(svn_command,strlen(name)+127,"svnadmin pack %s\n", name); |
187 |
if (system(svn_command)) { |
188 |
fprintf(stderr,"\"%s\" didn't work.", svn_command); |
189 |
WRONG |
190 |
} |
191 |
} |
192 |
break; |
150 |
default: WRONG |
193 |
default: WRONG |
151 |
} |
194 |
} |
152 |
} |
195 |
} |
153 |
/* XXX This should go away. Disallow trailing '/' */ |
196 |
|
154 |
j = strlen(name)-1; |
197 |
if (name) { |
155 |
if(name[j] == '/') name[j] = '\0'; |
198 |
/* XXX This should go away. Disallow trailing '/' */ |
156 |
|
199 |
j = strlen(name)-1; |
157 |
/* |
200 |
if(name[j] == '/') name[j] = '\0'; |
158 |
* If a filter list is specified, run thru the filter list and |
201 |
|
159 |
* match `name' against filters. If the name matches, set the |
202 |
/* |
160 |
* required action to that specified in the filter. |
203 |
* If a filter list is specified, run thru the filter list and |
161 |
* The default action if no filterlist is given is to match |
204 |
* match `name' against filters. If the name matches, set the |
162 |
* everything. |
205 |
* required action to that specified in the filter. |
163 |
*/ |
206 |
* The default action if no filterlist is given is to match |
164 |
|
207 |
* everything. |
165 |
match = (FilterList ? !(FilterList->Action) : CTM_FILTER_ENABLE); |
208 |
*/ |
166 |
for (filter = FilterList; filter; filter = filter->Next) { |
209 |
|
167 |
if (0 == regexec(&filter->CompiledRegex, name, |
210 |
match = (FilterList ? !(FilterList->Action) : CTM_FILTER_ENABLE); |
168 |
0, 0, 0)) { |
211 |
for (filter = FilterList; filter; filter = filter->Next) { |
169 |
match = filter->Action; |
212 |
if (0 == regexec(&filter->CompiledRegex, name, |
|
|
213 |
0, 0, 0)) { |
214 |
match = filter->Action; |
215 |
} |
170 |
} |
216 |
} |
171 |
} |
|
|
172 |
|
217 |
|
173 |
if (CTM_FILTER_DISABLE == match) /* skip file if disabled */ |
218 |
if (CTM_FILTER_DISABLE == match) /* skip file if disabled */ |
174 |
continue; |
219 |
continue; |
175 |
|
220 |
|
176 |
if (Verbose > 0) |
221 |
if (Verbose > 0 && strcmp(sp->Key,"SV") && strcmp(sp->Key,"TR")) |
177 |
fprintf(stderr,"> %s %s\n",sp->Key,name); |
222 |
fprintf(stderr,"> %s %s\n",sp->Key,name); |
178 |
if(!strcmp(sp->Key,"FM") || !strcmp(sp->Key, "FS")) { |
223 |
if(!strcmp(sp->Key,"FM") || !strcmp(sp->Key, "FS")) { |
179 |
i = open(name,O_WRONLY|O_CREAT|O_TRUNC,0666); |
224 |
i = open(name,O_WRONLY|O_CREAT|O_TRUNC,0666); |
180 |
if(i < 0) { |
225 |
if(i < 0) { |
181 |
warn("%s", name); |
226 |
warn("%s", name); |
182 |
WRONG |
227 |
WRONG |
183 |
} |
228 |
} |
184 |
if(cnt != write(i,trash,cnt)) { |
229 |
if(cnt != write(i,trash,cnt)) { |
185 |
warn("%s", name); |
230 |
warn("%s", name); |
186 |
WRONG |
231 |
WRONG |
187 |
} |
232 |
} |
188 |
close(i); |
233 |
close(i); |
189 |
if(strcmp(md5,MD5File(name,md5_1))) { |
234 |
if(strcmp(md5,MD5File(name,md5_1))) { |
190 |
fprintf(stderr," %s %s MD5 didn't come out right\n", |
235 |
fprintf(stderr," %s %s MD5 didn't come out right\n", |
191 |
sp->Key,name); |
236 |
sp->Key,name); |
192 |
WRONG |
237 |
WRONG |
|
|
238 |
} |
239 |
if (settime(name,times)) WRONG |
240 |
continue; |
193 |
} |
241 |
} |
194 |
if (settime(name,times)) WRONG |
|
|
195 |
continue; |
196 |
} |
242 |
} |
|
|
243 |
|
197 |
if(!strcmp(sp->Key,"FE")) { |
244 |
if(!strcmp(sp->Key,"FE")) { |
198 |
ed = popen("ed","w"); |
245 |
ed = popen("ed","w"); |
199 |
if(!ed) { |
246 |
if(!ed) { |
Lines 276-281
Link Here
|
276 |
} |
323 |
} |
277 |
continue; |
324 |
continue; |
278 |
} |
325 |
} |
|
|
326 |
if(!strcmp(sp->Key,"TR") || !strcmp(sp->Key,"SV")) |
327 |
continue; |
279 |
WRONG |
328 |
WRONG |
280 |
} |
329 |
} |
281 |
|
330 |
|