Mercurial > noffle
comparison src/noffle.c @ 270:d6fedc09b052 noffle
[svn] * src/noffle.c: Rearrange initialisation so that a requested usage
message will be output before Noffle can fail due to misconfiguration.
Introduce routine (currently stub) for checking file ownership and
permissions on startup - I suspect a lot of reported errors are due
to ownership problems.
author | bears |
---|---|
date | Sun, 10 Nov 2002 11:30:40 +0000 |
parents | 52f467c7213b |
children | 5eece4dfd945 |
comparison
equal
deleted
inserted
replaced
269:b3a2f710fe2c | 270:d6fedc09b052 |
---|---|
8 not as server. If noffle runs as server, locking is performed while | 8 not as server. If noffle runs as server, locking is performed while |
9 executing NNTP commands, but temporarily released if no new command is | 9 executing NNTP commands, but temporarily released if no new command is |
10 received for some seconds (to allow multiple clients connect at the same | 10 received for some seconds (to allow multiple clients connect at the same |
11 time). | 11 time). |
12 | 12 |
13 $Id: noffle.c 387 2002-06-26 13:15:44Z bears $ | 13 $Id: noffle.c 402 2002-11-10 11:30:40Z bears $ |
14 */ | 14 */ |
15 | 15 |
16 #if HAVE_CONFIG_H | 16 #if HAVE_CONFIG_H |
17 #include <config.h> | 17 #include <config.h> |
18 #endif | 18 #endif |
551 " -v | --version Print version\n"; | 551 " -v | --version Print version\n"; |
552 fprintf( stderr, "%s", msg ); | 552 fprintf( stderr, "%s", msg ); |
553 } | 553 } |
554 | 554 |
555 /* | 555 /* |
556 Check file ownership and permissions. | |
557 This assumes we have cd'd to the spool directory. | |
558 */ | |
559 static Bool | |
560 checkFileOwnership( void ) | |
561 { | |
562 return TRUE; | |
563 } | |
564 | |
565 /* | |
556 Allow core files: Change core limit and change working directory | 566 Allow core files: Change core limit and change working directory |
557 to spool directory, where news has write permissions. | 567 to spool directory, where news has write permissions. |
558 */ | 568 */ |
559 static void | 569 static void |
560 enableCorefiles( void ) | 570 enableCorefiles( void ) |
571 { | 581 { |
572 Log_err( "Cannot set system core limit: %s", strerror( errno ) ); | 582 Log_err( "Cannot set system core limit: %s", strerror( errno ) ); |
573 return; | 583 return; |
574 } | 584 } |
575 Log_dbg( LOG_DBG_NOFFLE, "Core limit set to %i", lim.rlim_max ); | 585 Log_dbg( LOG_DBG_NOFFLE, "Core limit set to %i", lim.rlim_max ); |
576 if ( chdir( Cfg_spoolDir() ) != 0 ) | |
577 { | |
578 Log_err( "Cannot change to directory '%s'", Cfg_spoolDir() ); | |
579 return; | |
580 } | |
581 Log_dbg( LOG_DBG_NOFFLE, "Changed to directory '%s'", Cfg_spoolDir() ); | |
582 } | 586 } |
583 | 587 |
584 static Bool | 588 static Bool |
585 initNoffle( void ) | 589 initNoffle( void ) |
586 { | 590 { |
587 Log_init( "noffle", noffle.lockAtStartup, LOG_NEWS ); | 591 Log_init( "noffle", noffle.lockAtStartup, LOG_NEWS ); |
588 Cfg_read(); | 592 Cfg_read(); |
589 Log_dbg( LOG_DBG_NOFFLE, "NOFFLE version %s", Cfg_version() ); | 593 Log_dbg( LOG_DBG_NOFFLE, "NOFFLE version %s", Cfg_version() ); |
594 | |
595 /* cd to the spool directory */ | |
596 if ( chdir( Cfg_spoolDir() ) != 0 ) | |
597 { | |
598 Log_err( "Cannot change to directory '%s'", Cfg_spoolDir() ); | |
599 return FALSE; | |
600 } | |
601 Log_dbg( LOG_DBG_NOFFLE, "Changed to directory '%s'", Cfg_spoolDir() ); | |
602 | |
603 if ( ! checkFileOwnership() ) | |
604 return FALSE; | |
605 | |
590 if ( noffle.lockAtStartup ) | 606 if ( noffle.lockAtStartup ) |
591 if ( ! Lock_openDatabases() ) | 607 if ( ! Lock_openDatabases() ) |
592 return FALSE; | 608 return FALSE; |
593 enableCorefiles(); | 609 enableCorefiles(); |
594 return TRUE; | 610 return TRUE; |
665 | 681 |
666 static int | 682 static int |
667 doInews( int argc, char **argv ) | 683 doInews( int argc, char **argv ) |
668 { | 684 { |
669 int result; | 685 int result; |
670 int flags; | 686 unsigned flags; |
671 FILE *f; | 687 FILE *f; |
672 | 688 |
673 UNUSED( argc ); | 689 UNUSED( argc ); |
674 | 690 |
675 noffle.lockAtStartup = TRUE; | 691 noffle.lockAtStartup = TRUE; |
816 argv++; | 832 argv++; |
817 argc--; | 833 argc--; |
818 } | 834 } |
819 | 835 |
820 noffle.lockAtStartup = ! ( c == 'r' || c == 'h' ); | 836 noffle.lockAtStartup = ! ( c == 'r' || c == 'h' ); |
837 | |
838 /* | |
839 If they asked for help, give it before there's a possibility | |
840 we could fail on init. | |
841 */ | |
842 if ( c == 'h' ) | |
843 { | |
844 printUsage(); | |
845 return EXIT_SUCCESS; | |
846 } | |
847 | |
821 if ( ! initNoffle() ) | 848 if ( ! initNoffle() ) |
822 return EXIT_FAILURE; | 849 return EXIT_FAILURE; |
823 result = EXIT_SUCCESS; | 850 result = EXIT_SUCCESS; |
824 switch ( c ) | 851 switch ( c ) |
825 { | 852 { |