/[muddleftpd]/muddleftpd/src/cfloader.c
ViewVC logotype

Diff of /muddleftpd/src/cfloader.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by ganneff, Thu Sep 26 07:55:42 2002 UTC revision 1.1.12.1 by rugger, Tue Nov 4 15:41:22 2003 UTC
# Line 37  VSERVER serverdefaults = Line 37  VSERVER serverdefaults =
37          NULL          NULL
38  };        };      
39    
40    IPACL nat_locallist[] =
41    {
42            /* 127.0.0.0 Local interface */
43            { 0x7F000000, 0xFF000000, NULL, 2, TRUE },
44            /* 192.168.0.0/16 Private address space */
45            { 0xC0A80000, 0xFFFF0000, NULL, 2, TRUE },
46            /* 10.0.0.0/8 Private address space */
47            { 0x0A000000, 0xFF000000, NULL, 2, TRUE },
48            /* 172.16.0.0/12 Private address space */
49            { 0xAC100000, 0xFFF00000, NULL, 2, TRUE },
50    };
51    
52    IPACLLIST nat_localdefault =
53    {
54            4,              /* count */
55            0,              /* defualt is notlocal */
56            nat_locallist
57    };
58    
59  char *gethostname2(void)  char *gethostname2(void)
60  {  {
61          char *hostname;          char *hostname;
# Line 196  VSERVER *vserver_load(CONFIGDATA *cf, ch Line 215  VSERVER *vserver_load(CONFIGDATA *cf, ch
215                  converttorealstr(newvs->prelogindumpdata);                  converttorealstr(newvs->prelogindumpdata);
216          }                }      
217          newvs->grouplist = makeconfiglist(cf->configfile, sectionname, "group");          newvs->grouplist = makeconfiglist(cf->configfile, sectionname, "group");
218          newvs->ipaccess = ipacllist_new(cf->configfile, section, "ipacl");          newvs->ipaccess = ipacllist_new(cf->configfile, section, "ipacl", 'A', FALSE);
219    
220          if (vp == NULL)          if (vp == NULL)
221                  return(newvs);                  return(newvs);
# Line 254  void ftpd_killconfig(CONFIGDATA *dc) Line 273  void ftpd_killconfig(CONFIGDATA *dc)
273          }          }
274          if (dc->defaults)          if (dc->defaults)
275                  vserver_kill(dc->defaults);                  vserver_kill(dc->defaults);
276            if (dc->nat_localips)
277                    if (dc->nat_localips != &nat_localdefault)
278                            ipacllist_destroy(dc->nat_localips);
279          freewrapper(dc);          freewrapper(dc);
280  }  }
281    
282    /* this loads the configuration into a new configdata structure. Checking does
283       not need to be done at this point. Do not mess with the current config
284       because this can be called due to a signal while the FTP server is live
285    */
286    
287  CONFIGDATA *ftpd_loadconfig(char *inidata, int as_inetd, int use_umask)  CONFIGDATA *ftpd_loadconfig(char *inidata, int as_inetd, int use_umask)
288  {  {
289          CONFIGDATA *newconfig = mallocwrapper(sizeof(CONFIGDATA));          CONFIGDATA *newconfig = mallocwrapper(sizeof(CONFIGDATA));
# Line 275  CONFIGDATA *ftpd_loadconfig(char *inidat Line 302  CONFIGDATA *ftpd_loadconfig(char *inidat
302          newconfig->parentpid = getpid();          newconfig->parentpid = getpid();
303          newconfig->defaults = NULL;          newconfig->defaults = NULL;
304          newconfig->defaulthost = 0;          newconfig->defaulthost = 0;
305            newconfig->nat_localips = NULL;
306    
307          userinfo = getpwnam("nobody");          userinfo = getpwnam("nobody");
308          if (userinfo == NULL)          if (userinfo == NULL)
# Line 321  CONFIGDATA *ftpd_loadconfig(char *inidat Line 349  CONFIGDATA *ftpd_loadconfig(char *inidat
349                            &(newconfig->zerobind), ZEROBIND);                            &(newconfig->zerobind), ZEROBIND);
350          loadintfromconfig(newconfig->configfile, section, "vserverhost",          loadintfromconfig(newconfig->configfile, section, "vserverhost",
351                            &(newconfig->hostvservers), 0);                            &(newconfig->hostvservers), 0);
   
352          loadintfromconfig(newconfig->configfile, section, "rdnstimeout",          loadintfromconfig(newconfig->configfile, section, "rdnstimeout",
353                            &(newconfig->dnstimeout), RDNSTIMEOUT);                            &(newconfig->dnstimeout), RDNSTIMEOUT);
354          if (newconfig->dnstimeout == 0)          if (newconfig->dnstimeout == 0)
# Line 400  CONFIGDATA *ftpd_loadconfig(char *inidat Line 427  CONFIGDATA *ftpd_loadconfig(char *inidat
427                                    
428                  if (vpos == NULL)                  if (vpos == NULL)
429                  {                  {
430                          configerror(safe_snprintf("vserverdefault section '%s' is not defined."));                          configerror(safe_snprintf("vserverdefault section '%s' is not defined.", setting));
431                          ftpd_killconfig(newconfig);                          ftpd_killconfig(newconfig);
432                          return(NULL);                          return(NULL);
433                  }                  }
434                  newconfig->defaulthost = vpos;                    newconfig->defaulthost = vpos;  
435          }          }
436            
437            /* process pasvrange */
438            
439            if (!(setting = getconfigdata(newconfig->configfile, section, "pasvrange", 1)))
440            {
441                    newconfig->pasvport_first = 0;
442                    newconfig->pasvport_last = 0;
443            }
444            else
445            {
446                    char *rsetting = strdupwrapper(setting);
447                    char a;
448                    
449                    strtrimspace(rsetting);
450                    if (sscanf(rsetting, "%u-%u%c", &(newconfig->pasvport_first), &(newconfig->pasvport_last), &a) != 2)
451                    {
452                            freewrapper(rsetting);
453                            configerror(strdupwrapper("pasvrange requires parameter in the form of x-y (eg 1500-2000)"));
454                            ftpd_killconfig(newconfig);
455                            return(NULL);
456                    }
457            }
458    
459            /* process natip */
460            
461            if (!(setting = getconfigdata(newconfig->configfile, section, "natip", 1)))
462            {
463                    newconfig->natip = 0;
464            }
465            else
466            {
467                    if (getnetworkint(setting, &(newconfig->natip)) == -1)
468                    {
469                            configerror(safe_snprintf("natip '%s' does not resolve to an IP address", setting));
470                            ftpd_killconfig(newconfig);
471                            return(NULL);
472                    }      
473            }
474    
475            /* process nat_netclass */
476    
477            if (newconfig->natip != 0)
478            {
479                    newconfig->nat_localips = ipacllist_new(newconfig->configfile, section, "nat_netclass", 'L', FALSE);
480                    if (newconfig->nat_localips->count == 0)
481                    {
482                            ipacllist_destroy(newconfig->nat_localips);
483                            newconfig->nat_localips = &nat_localdefault;
484                    }
485            }
486            
487          return(newconfig);          return(newconfig);
488  }  }
489    
# Line 492  int ftpd_checkconfig(CONFIGDATA *cdat) Line 569  int ftpd_checkconfig(CONFIGDATA *cdat)
569          while ((vsc != NULL) && result)          while ((vsc != NULL) && result)
570          {          {
571                  vsc2 = vsc->next;                  vsc2 = vsc->next;
572                  if ((vsc->port <= 0) || (vsc->port > 32768))                  if ((vsc->port <= 0) || (vsc->port > 65535))
573                  {                  {
574                          result = FALSE;                          result = FALSE;
575                          configerror(strdupwrapper("port to bind to not in valid range"));                                configerror(strdupwrapper("port to bind is not valid"));
576                  }                  }
577    
578                  while ((vsc2 != NULL) && result)                  while ((vsc2 != NULL) && result)
# Line 512  int ftpd_checkconfig(CONFIGDATA *cdat) Line 589  int ftpd_checkconfig(CONFIGDATA *cdat)
589                  vsc = vsc->next;                  vsc = vsc->next;
590          }          }
591    
592            /* now check pasvrange */
593            
594            if (cdat->pasvport_first || cdat->pasvport_last)
595            {
596                    if ((cdat->pasvport_first < 1024) || (cdat->pasvport_last > 65535)
597                            || (cdat->pasvport_first > cdat->pasvport_last))
598                    {
599                            result = FALSE;
600                            configerror(strdupwrapper("pasvrange is not valid!"));
601                    }
602            }
603    
604          /* now check all the vservers */          /* now check all the vservers */
605    
606          vs = cdat->vservers;          vs = cdat->vservers;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.12.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26