~ubuntu-branches/ubuntu/dapper/fetchmail/dapper-security

« back to all changes in this revision

Viewing changes to fetchmail.c

  • Committer: Bazaar Package Importer
  • Author(s): Nathaniel McCallum
  • Date: 2004-09-03 14:53:58 UTC
  • Revision ID: james.westby@ubuntu.com-20040903145358-dluq0c58tfe3cpcm
Tags: 6.2.5-8ubuntu2
Added versioned depend on lsb-base

Show diffs side-by-side

added added

removed removed

Lines of Context:
247
247
        system("uname -a");
248
248
    }
249
249
 
250
 
    /* avoid parsing the config file if all we're doing is killing a daemon */ 
251
 
    if (!(quitmode && argc == 2))
 
250
    /* construct the lockfile */
 
251
    lock_setup();
 
252
 
 
253
    /* check for another fetchmail running concurrently */
 
254
    pid = lock_state();
 
255
    bkgd = (pid < 0);
 
256
    pid = bkgd ? -pid : pid;
 
257
 
 
258
    /*
 
259
     * Avoid parsing the config file if all we're doing is killing a daemon,
 
260
     * unless this appears to be a self-restarted instance because we detected an 
 
261
     * "under-our-noses" configuration file change, in which case we definitely want
 
262
     * to reload the config file.
 
263
     */
 
264
    if ((!quitmode && !pid) || pid == getpid())
252
265
        implicitmode = load_params(argc, argv, optind);
 
266
    else if (pid)
 
267
      implicitmode = 1;
253
268
 
254
269
#if defined(HAVE_SYSLOG)
255
270
    /* logging should be set up early in case we were restarted from exec */
267
282
#endif
268
283
        report_init((run.poll_interval == 0 || nodetach) && !run.logfile);
269
284
 
270
 
    /* construct the lockfile */
271
 
    lock_setup();
272
 
 
273
285
#ifdef HAVE_SETRLIMIT
274
286
    /*
275
287
     * Before getting passwords, disable core dumps unless -v -d0 mode is on.
348
360
        exit(0);
349
361
    }
350
362
 
351
 
    /* check for another fetchmail running concurrently */
352
 
    pid = lock_state();
353
 
    bkgd = (pid < 0);
354
 
    pid = bkgd ? -pid : pid;
355
 
 
356
363
    /* if no mail servers listed and nothing in background, we're done */
357
 
    if (!(quitmode && argc == 2) && pid == 0 && querylist == NULL) {
 
364
    if (!quitmode && pid == 0 && querylist == NULL) {
358
365
        (void)fputs(GT_("fetchmail: no mailservers have been specified.\n"),stderr);
359
366
        exit(PS_SYNTAX);
360
367
    }
365
372
        if (pid == 0) 
366
373
        {
367
374
            fprintf(stderr,GT_("fetchmail: no other fetchmail is running\n"));
368
 
            if (argc == 2)
369
 
                exit(PS_EXCLUDE);
 
375
            exit(PS_EXCLUDE);
370
376
        }
371
377
        else if (getpid() == pid)
372
378
        {
388
394
            fprintf(stderr,GT_("fetchmail: %s fetchmail at %d killed.\n"),
389
395
                    bkgd ? GT_("background") : GT_("foreground"), pid);
390
396
            lock_release();
391
 
            if (argc == 2)
392
 
                exit(0);
393
 
            else
394
 
                pid = 0; 
 
397
            exit(0);
395
398
        }
396
399
    }
397
400
 
421
424
        else if (getpid() == pid)
422
425
            /* this test enables re-execing on a changed rcfile */
423
426
            lock_assert();
424
 
        else if (argc > 1)
425
 
        {
426
 
            fprintf(stderr,
427
 
                    GT_("fetchmail: can't accept options while a background fetchmail is running.\n"));
428
 
            return(PS_EXCLUDE);
429
 
        }
430
427
        else if (kill(pid, SIGUSR1) == 0)
431
428
        {
432
429
            fprintf(stderr,