Exemple #1
0
int
vacm_warn_if_not_configured(int majorID, int minorID, void *serverarg,
                            void *clientarg)
{
    const char * name = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
                                        NETSNMP_DS_LIB_APPTYPE);
    const int agent_mode =  netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, 
                                                   NETSNMP_DS_AGENT_ROLE);
    if (NULL==name)
        name = "snmpd";
    
    if (!vacm_is_configured()) {
        /*
         *  An AgentX subagent relies on the master agent to apply suitable
         *    access control checks, so doesn't need local VACM configuration.
         *  The trap daemon has a separate check (see below).
         *
         *  Otherwise, an AgentX master or SNMP standalone agent requires some
         *    form of VACM configuration.  No config means that no incoming
         *    requests will be accepted, so warn the user accordingly.
         */
        if ((MASTER_AGENT == agent_mode) && (strcmp(name, "snmptrapd") != 0)) {
            snmp_log(LOG_WARNING,
                 "Warning: no access control information configured.\n"
                 "  (Config search path: %s)\n"
                 "  It's unlikely this agent can serve any useful purpose in this state.\n"
                 "  Run \"snmpconf -g basic_setup\" to help you "
                 "configure the %s.conf file for this agent.\n",
                 get_configuration_directory(), name);
        }

        /*
         *  The trap daemon implements VACM-style access control for incoming
         *    notifications, but offers a way of turning this off (for backwards
         *    compatability).  Check for this explicitly, and warn if necessary.
         *
         *  NB:  The NETSNMP_DS_APP_NO_AUTHORIZATION definition is a duplicate
         *       of an identical setting in "apps/snmptrapd_ds.h".
         *       These two need to be kept in synch.
         */
#ifndef NETSNMP_DS_APP_NO_AUTHORIZATION
#define NETSNMP_DS_APP_NO_AUTHORIZATION 17
#endif
        if (!strcmp(name, "snmptrapd") &&
            !netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, 
                                    NETSNMP_DS_APP_NO_AUTHORIZATION)) {
            snmp_log(LOG_WARNING,
                 "Warning: no access control information configured.\n"
                 "  (Config search path: %s)\n"
                 "This receiver will *NOT* accept any incoming notifications.\n",
                 get_configuration_directory());
        }
    }
    return SNMP_ERR_NOERROR;
}
Exemple #2
0
	/* Local functions definitions */
	void parse_service_options(int argc, LPTSTR* argv, service_configuration& configuration)
	{
		namespace po = boost::program_options;

		po::options_description service_options("Service options");
		service_options.add_options()
		("configuration_file,c", po::value<std::string>()->default_value((get_configuration_directory() / "freelan.cfg").string()), "The configuration file to use.")
		("debug,d", "Enables debug output.")
		("threads,t", po::value<unsigned int>(&configuration.thread_count)->default_value(0), "The number of threads to use.")
		("log_file,l", po::value<std::string>(), "The log file to use.")
		;

		po::variables_map vm;
		po::store(po::parse_command_line(argc, argv, service_options), vm);
		po::notify(vm);

		const fs::path installation_directory = get_installation_directory();

		if (vm.count("configuration_file"))
		{
			configuration.configuration_file = fs::absolute(vm["configuration_file"].as<std::string>(), installation_directory);
		}

		configuration.debug = (vm.count("debug") > 0);

		if (vm.count("log_file"))
		{
			configuration.log_file = fs::absolute(vm["log_file"].as<std::string>(), installation_directory);
		}
		else
		{
			configuration.log_file = installation_directory / "log" / "freelan.log";
		}
	}
Exemple #3
0
std::vector<fs::path> get_configuration_files()
{
	std::vector<fs::path> configuration_files;

	configuration_files.push_back(get_home_directory() / "freelan.cfg");
	configuration_files.push_back(get_configuration_directory() / "freelan.cfg");

	return configuration_files;
}
Exemple #4
0
static void
usage(char *prog)
{
#ifdef WIN32SERVICE
    printf("\nUsage:  %s [-register] [-quiet] [OPTIONS] [LISTENING ADDRESSES]"
           "\n        %s [-unregister] [-quiet]", prog, prog);
#else
    printf("\nUsage:  %s [OPTIONS] [LISTENING ADDRESSES]", prog);
#endif
    printf("\n"
           "\n\tVersion:  %s\n%s"
           "\t\t\t  (config search path: %s)\n%s%s",
           netsnmp_get_version(),
           "\tWeb:      http://www.net-snmp.org/\n"
           "\tEmail:    [email protected]\n"
           "\n  -a\t\t\tlog addresses\n"
           "  -A\t\t\tappend to the logfile rather than truncating it\n"
           "  -c FILE[,...]\t\tread FILE(s) as configuration file(s)\n"
           "  -C\t\t\tdo not read the default configuration files\n",
           get_configuration_directory(),
           "  -d\t\t\tdump sent and received SNMP packets\n"
           "  -D[TOKEN[,...]]\tturn on debugging output for the given TOKEN(s)\n"
	   "\t\t\t  (try ALL for extremely verbose output)\n"
	   "\t\t\t  Don't put space(s) between -D and TOKEN(s).\n"
           "  -f\t\t\tdo not fork from the shell\n",
#if HAVE_UNISTD_H
           "  -g GID\t\tchange to this numeric gid after opening\n"
	   "\t\t\t  transport endpoints\n"
#endif
           "  -h, --help\t\tdisplay this usage message\n"
           "  -H\t\t\tdisplay configuration file directives understood\n"
           "  -I [-]INITLIST\tlist of mib modules to initialize (or not)\n"
           "\t\t\t  (run snmpd with -Dmib_init for a list)\n"
           "  -L <LOGOPTS>\t\ttoggle options controlling where to log to\n");
    snmp_log_options_usage("\t", stdout);
    printf("  -m MIBLIST\t\tuse MIBLIST instead of the default MIB list\n"
           "  -M DIRLIST\t\tuse DIRLIST as the list of locations to look for MIBs\n"
           "\t\t\t  (default %s)\n%s%s",
#ifndef NETSNMP_DISABLE_MIB_LOADING
           netsnmp_get_mib_directory(),
#else
           "MIBs not loaded",
#endif
           "  -p FILE\t\tstore process id in FILE\n"
           "  -q\t\t\tprint information in a more parsable format\n"
           "  -r\t\t\tdo not exit if files only accessible to root\n"
	   "\t\t\t  cannot be opened\n"
#ifdef WIN32SERVICE
           "  -register\t\tregister as a Windows service\n"
           "  \t\t\t  (followed by -quiet to prevent message popups)\n"
           "  \t\t\t  (followed by the startup parameter list)\n"
           "  \t\t\t  Note that some parameters are not relevant when running as a service\n"
#endif
#if HAVE_UNISTD_H
           "  -u UID\t\tchange to this uid (numeric or textual) after\n"
	   "\t\t\t  opening transport endpoints\n"
#endif
#ifdef WIN32SERVICE
           "  -unregister\t\tunregister as a Windows service\n"
           "  \t\t\t  (followed -quiet to prevent message popups)\n"
#endif
           "  -v, --version\t\tdisplay version information\n"
           "  -V\t\t\tverbose display\n"
#if defined(USING_AGENTX_SUBAGENT_MODULE)|| defined(USING_AGENTX_MASTER_MODULE)
           "  -x ADDRESS\t\tuse ADDRESS as AgentX address\n"
#endif
#ifdef USING_AGENTX_SUBAGENT_MODULE
           "  -X\t\t\trun as an AgentX subagent rather than as an\n"
	   "\t\t\t  SNMP master agent\n"
#endif
           ,
           "\nDeprecated options:\n"
           "  -l FILE\t\tuse -Lf <FILE> instead\n"
           "  -P\t\t\tuse -p instead\n"
           "  -s\t\t\tuse -Lsd instead\n"
           "  -S d|i|0-7\t\tuse -Ls <facility> instead\n"
           "\n"
           );
    exit(1);
}