From: Kern Sibbald Date: Thu, 22 Aug 2002 11:13:40 +0000 (+0000) Subject: Small cleanups X-Git-Tag: Release-1.25~29 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=620c42f0e526c8ac207a1233358bb1e3c65ffd47;p=bacula%2Fbacula Small cleanups git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@114 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/bacula-dir.conf.in b/bacula/src/dird/bacula-dir.conf.in index 8b266fd914..fd42c29fd3 100644 --- a/bacula/src/dird/bacula-dir.conf.in +++ b/bacula/src/dird/bacula-dir.conf.in @@ -27,13 +27,28 @@ Director { # define myself # Define the backup Job Job { Name = "NightlySave" - Backup = Client=@hostname@-fd FileSet="Full Set" + Type = Backup + Client=@hostname@-fd + FileSet="Full Set" Schedule = "WeeklyCycle" Storage = DLTDrive Messages = Standard Pool = Default } +# Standard Restore template, to be changed by Console program +Job { + Name = "RestoreFiles + Type = Restore + Client=@hostname@-fd + FileSet="Full Set" + Storage = DLTDrive + Messages = Standard + Pool = Default + Where = /tmp +} + + # List of files to be backed up FileSet { Name = "Full Set" diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index edf2297847..d89099596d 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -343,7 +343,7 @@ Without that I don't know who I am :-(\n"), configfile); Emsg1(M_FATAL, 0, _("No Pool resource defined for job %s\n"), job->hdr.name); OK = FALSE; } - if (job->client->catalog) { + if (job->client && job->client->catalog) { CAT *catalog = job->client->catalog; B_DB *db; @@ -358,9 +358,11 @@ Without that I don't know who I am :-(\n"), configfile); } db_close_database(db); } else { - Emsg1(M_FATAL, 0, _("No Catalog resource defined for client %s\n"), + if (job->client) { + Emsg1(M_FATAL, 0, _("No Catalog resource defined for client %s\n"), job->client->hdr.name); - OK = FALSE; + OK = FALSE; + } } } diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index d68159811d..b63ce59991 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -139,7 +139,7 @@ bnet_recv(BSOCK *bsock) if (nbytes != sizeof(int32_t)) { bsock->errors++; bsock->b_errno = EIO; - Emsg3(M_ERROR, 0, "Read %d expected %d from %s\n", nbytes, sizeof(int32_t), + Emsg3(M_ERROR, 0, _("Read %d expected %d from %s\n"), nbytes, sizeof(int32_t), bsock->who); return -2; } @@ -172,7 +172,7 @@ bnet_recv(BSOCK *bsock) bsock->b_errno = errno; } bsock->errors++; - Emsg4(M_ERROR, 0, "Read error from %s:%s:%d: ERR=%s\n", + Emsg4(M_ERROR, 0, _("Read error from %s:%s:%d: ERR=%s\n"), bsock->who, bsock->host, bsock->port, bnet_strerror(bsock)); return -2; } @@ -182,7 +182,7 @@ bnet_recv(BSOCK *bsock) if (nbytes != pktsiz) { bsock->b_errno = EIO; bsock->errors++; - Emsg5(M_ERROR, 0, "Read expected %d got %d from %s:%s:%d\n", pktsiz, nbytes, + Emsg5(M_ERROR, 0, _("Read expected %d got %d from %s:%s:%d\n"), pktsiz, nbytes, bsock->who, bsock->host, bsock->port); return -2; } @@ -255,10 +255,10 @@ bnet_send(BSOCK *bsock) } if (rc < 0) { /****FIXME***** use Mmsg */ - Emsg4(M_ERROR, 0, "Write error sending to %s:%s:%d: ERR=%s\n", + Emsg4(M_ERROR, 0, _("Write error sending to %s:%s:%d: ERR=%s\n"), bsock->who, bsock->host, bsock->port, bnet_strerror(bsock)); } else { - Emsg5(M_ERROR, 0, "Wrote %d bytes to %s:%s:%d, but only %d accepted.\n", + Emsg5(M_ERROR, 0, _("Wrote %d bytes to %s:%s:%d, but only %d accepted.\n"), bsock->who, bsock->host, bsock->port, bsock->msglen, rc); } return 0; @@ -283,10 +283,10 @@ bnet_send(BSOCK *bsock) } if (rc < 0) { /************FIXME********* use Pmsg() **/ - Emsg4(M_ERROR, 0, "Write error sending to %s:%s:%d: ERR=%s\n", + Emsg4(M_ERROR, 0, _("Write error sending to %s:%s:%d: ERR=%s\n"), bsock->who, bsock->host, bsock->port, bnet_strerror(bsock)); } else { - Emsg5(M_ERROR, 0, "Wrote %d bytes to %s:%s:%d, but only %d accepted.\n", + Emsg5(M_ERROR, 0, _("Wrote %d bytes to %s:%s:%d, but only %d accepted.\n"), bsock->who, bsock->host, bsock->port, bsock->msglen, rc); } return 0; @@ -353,8 +353,8 @@ static uint32_t *bget_host_ip(char *host) return NULL; } if (hp->h_length != sizeof(inaddr.s_addr) || hp->h_addrtype != AF_INET) { - Emsg2(M_WARNING, 0, "gethostbyname() network address length error.\n\ -Wanted %d got %d bytes for s_addr.\n", sizeof(inaddr.s_addr), hp->h_length); + Emsg2(M_WARNING, 0, _("gethostbyname() network address length error.\n\ +Wanted %d got %d bytes for s_addr.\n"), sizeof(inaddr.s_addr), hp->h_length); return NULL; } i = 0; @@ -410,7 +410,7 @@ bnet_open(char *name, char *host, char *service, int port) * Receive notification when connection dies. */ if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &turnon, sizeof(turnon)) < 0) { - Emsg1(M_WARNING, 0, "Cannot set SO_KEEPALIVE on socket: %s\n" , strerror(errno)); + Emsg1(M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"), strerror(errno)); } for (i = 0; addr_list[i] != ((uint32_t) -1); i++) { @@ -519,20 +519,20 @@ int bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw) dbuf_size = size; if ((bs->msg = realloc_pool_memory(bs->msg, dbuf_size+100)) == NULL) { - Emsg0(M_FATAL, 0, "Could not malloc 32K BSOCK data buffer\n"); + Emsg0(M_FATAL, 0, _("Could not malloc 32K BSOCK data buffer\n")); return 0; } if (rw & BNET_SETBUF_READ) { while ((dbuf_size > TAPE_BSIZE) && (setsockopt(bs->fd, SOL_SOCKET, SO_RCVBUF, (char *)&dbuf_size, sizeof(dbuf_size)) < 0)) { - Emsg1(M_ERROR, 0, "sockopt error: %s\n", strerror(errno)); + Emsg1(M_ERROR, 0, _("sockopt error: %s\n"), strerror(errno)); dbuf_size -= TAPE_BSIZE; } Dmsg1(200, "set network buffer size=%d\n", dbuf_size); if (dbuf_size != MAX_NETWORK_BUFFER_SIZE) - Emsg1(M_WARNING, 0, "Warning network buffer = %d bytes not max size.\n", dbuf_size); + Emsg1(M_WARNING, 0, _("Warning network buffer = %d bytes not max size.\n"), dbuf_size); if (dbuf_size % TAPE_BSIZE != 0) { - Emsg1(M_ABORT, 0, "Network buffer size %d not multiple of tape block size.\n", + Emsg1(M_ABORT, 0, _("Network buffer size %d not multiple of tape block size.\n"), dbuf_size); } } @@ -540,14 +540,14 @@ int bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw) if (rw & BNET_SETBUF_WRITE) { while ((dbuf_size > TAPE_BSIZE) && (setsockopt(bs->fd, SOL_SOCKET, SO_SNDBUF, (char *)&dbuf_size, sizeof(dbuf_size)) < 0)) { - Emsg1(M_ERROR, 0, "sockopt error: %s\n", strerror(errno)); + Emsg1(M_ERROR, 0, _("sockopt error: %s\n"), strerror(errno)); dbuf_size -= TAPE_BSIZE; } Dmsg1(200, "set network buffer size=%d\n", dbuf_size); if (dbuf_size != MAX_NETWORK_BUFFER_SIZE) - Emsg1(M_WARNING, 0, "Warning network buffer = %d bytes not max size.\n", dbuf_size); + Emsg1(M_WARNING, 0, _("Warning network buffer = %d bytes not max size.\n"), dbuf_size); if (dbuf_size % TAPE_BSIZE != 0) { - Emsg1(M_ABORT, 0, "Network buffer size %d not multiple of tape block size.\n", + Emsg1(M_ABORT, 0, _("Network buffer size %d not multiple of tape block size.\n"), dbuf_size); } } @@ -608,9 +608,6 @@ BSOCK * init_bsock(int sockfd, char *who, char *host, int port) { BSOCK *bsock = (BSOCK *)malloc(sizeof(BSOCK)); - if (bsock == NULL) { - Emsg0(M_ABORT, 0, "Out of memory in init_bsock.\n"); - } memset(bsock, 0, sizeof(BSOCK)); bsock->fd = sockfd; bsock->errors = 0; @@ -631,9 +628,6 @@ BSOCK * dup_bsock(BSOCK *osock) { BSOCK *bsock = (BSOCK *) malloc(sizeof(BSOCK)); - if (bsock == NULL) { - Emsg0(M_ABORT, 0, "Out of memory in dup_bsock.\n"); - } memcpy(bsock, osock, sizeof(BSOCK)); bsock->msg = get_pool_memory(PM_MESSAGE); bsock->errmsg = get_pool_memory(PM_MESSAGE); diff --git a/bacula/src/lib/bnet_server.c b/bacula/src/lib/bnet_server.c index a3abc674bf..7254463713 100644 --- a/bacula/src/lib/bnet_server.c +++ b/bacula/src/lib/bnet_server.c @@ -60,7 +60,7 @@ bnet_thread_server(int port, int max_clients, workq_t *client_wq, for (tlog=0; (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0; tlog -= 10 ) { if (tlog <= 0) { tlog = 60; - Emsg1(M_ERROR, 0, "Cannot open stream socket: %s. Retrying ...\n", strerror(errno)); + Emsg1(M_ERROR, 0, _("Cannot open stream socket: %s. Retrying ...\n"), strerror(errno)); } sleep(10); } @@ -69,7 +69,7 @@ bnet_thread_server(int port, int max_clients, workq_t *client_wq, * Reuse old sockets */ if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &turnon, sizeof(turnon)) < 0) { - Emsg1(M_WARNING, 0, "Cannot set SO_REUSEADDR on socket: %s\n" , strerror(errno)); + Emsg1(M_WARNING, 0, _("Cannot set SO_REUSEADDR on socket: %s\n"), strerror(errno)); } /* @@ -84,11 +84,11 @@ bnet_thread_server(int port, int max_clients, workq_t *client_wq, for (tlog=0; bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0; tlog -= 5 ) { if (tlog <= 0) { tlog = 2*60; /* Complain every 2 minutes */ - Emsg2(M_WARNING, 0, "Cannot bind port %d: %s. Retrying ...\n", port, strerror(errno)); + Emsg2(M_WARNING, 0, _("Cannot bind port %d: %s. Retrying ...\n"), port, strerror(errno)); } sleep(5); if (--tmax <= 0) { - Emsg2(M_ABORT, 0, "Cannot bind port %d: %s.\n", port, strerror(errno)); + Emsg2(M_ABORT, 0, _("Cannot bind port %d: %s.\n"), port, strerror(errno)); } } listen(sockfd, 5); /* tell system we are ready */ @@ -98,7 +98,7 @@ bnet_thread_server(int port, int max_clients, workq_t *client_wq, /* Start work queue thread */ if ((stat = workq_init(client_wq, max_clients, handle_client_request)) != 0) { - Emsg1(M_ABORT, 0, "Could not init client queue: ERR=%s\n", strerror(stat)); + Emsg1(M_ABORT, 0, _("Could not init client queue: ERR=%s\n"), strerror(stat)); } for (;;) { @@ -112,7 +112,7 @@ bnet_thread_server(int port, int max_clients, workq_t *client_wq, continue; } close(sockfd); - Emsg1(M_FATAL, 0, "Error in select: %s\n", strerror(errno)); + Emsg1(M_FATAL, 0, _("Error in select: %s\n"), strerror(errno)); break; } clilen = sizeof(cli_addr); @@ -124,7 +124,7 @@ bnet_thread_server(int port, int max_clients, workq_t *client_wq, fromhost(&request); if (!hosts_access(&request)) { V(mutex); - Emsg2(M_WARNING, 0, "Connection from %s:%d refused by hosts.access", + Emsg2(M_WARNING, 0, _("Connection from %s:%d refused by hosts.access"), inet_ntoa(cli_addr.sin_addr), ntohs(cli_addr.sin_port)); close(newsockfd); continue; @@ -136,7 +136,7 @@ bnet_thread_server(int port, int max_clients, workq_t *client_wq, * Receive notification when connection dies. */ if (setsockopt(newsockfd, SOL_SOCKET, SO_KEEPALIVE, &turnon, sizeof(turnon)) < 0) { - Emsg1(M_WARNING, 0, "Cannot set SO_KEEPALIVE on socket: %s\n" , strerror(errno)); + Emsg1(M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n") , strerror(errno)); } /* see who client is. i.e. who connected to us. */ @@ -148,7 +148,7 @@ bnet_thread_server(int port, int max_clients, workq_t *client_wq, /* Queue client to be served */ if ((stat = workq_add(client_wq, (void *)init_bsock(newsockfd, "client", caller, port))) != 0) { - Emsg1(M_ABORT, 0, "Could not add job to client queue: ERR=%s\n", strerror(stat)); + Emsg1(M_ABORT, 0, _("Could not add job to client queue: ERR=%s\n"), strerror(stat)); } } } @@ -173,7 +173,7 @@ bnet_bind(int port) for (tlog=0; (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0; tlog -= 10 ) { if (tlog <= 0) { tlog = 2*60; - Emsg1(M_ERROR, 0, "Cannot open stream socket: %s\n", strerror(errno)); + Emsg1(M_ERROR, 0, _("Cannot open stream socket: %s\n"), strerror(errno)); } sleep(60); } @@ -182,7 +182,7 @@ bnet_bind(int port) * Reuse old sockets */ if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &turnon, sizeof(turnon)) < 0) { - Emsg1(M_WARNING, 0, "Cannot set SO_REUSEADDR on socket: %s\n" , strerror(errno)); + Emsg1(M_WARNING, 0, _("Cannot set SO_REUSEADDR on socket: %s\n") , strerror(errno)); } /* @@ -196,12 +196,12 @@ bnet_bind(int port) for (tlog=0; bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0; tlog -= 5 ) { if (tlog <= 0) { tlog = 2*60; - Emsg2(M_WARNING, 0, "Cannot bind port %d: %s: retrying ...\n", port, strerror(errno)); + Emsg2(M_WARNING, 0, _("Cannot bind port %d: %s: retrying ...\n"), port, strerror(errno)); } sleep(5); } listen(sockfd, 1); /* tell system we are ready */ - return init_bsock(sockfd, "Server socket", "client", port); + return init_bsock(sockfd, _("Server socket"), _("client"), port); } /* @@ -237,7 +237,7 @@ bnet_accept(BSOCK *bsock, char *who) errno = 0; continue; } - Emsg1(M_FATAL, 0, "Error in select: %s\n", strerror(errno)); + Emsg1(M_FATAL, 0, _("Error in select: %s\n"), strerror(errno)); newsockfd = -1; break; } @@ -252,7 +252,7 @@ bnet_accept(BSOCK *bsock, char *who) fromhost(&request); if (!hosts_access(&request)) { V(mutex); - Emsg2(M_WARNING, 0, "Connection from %s:%d refused by hosts.access", + Emsg2(M_WARNING, 0, _("Connection from %s:%d refused by hosts.access"), inet_ntoa(cli_addr.sin_addr), ntohs(cli_addr.sin_port)); close(newsockfd); return NULL; @@ -264,7 +264,7 @@ bnet_accept(BSOCK *bsock, char *who) * Receive notification when connection dies. */ if (setsockopt(newsockfd, SOL_SOCKET, SO_KEEPALIVE, &turnon, sizeof(turnon)) < 0) { - Emsg1(M_WARNING, 0, "Cannot set SO_KEEPALIVE on socket: %s\n" , strerror(errno)); + Emsg1(M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"), strerror(errno)); } /* see who client is. I.e. who connected to us. @@ -278,7 +278,7 @@ bnet_accept(BSOCK *bsock, char *who) bsock->msglen = strlen(bsock->msg); if (newsockfd < 0) { - Emsg2(M_FATAL, 0, "Socket accept error for %s. ERR=%s\n", who, + Emsg2(M_FATAL, 0, _("Socket accept error for %s. ERR=%s\n"), who, strerror(errno)); return NULL; } else { @@ -297,192 +297,3 @@ bnet_accept(BSOCK *bsock, char *who) } #endif - - - -/* - * The following code will soon be deleted, don't attempt - * to use it. - */ -#ifdef dont_have_threads - -/* - * This routine is called by the main process to - * track its children. On CYGWIN, the child processes - * don't always exit when the other end of the socket - * hangs up. Thus they remain hung on a read(). After - * 30 seconds, we send them a SIGTERM signal, which - * causes them to wake up to the reality of the situation. - * - * Also, on certain Unix systems such as SunOS, we must - * explicitly do the wait, otherwise, the child that dies - * remains a zombie potentially remaining bound to the - * port. - */ - -#ifdef HAVE_SUN_OS - -static void reap_children(int childpid) -{ - static int pids[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - static int times[10]; - int i; - time_t now; - - time(&now); - for (i=0; i<10; i++) { - if (pids[i] && (waitpid(pids[i], NULL, WNOHANG) == pids[i])) { - pids[i] = 0; - } else { - if (pids[i] && ((now - times[i]) > 30)) - kill(pids[i], SIGTERM); - } - } - for (i=0; i<10; i++) { - if (pids[i] && (waitpid(pids[i], NULL, WNOHANG) == pids[i])) { - pids[i] = 0; - } - if (childpid && (pids[i] == 0)) { - pids[i] = childpid; - times[i] = now; - childpid = 0; - } - } -} - -#endif /* HAVE_SUN_OS */ - -/* Become network server */ -void -bnet_server(int port, void handle_client_request(BSOCK *bsock)) -{ - int newsockfd, sockfd, clilen, childpid, stat; - struct sockaddr_in cli_addr; /* client's address */ - struct sockaddr_in serv_addr; /* our address */ - int tlog; - fd_set ready, sockset; - int turnon = 1; - char *caller; -#ifdef HAVE_LIBWRAP - struct request_info request; -#endif - - /* **** FIXME **** handle BSD too */ - signal(SIGCHLD, SIG_IGN); - - /* - * Open a TCP socket - */ - for (tlog=0; (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0; tlog -= 10 ) { - if (tlog <= 0) { - tlog = 60; - Emsg1(M_ERROR, 0, "Cannot open stream socket: %s. Retrying ...\n", strerror(errno)); - } - sleep(10); - } - - /* - * Reuse old sockets - */ - if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &turnon, sizeof(turnon)) < 0) { - Emsg1(M_WARNING, 0, "Cannot set SO_REUSEADDR on socket: %s\n" , strerror(errno)); - } - - /* - * Receive notification when connection dies. - */ - if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &turnon, sizeof(turnon)) < 0) { - Emsg1(M_WARNING, 0, "Cannot set SO_KEEPALIVE on socket: %s\n" , strerror(errno)); - } - - /* - * Bind our local address so that the client can send to us. - */ - bzero((char *) &serv_addr, sizeof(serv_addr)); - serv_addr.sin_family = AF_INET; - serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); - serv_addr.sin_port = htons(port); - - for (tlog=0; bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0; tlog -= 5 ) { - if (tlog <= 0) { - tlog = 2*60; /* Complain every 2 minutes */ - Emsg2(M_WARNING, 0, "Cannot bind port %d: %s. Retrying ...\n", port, strerror(errno)); - } - sleep(5); - } - listen(sockfd, 5); /* tell system we are ready */ - - FD_ZERO(&sockset); - FD_SET(sockfd, &sockset); - - for (;;) { - /* - * Wait for a connection from a client process. - */ - ready = sockset; - if ((stat = select(sockfd+1, &ready, NULL, NULL, NULL)) < 0) { - if (errno == EINTR || errno == EAGAIN) { - errno = 0; - continue; - } - close(sockfd); - Emsg1(M_FATAL, 0, "Error in select: %s\n", strerror(errno)); - break; - } - clilen = sizeof(cli_addr); - newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen); - -#ifdef HAVE_LIBWRAP - request_init(&request, RQ_DAEMON, my_name, RQ_FILE, newsockfd, 0); - fromhost(&request); - if (!hosts_access(&request)) { - Emsg2(M_WARNING, 0, "Connection from %s:%d refused by hosts.access", - inet_ntoa(cli_addr.sin_addr), ntohs(cli_addr.sin_port)); - close(newsockfd); - continue; - } -#endif - - /* - * Receive notification when connection dies. - */ - if (setsockopt(newsockfd, SOL_SOCKET, SO_KEEPALIVE, &turnon, sizeof(turnon)) < 0) { - Emsg1(M_WARNING, 0, "Cannot set SO_KEEPALIVE on socket: %s\n" , strerror(errno)); - } - - - /* see who client is. i.e. who connected to us. */ - caller = inet_ntoa(cli_addr.sin_addr); - if (caller == NULL) { - caller = "client"; - } - -#ifdef HAVE_CYGWIN - childpid = 0; - handle_client_request(init_bsock(newsockfd, "client", caller, port)); -#else - /* fork to provide the response */ - for (tlog=0; (childpid = fork()) < 0; tlog -= 5*60 ) { - if (tlog <= 0) { - tlog = 60*60; - Emsg1(M_FATAL, 0, "Fork error: %s\n", strerror(errno)); - } - sleep(5*60); - } - if (childpid == 0) { /* child process */ - close(sockfd); /* close original socket */ - handle_client_request(init_bsock(newsockfd, "client", caller, port)); /* process the request */ - Dmsg0(99, "back from handle request\n"); - close(newsockfd); - exit(0); - } -#endif - - close(newsockfd); /* parent process */ -#ifdef HAVE_SUN_OS - reap_children(childpid); -#endif /* HAVE_SUN_OS */ - } -} - -#endif /* no threads -- not supported any more sorry! */