Exemplo n.º 1
0
static void test_task(void *pvParams)
{
    while (true) {
        vTaskDelay(5000/portTICK_RATE_MS);
        printf("Test config start\n");
        config_test();
        printf("Test config finished\n");
    }
}
Exemplo n.º 2
0
int main(int argc, char **argv, char **env)
{
	int c, ret;
	my_argv	= argv;
        char *ce;

    uselogchan  = 1;
    starttime   = time(NULL);
    skip_banner = 0;

#if defined(RLIMIT_CORE) && defined(HAVE_SYS_RESOURCE_H)
    // Make sure we can dump a core
    struct rlimit   rlim;
    ret = getrlimit (RLIMIT_CORE, &rlim);

    if (ret == 0)
    {
        if (rlim.rlim_cur == 0)
        {
            //fprintf (stderr, "Core limit 0, attempting to set to %d\n", rlim.rlim_max);

            rlim.rlim_cur    = rlim.rlim_max;

            setrlimit (RLIMIT_CORE, &rlim);
        }
    }
#endif

#ifdef HAVE_GNUTLS
    gnutls_global_init ();

    gnutls_certificate_allocate_credentials (&tls_x509_cred);
#endif

		SetTime();

        sprintf (CfgSettings.conf_name, "%s/%s", EPATH, "security.cfg");

        my_env = env;

        while ((c = getopt (argc, argv, "xrshbvntd:c:l:")) != -1)
        {
            switch (c)
            {
                case 'x':
			skip_banner = 1;
			break; 
				case 'h':
					showHelp ();
                    break;
                case 'v':
                        printf("Version: \033[1;31m%s %s-%s\033[0m\n",PACKAGE_NAME,PACKAGE_VERSION,VERSION_STRING);
                        exit(0);
                case 's':
                        nomodules = 1;
                        break;
                case 'd':
						if (optarg)	{
							debug	= atoi(optarg);
							if ((debug < 1) || (debug > 3))
							{
								fprintf (stderr, "Invalid value for -d (%d)\n", debug);
								exit (0);
							}
						}
                        break;
                case 'n':
                        nofork = 1;
                        break;
                case 'c':
						if (optarg) {
	                        if ((optarg[strlen(optarg) - 4] == '.') && optarg[strlen(optarg) - 3] == 'c') {
                                if ((*optarg == '/') || (*optarg == '.'))
                                    strlcpy (CfgSettings.conf_name, optarg, sizeof(CfgSettings.conf_name));
                                else
	                                sprintf (CfgSettings.conf_name, "%s/%s", EPATH, optarg);
                            }
							else
								fprintf(stderr,"Invalid config file specified with -c option skipping.\n");
						}
                        break;
                case 'l':
                        if (optarg)
                            memcpy(logchan,optarg,sizeof(logchan));
                        break;
                case 't':
			config_test();
			exit(0);
            }
        }


        //check to see if were running under root and bail
        if ((getuid() == 0) && (getgid() == 0))
        {
            printf("Error: You are currently trying to run this program as root\n");
            printf("This program does not require root privileges ...\n");
            printf(" \n");
            printf("Running an application as root that does not require root privileges\n");
            printf("can and may have undesirable side effects. \n");
            printf("    We strongly caution against this.       \n");
            exit(0);
        }

        if (chdir (DPATH))
        {
              fprintf (stderr, "Unable to chdir to %s: %s\n", DPATH, strerror(errno));
              exit (EXIT_FAILURE);
        }


		Omega = Core_Construct(); //initialize our core class.
		
        init_lists ();
		InitDefaults();
	
        //we should work on making this more detailed in its error throws
        if (!config_load (CfgSettings.conf_name)) {
               fprintf(stderr, "Unable to read config file.\n");
               exit(0);
        } 
		VerifyConf();
		 

        DaemonSeed();

        atexit(AtExit);
	 
        Run();

        //we returned from Run() Some how :/ i shit you not.. we need to exit ;( *tear*
            Exit(0);
        return 0;
}