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.
8 Apply it to Bacula 2.4.3 (possibly earlier versions)
12 patch -p0 <2.4.3-jobs.patch
13 ./configure <your-options>
20 ===================================================================
21 --- src/dird/job.c (revision 8011)
22 +++ src/dird/job.c (working copy)
24 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
25 static time_t last_start_time = 0;
28 + time_t now = time(NULL);
30 char dt[MAX_TIME_LENGTH];
31 char name[MAX_NAME_LENGTH];
35 /* Guarantee unique start time -- maximum one per second, and
36 * thus unique Job Name
38 P(mutex); /* lock creation of jobs */
41 if (seq > 59) { /* wrap as if it is seconds */
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++) {
60 + Dmsg2(100, "JobId=%u created Job=%s\n", jcr->JobId, jcr->Job);
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)
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);
76 - jcr->file_bsock = fd;
77 - jcr->file_bsock->set_jcr(jcr);
79 Dmsg1(110, "Found Job %s\n", job_name);
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);
91 + jcr->file_bsock = fd;
92 + jcr->file_bsock->set_jcr(jcr);
95 * Authenticate the File daemon
97 Index: src/lib/bnet_server.c
98 ===================================================================
99 --- src/lib/bnet_server.c (revision 8011)
100 +++ src/lib/bnet_server.c (working copy)
103 Bacula® - The Network Backup Solution
105 - Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
106 + Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
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.
111 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
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.
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);
127 /* Start work queue thread */