Mercurial > noffle
diff src/configfile.c @ 287:01755687c565 noffle
[svn] * src/configfile.c: Change snprintf() to Utl_cpyStr();
* src/configfile.c,src/fetch.c,src/fetchlist.c,src/protocol.c,
src/server.c: Replace strcpy() with Utl_cpyStr() where appropriate.
See Debian bug 168128.
* src/client.c. Replace strcpy() here too.
* src/configfile.h,src/configfile.c,docs/noffle.conf.5: Add noffle-user
and noffle-group configs.
* src/control.c,src/configfile.c,src/noffle.c: Replace [s]scanf("%s")
with [s]scanf(MAXCHAR_FMT).
author | bears |
---|---|
date | Fri, 10 Jan 2003 23:11:43 +0000 |
parents | 18d6c61ed4e7 |
children | f35a7d45efd5 |
line wrap: on
line diff
--- a/src/configfile.c Fri Jan 10 23:08:17 2003 +0000 +++ b/src/configfile.c Fri Jan 10 23:11:43 2003 +0000 @@ -6,7 +6,7 @@ SPOOLDIR VERSION - $Id: configfile.c 405 2002-11-10 15:06:33Z bears $ + $Id: configfile.c 419 2003-01-10 23:11:43Z bears $ */ #if HAVE_CONFIG_H @@ -79,6 +79,7 @@ Bool replaceMsgId; Str hostnameMsgId; Bool postLocal; + Bool clientAuth; Str defaultAutoSubscribeMode; Str mailTo; int defaultExpire; @@ -95,6 +96,8 @@ Str pathHeader; Str fromDomain; Str organization; + Str noffleUser; + Str noffleGroup; } config = { SPOOLDIR, /* spoolDir */ @@ -109,6 +112,7 @@ FALSE, /* replaceMsgId */ "", /* hostnameMsgId */ FALSE, /* postLocal */ + FALSE, /* clientAuth */ "over", /* defaultAutoSubscribeMode */ "", /* mailTo */ 14, /* defaultExpire */ @@ -124,7 +128,9 @@ NULL, /* autoSubscribeMode */ "", /* pathHeader */ "", /* fromDomain */ - "" /* organization */ + "", /* organization */ + "news", /* user Noffle runs as */ + "news" /* group Noffle runs as */ }; const char * Cfg_spoolDir( void ) { return config.spoolDir; } @@ -140,6 +146,7 @@ Bool Cfg_replaceMsgId( void ) { return config.replaceMsgId; } const char * Cfg_hostnameMsgId( void ) { return config.hostnameMsgId; } Bool Cfg_postLocal( void ) { return config.postLocal; } +Bool Cfg_needClientAuth( void ) { return config.clientAuth; } const char * Cfg_defaultAutoSubscribeMode( void ) { return config.defaultAutoSubscribeMode; } const char * Cfg_mailTo( void ) { return config.mailTo; } @@ -147,6 +154,8 @@ const char * Cfg_pathHeader( void ) { return config.pathHeader; } const char * Cfg_fromDomain( void ) { return config.fromDomain; } const char * Cfg_organization( void ) { return config.organization; } +const char * Cfg_noffleUser( void ) { return config.noffleUser; } +const char * Cfg_noffleGroup( void ) { return config.noffleGroup; } void Cfg_beginServEnum( void ) @@ -159,7 +168,7 @@ { if ( config.servIdx >= config.numServ ) return FALSE; - strcpy( name, config.serv[ config.servIdx ].name ); + Utl_cpyStr( name, config.serv[ config.servIdx ].name ); ++config.servIdx; return TRUE; } @@ -209,8 +218,8 @@ if ( searchServ( name, &idx ) ) { - strcpy( user, config.serv[ idx ].user ); - strcpy( pass, config.serv[ idx ].pass ); + Utl_cpyStr( user, config.serv[ idx ].user ); + Utl_cpyStr( pass, config.serv[ idx ].pass ); } else { @@ -264,10 +273,7 @@ res = (GroupEnum *) malloc( sizeof( GroupEnum ) ); if ( res == NULL ) - { - Log_err( "Malloc of GroupEnum failed." ); - exit( EXIT_FAILURE ); - } + Log_fatal( "Malloc of GroupEnum failed." ); if ( ! searchServ( name, &servIdx ) ) res->groupEntry = NULL; else @@ -284,10 +290,7 @@ res = (GroupEnum *) malloc( sizeof( GroupEnum ) ); if ( res == NULL ) - { - Log_err( "Malloc of GroupEnum failed." ); - exit( EXIT_FAILURE ); - } + Log_fatal( "Malloc of GroupEnum failed." ); if ( ! searchServ( name, &servIdx ) ) res->groupEntry = NULL; else @@ -328,9 +331,9 @@ { Str value, name, lowerLn; - strcpy( lowerLn, line ); + Utl_cpyStr( lowerLn, line ); Utl_toLower( lowerLn ); - if ( sscanf( lowerLn, "%s %s", name, value ) != 2 ) + if ( sscanf( lowerLn, MAXCHAR_FMT " " MAXCHAR_FMT, name, value ) != 2 ) { logSyntaxErr( line ); return; @@ -350,7 +353,7 @@ int value; Str name; - if ( sscanf( line, "%s %d", name, &value ) != 2 ) + if ( sscanf( line, MAXCHAR_FMT " %d", name, &value ) != 2 ) { logSyntaxErr( line ); return; @@ -368,7 +371,7 @@ { Str dummy; - if ( sscanf( line, "%s %s", dummy, variable ) != 2 ) + if ( sscanf( line, MAXCHAR_FMT " " MAXCHAR_FMT, dummy, variable ) != 2 ) { logSyntaxErr( line ); return; @@ -394,7 +397,8 @@ memset( &entry, 0, sizeof( entry ) ); user[ 0 ] = pass[ 0 ] = '\0'; - r = sscanf( line, "%s %s %s %s", + r = sscanf( line, + MAXCHAR_FMT " " MAXCHAR_FMT " " MAXCHAR_FMT " " MAXCHAR_FMT, dummy, name, user, pass ); if ( r < 2 ) { @@ -417,10 +421,7 @@ if ( ! ( config.serv = realloc( config.serv, ( config.maxServ + 5 ) * sizeof( ServEntry ) ) ) ) - { - Log_err( "Could not realloc server list" ); - exit( EXIT_FAILURE ); - } + Log_fatal( "Could not realloc server list" ); config.maxServ += 5; } config.serv[ config.numServ++ ] = entry; @@ -433,7 +434,8 @@ ExpireEntry entry; int days; - if ( sscanf( line, "%s %s %d", dummy, pattern, &days ) != 3 ) + if ( sscanf( line, MAXCHAR_FMT " " MAXCHAR_FMT " %d", + dummy, pattern, &days ) != 3 ) { logSyntaxErr( line ); return; @@ -456,10 +458,7 @@ if ( ! ( config.expire = realloc( config.expire, ( config.maxExpire + 5 ) * sizeof( ExpireEntry ) ) ) ) - { - Log_err( "Could not realloc expire list" ); - exit( EXIT_FAILURE ); - } + Log_fatal( "Could not realloc expire list" ); config.maxExpire += 5; } config.expire[ config.numExpire++ ] = entry; @@ -507,10 +506,7 @@ if ( ! ( g->groups = realloc( g->groups, ( g->maxGroup + 5 ) * sizeof( char * ) ) ) ) - { - Log_err( "Could not realloc group list" ); - exit( EXIT_FAILURE ); - } + Log_fatal( "Could not realloc group list" ); g->maxGroup += 5; } Utl_allocAndCpy( &g->groups[ g->numGroup++ ], pattern ); @@ -570,6 +566,8 @@ mask |= LOG_DBG_REQUESTS; else if ( strcmp( maskName, "server" ) == 0 ) mask |= LOG_DBG_SERVER; + else if ( strcmp( maskName, "auth" ) == 0 ) + mask |= LOG_DBG_AUTH; else logSyntaxErr( line ); } @@ -593,7 +591,8 @@ AutoSubscribeModeEntry entry; int items; - items = sscanf( line, "%s %s %s", dummy, pattern, mode ); + items = sscanf( line, MAXCHAR_FMT " " MAXCHAR_FMT " " MAXCHAR_FMT, + dummy, pattern, mode ); if ( items == 2 ) { /* Backwards compat. default-auto-subscribe-mode */ @@ -604,7 +603,7 @@ logSyntaxErr( line ); return; } - strcpy( config.defaultAutoSubscribeMode, mode ); + Utl_cpyStr( config.defaultAutoSubscribeMode, mode ); return; } else if ( items != 3 ) @@ -630,10 +629,7 @@ realloc( config.autoSubscribeMode, ( config.maxAutoSubscribeMode + 5 ) * sizeof( AutoSubscribeModeEntry ) ) ) ) - { - Log_err( "Could not realloc auto subscribe mode list" ); - exit( EXIT_FAILURE ); - } + Log_fatal( "Could not realloc auto subscribe mode list" ); config.maxAutoSubscribeMode += 5; } config.autoSubscribeMode[ config.numAutoSubscribeMode++ ] = entry; @@ -919,7 +915,7 @@ FILE *f; Str file, line, lowerLine, name, s; - snprintf( file, MAXCHAR, CONFIGFILE ); + Utl_cpyStr( file, CONFIGFILE ); if ( ! ( f = fopen( file, "r" ) ) ) { Log_err( "Cannot read %s", file ); @@ -934,7 +930,7 @@ p = lowerLine; if ( *p == '\0' ) continue; - if ( sscanf( p, "%s", name ) != 1 ) + if ( sscanf( p, MAXCHAR_FMT, name ) != 1 ) Log_err( "Syntax error in %s: %s", file, line ); else if ( strcmp( "max-fetch", name ) == 0 ) getInt( &config.maxFetch, 0, INT_MAX, p ); @@ -959,6 +955,8 @@ getStr( config.hostnameMsgId, line ); else if ( strcmp( "post-locally", name ) == 0 ) getBool( &config.postLocal, p ); + else if ( strcmp( "authenticate-client", name ) == 0 ) + getBool( &config.clientAuth, p ); else if ( strcmp( "default-auto-subscribe-mode", name ) == 0 ) { getStr( s, p ); @@ -968,7 +966,7 @@ return; } else - strcpy( config.defaultAutoSubscribeMode, s ); + Utl_cpyStr( config.defaultAutoSubscribeMode, s ); } else if ( strcmp( "mail-to", name ) == 0 ) getStr( config.mailTo, p ); @@ -989,6 +987,10 @@ /* The following need line because they may have uppercase data */ else if ( strcmp( "organization", name ) == 0 ) getText( config.organization, line ); + else if ( strcmp( "noffle-user", name ) == 0 ) + getText( config.noffleUser, line ); + else if ( strcmp( "noffle-group", name ) == 0 ) + getText( config.noffleUser, line ); else if ( strcmp( "server", name ) == 0 ) getServ( line ); else if ( strcmp( "filter", name ) == 0 ) @@ -998,8 +1000,5 @@ } fclose( f ); if ( ! config.numServ ) - { - Log_err( "Config file contains no server" ); - exit( EXIT_FAILURE ); - } + Log_fatal( "Config file contains no server" ); }