+/**
+ * Output all IRC operator configuration structures.
+ */
+static void
+opers_puts(void)
+{
+ struct Conf_Oper *op;
+ size_t count, i;
+
+ count = array_length(&Conf_Opers, sizeof(*op));
+ op = array_start(&Conf_Opers);
+ for (i = 0; i < count; i++, op++) {
+ if (!op->name[0])
+ continue;
+
+ puts("[OPERATOR]");
+ printf(" Name = %s\n", op->name);
+ printf(" Password = %s\n", op->pwd);
+ printf(" Mask = %s\n\n", op->mask ? op->mask : "");
+ }
+}
+
+/**
+ * Read configuration, validate and output it.
+ *
+ * This function waits for a keypress of the user when stdin/stdout are valid
+ * tty's ("you can read our nice message and we can read in your keypress").
+ *
+ * @return 0 on succes, 1 on failure(s); therefore the result code can
+ * directly be used by exit() when running "ngircd --configtest".
+ */
+GLOBAL int
+Conf_Test( void )
+{
+ struct passwd *pwd;
+ struct group *grp;
+ unsigned int i;
+ bool config_valid;
+ size_t predef_channel_count;
+ struct Conf_Channel *predef_chan;
+
+ Use_Log = false;
+
+ if (!Read_Config(true, true))
+ return 1;
+
+ config_valid = Validate_Config(true, false);
+
+ /* Valid tty? */
+ if(isatty(fileno(stdin)) && isatty(fileno(stdout))) {
+ puts("OK, press enter to see a dump of your server configuration ...");
+ getchar();
+ } else
+ puts("Ok, dump of your server configuration follows:\n");
+
+ puts("[GLOBAL]");
+ printf(" Name = %s\n", Conf_ServerName);
+ printf(" AdminInfo1 = %s\n", Conf_ServerAdmin1);
+ printf(" AdminInfo2 = %s\n", Conf_ServerAdmin2);
+ printf(" AdminEMail = %s\n", Conf_ServerAdminMail);
+ printf(" Info = %s\n", Conf_ServerInfo);
+ printf(" Listen = %s\n", Conf_ListenAddress);
+ if (Using_MotdFile) {
+ printf(" MotdFile = %s\n", Conf_MotdFile);
+ printf(" MotdPhrase =\n");
+ } else {
+ printf(" MotdFile = \n");
+ printf(" MotdPhrase = %s\n", array_bytes(&Conf_Motd)
+ ? (const char*) array_start(&Conf_Motd) : "");
+ }
+#ifndef PAM
+ printf(" Password = %s\n", Conf_ServerPwd);
+#endif
+ printf(" PidFile = %s\n", Conf_PidFile);
+ printf(" Ports = ");
+ ports_puts(&Conf_ListenPorts);
+ grp = getgrgid(Conf_GID);
+ if (grp)
+ printf(" ServerGID = %s\n", grp->gr_name);
+ else
+ printf(" ServerGID = %ld\n", (long)Conf_GID);
+ pwd = getpwuid(Conf_UID);
+ if (pwd)
+ printf(" ServerUID = %s\n", pwd->pw_name);
+ else
+ printf(" ServerUID = %ld\n", (long)Conf_UID);
+ puts("");
+
+ puts("[LIMITS]");
+ printf(" ConnectRetry = %d\n", Conf_ConnectRetry);
+ printf(" MaxConnections = %d\n", Conf_MaxConnections);
+ printf(" MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP);
+ printf(" MaxJoins = %d\n", Conf_MaxJoins > 0 ? Conf_MaxJoins : -1);
+ printf(" MaxNickLength = %u\n", Conf_MaxNickLength - 1);
+ printf(" PingTimeout = %d\n", Conf_PingTimeout);
+ printf(" PongTimeout = %d\n", Conf_PongTimeout);
+ puts("");
+
+ puts("[OPTIONS]");
+ printf(" AllowRemoteOper = %s\n", yesno_to_str(Conf_AllowRemoteOper));
+ printf(" ChrootDir = %s\n", Conf_Chroot);
+ printf(" CloakHost = %s\n", Conf_CloakHost);
+ printf(" CloakHostModeX = %s\n", Conf_CloakHostModeX);
+ printf(" CloakHostSalt = %s\n", Conf_CloakHostSalt);
+ printf(" CloakUserToNick = %s\n", yesno_to_str(Conf_CloakUserToNick));
+#ifdef WANT_IPV6
+ printf(" ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6));
+ printf(" ConnectIPv6 = %s\n", yesno_to_str(Conf_ConnectIPv4));
+#endif
+ printf(" DNS = %s\n", yesno_to_str(Conf_DNS));
+#ifdef IDENT
+ printf(" Ident = %s\n", yesno_to_str(Conf_Ident));
+#endif
+ printf(" MorePrivacy = %s\n", yesno_to_str(Conf_MorePrivacy));
+ printf(" NoticeAuth = %s\n", yesno_to_str(Conf_NoticeAuth));
+ printf(" OperCanUseMode = %s\n", yesno_to_str(Conf_OperCanMode));
+ printf(" OperServerMode = %s\n", yesno_to_str(Conf_OperServerMode));
+#ifdef PAM
+ printf(" PAM = %s\n", yesno_to_str(Conf_PAM));
+ printf(" PAMIsOptional = %s\n", yesno_to_str(Conf_PAMIsOptional));
+#endif
+ printf(" PredefChannelsOnly = %s\n", yesno_to_str(Conf_PredefChannelsOnly));
+#ifndef STRICT_RFC
+ printf(" RequireAuthPing = %s\n", yesno_to_str(Conf_AuthPing));
+#endif
+ printf(" ScrubCTCP = %s\n", yesno_to_str(Conf_ScrubCTCP));
+#ifdef SYSLOG
+ printf(" SyslogFacility = %s\n",
+ ngt_SyslogFacilityName(Conf_SyslogFacility));
+#endif
+ printf(" WebircPassword = %s\n", Conf_WebircPwd);
+ puts("");
+
+#ifdef SSL_SUPPORT
+ puts("[SSL]");
+ printf(" CertFile = %s\n", Conf_SSLOptions.CertFile
+ ? Conf_SSLOptions.CertFile : "");
+ printf(" DHFile = %s\n", Conf_SSLOptions.DHFile
+ ? Conf_SSLOptions.DHFile : "");
+ printf(" KeyFile = %s\n", Conf_SSLOptions.KeyFile
+ ? Conf_SSLOptions.KeyFile : "");
+ if (array_bytes(&Conf_SSLOptions.KeyFilePassword))
+ puts(" KeyFilePassword = <secret>");
+ else
+ puts(" KeyFilePassword = ");
+ array_free_wipe(&Conf_SSLOptions.KeyFilePassword);
+ printf(" Ports = ");
+ ports_puts(&Conf_SSLOptions.ListenPorts);
+ puts("");
+#endif
+
+ opers_puts();
+
+ for( i = 0; i < MAX_SERVERS; i++ ) {