1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
/* sockd_dumpcf */
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
#include <syslog.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "socks.h"
void sockd_dumpcf(cfAddr, Ncf, useSyslog)
struct config *cfAddr;
int Ncf;
int useSyslog;
{
char buf[1024], *bp;
struct config *cp;
char buf2[1024];
int i, t;
struct in_addr addr;
if (useSyslog)
syslog(LOG_HIGH,"Effective configuration entries: %d\n",Ncf);
else
printf("Effective configuration entries: %d\n",Ncf);
for (i = 0, cp = cfAddr; i++ < Ncf; cp++) {
switch (cp->action) {
case NO_IDENTD:
strcpy(buf, NO_IDENTD_STR);
strcat(buf, " ");
strcat(buf, cp->cmdp);
buf2[0] = '\0';
goto dump_it;
case BAD_ID:
strcpy(buf, BAD_ID_STR);
strcat(buf, " ");
strcat(buf, cp->cmdp);
buf2[0] = '\0';
goto dump_it;
case SOCKD_PERMIT:
strcpy(buf, "permit ");
break;
case SOCKD_DENY:
strcpy(buf, "deny ");
break;
default:
strcpy(buf, "*badaction* ");
continue;
}
if ((t = cp->use_identd) != 0) {
strcat(buf, t == 3 ? "?=n " :
t == 1 ? "?=i " :
t == 2 ? "?=I " :
"?=*badvalue* ");
}
if (cp->userlist != NULL) {
strcat(buf, "*=");
strcat(buf, cp->userlist);
strcat(buf, " ");
}
if (cp->sdomain != NULL)
strcat(buf, cp->sdomain);
else
strcat(buf, inet_ntoa(cp->saddr));
strcat(buf, " ");
strcat(buf, inet_ntoa(cp->smask));
strcat(buf, " ");
if (cp->ddomain != NULL)
strcat(buf, cp->ddomain);
else
strcat(buf, inet_ntoa(cp->daddr));
strcat(buf, " ");
strcat(buf, inet_ntoa(cp->dmask));
switch (cp->tst) {
case e_lt:
sprintf(buf2,"lt %d ", cp->dport);
break;
case e_gt:
sprintf(buf2,"gt %d ", cp->dport);
break;
case e_eq:
sprintf(buf2,"eq %d ", cp->dport);
break;
case e_neq:
sprintf(buf2,"neq %d ", cp->dport);
break;
case e_le:
sprintf(buf2,"le %d ", cp->dport);
break;
case e_ge:
sprintf(buf2,"ge %d ", cp->dport);
break;
case e_nil:
buf2[0] = '\0';
break;
default:
sprintf(buf2, "*badcmp* %d ", cp->dport);
}
if (cp->cmdp) {
strcat(buf2, ": ");
strcat(buf2, cp->cmdp);
}
dump_it:
if (useSyslog)
syslog(LOG_HIGH, "CF%3d>>%s %s<<\n",i,buf, buf2);
else
printf("CF%3d>>%s %s<<\n",i,buf, buf2);
}
}
|