2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of U.M. not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. U.M. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
16 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: James da Silva, Systems Design and Analysis Group
24 * Computer Science Department
25 * University of Maryland at College Park
28 * $Id: selfcheck.c 10421 2008-03-06 18:48:30Z martineau $
30 * do self-check and send back any error messages
36 #include "amandates.h"
39 #include "pipespawn.h"
40 #include "amfeatures.h"
41 #include "client_util.h"
58 int need_xfsrestore=0;
63 int need_compress_path=0;
65 int need_global_check=0;
66 int program_is_application_api=0;
68 static char *amandad_auth = NULL;
69 static am_feature_t *our_features = NULL;
70 static char *our_feature_string = NULL;
71 static g_option_t *g_options = NULL;
74 int main(int argc, char **argv);
76 static void check_options(dle_t *dle);
77 static void check_disk(dle_t *dle);
78 static void check_overall(void);
79 static int check_file_exist(char *filename);
80 static void check_space(char *dir, off_t kbytes);
89 char *qamdevice = NULL;
91 char *err_extra = NULL;
102 * Configure program for internationalization:
103 * 1) Only set the message locale for now.
104 * 2) Set textdomain for all amanda related programs to "amanda"
105 * We don't want to be forced to support dozens of message catalogs.
107 setlocale(LC_MESSAGES, "C");
108 textdomain("amanda");
114 set_pname("selfcheck");
116 /* Don't die when child closes pipe */
117 signal(SIGPIPE, SIG_IGN);
119 add_amanda_log_handler(amanda_log_stderr);
120 add_amanda_log_handler(amanda_log_syslog);
121 dbopen(DBG_SUBDIR_CLIENT);
123 dbprintf(_("version %s\n"), VERSION);
125 if(argc > 2 && strcmp(argv[1], "amandad") == 0) {
126 amandad_auth = stralloc(argv[2]);
129 config_init(CONFIG_INIT_CLIENT, NULL);
130 /* (check for config errors comes later) */
132 check_running_as(RUNNING_AS_CLIENT_LOGIN);
134 our_features = am_init_feature_set();
135 our_feature_string = am_feature_to_string(our_features);
137 /* handle all service requests */
140 for(; (line = agets(stdin)) != NULL; free(line)) {
145 if(strncmp_const(line, "OPTIONS ") == 0) {
146 g_options = parse_g_options(line+8, 1);
147 if(!g_options->hostname) {
148 g_options->hostname = alloc(MAX_HOSTNAME_LENGTH+1);
149 gethostname(g_options->hostname, MAX_HOSTNAME_LENGTH);
150 g_options->hostname[MAX_HOSTNAME_LENGTH] = '\0';
153 g_printf("OPTIONS ");
154 if(am_has_feature(g_options->features, fe_rep_options_features)) {
155 g_printf("features=%s;", our_feature_string);
157 if(am_has_feature(g_options->features, fe_rep_options_hostname)) {
158 g_printf("hostname=%s;", g_options->hostname);
163 if (g_options->config) {
164 /* overlay this configuration on the existing (nameless) configuration */
165 config_init(CONFIG_INIT_CLIENT | CONFIG_INIT_EXPLICIT_NAME | CONFIG_INIT_OVERLAY,
168 dbrename(get_config_name(), DBG_SUBDIR_CLIENT);
171 /* check for any config errors now */
172 if (config_errors(&errlist) >= CFGERR_ERRORS) {
173 char *errstr = config_errors_to_error_string(errlist);
174 g_printf("%s\n", errstr);
179 if (am_has_feature(g_options->features, fe_req_xml)) {
189 skip_whitespace(s, ch); /* find program name */
191 goto err; /* no program */
193 dle->program = s - 1;
194 skip_non_whitespace(s, ch);
195 s[-1] = '\0'; /* terminate the program name */
197 dle->program_is_application_api = 0;
198 if(strcmp(dle->program,"APPLICATION")==0) {
199 dle->program_is_application_api = 1;
200 skip_whitespace(s, ch); /* find dumper name */
202 goto err; /* no program */
204 dle->program = s - 1;
205 skip_non_whitespace(s, ch);
206 s[-1] = '\0'; /* terminate the program name */
209 if(strncmp_const(dle->program, "CALCSIZE") == 0) {
210 skip_whitespace(s, ch); /* find program name */
212 goto err; /* no program */
214 dle->program = s - 1;
215 skip_non_whitespace(s, ch);
217 dle->estimatelist = g_slist_append(dle->estimatelist,
218 GINT_TO_POINTER(ES_CALCSIZE));
221 dle->estimatelist = g_slist_append(dle->estimatelist,
222 GINT_TO_POINTER(ES_CLIENT));
225 skip_whitespace(s, ch); /* find disk name */
227 goto err; /* no disk */
230 skip_quoted_string(s, ch);
231 s[-1] = '\0'; /* terminate the disk name */
232 dle->disk = unquote_string(qdisk);
234 skip_whitespace(s, ch); /* find the device or level */
236 goto err; /* no device or level */
238 if(!isdigit((int)s[-1])) {
240 skip_quoted_string(s, ch);
241 s[-1] = '\0'; /* terminate the device */
242 qamdevice = stralloc(fp);
243 dle->device = unquote_string(qamdevice);
244 skip_whitespace(s, ch); /* find level number */
247 dle->device = stralloc(dle->disk);
248 qamdevice = stralloc(qdisk);
251 /* find level number */
252 if (ch == '\0' || sscanf(s - 1, "%d", &level) != 1) {
253 goto err; /* bad level */
255 alevel = g_new0(level_t, 1);
256 alevel->level = level;
257 dle->levellist = g_slist_append(dle->levellist, alevel);
260 skip_whitespace(s, ch);
261 if (ch && strncmp_const_skip(s - 1, "OPTIONS ", s, ch) == 0) {
262 skip_whitespace(s, ch); /* find the option string */
264 goto err; /* bad options string */
267 skip_quoted_string(s, ch);
268 s[-1] = '\0'; /* terminate the options */
269 parse_options(optstr, dle, g_options->features, 1);
276 } else if (ch == '\0') {
277 /* check all since no option */
290 need_compress_path=1;
297 goto err; /* bad syntax */
301 if (g_options == NULL) {
302 g_printf(_("ERROR [Missing OPTIONS line in selfcheck input]\n"));
303 error(_("Missing OPTIONS line in selfcheck input\n"));
307 if (am_has_feature(g_options->features, fe_req_xml)) {
311 dles = amxml_parse_node_FILE(stdin, &errmsg);
316 for (dle = dles; dle != NULL; dle = dle->next) {
317 run_client_scripts(EXECUTE_ON_PRE_HOST_AMCHECK, g_options, dle,
320 for (dle = dles; dle != NULL; dle = dle->next) {
322 run_client_scripts(EXECUTE_ON_PRE_DLE_AMCHECK, g_options, dle,
325 run_client_scripts(EXECUTE_ON_POST_DLE_AMCHECK, g_options, dle,
328 for (dle = dles; dle != NULL; dle = dle->next) {
329 run_client_scripts(EXECUTE_ON_POST_HOST_AMCHECK, g_options, dle,
337 amfree(our_feature_string);
338 am_release_feature_set(our_features);
340 free_g_options(g_options);
347 g_printf(_("ERROR [FORMAT ERROR IN REQUEST PACKET %s]\n"), err_extra);
348 dbprintf(_("REQ packet is bogus: %s\n"), err_extra);
350 g_printf(_("ERROR [FORMAT ERROR IN REQUEST PACKET]\n"));
351 dbprintf(_("REQ packet is bogus\n"));
362 if (GPOINTER_TO_INT(dle->estimatelist->data) == ES_CALCSIZE) {
366 if (strcmp(dle->program,"GNUTAR") == 0) {
368 if(dle->device && dle->device[0] == '/' && dle->device[1] == '/') {
369 if(dle->exclude_file && dle->exclude_file->nb_element > 1) {
370 g_printf(_("ERROR [samba support only one exclude file]\n"));
372 if (dle->exclude_list && dle->exclude_list->nb_element > 0 &&
373 dle->exclude_optional==0) {
374 g_printf(_("ERROR [samba does not support exclude list]\n"));
376 if (dle->include_file && dle->include_file->nb_element > 0) {
377 g_printf(_("ERROR [samba does not support include file]\n"));
379 if (dle->include_list && dle->include_list->nb_element > 0 &&
380 dle->include_optional==0) {
381 g_printf(_("ERROR [samba does not support include list]\n"));
387 char *file_exclude = NULL;
388 char *file_include = NULL;
390 if (dle->exclude_file) nb_exclude += dle->exclude_file->nb_element;
391 if (dle->exclude_list) nb_exclude += dle->exclude_list->nb_element;
392 if (dle->include_file) nb_include += dle->include_file->nb_element;
393 if (dle->include_list) nb_include += dle->include_list->nb_element;
395 if (nb_exclude > 0) file_exclude = build_exclude(dle, 1);
396 if (nb_include > 0) file_include = build_include(dle, 1);
398 amfree(file_exclude);
399 amfree(file_include);
405 if (strcmp(dle->program,"DUMP") == 0) {
406 if (dle->exclude_file && dle->exclude_file->nb_element > 0) {
407 g_printf(_("ERROR [DUMP does not support exclude file]\n"));
409 if (dle->exclude_list && dle->exclude_list->nb_element > 0) {
410 g_printf(_("ERROR [DUMP does not support exclude list]\n"));
412 if (dle->include_file && dle->include_file->nb_element > 0) {
413 g_printf(_("ERROR [DUMP does not support include file]\n"));
415 if (dle->include_list && dle->include_list->nb_element > 0) {
416 g_printf(_("ERROR [DUMP does not support include list]\n"));
424 if (dle->device && strcmp(amname_to_fstype(dle->device), "advfs") == 0)
431 if (dle->create_index)
438 if (dle->device && strcmp(amname_to_fstype(dle->device), "xfs") == 0)
445 if (dle->create_index)
452 if (dle->device && strcmp(amname_to_fstype(dle->device), "vxfs") == 0)
458 if (dle->create_index)
465 if (dle->create_index)
469 /* AIX backup program */
471 if (dle->create_index)
475 if ((dle->compress == COMP_BEST) || (dle->compress == COMP_FAST)
476 || (dle->compress == COMP_CUST)) {
477 need_compress_path=1;
479 if (dle->auth && amandad_auth) {
480 if (strcasecmp(dle->auth, amandad_auth) != 0) {
481 g_fprintf(stdout,_("ERROR [client configured for auth=%s while server requested '%s']\n"),
482 amandad_auth, dle->auth);
483 if (strcmp(dle->auth, "ssh") == 0) {
484 g_fprintf(stderr, _("ERROR [The auth in ~/.ssh/authorized_keys "
485 "should be \"--auth=ssh\", or use another auth "
489 g_fprintf(stderr, _("ERROR [The auth in the inetd/xinetd configuration "
490 " must be the same as the DLE]\n"));
502 char *user_and_password = NULL;
504 char *share = NULL, *subdir = NULL;
509 char *extra_info = NULL;
511 char *qamdevice = NULL;
512 char *qdevice = NULL;
516 qdisk = quote_string(dle->disk);
517 qamdevice = quote_string(dle->device);
518 device = stralloc("nodevice");
519 dbprintf(_("checking disk %s\n"), qdisk);
520 if (GPOINTER_TO_INT(dle->estimatelist->data) == ES_CALCSIZE) {
521 if (dle->device[0] == '/' && dle->device[1] == '/') {
523 _("Can't use CALCSIZE for samba estimate, use CLIENT: %s"),
529 if (strcmp(dle->program, "GNUTAR")==0) {
530 if(dle->device[0] == '/' && dle->device[1] == '/') {
532 int nullfd, checkerr;
546 parsesharename(dle->device, &share, &subdir);
549 _("cannot parse for share/subdir disk entry %s"),
553 if ((subdir) && (SAMBA_VERSION < 2)) {
554 err = vstrallocf(_("subdirectory specified for share '%s' but, samba is not v2 or better"),
558 if ((user_and_password = findpass(share, &domain)) == NULL) {
559 err = vstrallocf(_("cannot find password for %s"),
563 lpass = strlen(user_and_password);
564 if ((pwtext = strchr(user_and_password, '%')) == NULL) {
566 _("password field not \'user%%pass\' for %s"),
571 pwtext_len = (size_t)strlen(pwtext);
573 if ((device = makesharename(share, 0)) == NULL) {
574 err = vstrallocf(_("cannot make share name of %s"), share);
578 if ((nullfd = open("/dev/null", O_RDWR)) == -1) {
579 err = vstrallocf(_("Cannot access /dev/null : %s"),
584 if (pwtext_len > 0) {
585 pw_fd_env = "PASSWD_FD";
587 pw_fd_env = "dummy_PASSWD_FD";
589 checkpid = pipespawn(SAMBA_CLIENT, STDERR_PIPE|PASSWD_PIPE, 0,
590 &nullfd, &nullfd, &checkerr,
591 pw_fd_env, &passwdfd,
594 *user_and_password ? "-U" : skip_argument,
595 *user_and_password ? user_and_password
598 domain ? "-W" : skip_argument,
599 domain ? domain : skip_argument,
600 #if SAMBA_VERSION >= 2
601 subdir ? "-D" : skip_argument,
602 subdir ? subdir : skip_argument,
609 if ((pwtext_len > 0) &&
610 full_write(passwdfd, pwtext, pwtext_len) < pwtext_len) {
611 err = vstrallocf(_("password write failed: %s: %s"),
612 dle->device, strerror(errno));
617 memset(user_and_password, '\0', (size_t)lpass);
618 amfree(user_and_password);
620 ferr = fdopen(checkerr, "r");
622 g_printf(_("ERROR [Can't fdopen: %s]\n"), strerror(errno));
623 error(_("Can't fdopen: %s"), strerror(errno));
628 for(sep = ""; (line = agets(ferr)) != NULL; free(line)) {
631 strappend(extra_info, sep);
632 strappend(extra_info, line);
634 if(strstr(line, "ERRDOS") != NULL) {
642 while ((wpid = wait(&retstat)) != -1) {
643 if (!WIFEXITED(retstat) || WEXITSTATUS(retstat) != 0) {
644 char *exitstr = str_exit_status("smbclient", retstat);
646 strappend(err, exitstr);
653 if (errdos != 0 || rc != 0) {
655 err = newvstrallocf(err,
656 _("samba access error: %s: %s %s"),
657 dle->device, extra_info, err);
660 err = newvstrallocf(err,
661 _("samba access error: %s: %s"),
667 _("This client is not configured for samba: %s"),
674 device = amname_to_dirname(dle->device);
675 } else if (strcmp(dle->program, "DUMP") == 0) {
676 if(dle->device[0] == '/' && dle->device[1] == '/') {
678 _("The DUMP program cannot handle samba shares, use GNUTAR: %s"),
684 if (strcmp(amname_to_fstype(dle->device), "advfs") == 0)
690 device = amname_to_dirname(dle->device);
696 device = amname_to_devname(dle->device);
705 if (dle->program_is_application_api) {
706 pid_t application_api_pid;
707 backup_support_option_t *bsu;
711 bsu = backup_support_option(dle->program, g_options, dle->disk,
712 dle->device, &errarray);
717 for (i=0; i < errarray->len; i++) {
718 line = g_ptr_array_index(errarray, i);
719 fprintf(stdout, _("ERROR Application '%s': %s\n"),
723 err = vstrallocf(_("Application '%s': can't run support command"),
728 if (dle->data_path == DATA_PATH_AMANDA &&
729 (bsu->data_path_set & DATA_PATH_AMANDA)==0) {
730 g_printf("ERROR application %s doesn't support amanda data-path\n",
733 if (dle->data_path == DATA_PATH_DIRECTTCP &&
734 (bsu->data_path_set & DATA_PATH_DIRECTTCP)==0) {
735 g_printf("ERROR application %s doesn't support directtcp data-path\n",
738 if (GPOINTER_TO_INT(dle->estimatelist->data) == ES_CALCSIZE &&
740 g_printf("ERROR application %s doesn't support calcsize estimate\n",
743 if (dle->include_file && dle->include_file->nb_element > 0 &&
744 !bsu->include_file) {
745 g_printf("ERROR application %s doesn't support include-file\n",
748 if (dle->include_list && dle->include_list->nb_element > 0 &&
749 !bsu->include_list) {
750 g_printf("ERROR application %s doesn't support include-list\n",
753 if (dle->include_optional && !bsu->include_optional) {
754 g_printf("ERROR application %s doesn't support optional include\n",
757 if (dle->exclude_file && dle->exclude_file->nb_element > 0 &&
758 !bsu->exclude_file) {
759 g_printf("ERROR application %s doesn't support exclude-file\n",
762 if (dle->exclude_list && dle->exclude_list->nb_element > 0 &&
763 !bsu->exclude_list) {
764 g_printf("ERROR application %s doesn't support exclude-list\n",
767 if (dle->exclude_optional && !bsu->exclude_optional) {
768 g_printf("ERROR application %s doesn't support optional exclude\n",
771 fflush(stdout);fflush(stderr);
773 if (pipe(app_err) < 0) {
774 err = vstrallocf(_("Application '%s': can't create pipe"),
779 switch (application_api_pid = fork()) {
781 err = vstrallocf(_("fork failed: %s"), strerror(errno));
786 GPtrArray *argv_ptr = g_ptr_array_new();
788 char *cmd = vstralloc(APPLICATION_DIR, "/", dle->program, NULL);
797 g_ptr_array_add(argv_ptr, stralloc(dle->program));
798 g_ptr_array_add(argv_ptr, stralloc("selfcheck"));
799 if (bsu->message_line == 1) {
800 g_ptr_array_add(argv_ptr, stralloc("--message"));
801 g_ptr_array_add(argv_ptr, stralloc("line"));
803 if (g_options->config != NULL && bsu->config == 1) {
804 g_ptr_array_add(argv_ptr, stralloc("--config"));
805 g_ptr_array_add(argv_ptr, stralloc(g_options->config));
807 if (g_options->hostname != NULL && bsu->host == 1) {
808 g_ptr_array_add(argv_ptr, stralloc("--host"));
809 g_ptr_array_add(argv_ptr, stralloc(g_options->hostname));
811 if (dle->disk != NULL && bsu->disk == 1) {
812 g_ptr_array_add(argv_ptr, stralloc("--disk"));
813 g_ptr_array_add(argv_ptr, stralloc(dle->disk));
816 g_ptr_array_add(argv_ptr, stralloc("--device"));
817 g_ptr_array_add(argv_ptr, stralloc(dle->device));
819 if (dle->create_index && bsu->index_line == 1) {
820 g_ptr_array_add(argv_ptr, stralloc("--index"));
821 g_ptr_array_add(argv_ptr, stralloc("line"));
823 if (dle->record && bsu->record == 1) {
824 g_ptr_array_add(argv_ptr, stralloc("--record"));
827 for (el = dle->estimatelist; el != NULL; el=el->next) {
828 estimate_t estimate = (estimate_t)GPOINTER_TO_INT(el->data);
829 if (estimate == ES_CALCSIZE && bsu->calcsize == 1) {
830 g_ptr_array_add(argv_ptr, stralloc("--calcsize"));
833 application_property_add_to_argv(argv_ptr, dle, bsu,
834 g_options->features);
836 for (scriptlist = dle->scriptlist; scriptlist != NULL;
837 scriptlist = scriptlist->next) {
838 script = (script_t *)scriptlist->data;
839 if (script->result && script->result->proplist) {
840 property_add_to_argv(argv_ptr,
841 script->result->proplist);
845 g_ptr_array_add(argv_ptr, NULL);
847 cmdline = stralloc(cmd);
848 for (i = 0; i < argv_ptr->len-1; i++) {
849 char *quoted = quote_string(
850 (char *)g_ptr_array_index(argv_ptr,i));
851 cmdline = vstrextend(&cmdline, " ", quoted, NULL);
854 dbprintf(_("Spawning \"%s\" in pipeline\n"), cmdline);
858 execve(cmd, (char **)argv_ptr->pdata, safe_env());
859 g_printf(_("ERROR [Can't execute %s: %s]\n"), cmd, strerror(errno));
862 default: /* parent */
869 app_stderr = fdopen(app_err[0], "r");
870 while((line = agets(app_stderr)) != NULL) {
871 if (strlen(line) > 0) {
872 fprintf(stdout, "ERROR Application '%s': %s\n",
874 dbprintf("ERROR %s\n", line);
879 if (waitpid(application_api_pid, &status, 0) < 0) {
880 err = vstrallocf(_("waitpid failed: %s"),
883 } else if (!WIFEXITED(status)) {
884 err = vstrallocf(_("Application '%s': exited with signal %d"),
885 dle->program, WTERMSIG(status));
887 } else if (WEXITSTATUS(status) != 0) {
888 err = vstrallocf(_("Application '%s': exited with status %d"),
889 dle->program, WEXITSTATUS(status));
895 fflush(stdout);fflush(stderr);
903 qdevice = quote_string(device);
904 dbprintf(_("device %s\n"), qdevice);
906 /* skip accessability test if this is an AFS entry */
907 if(strncmp_const(device, "afs:") != 0) {
908 #ifdef CHECK_FOR_ACCESS_WITH_OPEN
909 access_result = open(device, O_RDONLY);
910 access_type = "open";
912 access_result = access(device, amode);
913 access_type = "access";
915 if(access_result == -1) {
916 err = vstrallocf(_("Could not access %s (%s): %s"),
917 qdevice, qdisk, strerror(errno));
919 #ifdef CHECK_FOR_ACCESS_WITH_OPEN
920 aclose(access_result);
928 qdevice = quote_string(device);
932 if(user_and_password) {
933 memset(user_and_password, '\0', (size_t)lpass);
934 amfree(user_and_password);
939 g_printf(_("ERROR %s\n"), err);
940 dbprintf(_("%s\n"), err);
944 g_printf("OK %s\n", qdisk);
945 dbprintf(_("disk %s OK\n"), qdisk);
948 g_printf("OK %s\n", qamdevice);
949 dbprintf(_("amdevice %s OK\n"), qamdevice);
952 g_printf("OK %s\n", qdevice);
953 dbprintf(_("device %s OK\n"), qdevice);
957 dbprintf(_("extra info: %s\n"), extra_info);
965 /* XXX perhaps do something with level: read dumpdates and sanity check */
974 char *gnutar_list_dir;
975 int need_amandates = 0;
979 cmd = vstralloc(amlibexecdir, "/", "runtar", NULL);
980 check_file(cmd,X_OK);
987 cmd = vstralloc(amlibexecdir, "/", "rundump", NULL);
988 check_file(cmd,X_OK);
995 check_file(DUMP, X_OK);
997 g_printf(_("ERROR [DUMP program not available]\n"));
1001 if( need_restore ) {
1003 check_file(RESTORE, X_OK);
1005 g_printf(_("ERROR [RESTORE program not available]\n"));
1011 check_file(VDUMP, X_OK);
1013 g_printf(_("ERROR [VDUMP program not available]\n"));
1017 if ( need_vrestore ) {
1019 check_file(VRESTORE, X_OK);
1021 g_printf(_("ERROR [VRESTORE program not available]\n"));
1025 if( need_xfsdump ) {
1027 check_file(XFSDUMP, F_OK);
1029 g_printf(_("ERROR [XFSDUMP program not available]\n"));
1033 if( need_xfsrestore ) {
1035 check_file(XFSRESTORE, X_OK);
1037 g_printf(_("ERROR [XFSRESTORE program not available]\n"));
1043 check_file(VXDUMP, X_OK);
1045 g_printf(_("ERROR [VXDUMP program not available]\n"));
1049 if( need_vxrestore ) {
1051 check_file(VXRESTORE, X_OK);
1053 g_printf(_("ERROR [VXRESTORE program not available]\n"));
1059 check_file(GNUTAR, X_OK);
1061 g_printf(_("ERROR [GNUTAR program not available]\n"));
1063 gnutar_list_dir = getconf_str(CNF_GNUTAR_LIST_DIR);
1064 if (strlen(gnutar_list_dir) == 0)
1065 gnutar_list_dir = NULL;
1066 if (gnutar_list_dir) {
1067 /* make sure our listed-incremental dir is ready */
1068 check_dir(gnutar_list_dir, R_OK|W_OK);
1070 /* no listed-incremental dir, so check that amandates is ready */
1075 if( need_calcsize ) {
1078 cmd = vstralloc(amlibexecdir, "/", "calcsize", NULL);
1080 check_file(cmd, X_OK);
1084 /* calcsize uses amandates */
1088 if (need_amandates) {
1089 char *amandates_file;
1090 amandates_file = getconf_str(CNF_AMANDATES);
1091 check_file(amandates_file, R_OK|W_OK);
1096 check_file(SAMBA_CLIENT, X_OK);
1098 g_printf(_("ERROR [SMBCLIENT program not available]\n"));
1100 testfd = open("/etc/amandapass", R_OK);
1102 if(fstat(testfd, &buf) == 0) {
1103 if ((buf.st_mode & 0x7) != 0) {
1104 g_printf(_("ERROR [/etc/amandapass is world readable!]\n"));
1106 g_printf(_("OK [/etc/amandapass is readable, but not by all]\n"));
1109 g_printf(_("OK [unable to stat /etc/amandapass: %s]\n"),
1114 g_printf(_("ERROR [unable to open /etc/amandapass: %s]\n"),
1119 if (need_compress_path )
1120 check_file(COMPRESS_PATH, X_OK);
1122 if (need_dump || need_xfsdump ) {
1123 if (check_file_exist("/etc/dumpdates")) {
1124 check_file("/etc/dumpdates",
1133 if (access("/etc", R_OK|W_OK) == -1) {
1134 g_printf(_("ERROR [dump will not be able to create the /etc/dumpdates file: %s]\n"), strerror(errno));
1141 if (check_file_exist("/etc/vdumpdates")) {
1142 check_file("/etc/vdumpdates", F_OK);
1146 if (need_global_check) {
1147 check_access("/dev/null", R_OK|W_OK);
1148 check_space(AMANDA_TMPDIR, (off_t)64); /* for amandad i/o */
1150 #ifdef AMANDA_DBGDIR
1151 check_space(AMANDA_DBGDIR, (off_t)64); /* for amandad i/o */
1154 check_space("/etc", (off_t)64); /* for /etc/dumpdates writing */
1163 struct fs_usage fsusage;
1164 char *quoted = quote_string(dir);
1167 if(get_fs_usage(dir, NULL, &fsusage) == -1) {
1168 g_printf(_("ERROR [cannot get filesystem usage for %s: %s]\n"), quoted, strerror(errno));
1173 /* do the division first to avoid potential integer overflow */
1174 kb_avail = fsusage.fsu_bavail / 1024 * fsusage.fsu_blocksize;
1176 if (fsusage.fsu_bavail_top_bit_set || fsusage.fsu_bavail == 0) {
1177 g_printf(_("ERROR [dir %s needs %lldKB, has nothing available.]\n"), quoted,
1179 } else if (kb_avail < kbytes) {
1180 g_printf(_("ERROR [dir %s needs %lldKB, only has %lldKB available.]\n"), quoted,
1182 (long long)kb_avail);
1184 g_printf(_("OK %s has more than %lldKB available.\n"),
1185 quoted, (long long)kbytes);
1194 struct stat stat_buf;
1196 if (stat(filename, &stat_buf) != 0) {
1197 if(errno == ENOENT) {