MCPcopy Index your code
hub / github.com/3proxy/3proxy / adminchild

Function adminchild

src/webadmin.c:337–578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335}
336
337void * adminchild(struct clientparam* param) {
338 int i, res;
339 char * buf;
340 char username[256];
341 char *sb;
342 char *req = NULL;
343 struct printparam pp;
344 int contentlen = 0;
345 int isform = 0;
346
347 pp.inbuf = 0;
348 pp.cp = param;
349
350 buf = myalloc(LINESIZE);
351 if(!buf) {RETURN(555);}
352 i = sockgetlinebuf(param, CLIENT, (unsigned char *)buf, LINESIZE - 1, '\n', conf.timeouts[STRING_S]);
353 if(i<5 || ((buf[0]!='G' || buf[1]!='E' || buf[2]!='T' || buf[3]!=' ' || buf[4]!='/') &&
354 (buf[0]!='P' || buf[1]!='O' || buf[2]!='S' || buf[3]!='T' || buf[4]!=' ' || buf[5]!='/')))
355 {
356 RETURN(701);
357 }
358 buf[i] = 0;
359 sb = strchr(buf+5, ' ');
360 if(!sb){
361 RETURN(702);
362 }
363 *sb = 0;
364 req = mystrdup(buf + ((*buf == 'P')? 6 : 5));
365 while((i = sockgetlinebuf(param, CLIENT, (unsigned char *)buf, LINESIZE - 1, '\n', conf.timeouts[STRING_S])) > 2){
366 buf[i] = 0;
367 if(i > 19 && (!strncasecmp(buf, "authorization", 13))){
368 sb = strchr(buf, ':');
369 if(!sb)continue;
370 ++sb;
371 while(isspace(*sb))sb++;
372 if(!*sb || strncasecmp(sb, "basic", 5)){
373 continue;
374 }
375 sb+=5;
376 while(isspace(*sb))sb++;
377 i = de64((unsigned char *)sb, (unsigned char *)username, 255);
378 if(i<=0)continue;
379 username[i] = 0;
380 sb = strchr((char *)username, ':');
381 if(sb){
382 *sb = 0;
383 if(param->password)myfree(param->password);
384 param->password = (unsigned char *)mystrdup(sb+1);
385 }
386 if(param->username) myfree(param->username);
387 param->username = (unsigned char *)mystrdup(username);
388 continue;
389 }
390 else if(i > 15 && (!strncasecmp(buf, "content-length:", 15))){
391 sb = buf + 15;
392 while(isspace(*sb))sb++;
393 contentlen = atoi(sb);
394 }

Callers

nothing calls this directly

Calls 15

myallocFunction · 0.85
sockgetlinebufFunction · 0.85
mystrdupFunction · 0.85
de64Function · 0.85
myfreeFunction · 0.85
printstrFunction · 0.85
stdprFunction · 0.85
ACLmatchesFunction · 0.85
printuserlistFunction · 0.85
printiplistFunction · 0.85
printportlistFunction · 0.85
printvalFunction · 0.85

Tested by

no test coverage detected