]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/ngircd.c
Don't create version information string each time a client connects but
[ngircd-alex.git] / src / ngircd / ngircd.c
1 /*
2  * ngIRCd -- The Next Generation IRC Daemon
3  * Copyright (c)2001-2005 by Alexander Barton (alex@barton.de)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * Please read the file COPYING, README and AUTHORS for more information.
10  *
11  * Main program -- main()
12  */
13
14
15 #include "portab.h"
16
17 static char UNUSED id[] = "$Id: ngircd.c,v 1.90 2005/02/09 09:52:58 alex Exp $";
18
19 #include "imp.h"
20 #include <assert.h>
21 #include <errno.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <signal.h>
25 #include <string.h>
26 #include <unistd.h>
27 #include <time.h>
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <sys/wait.h>
31 #include <pwd.h>
32 #include <grp.h>
33
34 #include "defines.h"
35 #include "resolve.h"
36 #include "conn.h"
37 #include "client.h"
38 #include "channel.h"
39 #include "conf.h"
40 #include "cvs-version.h"
41 #include "lists.h"
42 #include "log.h"
43 #include "parse.h"
44 #include "irc.h"
45
46 #ifdef RENDEZVOUS
47 #include "rendezvous.h"
48 #endif
49
50 #include "exp.h"
51 #include "ngircd.h"
52
53
54 LOCAL VOID Initialize_Signal_Handler PARAMS(( VOID ));
55 LOCAL VOID Signal_Handler PARAMS(( INT Signal ));
56
57 LOCAL VOID Show_Version PARAMS(( VOID ));
58 LOCAL VOID Show_Help PARAMS(( VOID ));
59
60 LOCAL VOID Pidfile_Create PARAMS(( LONG ));
61 LOCAL VOID Pidfile_Delete PARAMS(( VOID ));
62
63 LOCAL VOID NGIRCd_FillVersion PARAMS(( VOID ));
64
65
66 GLOBAL int
67 main( int argc, const char *argv[] )
68 {
69         struct passwd *pwd;
70         struct group *grp;
71         BOOLEAN ok, configtest = FALSE;
72         LONG pid, n;
73         INT i;
74
75         umask( 0077 );
76
77         NGIRCd_SignalQuit = NGIRCd_SignalRestart = NGIRCd_SignalRehash = FALSE;
78         NGIRCd_NoDaemon = NGIRCd_Passive = FALSE;
79 #ifdef DEBUG
80         NGIRCd_Debug = FALSE;
81 #endif
82 #ifdef SNIFFER
83         NGIRCd_Sniffer = FALSE;
84 #endif
85         strlcpy( NGIRCd_ConfFile, SYSCONFDIR, sizeof( NGIRCd_ConfFile ));
86         strlcat( NGIRCd_ConfFile, CONFIG_FILE, sizeof( NGIRCd_ConfFile ));
87
88         NGIRCd_FillVersion( );
89
90         /* Kommandozeile parsen */
91         for( i = 1; i < argc; i++ )
92         {
93                 ok = FALSE;
94                 if(( argv[i][0] == '-' ) && ( argv[i][1] == '-' ))
95                 {
96                         /* Lange Option */
97
98                         if( strcmp( argv[i], "--config" ) == 0 )
99                         {
100                                 if( i + 1 < argc )
101                                 {
102                                         /* Ok, there's an parameter left */
103                                         strlcpy( NGIRCd_ConfFile, argv[i + 1], sizeof( NGIRCd_ConfFile ));
104
105                                         /* next parameter */
106                                         i++; ok = TRUE;
107                                 }
108                         }
109                         if( strcmp( argv[i], "--configtest" ) == 0 )
110                         {
111                                 configtest = TRUE;
112                                 ok = TRUE;
113                         }
114 #ifdef DEBUG
115                         if( strcmp( argv[i], "--debug" ) == 0 )
116                         {
117                                 NGIRCd_Debug = TRUE;
118                                 ok = TRUE;
119                         }
120 #endif
121                         if( strcmp( argv[i], "--help" ) == 0 )
122                         {
123                                 Show_Version( );
124                                 puts( "" ); Show_Help( ); puts( "" );
125                                 exit( 1 );
126                         }
127                         if( strcmp( argv[i], "--nodaemon" ) == 0 )
128                         {
129                                 NGIRCd_NoDaemon = TRUE;
130                                 ok = TRUE;
131                         }
132                         if( strcmp( argv[i], "--passive" ) == 0 )
133                         {
134                                 NGIRCd_Passive = TRUE;
135                                 ok = TRUE;
136                         }
137 #ifdef SNIFFER
138                         if( strcmp( argv[i], "--sniffer" ) == 0 )
139                         {
140                                 NGIRCd_Sniffer = TRUE;
141                                 ok = TRUE;
142                         }
143 #endif
144                         if( strcmp( argv[i], "--version" ) == 0 )
145                         {
146                                 Show_Version( );
147                                 exit( 1 );
148                         }
149                 }
150                 else if(( argv[i][0] == '-' ) && ( argv[i][1] != '-' ))
151                 {
152                         /* Kurze Option */
153                         
154                         for( n = 1; n < (LONG)strlen( argv[i] ); n++ )
155                         {
156                                 ok = FALSE;
157 #ifdef DEBUG
158                                 if( argv[i][n] == 'd' )
159                                 {
160                                         NGIRCd_Debug = TRUE;
161                                         ok = TRUE;
162                                 }
163 #endif
164                                 if( argv[i][n] == 'f' )
165                                 {
166                                         if(( ! argv[i][n + 1] ) && ( i + 1 < argc ))
167                                         {
168                                                 /* Ok, next character is a blank */
169                                                 strlcpy( NGIRCd_ConfFile, argv[i + 1], sizeof( NGIRCd_ConfFile ));
170
171                                                 /* go to the following parameter */
172                                                 i++; n = (LONG)strlen( argv[i] );
173                                                 ok = TRUE;
174                                         }
175                                 }
176                                 if( argv[i][n] == 'n' )
177                                 {
178                                         NGIRCd_NoDaemon = TRUE;
179                                         ok = TRUE;
180                                 }
181                                 if( argv[i][n] == 'p' )
182                                 {
183                                         NGIRCd_Passive = TRUE;
184                                         ok = TRUE;
185                                 }
186 #ifdef SNIFFER
187                                 if( argv[i][n] == 's' )
188                                 {
189                                         NGIRCd_Sniffer = TRUE;
190                                         ok = TRUE;
191                                 }
192 #endif
193                                 if( argv[i][n] == 't' )
194                                 {
195                                         configtest = TRUE;
196                                         ok = TRUE;
197                                 }
198
199                                 if( ! ok )
200                                 {
201                                         printf( "%s: invalid option \"-%c\"!\n", PACKAGE_NAME, argv[i][n] );
202                                         printf( "Try \"%s --help\" for more information.\n", PACKAGE_NAME );
203                                         exit( 1 );
204                                 }
205                         }
206
207                 }
208                 if( ! ok )
209                 {
210                         printf( "%s: invalid option \"%s\"!\n", PACKAGE_NAME, argv[i] );
211                         printf( "Try \"%s --help\" for more information.\n", PACKAGE_NAME );
212                         exit( 1 );
213                 }
214         }
215
216         /* Debug-Level (fuer IRC-Befehl "VERSION") ermitteln */
217         NGIRCd_DebugLevel[0] = '\0';
218 #ifdef DEBUG
219         if( NGIRCd_Debug ) strcpy( NGIRCd_DebugLevel, "1" );
220 #endif
221 #ifdef SNIFFER
222         if( NGIRCd_Sniffer )
223         {
224                 NGIRCd_Debug = TRUE;
225                 strcpy( NGIRCd_DebugLevel, "2" );
226         }
227 #endif
228
229         /* Soll nur die Konfigurations ueberprueft und ausgegeben werden? */
230         if( configtest )
231         {
232                 Show_Version( ); puts( "" );
233                 exit( Conf_Test( ));
234         }
235         
236         while( ! NGIRCd_SignalQuit )
237         {
238                 /* Initialize global variables */
239                 NGIRCd_Start = time( NULL );
240                 (VOID)strftime( NGIRCd_StartStr, 64, "%a %b %d %Y at %H:%M:%S (%Z)", localtime( &NGIRCd_Start ));
241
242                 NGIRCd_SignalRehash = FALSE;
243                 NGIRCd_SignalRestart = FALSE;
244                 NGIRCd_SignalQuit = FALSE;
245
246                 /* Initialize modules, part I */
247                 Log_Init( );
248                 Conf_Init( );
249
250                 if( Conf_Chroot[0] )
251                 {
252                         /* Chroot */
253                         if( chdir( Conf_Chroot ) != 0 ) Log( LOG_ERR, "Can't chdir() in ChrootDir (%s): %s", Conf_Chroot, strerror( errno ));
254
255                         if( chroot( Conf_Chroot ) != 0 ) Log( LOG_ERR, "Can't change root directory to \"%s\": %s", Conf_Chroot, strerror( errno ));
256                         else Log( LOG_INFO, "Changed root and working directory to \"%s\".", Conf_Chroot );
257                 }
258
259                 if( Conf_GID != 0 )
260                 {
261                         /* Set new group ID */
262                         if( setgid( Conf_GID ) != 0 ) Log( LOG_ERR, "Can't change group ID to %u: %s", Conf_GID, strerror( errno ));
263                 }
264                 if( Conf_UID != 0 )
265                 {
266                         /* Set new user ID */
267                         if( setuid( Conf_UID ) != 0 ) Log( LOG_ERR, "Can't change user ID to %u: %s", Conf_UID, strerror( errno ));
268                 }
269
270                 /* In der Regel wird ein Sub-Prozess ge-fork()'t, der
271                  * nicht mehr mit dem Terminal verbunden ist. Mit der
272                  * Option "--nodaemon" kann dies (z.B. zum Debuggen)
273                  * verhindert werden. */
274                 if( ! NGIRCd_NoDaemon )
275                 {
276                         /* Daemon im Hintergrund erzeugen */
277                         pid = (LONG)fork( );
278                         if( pid > 0 )
279                         {
280                                 /* "alter" Prozess */
281                                 exit( 0 );
282                         }
283                         if( pid < 0 )
284                         {
285                                 /* Fehler */
286                                 printf( "%s: Can't fork: %s!\nFatal error, exiting now ...\n", PACKAGE_NAME, strerror( errno ));
287                                 exit( 1 );
288                         }
289
290                         /* Child-Prozess initialisieren */
291                         (VOID)setsid( );
292                         chdir( "/" );
293                 }
294
295                 /* Create PID file */
296                 pid = (LONG) getpid( );
297                 Pidfile_Create( pid );
298
299                 /* Show user, group, and PID of the running daemon */
300                 pwd = getpwuid( getuid( )); grp = getgrgid( getgid( ));
301                 Log( LOG_INFO, "Running as user %s(%ld), group %s(%ld), with PID %ld.", pwd ? pwd->pw_name : "unknown", (LONG)getuid( ), grp ? grp->gr_name : "unknown", (LONG)getgid( ), pid);
302
303                 /* Change working directory to home directory of the user
304                  * we are running as (when not running chroot()'ed!) */
305                 if( Conf_UID != 0 && ! Conf_Chroot[0] )
306                 {
307                         struct passwd *pwd;
308
309                         pwd = getpwuid( Conf_UID );
310                         if( pwd != NULL )
311                         {
312                                 if( chdir( pwd->pw_dir ) == 0 ) Log( LOG_DEBUG, "Changed working directory to \"%s\" ...", pwd->pw_dir );
313                                 else Log( LOG_ERR, "Can't change working directory to \"%s\": %s", pwd->pw_dir, strerror( errno ));
314                         }
315                         else Log( LOG_ERR, "Can't get user informaton for UID %d!?", Conf_UID );
316                 }
317
318                 /* Initialize modules, part II: these functions are eventually
319                  * called with already dropped privileges ... */
320                 Resolve_Init( );
321                 Lists_Init( );
322                 Channel_Init( );
323                 Client_Init( );
324 #ifdef RENDEZVOUS
325                 Rendezvous_Init( );
326 #endif
327                 Conn_Init( );
328
329                 /* Redirect stderr handle to "error file" for debugging.
330                  * But don't try to write in the chroot jail, since it's more 
331                  * secure to have a chroot dir not writable by the daemon.
332                  */
333                 if( ! Conf_Chroot[0] ) Log_InitErrorfile( );
334
335                 /* Signal-Handler initialisieren */
336                 Initialize_Signal_Handler( );
337
338                 /* Protokoll- und Server-Identifikation erzeugen. Die vom ngIRCd
339                  * beim PASS-Befehl verwendete Syntax sowie die erweiterten Flags
340                  * sind in doc/Protocol.txt beschrieben. */
341 #ifdef IRCPLUS
342                 sprintf( NGIRCd_ProtoID, "%s%s %s|%s:%s", PROTOVER, PROTOIRCPLUS, PACKAGE_NAME, PACKAGE_VERSION, IRCPLUSFLAGS );
343 #ifdef ZLIB
344                 strcat( NGIRCd_ProtoID, "Z" );
345 #endif
346                 if( Conf_OperCanMode ) strcat( NGIRCd_ProtoID, "o" );
347 #else
348                 sprintf( NGIRCd_ProtoID, "%s%s %s|%s", PROTOVER, PROTOIRC, PACKAGE_NAME, PACKAGE_VERSION );
349 #endif
350                 strcat( NGIRCd_ProtoID, " P" );
351 #ifdef ZLIB
352                 strcat( NGIRCd_ProtoID, "Z" );
353 #endif
354                 Log( LOG_DEBUG, "Protocol and server ID is \"%s\".", NGIRCd_ProtoID );
355
356                 /* Vordefinierte Channels anlegen */
357                 Channel_InitPredefined( );
358
359                 /* Listen-Ports initialisieren */
360                 if( Conn_InitListeners( ) < 1 )
361                 {
362                         Log( LOG_ALERT, "Server isn't listening on a single port!" );
363                         Log( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
364                         Pidfile_Delete( );
365                         exit( 1 );
366                 }
367                 
368                 /* Hauptschleife */
369                 Conn_Handler( );
370
371                 /* Alles abmelden */
372                 Conn_Exit( );
373 #ifdef RENDEZVOUS
374                 Rendezvous_Exit( );
375 #endif
376                 Client_Exit( );
377                 Channel_Exit( );
378                 Lists_Exit( );
379                 Log_Exit( );
380
381                 Pidfile_Delete( );
382         }
383
384         return 0;
385 } /* main */
386
387
388 LOCAL VOID
389 NGIRCd_FillVersion( VOID )
390 {
391         NGIRCd_VersionAddition[0] = '\0';
392
393 #ifdef SYSLOG
394         strcpy( NGIRCd_VersionAddition, "SYSLOG" );
395 #endif
396 #ifdef ZLIB
397         if( NGIRCd_VersionAddition[0] ) strcat( NGIRCd_VersionAddition, "+" );
398         strcat( NGIRCd_VersionAddition, "ZLIB" );
399 #endif
400 #ifdef TCPWRAP
401         if( NGIRCd_VersionAddition[0] ) strcat( NGIRCd_VersionAddition, "+" );
402         strcat( NGIRCd_VersionAddition, "TCPWRAP" );
403 #endif
404 #ifdef RENDEZVOUS
405         if( NGIRCd_VersionAddition[0] ) strcat( NGIRCd_VersionAddition, "+" );
406         strcat( NGIRCd_VersionAddition, "RENDEZVOUS" );
407 #endif
408 #ifdef IDENTAUTH
409         if( NGIRCd_VersionAddition[0] ) strcat( NGIRCd_VersionAddition, "+" );
410         strcat( NGIRCd_VersionAddition, "IDENT" );
411 #endif
412 #ifdef DEBUG
413         if( NGIRCd_VersionAddition[0] ) strcat( NGIRCd_VersionAddition, "+" );
414         strcat( NGIRCd_VersionAddition, "DEBUG" );
415 #endif
416 #ifdef SNIFFER
417         if( NGIRCd_VersionAddition[0] ) strcat( NGIRCd_VersionAddition, "+" );
418         strcat( NGIRCd_VersionAddition, "SNIFFER" );
419 #endif
420 #ifdef STRICT_RFC
421         if( NGIRCd_VersionAddition[0] ) strcat( NGIRCd_VersionAddition, "+" );
422         strcat( NGIRCd_VersionAddition, "RFC" );
423 #endif
424 #ifdef IRCPLUS
425         if( NGIRCd_VersionAddition[0] ) strcat( NGIRCd_VersionAddition, "+" );
426         strcat( NGIRCd_VersionAddition, "IRCPLUS" );
427 #endif
428
429         if( NGIRCd_VersionAddition[0] ) strlcat( NGIRCd_VersionAddition, "-", sizeof( NGIRCd_VersionAddition ));
430         strlcat( NGIRCd_VersionAddition, TARGET_CPU, sizeof( NGIRCd_VersionAddition ));
431         strlcat( NGIRCd_VersionAddition, "/", sizeof( NGIRCd_VersionAddition ));
432         strlcat( NGIRCd_VersionAddition, TARGET_VENDOR, sizeof( NGIRCd_VersionAddition ));
433         strlcat( NGIRCd_VersionAddition, "/", sizeof( NGIRCd_VersionAddition ));
434         strlcat( NGIRCd_VersionAddition, TARGET_OS, sizeof( NGIRCd_VersionAddition ));
435
436 #ifdef CVSDATE
437         snprintf( NGIRCd_Version, sizeof NGIRCd_Version,"%s %s(%s)-%s", PACKAGE_NAME, PACKAGE_VERSION, CVSDATE, NGIRCd_VersionAddition);
438 #else
439         snprintf( NGIRCd_Version, sizeof NGIRCd_Version, "%s %s-%s", PACKAGE_NAME, PACKAGE_VERSION, NGIRCd_VersionAddition);
440 #endif
441 } /* NGIRCd_FillVersion */
442
443
444 GLOBAL VOID
445 NGIRCd_Rehash( VOID )
446 {
447         CHAR old_name[CLIENT_ID_LEN];
448
449         Log( LOG_NOTICE|LOG_snotice, "Re-reading configuration NOW!" );
450         NGIRCd_SignalRehash = FALSE;
451
452         /* Close down all listening sockets */
453         Conn_ExitListeners( );
454
455         /* Remember old server name */
456         strcpy( old_name, Conf_ServerName );
457
458         /* Re-read configuration ... */
459         Conf_Rehash( );
460
461         /* Recover old server name: it can't be changed during run-time */
462         if( strcmp( old_name, Conf_ServerName ) != 0 )
463         {
464                 strcpy( Conf_ServerName, old_name );
465                 Log( LOG_ERR, "Can't change \"ServerName\" on runtime! Ignored new name." );
466         }
467
468         /* Create new pre-defined channels */
469         Channel_InitPredefined( );
470         
471         /* Start listening on sockets */
472         Conn_InitListeners( );
473
474         /* Sync configuration with established connections */
475         Conn_SyncServerStruct( );
476
477         Log( LOG_NOTICE|LOG_snotice, "Re-reading of configuration done." );
478 } /* NGIRCd_Rehash */
479
480
481 LOCAL VOID
482 Initialize_Signal_Handler( VOID )
483 {
484         /* Signal-Handler initialisieren: einige Signale
485          * werden ignoriert, andere speziell behandelt. */
486
487 #ifdef HAVE_SIGACTION
488         /* sigaction() ist vorhanden */
489
490         struct sigaction saction;
491
492         /* Signal-Struktur initialisieren */
493         memset( &saction, 0, sizeof( saction ));
494         saction.sa_handler = Signal_Handler;
495 #ifdef SA_RESTART
496         saction.sa_flags |= SA_RESTART;
497 #endif
498 #ifdef SA_NOCLDWAIT
499         saction.sa_flags |= SA_NOCLDWAIT;
500 #endif
501
502         /* Signal-Handler einhaengen */
503         sigaction( SIGINT, &saction, NULL );
504         sigaction( SIGQUIT, &saction, NULL );
505         sigaction( SIGTERM, &saction, NULL);
506         sigaction( SIGHUP, &saction, NULL);
507         sigaction( SIGCHLD, &saction, NULL);
508
509         /* einige Signale ignorieren */
510         saction.sa_handler = SIG_IGN;
511         sigaction( SIGPIPE, &saction, NULL );
512 #else
513         /* kein sigaction() vorhanden */
514
515         /* Signal-Handler einhaengen */
516         signal( SIGINT, Signal_Handler );
517         signal( SIGQUIT, Signal_Handler );
518         signal( SIGTERM, Signal_Handler );
519         signal( SIGHUP, Signal_Handler );
520         signal( SIGCHLD, Signal_Handler );
521
522         /* einige Signale ignorieren */
523         signal( SIGPIPE, SIG_IGN );
524 #endif
525 } /* Initialize_Signal_Handler */
526
527
528 LOCAL VOID
529 Signal_Handler( INT Signal )
530 {
531         /* Signal-Handler. Dieser wird aufgerufen, wenn eines der Signale eintrifft,
532          * fuer das wir uns registriert haben (vgl. Initialize_Signal_Handler). Die
533          * Nummer des eingetroffenen Signals wird der Funktion uebergeben. */
534
535         switch( Signal )
536         {
537                 case SIGTERM:
538                 case SIGINT:
539                 case SIGQUIT:
540                         /* wir soll(t)en uns wohl beenden ... */
541                         NGIRCd_SignalQuit = TRUE;
542                         break;
543                 case SIGHUP:
544                         /* Konfiguration neu einlesen: */
545                         NGIRCd_SignalRehash = TRUE;
546                         break;
547                 case SIGCHLD:
548                         /* Child-Prozess wurde beendet. Zombies vermeiden: */
549                         while( waitpid( -1, NULL, WNOHANG ) > 0);
550                         break;
551 #ifdef DEBUG
552                 default:
553                         /* unbekanntes bzw. unbehandeltes Signal */
554                         Log( LOG_DEBUG, "Got signal %d! Ignored.", Signal );
555 #endif
556         }
557 } /* Signal_Handler */
558
559
560 LOCAL VOID
561 Show_Version( VOID )
562 {
563         puts( NGIRCd_Version );
564         puts( "Copyright (c)2001-2005 by Alexander Barton (<alex@barton.de>)." );
565         puts( "Homepage: <http://arthur.ath.cx/~alex/ngircd/>\n" );
566         puts( "This is free software; see the source for copying conditions. There is NO" );
567         puts( "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." );
568 } /* Show_Version */
569
570
571 LOCAL VOID
572 Show_Help( VOID )
573 {
574 #ifdef DEBUG
575         puts( "  -d, --debug        log extra debug messages" );
576 #endif
577         puts( "  -f, --config <f>   use file <f> as configuration file" );
578         puts( "  -n, --nodaemon     don't fork and don't detach from controlling terminal" );
579         puts( "  -p, --passive      disable automatic connections to other servers" );
580 #ifdef SNIFFER
581         puts( "  -s, --sniffer      enable network sniffer and display all IRC traffic" );
582 #endif
583         puts( "  -t, --configtest   read, validate and display configuration; then exit" );
584         puts( "      --version      output version information and exit" );
585         puts( "      --help         display this help and exit" );
586 } /* Show_Help */
587
588
589 LOCAL VOID
590 Pidfile_Delete( VOID )
591 {
592         /* Pidfile configured? */
593         if( ! Conf_PidFile[0] ) return;
594
595 #ifdef DEBUG
596         Log( LOG_DEBUG, "Removing PID file (%s) ...", Conf_PidFile );
597 #endif
598
599         if( unlink( Conf_PidFile ))
600                 Log( LOG_ERR, "Error unlinking PID file (%s): %s", Conf_PidFile, strerror( errno ));
601 } /* Pidfile_Delete */
602
603
604 LOCAL VOID
605 Pidfile_Create( LONG pid )
606 {
607         FILE *pidf;
608
609         /* Pidfile configured? */
610         if( ! Conf_PidFile[0] ) return;
611
612 #ifdef DEBUG
613         Log( LOG_DEBUG, "Creating PID file (%s) ...", Conf_PidFile );
614 #endif
615
616         pidf = fopen( Conf_PidFile, "w" );
617
618         if( ! pidf )
619         {
620                 Log( LOG_ERR, "Error writing PID file (%s): %s", Conf_PidFile, strerror( errno ));
621                 return;
622         }
623
624         if( fprintf( pidf, "%ld\n", pid ) < 0 )
625                 Log( LOG_ERR, "Can't write PID file (%s): %s", Conf_PidFile, strerror( errno ));
626
627         if( fclose(pidf) != 0 )
628                 Log( LOG_ERR, "Error closing PID file (%s): %s", Conf_PidFile, strerror( errno ));
629 } /* Pidfile_Create */
630
631
632 /* -eof- */