X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Fconf.c;h=a70973e78cf8b47d33eeac5cb54a27f8388e4fef;hb=04e38f17ae671f84b93e06c6eefa9235dd71d6ce;hp=f78eaee64d985f01aa294e9cdf7ce6fd56401aa0;hpb=761b2284b953de0d5c2f847e55e3fbc030243178;p=ngircd-alex.git diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index f78eaee6..a70973e7 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -55,6 +55,8 @@ static int New_Server_Idx; static size_t Conf_Oper_Count; static size_t Conf_Channel_Count; +static char Conf_MotdFile[FNAME_LEN]; + static void Set_Defaults PARAMS(( bool InitServers )); static bool Read_Config PARAMS(( bool ngircd_starting )); static bool Validate_Config PARAMS(( bool TestOnly, bool Rehash )); @@ -299,7 +301,7 @@ Conf_Test( void ) printf(" AdminInfo2 = %s\n", Conf_ServerAdmin2); printf(" AdminEMail = %s\n", Conf_ServerAdminMail); printf(" MotdFile = %s\n", Conf_MotdFile); - printf(" MotdPhrase = %s\n", Conf_MotdPhrase); + printf(" MotdPhrase = %.32s\n", array_bytes(&Conf_Motd) ? (const char*) array_start(&Conf_Motd) : ""); printf(" ChrootDir = %s\n", Conf_Chroot); printf(" PidFile = %s\n", Conf_PidFile); printf(" Listen = %s\n", Conf_ListenAddress); @@ -331,6 +333,7 @@ Conf_Test( void ) printf(" PredefChannelsOnly = %s\n", yesno_to_str(Conf_PredefChannelsOnly)); printf(" NoDNS = %s\n", yesno_to_str(Conf_NoDNS)); printf(" NoIdent = %s\n", yesno_to_str(Conf_NoIdent)); + printf(" NoPAM = %s\n", yesno_to_str(Conf_NoPAM)); #ifdef WANT_IPV6 printf(" ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6)); @@ -566,7 +569,6 @@ Set_Defaults(bool InitServers) strlcpy(Conf_MotdFile, SYSCONFDIR, sizeof(Conf_MotdFile)); strlcat(Conf_MotdFile, MOTD_FILE, sizeof(Conf_MotdFile)); - strlcpy(Conf_MotdPhrase, MOTD_PHRASE, sizeof(Conf_MotdPhrase)); Conf_UID = Conf_GID = 0; strlcpy(Conf_Chroot, CHROOT_DIR, sizeof(Conf_Chroot)); @@ -580,6 +582,7 @@ Set_Defaults(bool InitServers) Conf_ConnectRetry = 60; Conf_NoDNS = false; Conf_NoIdent = false; + Conf_NoPAM = false; Conf_Oper_Count = 0; Conf_Channel_Count = 0; @@ -615,6 +618,36 @@ no_listenports(void) return cnt == 0; } +static void +Read_Motd(const char *filename) +{ + char line[127]; + FILE *fp; + + if (*filename == '\0') + return; + + fp = fopen(filename, "r"); + if (!fp) { + Log(LOG_WARNING, "Can't read MOTD file \"%s\": %s", + filename, strerror(errno)); + return; + } + + array_free(&Conf_Motd); + + while (fgets(line, (int)sizeof line, fp)) { + ngt_TrimLastChr( line, '\n'); + + /* add text including \0 */ + if (!array_catb(&Conf_Motd, line, strlen(line) + 1)) { + Log(LOG_WARNING, "Cannot add MOTD text: %s", strerror(errno)); + break; + } + } + fclose(fp); +} + static bool Read_Config( bool ngircd_starting ) { @@ -778,6 +811,10 @@ Read_Config( bool ngircd_starting ) Config_Error(LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME); exit(1); } + + /* No MOTD phrase configured? (re)try motd file. */ + if (array_bytes(&Conf_Motd) == 0) + Read_Motd(Conf_MotdFile); return true; } /* Read_Config */ @@ -814,6 +851,7 @@ static unsigned int Handle_MaxNickLength(int Line, const char *Arg) } /* Handle_MaxNickLength */ + static void Handle_GLOBAL( int Line, char *Var, char *Arg ) { @@ -880,17 +918,24 @@ Handle_GLOBAL( int Line, char *Var, char *Arg ) return; } if( strcasecmp( Var, "MotdFile" ) == 0 ) { - /* "Message of the day" (MOTD) file */ len = strlcpy( Conf_MotdFile, Arg, sizeof( Conf_MotdFile )); if (len >= sizeof( Conf_MotdFile )) Config_Error_TooLong( Line, Var ); + Read_Motd(Arg); return; } if( strcasecmp( Var, "MotdPhrase" ) == 0 ) { /* "Message of the day" phrase (instead of file) */ - len = strlcpy( Conf_MotdPhrase, Arg, sizeof( Conf_MotdPhrase )); - if (len >= sizeof( Conf_MotdPhrase )) + len = strlen(Arg); + if (len == 0) + return; + if (len >= LINE_LEN) { Config_Error_TooLong( Line, Var ); + return; + } + if (!array_copyb(&Conf_Motd, Arg, len + 1)) + Config_Error(LOG_WARNING, "%s, line %d: Could not append MotdPhrase: %s", + NGIRCd_ConfFile, Line, strerror(errno)); return; } if( strcasecmp( Var, "ChrootDir" ) == 0 ) { @@ -986,6 +1031,11 @@ Handle_GLOBAL( int Line, char *Var, char *Arg ) #endif return; } + if(strcasecmp(Var, "NoPAM") == 0) { + /* don't use PAM library to authenticate users */ + Conf_NoPAM = Check_ArgIsTrue(Arg); + return; + } #ifdef WANT_IPV6 /* the default setting for all the WANT_IPV6 special options is 'true' */ if( strcasecmp( Var, "ConnectIPv6" ) == 0 ) {