summaryrefslogtreecommitdiff
blob: 6be612358fa076c6889bc14b4a86a6f97891bb0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
*** exim-4.10/src/daemon.c  Mon Jul 22 09:59:48 2002
- --- daemon.c   Wed Dec  4 10:52:04 2002
***************
*** 960,991 ****
    (b) When -bd is used and -oX is not used, or
    (c) When -oP is used to supply a path.

! The variable daemon_write_pid is used to control this.

- - Note re use of sprintf: spool_directory and pid_file_path are checked on
- - input to be < 200 characters. */
- -
  if (running_in_test_harness || daemon_write_pid)
    {
    FILE *f;
- -   uschar buff[256];
- -
    if (pid_file_path[0] == 0)
!     sprintf(CS buff, "%s/exim-daemon.pid", spool_directory);
!   else
!     sprintf(CS buff, CS pid_file_path, "");   /* Backward compatibility */

!   f = Ufopen(buff, "wb");
    if (f != NULL)
      {
      fprintf(f, "%d\n", (int)getpid());
      fchmod(fileno(f), 0644);
      fclose(f);
!     DEBUG(D_any) debug_printf("pid written to %s\n", buff);
      }
    else
      DEBUG(D_any)
!       debug_printf("%s\n", string_open_failed(errno, "pid file %s", buff));
    }

  /* Set up the handler for SIGHUP, which causes a restart of the daemon. */
- --- 960,987 ----
    (b) When -bd is used and -oX is not used, or
    (c) When -oP is used to supply a path.

! The variable daemon_write_pid is used to control this. */

  if (running_in_test_harness || daemon_write_pid)
    {
    FILE *f;
    if (pid_file_path[0] == 0)
!     pid_file_path = string_sprintf("%s/exim-daemon.pid", spool_directory);

!   f = Ufopen(pid_file_path, "wb");
    if (f != NULL)
      {
      fprintf(f, "%d\n", (int)getpid());
      fchmod(fileno(f), 0644);
      fclose(f);
!     DEBUG(D_any) debug_printf("pid written to %s\n", pid_file_path);
      }
    else
+     {
      DEBUG(D_any)
!       debug_printf("%s\n", string_open_failed(errno, "pid file %s",
!         pid_file_path));
!     }
    }

  /* Set up the handler for SIGHUP, which causes a restart of the daemon. */