summaryrefslogtreecommitdiff
path: root/src/file.c
diff options
context:
space:
mode:
authorJakub Sławiński2005-11-03 20:37:56 +0100
committerJoshua Judson Rosen2014-07-17 21:15:00 +0200
commit63bbc710b23893742e5ccbd430f95bf2d29c2da6 (patch)
tree06d0585724cff8a4f1a7c052b5b89fd12c404094 /src/file.c
parentv0.7.2 (diff)
downloadapf-63bbc710b23893742e5ccbd430f95bf2d29c2da6.tar.gz
v0.7.4
- Fixed: sockets in CLOSE_WAIT state left by afclient - Added: --localname and --localport options - Added: --localdesname option - Added: kicking user in 'opening' state - Fixed: info about kicked user - Fixed: TERM signal handling - Fixed: id lost after reconnection - Fixed: printing wrong client name in 'SSL_accept failed (timeout)' message - Fixed: ignored 'certificate' and 'key' options from config file - Added: config files for afclient - Modified: some options in afserver config file
Diffstat (limited to 'src/file.c')
-rw-r--r--src/file.c262
1 files changed, 0 insertions, 262 deletions
diff --git a/src/file.c b/src/file.c
index 297503b..f7eeee1 100644
--- a/src/file.c
+++ b/src/file.c
@@ -104,265 +104,3 @@ parse_line(char* buff, char* tab1, char* tab2)
}
return 1;
}
-
-ConfigurationT
-parsefile(char* name, int* status)
-{
- static ConfigurationT cfg;
- FILE* file = NULL;
- int state, i, j, n, listencount, managecount;
- char buff[256];
- char helpbuf1[256];
- char helpbuf2[256];
- char* tmpbuf;
-
- *status = 1;
-
- memset(buff, 0, 256);
-
- cfg.certif = NULL;
- cfg.keys = NULL;
- cfg.size = 0;
- cfg.realmtable = NULL;
- cfg.dateformat = NULL;
-
- state = F_UNKNOWN;
-
- file = fopen(name, "r");
- if (file == NULL) {
- return cfg;
- }
-
- while (fgets(buff, 256, file) != NULL) { /* first loop - counting realm */
- helpbuf1[0] = 0;
- parse_line(buff, helpbuf1, helpbuf2);
- if (strcmp(helpbuf1, "realm")==0) {
- ++cfg.size;
- }
- }
- rewind(file);
-
- cfg.realmtable = calloc(cfg.size, sizeof(RealmT));
- for (i=0; i<cfg.size; ++i) {
- cfg.realmtable[i].pass[0] = 1;
- cfg.realmtable[i].pass[1] = 2;
- cfg.realmtable[i].pass[2] = 3;
- cfg.realmtable[i].pass[3] = 4;
- }
- cfg.size = 0;
- *status = 0;
-
- listencount = managecount = 0;
-
-
- while (fgets(buff, 256, file) != NULL) { /* second loop - counting listen */
- (*status)++;
- state = parse_line(buff, helpbuf1, helpbuf2);
- if (state) {
- if (strcmp(helpbuf1, "realm")==0) {
- ++cfg.size;
- if (listencount != managecount) {
- return cfg;
- }
- listencount = managecount = 0;
- }
- else if (strcmp(helpbuf1, "listen")==0) {
- if (cfg.size == 0) {
- return cfg;
- }
- ++cfg.realmtable[cfg.size-1].usrclinum;
- ++listencount;
- }
- else if (strcmp(helpbuf1, "manage")==0) {
- if (cfg.size == 0) {
- return cfg;
- }
- ++managecount;
- }
- }
- }
- rewind(file);
-
- if (listencount != managecount) {
- return cfg;
- }
-
- for (i = 0; i < cfg.size; ++i) {
- cfg.realmtable[i].usrclitable = calloc(cfg.realmtable[i].usrclinum, sizeof(UsrCli*));
- for (j = 0; j < cfg.realmtable[i].usrclinum; ++j) {
- cfg.realmtable[i].usrclitable[j] = UsrCli_new();
- if (cfg.realmtable[i].usrclitable[j] == NULL) {
- aflog(LOG_T_INIT, LOG_I_CRIT,
- "Problem with allocating memory for UsrCli structure... exiting");
- return cfg;
- }
- }
- }
-
- cfg.size = 0;
- *status = 0;
-
-
- while (fgets(buff, 256, file) != NULL) { /* third loop - parsing file */
- (*status)++;
- state = parse_line(buff, helpbuf1, helpbuf2);
- if (helpbuf1[0] == '#') {
- memset(buff, 0, 256);
- continue;
- }
- if (state == 1) {
- if (strcmp(helpbuf1, "realm")==0) {
- ++cfg.size;
- TYPE_SET_SSL(cfg.realmtable[cfg.size-1].type);
- TYPE_SET_ZLIB(cfg.realmtable[cfg.size-1].type);
- listencount = managecount = 0;
- }
- else if (cfg.size == 0) {
- return cfg;
- }
- else if (strcmp(helpbuf1, "nossl")==0) {
- TYPE_UNSET_SSL(cfg.realmtable[cfg.size-1].type);
- }
- else if (strcmp(helpbuf1, "nozlib")==0) {
- TYPE_UNSET_ZLIB(cfg.realmtable[cfg.size-1].type);
- }
- else if (strcmp(helpbuf1, "baseport")==0) {
- cfg.realmtable[cfg.size-1].baseport = 1;
- }
- else if (strcmp(helpbuf1, "audit")==0) {
- cfg.realmtable[cfg.size-1].audit = 1;
- }
- else if (strcmp(helpbuf1, "dnslookups")==0) {
- cfg.realmtable[cfg.size-1].dnslookups = 1;
- }
-#ifdef HAVE_LIBPTHREAD
- else if (strcmp(helpbuf1, "enableproxy")==0) {
- if (cfg.realmtable[cfg.size-1].tunneltype == 0) {
- cfg.realmtable[cfg.size-1].tunneltype = 1;
- }
- else {
- return cfg;
- }
- }
-#endif
-#ifdef AF_INET6
- else if (strcmp(helpbuf1, "ipv4")==0) {
- if (TYPE_IS_UNSPEC(cfg.realmtable[cfg.size-1].type)) {
- TYPE_SET_IPV4(cfg.realmtable[cfg.size-1].type);
- }
- else {
- return cfg;
- }
- }
- else if (strcmp(helpbuf1, "ipv6")==0) {
- if (TYPE_IS_UNSPEC(cfg.realmtable[cfg.size-1].type)) {
- TYPE_SET_IPV6(cfg.realmtable[cfg.size-1].type);
- }
- else {
- return cfg;
- }
- }
-#endif
- else {
- return cfg;
- }
- }
- else if (state == 2) {
- if (strcmp(helpbuf1, "realm")==0) {
- ++cfg.size;
- TYPE_SET_SSL(cfg.realmtable[cfg.size-1].type);
- TYPE_SET_ZLIB(cfg.realmtable[cfg.size-1].type);
- listencount = managecount = 0;
- cfg.realmtable[cfg.size-1].realmname = calloc(strlen(helpbuf2)+1, sizeof(char));
- strcpy(cfg.realmtable[cfg.size-1].realmname, helpbuf2);
- }
- else if (strcmp(helpbuf1, "certificate")==0) {
- cfg.certif = calloc(strlen(helpbuf2)+1, sizeof(char));
- strcpy(cfg.certif, helpbuf2);
- }
- else if (strcmp(helpbuf1, "key")==0) {
- cfg.keys = calloc(strlen(helpbuf2)+1, sizeof(char));
- strcpy(cfg.keys, helpbuf2);
- }
- else if (strcmp(helpbuf1, "log")==0) {
- tmpbuf = calloc(strlen(helpbuf2)+1, sizeof(char));
- strcpy(tmpbuf, helpbuf2);
- addlogtarget(tmpbuf);
- }
- else if (strcmp(helpbuf1, "dateformat")==0) {
- cfg.dateformat = calloc(strlen(helpbuf2)+1, sizeof(char));
- strcpy(cfg.dateformat, helpbuf2);
- }
- else if (cfg.size == 0) {
- return cfg;
- }
- else if (strcmp(helpbuf1, "hostname")==0) {
- cfg.realmtable[cfg.size-1].hostname = calloc(strlen(helpbuf2)+1, sizeof(char));
- strcpy(cfg.realmtable[cfg.size-1].hostname, helpbuf2);
- }
- else if (strcmp(helpbuf1, "listen")==0) {
- UsrCli_set_listenPortName(cfg.realmtable[cfg.size-1].usrclitable[listencount], helpbuf2);
- ++listencount;
- }
- else if (strcmp(helpbuf1, "pass")==0) {
- n = strlen(helpbuf2);
- memset(cfg.realmtable[cfg.size-1].pass, 0, 4);
- for (i = 0; i < n; ++i) {
- cfg.realmtable[cfg.size-1].pass[i%4] += helpbuf2[i];
- }
- }
- else if (strcmp(helpbuf1, "manage")==0) {
- UsrCli_set_managePortName(cfg.realmtable[cfg.size-1].usrclitable[managecount], helpbuf2);
- ++managecount;
- }
- else if (strcmp(helpbuf1, "users")==0) {
- cfg.realmtable[cfg.size-1].users = calloc(strlen(helpbuf2)+1, sizeof(char));
- strcpy(cfg.realmtable[cfg.size-1].users, helpbuf2);
- }
- else if (strcmp(helpbuf1, "timeout")==0) {
- cfg.realmtable[cfg.size-1].timeout = calloc(strlen(helpbuf2)+1, sizeof(char));
- strcpy(cfg.realmtable[cfg.size-1].timeout, helpbuf2);
- }
- else if (strcmp(helpbuf1, "clients")==0) {
- cfg.realmtable[cfg.size-1].clients = calloc(strlen(helpbuf2)+1, sizeof(char));
- strcpy(cfg.realmtable[cfg.size-1].clients, helpbuf2);
- }
- else if (strcmp(helpbuf1, "raclients")==0) {
- cfg.realmtable[cfg.size-1].raclients = calloc(strlen(helpbuf2)+1, sizeof(char));
- strcpy(cfg.realmtable[cfg.size-1].raclients, helpbuf2);
- }
- else if (strcmp(helpbuf1, "usrpcli")==0) {
- cfg.realmtable[cfg.size-1].usrpcli = calloc(strlen(helpbuf2)+1, sizeof(char));
- strcpy(cfg.realmtable[cfg.size-1].usrpcli, helpbuf2);
- }
- else if (strcmp(helpbuf1, "climode")==0) {
- cfg.realmtable[cfg.size-1].clim = calloc(strlen(helpbuf2)+1, sizeof(char));
- strcpy(cfg.realmtable[cfg.size-1].clim, helpbuf2);
- }
- else if (strcmp(helpbuf1, "proto")==0) {
- if (TYPE_IS_SET(cfg.realmtable[cfg.size-1].type)) {
- return cfg;
- }
- if (strcmp(helpbuf2, "tcp")==0) {
- TYPE_SET_TCP(cfg.realmtable[cfg.size-1].type);
- }
- else if (strcmp(helpbuf2, "udp")==0) {
- TYPE_SET_UDP(cfg.realmtable[cfg.size-1].type);
- }
- else {
- return cfg;
- }
- }
- else {
- return cfg;
- }
- }
- memset(buff, 0, 256);
- }
-
- fclose(file);
-
- *status = 0;
- return cfg;
-}
-