| 66 | | if (getrlimit(RLIMIT_AS, &rlim) == -1) |
| 67 | | { |
| 68 | | std::cerr << "getrlimit failed: " << strerror(errno) |
| 69 | | << std::endl; |
| 70 | | return 1; |
| 71 | | } |
| 72 | | |
| 73 | | struct utsname uts; |
| 74 | | if (uname(&uts) == -1) |
| 75 | | { |
| 76 | | std::cerr << "uname failed: " << strerror(errno) << std::endl; |
| 77 | | return 1; |
| 78 | | } |
| 79 | | |
| 80 | | po::options_description opts; |
| 81 | | opts.add_options() |
| 82 | | ( "help", "show this help message") |
| 83 | | ( "daemon", |
| 84 | | po::value<bool>()->default_value(true), |
| 85 | | "create a daemon process and exit immediately afterward") |
| 86 | | ( "user", po::value<std::string>(), |
| 87 | | "the user to run as (if started as root)") |
| 88 | | ( "canonical-name", |
| 89 | | po::value<std::string>()->default_value(uts.nodename), |
| 90 | | "the canonical name of this host" ) |
| 91 | | ("nntp-port", |
| 92 | | po::value<std::string>()->default_value("119"), |
| 93 | | "the port to listen on for NNTP clients") |
| 94 | | ("nntps-port", |
| 95 | | po::value<std::string>()->default_value("563"), |
| 96 | | "the port to listen on for NNTP/SSL clients") |
| 97 | | ("https-port", |
| 98 | | po::value<std::string>()->default_value("443"), |
| 99 | | "the port to listen on for HTTPS clients") |
| 100 | | ("key-file", |
| 101 | | po::value<std::string>()->default_value("key.pem"), |
| 102 | | "the file containing the SSL/TLS private key") |
| 103 | | ("cert-file", |
| 104 | | po::value<std::string>()->default_value("cert.pem"), |
| 105 | | "the file containing the SSL/TLS certificate") |
| 106 | | ("log-smtp", |
| 107 | | po::value<bool>()->default_value(false), |
| 108 | | "log SMTP extensively") |
| 109 | | ("log-http", |
| 110 | | po::value<bool>()->default_value(false), |
| 111 | | "log HTTP extensively (warning - user privacy invasive)") |
| 112 | | ("log-nntp", |
| 113 | | po::value<bool>()->default_value(false), |
| 114 | | "log HTTP extensively (warning - user privacy invasive)") |
| 115 | | ("logfile", |
| 116 | | po::value<std::string>()->default_value("alue.log"), |
| 117 | | "the name of the logfile") |
| 118 | | ("vm-limit", |
| 119 | | po::value<rlim_t>(&rlim.rlim_cur)->default_value(rlim.rlim_cur), |
| 120 | | "the AS (virtual memory) resource limit for this process") |
| 121 | | ("include-dir", |
| 122 | | po::value<std::string>()->default_value("templates/"), |
| 123 | | "include directory name") |
| 124 | | ("files-dir", |
| 125 | | po::value<std::string>()->default_value("templates/"), |
| 126 | | "verbatim HTTPS file directory name") |
| 127 | | ("config-file", |
| 128 | | po::value<std::string>()->default_value(CONFFILE), |
| 129 | | "name of the the configuration file") |
| 130 | | ("db-file", |
| 131 | | po::value<std::string>()->default_value("alue.db2"), |
| 132 | | "name of the database file") |
| 133 | | ("pw-file", |
| 134 | | po::value<std::string>()->default_value("passwds"), |
| 135 | | "name of the passwords file") |
| 136 | | ("home", |
| 137 | | po::value<std::string>()->default_value("/"), |
| 138 | | "name of the daemon home directory") |
| 139 | | ("operator-email", |
| 140 | | po::value<std::string>(), |
| 141 | | "a human operator's email address"); |
| 142 | | po::store(po::parse_command_line(argc, argv, opts), config); |
| 143 | | { |
| 144 | | std::string config_file_name = |
| 145 | | config["config-file"].as<std::string>(); |
| 146 | | std::ifstream config_file(config_file_name.c_str()); |
| 147 | | if (config_file) |
| 148 | | po::store(po::parse_config_file(config_file, opts), |
| 149 | | config); |
| 150 | | } |
| 151 | | po::notify(config); |
| 152 | | |
| 153 | | if (config.count("help") > 0) |
| 154 | | { |
| 155 | | std::cout << opts << std::endl; |
| 156 | | return 0; |
| 157 | | } |
| | 62 | configure(argc, argv, rlim); |