]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/2.4.3-jobs.patch
Commit 2.4.3-jobs.patch
[bacula/bacula] / bacula / patches / 2.4.3-jobs.patch
1
2  This patch corrects two problems:
3  1. If you start more than 60 jobs within a 1 minute period, the unique
4     jobname (critical for the daemons) can be duplicated leading to 
5     authentication failures and orphaned jobs.
6  2. FD jobs that fail SD authentication were not properly cleaned up.
7
8  Apply it to Bacula 2.4.3 (possibly earlier versions)
9  with:
10
11  cd <bacula-source>
12  patch -p0 <2.4.3-jobs.patch
13  ./configure <your-options>
14  make
15  ...
16  make install
17
18
19 Index: src/dird/job.c
20 ===================================================================
21 --- src/dird/job.c      (revision 8011)
22 +++ src/dird/job.c      (working copy)
23 @@ -758,17 +758,17 @@
24     static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
25     static time_t last_start_time = 0;
26     static int seq = 0;
27 -   time_t now;
28 +   time_t now = time(NULL);
29     struct tm tm;
30     char dt[MAX_TIME_LENGTH];
31     char name[MAX_NAME_LENGTH];
32     char *p;
33 +   int len;
34  
35     /* Guarantee unique start time -- maximum one per second, and
36      * thus unique Job Name
37      */
38     P(mutex);                          /* lock creation of jobs */
39 -   now = time(NULL);
40     seq++;
41     if (seq > 59) {                    /* wrap as if it is seconds */
42        seq = 0;
43 @@ -783,9 +783,10 @@
44     /* Form Unique JobName */
45     (void)localtime_r(&now, &tm);
46     /* Use only characters that are permitted in Windows filenames */
47 -   strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M", &tm);
48 +   strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M.%S", &tm);
49 +   len = strlen(dt) + 5;   /* dt + .%02d EOS */
50     bstrncpy(name, base_name, sizeof(name));
51 -   name[sizeof(name)-22] = 0;          /* truncate if too long */
52 +   name[sizeof(name)-len] = 0;          /* truncate if too long */
53     bsnprintf(jcr->Job, sizeof(jcr->Job), "%s.%s.%02d", name, dt, seq); /* add date & time */
54     /* Convert spaces into underscores */
55     for (p=jcr->Job; *p; p++) {
56 @@ -793,6 +794,7 @@
57           *p = '_';
58        }
59     }
60 +   Dmsg2(100, "JobId=%u created Job=%s\n", jcr->JobId, jcr->Job);
61  }
62  
63  /* Called directly from job rescheduling */
64 Index: src/stored/job.c
65 ===================================================================
66 --- src/stored/job.c    (revision 8011)
67 +++ src/stored/job.c    (working copy)
68 @@ -228,21 +228,25 @@
69     if (!(jcr=get_jcr_by_full_name(job_name))) {
70        Jmsg1(NULL, M_FATAL, 0, _("FD connect failed: Job name not found: %s\n"), job_name);
71        Dmsg1(3, "**** Job \"%s\" not found\n", job_name);
72 +      fd->close();
73        return;
74     }
75  
76 -   jcr->file_bsock = fd;
77 -   jcr->file_bsock->set_jcr(jcr);
78 -
79     Dmsg1(110, "Found Job %s\n", job_name);
80  
81     if (jcr->authenticated) {
82        Jmsg2(jcr, M_FATAL, 0, _("Hey!!!! JobId %u Job %s already authenticated.\n"),
83           (uint32_t)jcr->JobId, jcr->Job);
84 +      Dmsg2(50, "Hey!!!! JobId %u Job %s already authenticated.\n",
85 +         (uint32_t)jcr->JobId, jcr->Job);
86 +      fd->close();
87        free_jcr(jcr);
88        return;
89     }
90  
91 +   jcr->file_bsock = fd;
92 +   jcr->file_bsock->set_jcr(jcr);
93 +
94     /*
95      * Authenticate the File daemon
96      */
97 Index: src/lib/bnet_server.c
98 ===================================================================
99 --- src/lib/bnet_server.c       (revision 8011)
100 +++ src/lib/bnet_server.c       (working copy)
101 @@ -1,7 +1,7 @@
102  /*
103     Bacula® - The Network Backup Solution
104  
105 -   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
106 +   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
107  
108     The main author of Bacula is Kern Sibbald, with contributions from
109     many others, a complete list can be found in the file AUTHORS.
110 @@ -20,7 +20,7 @@
111     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
112     02110-1301, USA.
113  
114 -   Bacula® is a registered trademark of John Walker.
115 +   Bacula® is a registered trademark of Kern Sibbald.
116     The licensor of Bacula is the Free Software Foundation Europe
117     (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
118     Switzerland, email:ftf@fsfeurope.org.
119 @@ -137,7 +137,7 @@
120                    be.bstrerror());
121           }
122        }
123 -      listen(fd_ptr->fd, 5);       /* tell system we are ready */
124 +      listen(fd_ptr->fd, 20);      /* tell system we are ready */
125        sockfds.append(fd_ptr);
126     }
127     /* Start work queue thread */