From: Kern Sibbald Date: Fri, 16 Jan 2004 11:46:31 +0000 (+0000) Subject: Add IP address to BSOCK + authentication sets console + tweak run argument handling... X-Git-Tag: Release-1.34.0~160 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=80fae1f964b16c1c7e02c5f7ca823a04c1c3f5c4;p=bacula%2Fbacula Add IP address to BSOCK + authentication sets console + tweak run argument handling + add device/Volume to SD error messages git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1013 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index 1932a6f3df..d8790bd738 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -166,6 +166,39 @@ For 1.33 In SD allow Device to have Multiple MediaTypes After 1.33: +Ideas from Jerry Scharf: + First let's point out some big pluses that bacula has for this + it's open source + more importantly it's active. Thank you so much for that + even more important, it's not flaky + it has an open access catalog, opening many possibilities + it's pushing toward heterogeneous systems capability + simple things: + I don't remember an include file directive for config files + (not filesets, actual config directives) + can you check the configs without starting the daemon? + some warnings about possible common mistakes + big things: + doing the testing and blessing of concurrent backup writes + this is absolutely necessary in the enterprise + easy user recovery GUI with full access checking + Macintosh file client + macs are an interesting niche, but I fear a server is a rathole + working bare iron recovery for windows + much better handling on running config changes + thinking through the logic of what happens to jobs in progress + the option for inc/diff backups not reset on fileset revision + a) use both change and inode update time against base time + b) do the full catalog check (expensive but accurate) + sizing guide (how much system is needed to back up N systems/files) + consultants on using bacula in building a disaster recovery system + an integration guide + or how to get at fancy things that one could do with bacula + logwatch code for bacula logs (or similar) + linux distro inclusion of bacula (brings good and bad, but necessary) + win2k/XP server capability (icky but you asked) + support for Oracle database ?? +=== - Look at adding SQL server and Exchange support for Windows. - Restore: Enter Filename: 'C:/Documents and Settings/Comercial/My Documents/MOP/formulário de registro BELAS ARTES.doc' causes Bacula to diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index b59e601eba..8ea78bbbad 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -359,7 +359,9 @@ Without that I don't how to speak to the Director :-(\n"), configfile); if (ndir > 1) { - UA_sock = init_bsock(NULL, 0, "", "", 0); + struct sockaddr_in client_addr; + memset(&client_addr, 0, sizeof(client_addr)); + UA_sock = init_bsock(NULL, 0, "", "", 0, &client_addr); try_again: sendit(_("Available Directors:\n")); LockRes(); diff --git a/bacula/src/dird/authenticate.c b/bacula/src/dird/authenticate.c index 9dacdb6d87..a4ed421cd0 100644 --- a/bacula/src/dird/authenticate.c +++ b/bacula/src/dird/authenticate.c @@ -126,11 +126,12 @@ int authenticate_file_daemon(JCR *jcr) /********************************************************************* * */ -int authenticate_user_agent(BSOCK *ua) +int authenticate_user_agent(UAContext *uac) { char name[MAX_NAME_LENGTH]; int ssl_need = BNET_SSL_NONE; bool ok; + BSOCK *ua = uac->UA_sock; if (ua->msglen < 16 || ua->msglen >= MAX_NAME_LENGTH + 15) { Emsg2(M_ERROR, 0, _("UA Hello from %s is invalid. Len=%d\n"), ua->who, @@ -144,6 +145,7 @@ int authenticate_user_agent(BSOCK *ua) ua->msg); return 0; } +// Dmsg2(000, "Console=%s addr=%s\n", name, inet_ntoa(ua->client_addr.sin_addr)); name[MAXSTRING-1] = 0; /* terminate name */ if (strcmp(name, "*UserAgent*") == 0) { /* default console */ ok = cram_md5_auth(ua, director->password, ssl_need) && @@ -154,6 +156,9 @@ int authenticate_user_agent(BSOCK *ua) if (cons) { ok = cram_md5_auth(ua, cons->password, ssl_need) && cram_md5_get_auth(ua, cons->password, ssl_need); + if (ok) { + uac->cons = cons; /* save console resource pointer */ + } } else { ok = false; } diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index a3b9e596dc..2eed7fdbaf 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -26,7 +26,7 @@ /* authenticate.c */ extern int authenticate_storage_daemon(JCR *jcr); extern int authenticate_file_daemon(JCR *jcr); -extern int authenticate_user_agent(BSOCK *ua); +extern int authenticate_user_agent(UAContext *ua); /* autoprune.c */ extern int do_autoprune(JCR *jcr); @@ -62,7 +62,7 @@ int variable_expansion(JCR *jcr, char *inp, POOLMEM **exp); /* fd_cmds.c */ extern int connect_to_file_daemon(JCR *jcr, int retry_interval, - int max_retry_time, int verbose); + int max_retry_time, int verbose); extern int send_include_list(JCR *jcr); extern int send_exclude_list(JCR *jcr); extern int send_bootstrap_file(JCR *jcr); @@ -70,7 +70,7 @@ extern int send_level_command(JCR *jcr); extern int get_attributes_and_put_in_catalog(JCR *jcr); extern int get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId); extern int put_file_into_catalog(JCR *jcr, long file_index, char *fname, - char *link, char *attr, int stream); + char *link, char *attr, int stream); extern void get_level_since_time(JCR *jcr, char *since, int since_len); extern int send_run_before_and_after_commands(JCR *jcr); @@ -94,7 +94,7 @@ extern void mount_request(JCR *jcr, BSOCK *bs, char *buf); /* msgchan.c */ extern int connect_to_storage_daemon(JCR *jcr, int retry_interval, - int max_retry_time, int verbose); + int max_retry_time, int verbose); extern int start_storage_daemon_job(JCR *jcr); extern int start_storage_daemon_message_thread(JCR *jcr); extern int bget_dirmsg(BSOCK *bs); @@ -142,28 +142,28 @@ JCR *create_control_jcr(char *base_name, int job_type); void free_ua_context(UAContext *ua); /* ua_select.c */ -STORE *select_storage_resource(UAContext *ua); -JOB *select_job_resource(UAContext *ua); -JOB *select_restore_job_resource(UAContext *ua); -CLIENT *select_client_resource(UAContext *ua); +STORE *select_storage_resource(UAContext *ua); +JOB *select_job_resource(UAContext *ua); +JOB *select_restore_job_resource(UAContext *ua); +CLIENT *select_client_resource(UAContext *ua); FILESET *select_fileset_resource(UAContext *ua); -int select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr); -int select_media_dbr(UAContext *ua, MEDIA_DBR *mr); -int select_pool_dbr(UAContext *ua, POOL_DBR *pr); -int select_client_dbr(UAContext *ua, CLIENT_DBR *cr); - -void start_prompt(UAContext *ua, char *msg); -void add_prompt(UAContext *ua, char *prompt); -int do_prompt(UAContext *ua, char *automsg, char *msg, char *prompt, int max_prompt); -CAT *get_catalog_resource(UAContext *ua); +int select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr); +int select_media_dbr(UAContext *ua, MEDIA_DBR *mr); +int select_pool_dbr(UAContext *ua, POOL_DBR *pr); +int select_client_dbr(UAContext *ua, CLIENT_DBR *cr); + +void start_prompt(UAContext *ua, char *msg); +void add_prompt(UAContext *ua, char *prompt); +int do_prompt(UAContext *ua, char *automsg, char *msg, char *prompt, int max_prompt); +CAT *get_catalog_resource(UAContext *ua); STORE *get_storage_resource(UAContext *ua, int use_default); -int get_media_type(UAContext *ua, char *MediaType, int max_media); -int get_pool_dbr(UAContext *ua, POOL_DBR *pr); -int get_client_dbr(UAContext *ua, CLIENT_DBR *cr); +int get_media_type(UAContext *ua, char *MediaType, int max_media); +int get_pool_dbr(UAContext *ua, POOL_DBR *pr); +int get_client_dbr(UAContext *ua, CLIENT_DBR *cr); POOL *get_pool_resource(UAContext *ua); POOL *select_pool_resource(UAContext *ua); CLIENT *get_client_resource(UAContext *ua); -int get_job_dbr(UAContext *ua, JOB_DBR *jr); +int get_job_dbr(UAContext *ua, JOB_DBR *jr); int find_arg_keyword(UAContext *ua, char **list); int find_arg(UAContext *ua, char *keyword); diff --git a/bacula/src/dird/ua.h b/bacula/src/dird/ua.h index 923a8c288c..3a3b49dedf 100644 --- a/bacula/src/dird/ua.h +++ b/bacula/src/dird/ua.h @@ -35,6 +35,7 @@ struct UAContext { JCR *jcr; B_DB *db; CAT *catalog; + CONRES *cons; /* console resource */ POOLMEM *cmd; /* return command/name buffer */ POOLMEM *args; /* command line arguments */ char *argk[MAX_CMD_ARGS]; /* argument keywords */ diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index 75d8277cb7..6b99e2a7cd 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -213,7 +213,7 @@ int restore_cmd(UAContext *ua, char *cmd) job->hdr.name, rx.ClientName, rx.store?rx.store->hdr.name:"", working_directory); } - if (find_arg(ua, _("run")) >= 0 || find_arg(ua, _("yes"))) { + if (find_arg(ua, _("yes")) > 0) { pm_strcat(&ua->cmd, " yes"); /* pass it on to the run command */ } Dmsg1(400, "Submitting: %s\n", ua->cmd); diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index 05113cc2b9..e95e050b06 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -52,7 +52,7 @@ int run_cmd(UAContext *ua, char *cmd) char *when, *verify_job_name; int Priority = 0; int i, j, opt; - bool found; + bool kw_ok; JOB *job = NULL; JOB *verify_job = NULL; STORE *store = NULL; @@ -75,7 +75,8 @@ int run_cmd(UAContext *ua, char *cmd) N_("when"), /* 12 */ N_("priority"), /* 13 */ N_("yes"), /* 14 -- if you change this change YES_POS too */ - N_("verifyjob"), /* 16 */ + N_("verifyjob"), /* 15 */ + N_("files"), /* 16 number of files to restore */ NULL}; #define YES_POS 14 @@ -98,9 +99,10 @@ int run_cmd(UAContext *ua, char *cmd) verify_job_name = NULL; for (i=1; iargc; i++) { - found = false; Dmsg2(200, "Doing arg %d = %s\n", i, ua->argk[i]); - for (j=0; !found && kw[j]; j++) { + kw_ok = false; + /* Keep looking until we find a good keyword */ + for (j=0; !kw_ok && kw[j]; j++) { if (strcasecmp(ua->argk[i], _(kw[j])) == 0) { /* Note, yes and run have no value, so do not err */ if (!ua->argv[i] && j != YES_POS /*yes*/) { @@ -115,7 +117,7 @@ int run_cmd(UAContext *ua, char *cmd) return 1; } job_name = ua->argv[i]; - found = true; + kw_ok = true; break; case 1: /* JobId */ if (jid) { @@ -123,7 +125,7 @@ int run_cmd(UAContext *ua, char *cmd) return 1; } jid = ua->argv[i]; - found = true; + kw_ok = true; break; case 2: /* client */ case 3: /* fd */ @@ -132,7 +134,7 @@ int run_cmd(UAContext *ua, char *cmd) return 1; } client_name = ua->argv[i]; - found = true; + kw_ok = true; break; case 4: /* fileset */ if (fileset_name) { @@ -140,7 +142,7 @@ int run_cmd(UAContext *ua, char *cmd) return 1; } fileset_name = ua->argv[i]; - found = true; + kw_ok = true; break; case 5: /* level */ if (level_name) { @@ -148,7 +150,7 @@ int run_cmd(UAContext *ua, char *cmd) return 1; } level_name = ua->argv[i]; - found = true; + kw_ok = true; break; case 6: /* storage */ case 7: /* sd */ @@ -157,7 +159,7 @@ int run_cmd(UAContext *ua, char *cmd) return 1; } store_name = ua->argv[i]; - found = true; + kw_ok = true; break; case 8: /* pool */ if (pool_name) { @@ -165,7 +167,7 @@ int run_cmd(UAContext *ua, char *cmd) return 1; } pool_name = ua->argv[i]; - found = true; + kw_ok = true; break; case 9: /* where */ if (where) { @@ -173,7 +175,7 @@ int run_cmd(UAContext *ua, char *cmd) return 1; } where = ua->argv[i]; - found = true; + kw_ok = true; break; case 10: /* bootstrap */ if (bootstrap) { @@ -181,7 +183,7 @@ int run_cmd(UAContext *ua, char *cmd) return 1; } bootstrap = ua->argv[i]; - found = true; + kw_ok = true; break; case 11: /* replace */ if (replace) { @@ -189,7 +191,7 @@ int run_cmd(UAContext *ua, char *cmd) return 1; } replace = ua->argv[i]; - found = true; + kw_ok = true; break; case 12: /* When */ if (when) { @@ -197,7 +199,7 @@ int run_cmd(UAContext *ua, char *cmd) return 1; } when = ua->argv[i]; - found = true; + kw_ok = true; break; case 13: /* Priority */ if (Priority) { @@ -209,9 +211,10 @@ int run_cmd(UAContext *ua, char *cmd) bsendmsg(ua, _("Priority must be positive nonzero setting it to 10.\n")); Priority = 10; } + kw_ok = true; break; case 14: /* yes */ - found = true; + kw_ok = true; break; case 15: /* Verify Job */ if (verify_job_name) { @@ -219,7 +222,10 @@ int run_cmd(UAContext *ua, char *cmd) return 1; } verify_job_name = ua->argv[i]; - found = true; + kw_ok = true; + break; + case 16: /* files -- ignore for now */ + kw_ok = true; break; default: @@ -227,7 +233,10 @@ int run_cmd(UAContext *ua, char *cmd) } } /* end strcase compare */ } /* end keyword loop */ - if (!found) { + /* + * End of keyword for loop -- if not found, we got a bogus keyword + */ + if (!kw_ok) { Dmsg1(200, "%s not found\n", ua->argk[i]); /* * Special case for Job Name, it can be the first @@ -385,11 +394,11 @@ try_again: } if (level_name) { /* Look up level name and pull code */ - found = 0; + bool found = false; for (i=0; joblevels[i].level_name; i++) { if (strcasecmp(level_name, _(joblevels[i].level_name)) == 0) { jcr->JobLevel = joblevels[i].level; - found = 1; + found = true; break; } } diff --git a/bacula/src/dird/ua_server.c b/bacula/src/dird/ua_server.c index cd6a94ab70..eecf65619e 100644 --- a/bacula/src/dird/ua_server.c +++ b/bacula/src/dird/ua_server.c @@ -140,7 +140,7 @@ static void *handle_UA_client_request(void *arg) ua->UA_sock = UA_sock; bnet_recv(ua->UA_sock); /* Get first message */ - if (!authenticate_user_agent(ua->UA_sock)) { + if (!authenticate_user_agent(ua)) { goto getout; } diff --git a/bacula/src/filed/filed.c b/bacula/src/filed/filed.c index 10c98fed25..4eb34b8ae4 100644 --- a/bacula/src/filed/filed.c +++ b/bacula/src/filed/filed.c @@ -228,7 +228,10 @@ Without that I don't know who I am :-(\n"), configfile); if (inetd_request) { /* Socket is on fd 0 */ - BSOCK *bs = init_bsock(NULL, 0, "client", "unknown client", me->FDport); + struct sockaddr_in client_addr; + memset(&client_addr, 0, sizeof(client_addr)); + BSOCK *bs = init_bsock(NULL, 0, "client", "unknown client", me->FDport, + &client_addr); handle_client_request((void *)bs); } else { /* Become server, and handle requests */ diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index 69039eda49..9ff0ec2312 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -625,7 +625,7 @@ bnet_open(JCR *jcr, char *name, char *host, char *service, int port, int *fatal) close(sockfd); return NULL; } - return init_bsock(jcr, sockfd, name, host, port); + return init_bsock(jcr, sockfd, name, host, port, &tcp_serv_addr); } /* @@ -807,7 +807,8 @@ char *bnet_sig_to_ascii(BSOCK *bs) * This probably should be done in net_open */ BSOCK * -init_bsock(JCR *jcr, int sockfd, char *who, char *host, int port) +init_bsock(JCR *jcr, int sockfd, char *who, char *host, int port, + struct sockaddr_in *client_addr) { BSOCK *bsock = (BSOCK *)malloc(sizeof(BSOCK)); memset(bsock, 0, sizeof(BSOCK)); @@ -818,6 +819,7 @@ init_bsock(JCR *jcr, int sockfd, char *who, char *host, int port) bsock->who = bstrdup(who); bsock->host = bstrdup(host); bsock->port = port; + memcpy(&bsock->client_addr, client_addr, sizeof(bsock->client_addr)); /* * ****FIXME**** reduce this to a few hours once * heartbeats are implemented diff --git a/bacula/src/lib/bnet_server.c b/bacula/src/lib/bnet_server.c index 308ef2c87e..82b72b3a92 100644 --- a/bacula/src/lib/bnet_server.c +++ b/bacula/src/lib/bnet_server.c @@ -174,7 +174,7 @@ bnet_thread_server(char *bind_addr, int port, int max_clients, workq_t *client_w caller = "unknown client"; } - BSOCK *bs = init_bsock(NULL, newsockfd, "client", caller, port); + BSOCK *bs = init_bsock(NULL, newsockfd, "client", caller, port, &cli_addr); if (bs == NULL) { Jmsg0(NULL, M_ABORT, 0, _("Could not create client BSOCK.\n")); } @@ -242,7 +242,7 @@ bnet_bind(int port) bmicrosleep(5, 0); } listen(sockfd, 1); /* tell system we are ready */ - return init_bsock(NULL, sockfd, _("Server socket"), _("client"), port); + return init_bsock(NULL, sockfd, _("Server socket"), _("client"), port, &serv_addr); } /* @@ -335,7 +335,7 @@ bnet_accept(BSOCK *bsock, char *who) strcpy(buf, who); strcat(buf, ": "); strcat(buf, caller); - bs = init_bsock(NULL, newsockfd, "client", buf, bsock->port); + bs = init_bsock(NULL, newsockfd, "client", buf, bsock->port, &cli_addr); free(buf); return bs; /* return new BSOCK */ } diff --git a/bacula/src/lib/bsock.h b/bacula/src/lib/bsock.h index 14a813a0f2..ad0da87d22 100644 --- a/bacula/src/lib/bsock.h +++ b/bacula/src/lib/bsock.h @@ -37,24 +37,25 @@ struct BSOCK { uint32_t out_msg_no; /* output message number */ int fd; /* socket file descriptor */ int32_t msglen; /* message length */ - int port; /* desired port */ - volatile int errors; /* set if errors on socket */ - volatile int suppress_error_msgs; /* set to suppress error messages */ int b_errno; /* bsock errno */ + int port; /* desired port */ + volatile bool errors: 1; /* set if errors on socket */ + volatile bool suppress_error_msgs: 1; /* set to suppress error messages */ + volatile bool timed_out: 1; /* timed out in read/write */ + volatile bool terminated: 1; /* set when BNET_TERMINATE arrives */ + bool duped: 1; /* set if duped BSOCK */ + bool spool: 1; /* set for spooling */ volatile time_t timer_start; /* time started read/write */ - volatile int timed_out; /* timed out in read/write */ - volatile int timeout; /* time out after this value */ - volatile int terminated; /* set when BNET_TERMINATE arrives */ - int duped; /* set if duped BSOCK */ + volatile time_t timeout; /* timeout BSOCK after this interval */ POOLMEM *msg; /* message pool buffer */ char *who; /* Name of daemon to which we are talking */ char *host; /* Host name/IP */ POOLMEM *errmsg; /* edited error message (to be implemented) */ RES *res; /* Resource to which we are connected */ BSOCK *next; /* next BSOCK if duped */ - int spool; /* set for spooling */ FILE *spool_fd; /* spooling file */ JCR *jcr; /* jcr or NULL for error msgs */ + struct sockaddr_in client_addr; /* client's IP address */ }; /* Signal definitions for use in bnet_sig() */ diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index a66b0327a2..128db706a3 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -26,97 +26,98 @@ struct JCR; /* attr.c */ -ATTR *new_attr(); -void free_attr(ATTR *attr); -int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr); -void build_attr_output_fnames(JCR *jcr, ATTR *attr); -void print_ls_output(JCR *jcr, ATTR *attr); +ATTR *new_attr(); +void free_attr(ATTR *attr); +int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr); +void build_attr_output_fnames(JCR *jcr, ATTR *attr); +void print_ls_output(JCR *jcr, ATTR *attr); /* base64.c */ -void base64_init (void); -int to_base64 (intmax_t value, char *where); -int from_base64 (intmax_t *value, char *where); -int bin_to_base64 (char *buf, char *bin, int len); +void base64_init (void); +int to_base64 (intmax_t value, char *where); +int from_base64 (intmax_t *value, char *where); +int bin_to_base64 (char *buf, char *bin, int len); /* bsys.c */ -char *bstrncpy (char *dest, const char *src, int maxlen); -char *bstrncat (char *dest, const char *src, int maxlen); -void *b_malloc (char *file, int line, size_t size); +char *bstrncpy (char *dest, const char *src, int maxlen); +char *bstrncat (char *dest, const char *src, int maxlen); +void *b_malloc (char *file, int line, size_t size); #ifndef DEBUG -void *bmalloc (size_t size); +void *bmalloc (size_t size); #endif -void *brealloc (void *buf, size_t size); -void *bcalloc (size_t size1, size_t size2); -int bsnprintf (char *str, int32_t size, const char *format, ...); -int bvsnprintf (char *str, int32_t size, const char *format, va_list ap); -int pool_sprintf (char *pool_buf, char *fmt, ...); -void create_pid_file (char *dir, char *progname, int port); -int delete_pid_file (char *dir, char *progname, int port); -void drop (char *uid, char *gid); -int bmicrosleep (time_t sec, long usec); -char *bfgets (char *s, int size, FILE *fd); -void make_unique_filename (POOLMEM **name, int Id, char *what); +void *brealloc (void *buf, size_t size); +void *bcalloc (size_t size1, size_t size2); +int bsnprintf (char *str, int32_t size, const char *format, ...); +int bvsnprintf (char *str, int32_t size, const char *format, va_list ap); +int pool_sprintf (char *pool_buf, char *fmt, ...); +void create_pid_file (char *dir, char *progname, int port); +int delete_pid_file (char *dir, char *progname, int port); +void drop (char *uid, char *gid); +int bmicrosleep (time_t sec, long usec); +char *bfgets (char *s, int size, FILE *fd); +void make_unique_filename (POOLMEM **name, int Id, char *what); #ifndef HAVE_STRTOLL -long long int strtoll (const char *ptr, char **endptr, int base); +long long int strtoll (const char *ptr, char **endptr, int base); #endif /* bnet.c */ -int32_t bnet_recv (BSOCK *bsock); -int bnet_send (BSOCK *bsock); -int bnet_fsend (BSOCK *bs, char *fmt, ...); -int bnet_set_buffer_size (BSOCK *bs, uint32_t size, int rw); -int bnet_sig (BSOCK *bs, int sig); -int bnet_ssl_server (BSOCK *bsock, char *password, int ssl_need, int ssl_has); -int bnet_ssl_client (BSOCK *bsock, char *password, int ssl_need); -BSOCK * bnet_connect (JCR *jcr, int retry_interval, - int max_retry_time, char *name, char *host, char *service, - int port, int verbose); -void bnet_close (BSOCK *bsock); -BSOCK * init_bsock (JCR *jcr, int sockfd, char *who, char *ip, int port); -BSOCK * dup_bsock (BSOCK *bsock); -void term_bsock (BSOCK *bsock); -char * bnet_strerror (BSOCK *bsock); -char * bnet_sig_to_ascii (BSOCK *bsock); -int bnet_wait_data (BSOCK *bsock, int sec); -int bnet_wait_data_intr (BSOCK *bsock, int sec); -int bnet_despool (BSOCK *bsock); -int is_bnet_stop (BSOCK *bsock); -int is_bnet_error (BSOCK *bsock); -void bnet_suppress_error_messages(BSOCK *bsock, int flag); +int32_t bnet_recv (BSOCK *bsock); +int bnet_send (BSOCK *bsock); +int bnet_fsend (BSOCK *bs, char *fmt, ...); +int bnet_set_buffer_size (BSOCK *bs, uint32_t size, int rw); +int bnet_sig (BSOCK *bs, int sig); +int bnet_ssl_server (BSOCK *bsock, char *password, int ssl_need, int ssl_has); +int bnet_ssl_client (BSOCK *bsock, char *password, int ssl_need); +BSOCK * bnet_connect (JCR *jcr, int retry_interval, + int max_retry_time, char *name, char *host, char *service, + int port, int verbose); +void bnet_close (BSOCK *bsock); +BSOCK * init_bsock (JCR *jcr, int sockfd, char *who, char *ip, + int port, struct sockaddr_in *client_addr); +BSOCK * dup_bsock (BSOCK *bsock); +void term_bsock (BSOCK *bsock); +char * bnet_strerror (BSOCK *bsock); +char * bnet_sig_to_ascii (BSOCK *bsock); +int bnet_wait_data (BSOCK *bsock, int sec); +int bnet_wait_data_intr (BSOCK *bsock, int sec); +int bnet_despool (BSOCK *bsock); +int is_bnet_stop (BSOCK *bsock); +int is_bnet_error (BSOCK *bsock); +void bnet_suppress_error_messages(BSOCK *bsock, int flag); /* bget_msg.c */ -int bget_msg(BSOCK *sock); +int bget_msg(BSOCK *sock); /* bpipe.c */ -BPIPE * open_bpipe(char *prog, int wait, char *mode); -int close_wpipe(BPIPE *bpipe); -int close_bpipe(BPIPE *bpipe); +BPIPE * open_bpipe(char *prog, int wait, char *mode); +int close_wpipe(BPIPE *bpipe); +int close_bpipe(BPIPE *bpipe); /* cram-md5.c */ int cram_md5_get_auth(BSOCK *bs, char *password, int ssl_need); int cram_md5_auth(BSOCK *bs, char *password, int ssl_need); void hmac_md5(uint8_t* text, int text_len, uint8_t* key, - int key_len, uint8_t *hmac); + int key_len, uint8_t *hmac); /* crc32.c */ uint32_t bcrc32(uint8_t *buf, int len); /* daemon.c */ -void daemon_start (); +void daemon_start (); /* edit.c */ -uint64_t str_to_uint64(char *str); -int64_t str_to_int64(char *str); -char * edit_uint64_with_commas (uint64_t val, char *buf); -char * add_commas (char *val, char *buf); -char * edit_uint64 (uint64_t val, char *buf); -int duration_to_utime (char *str, utime_t *value); -int size_to_uint64(char *str, int str_len, uint64_t *rtn_value); -char *edit_utime (utime_t val, char *buf); -int is_a_number (const char *num); -int is_an_integer (const char *n); -bool is_name_valid (char *name, POOLMEM **msg); +uint64_t str_to_uint64(char *str); +int64_t str_to_int64(char *str); +char * edit_uint64_with_commas (uint64_t val, char *buf); +char * add_commas (char *val, char *buf); +char * edit_uint64 (uint64_t val, char *buf); +int duration_to_utime (char *str, utime_t *value); +int size_to_uint64(char *str, int str_len, uint64_t *rtn_value); +char *edit_utime (utime_t val, char *buf); +int is_a_number (const char *num); +int is_an_integer (const char *n); +bool is_name_valid (char *name, POOLMEM **msg); /* jcr.c (most definitions are in src/jcr.h) */ void init_last_jobs_list(); @@ -126,35 +127,35 @@ void unlock_last_jobs_list(); /* lex.c */ -LEX * lex_close_file (LEX *lf); -LEX * lex_open_file (LEX *lf, char *fname, LEX_ERROR_HANDLER *scan_error); -int lex_get_char (LEX *lf); -void lex_unget_char (LEX *lf); -char * lex_tok_to_str (int token); -int lex_get_token (LEX *lf, int expect); +LEX * lex_close_file (LEX *lf); +LEX * lex_open_file (LEX *lf, char *fname, LEX_ERROR_HANDLER *scan_error); +int lex_get_char (LEX *lf); +void lex_unget_char (LEX *lf); +char * lex_tok_to_str (int token); +int lex_get_token (LEX *lf, int expect); /* message.c */ -void my_name_is (int argc, char *argv[], char *name); -void init_msg (JCR *jcr, MSGS *msg); -void term_msg (void); -void close_msg (JCR *jcr); -void add_msg_dest (MSGS *msg, int dest, int type, char *where, char *dest_code); -void rem_msg_dest (MSGS *msg, int dest, int type, char *where); -void Jmsg (JCR *jcr, int type, int level, char *fmt, ...); -void dispatch_message (JCR *jcr, int type, int level, char *buf); -void init_console_msg (char *wd); -void free_msgs_res (MSGS *msgs); -int open_spool_file (JCR *jcr, BSOCK *bs); -int close_spool_file (JCR *jcr, BSOCK *bs); +void my_name_is (int argc, char *argv[], char *name); +void init_msg (JCR *jcr, MSGS *msg); +void term_msg (void); +void close_msg (JCR *jcr); +void add_msg_dest (MSGS *msg, int dest, int type, char *where, char *dest_code); +void rem_msg_dest (MSGS *msg, int dest, int type, char *where); +void Jmsg (JCR *jcr, int type, int level, char *fmt, ...); +void dispatch_message (JCR *jcr, int type, int level, char *buf); +void init_console_msg (char *wd); +void free_msgs_res (MSGS *msgs); +int open_spool_file (JCR *jcr, BSOCK *bs); +int close_spool_file (JCR *jcr, BSOCK *bs); /* bnet_server.c */ -void bnet_thread_server(char *bind_addr, int port, int max_clients, workq_t *client_wq, - void *handle_client_request(void *bsock)); -void bnet_server (int port, void handle_client_request(BSOCK *bsock)); -int net_connect (int port); -BSOCK * bnet_bind (int port); -BSOCK * bnet_accept (BSOCK *bsock, char *who); +void bnet_thread_server(char *bind_addr, int port, int max_clients, workq_t *client_wq, + void *handle_client_request(void *bsock)); +void bnet_server (int port, void handle_client_request(BSOCK *bsock)); +int net_connect (int port); +BSOCK * bnet_bind (int port); +BSOCK * bnet_accept (BSOCK *bsock, char *who); /* idcache.c */ char *getuser(uid_t uid); @@ -164,37 +165,37 @@ void free_getgroup_cache(); /* signal.c */ -void init_signals (void terminate(int sig)); -void init_stack_dump (void); +void init_signals (void terminate(int sig)); +void init_stack_dump (void); /* scan.c */ -void strip_trailing_junk (char *str); -void strip_trailing_slashes (char *dir); -bool skip_spaces (char **msg); -bool skip_nonspaces (char **msg); -int fstrsch (char *a, char *b); -int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc, - char **argk, char **argv, int max_args); -char *next_arg(char **s); +void strip_trailing_junk (char *str); +void strip_trailing_slashes (char *dir); +bool skip_spaces (char **msg); +bool skip_nonspaces (char **msg); +int fstrsch (char *a, char *b); +int parse_args(POOLMEM *cmd, POOLMEM **args, int *argc, + char **argk, char **argv, int max_args); +char *next_arg(char **s); /* util.c */ -int is_buf_zero (char *buf, int len); -void lcase (char *str); -void bash_spaces (char *str); -void unbash_spaces (char *str); -char * encode_time (time_t time, char *buf); -char * encode_mode (mode_t mode, char *buf); -int do_shell_expansion (char *name, int name_len); -void jobstatus_to_ascii (int JobStatus, char *msg, int maxlen); -int pm_strcat (POOLMEM **pm, char *str); -int pm_strcpy (POOLMEM **pm, char *str); -int run_program (char *prog, int wait, POOLMEM *results); -char * job_type_to_str (int type); -char * job_status_to_str (int stat); -char * job_level_to_str (int level); -void make_session_key (char *key, char *seed, int mode); -POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, char *to); -void set_working_directory(char *wd); +int is_buf_zero (char *buf, int len); +void lcase (char *str); +void bash_spaces (char *str); +void unbash_spaces (char *str); +char * encode_time (time_t time, char *buf); +char * encode_mode (mode_t mode, char *buf); +int do_shell_expansion (char *name, int name_len); +void jobstatus_to_ascii (int JobStatus, char *msg, int maxlen); +int pm_strcat (POOLMEM **pm, char *str); +int pm_strcpy (POOLMEM **pm, char *str); +int run_program (char *prog, int wait, POOLMEM *results); +char * job_type_to_str (int type); +char * job_status_to_str (int stat); +char * job_level_to_str (int level); +void make_session_key (char *key, char *seed, int mode); +POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, char *to); +void set_working_directory(char *wd); /* watchdog.c */ diff --git a/bacula/src/lib/watchdog.c b/bacula/src/lib/watchdog.c index 3c216f1410..3b2e752bbe 100755 --- a/bacula/src/lib/watchdog.c +++ b/bacula/src/lib/watchdog.c @@ -31,7 +31,7 @@ #include "jcr.h" /* Exported globals */ -time_t watchdog_time; /* this has granularity of SLEEP_TIME */ +time_t watchdog_time = 0; /* this has granularity of SLEEP_TIME */ #define SLEEP_TIME 1 /* examine things every second */ diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 59b335ea36..3427e4baf9 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -247,7 +247,7 @@ DEVICE *acquire_device_for_append(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) recycle = strcmp(jcr->VolCatInfo.VolCatStatus, "Recycle") == 0; if (recycle && dev->num_writers != 0) { Jmsg(jcr, M_FATAL, 0, _("Cannot recycle volume \"%s\"" - " because it is in use by another job.")); + " because it is in use by another job.\n")); goto get_out; } } @@ -265,7 +265,7 @@ DEVICE *acquire_device_for_append(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) if (!mount_next_write_volume(jcr, dev, block, release)) { if (!job_canceled(jcr)) { /* Reduce "noise" -- don't print if job canceled */ - Jmsg(jcr, M_FATAL, 0, _("Could not ready device %s for append.\n"), + Jmsg(jcr, M_FATAL, 0, _("Could not ready device \"%s\" for append.\n"), dev_name(dev)); } goto get_out; diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index acd39dda2e..f25f818063 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -82,7 +82,7 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir) if (status == 0) { loaded = atoi(results); } else { - Jmsg(jcr, M_INFO, 0, _("3991 Bad autochanger \"load slot\" status=%d.\n"), status); + Jmsg(jcr, M_INFO, 0, _("3991 Bad autochanger \"loaded\" command, status=%d.\n"), status); loaded = -1; /* force unload */ } Dmsg1(400, "loaded=%s\n", results); @@ -110,11 +110,11 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir) jcr->device->changer_command, "load"); status = run_program(changer, timeout, NULL); if (status == 0) { - Jmsg(jcr, M_INFO, 0, _("3304 Autochanger \"load slot %d\" status is OK.\n"), + Jmsg(jcr, M_INFO, 0, _("3304 Autochanger \"load slot %d\", status is OK.\n"), slot); } else { - Jmsg(jcr, M_INFO, 0, _("3992 Bad autochanger \"load slot\" status=%d.\n"), - status); + Jmsg(jcr, M_INFO, 0, _("3992 Bad autochanger \"load slot %d\", status=%d.\n"), + slot, status); } Dmsg2(400, "load slot %d status=%d\n", slot, status); } diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index ba1063bc04..90c96bdd59 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -280,18 +280,18 @@ read_volume: */ if (!dev_cap(dev, CAP_STREAM)) { if (!rewind_dev(dev)) { - Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device %s. ERR=%s\n"), + Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device \"%s\". ERR=%s\n"), dev_name(dev), strerror_dev(dev)); } if (recycle) { if (!truncate_dev(dev)) { - Jmsg2(jcr, M_WARNING, 0, _("Truncate error on device %s. ERR=%s\n"), + Jmsg2(jcr, M_WARNING, 0, _("Truncate error on device \"%s\". ERR=%s\n"), dev_name(dev), strerror_dev(dev)); } } /* Attempt write to check write permission */ if (!write_block_to_dev(jcr, dev, block)) { - Jmsg2(jcr, M_ERROR, 0, _("Unable to write device %s. ERR=%s\n"), + Jmsg2(jcr, M_ERROR, 0, _("Unable to write device \"%s\". ERR=%s\n"), dev_name(dev), strerror_dev(dev)); goto mount_next_vol; } @@ -332,10 +332,10 @@ read_volume: bstrncpy(dev->VolCatInfo.VolCatStatus, "Append", sizeof(dev->VolCatInfo.VolCatStatus)); dir_update_volume_info(jcr, dev, 1); /* indicate doing relabel */ if (recycle) { - Jmsg(jcr, M_INFO, 0, _("Recycled volume \"%s\" on device %s, all previous data lost.\n"), + Jmsg(jcr, M_INFO, 0, _("Recycled volume \"%s\" on device \"%s\", all previous data lost.\n"), jcr->VolumeName, dev_name(dev)); } else { - Jmsg(jcr, M_INFO, 0, _("Wrote label to prelabeled Volume \"%s\" on device %s\n"), + Jmsg(jcr, M_INFO, 0, _("Wrote label to prelabeled Volume \"%s\" on device \"%s\"\n"), jcr->VolumeName, dev_name(dev)); } /* @@ -353,7 +353,7 @@ read_volume: Jmsg(jcr, M_INFO, 0, _("Volume \"%s\" previously written, moving to end of data.\n"), jcr->VolumeName); if (!eod_dev(dev)) { - Jmsg(jcr, M_ERROR, 0, _("Unable to position to end of data %s. ERR=%s\n"), + Jmsg(jcr, M_ERROR, 0, _("Unable to position to end of data on device \"%s\". ERR=%s\n"), dev_name(dev), strerror_dev(dev)); mark_volume_in_error(jcr, dev); goto mount_next_vol; @@ -365,12 +365,12 @@ read_volume: * that the database says we should be. */ if (dev->VolCatInfo.VolCatFiles == dev_file(dev)) { - Jmsg(jcr, M_INFO, 0, _("Ready to append to end of Volume at file=%d.\n"), - dev_file(dev)); + Jmsg(jcr, M_INFO, 0, _("Ready to append to end of Volume \"%s\" at file=%d.\n"), + jcr->VolumeName, dev_file(dev)); } else { - Jmsg(jcr, M_ERROR, 0, _("I canot write on this volume because:\n\ + Jmsg(jcr, M_ERROR, 0, _("I canot write on Volume \"%s\" because:\n\ The number of files mismatch! Volume=%u Catalog=%u\n"), - dev_file(dev), dev->VolCatInfo.VolCatFiles); + jcr->VolumeName, dev_file(dev), dev->VolCatInfo.VolCatFiles); mark_volume_in_error(jcr, dev); goto mount_next_vol; } diff --git a/bacula/src/version.h b/bacula/src/version.h index 8e793cbb11..54ae8eb9b1 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -2,8 +2,8 @@ #undef VERSION #define VERSION "1.33" #define VSTRING "1" -#define BDATE "14 Jan 2004" -#define LSMDATE "14Jan04" +#define BDATE "16 Jan 2004" +#define LSMDATE "16Jan04" /* Debug flags */ #undef DEBUG