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
37 #include "amandates.h"
40 #include "pipespawn.h"
41 #include "amfeatures.h"
42 #include "client_util.h"
59 int need_xfsrestore=0;
64 int need_compress_path=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;
101 * Configure program for internationalization:
102 * 1) Only set the message locale for now.
103 * 2) Set textdomain for all amanda related programs to "amanda"
104 * We don't want to be forced to support dozens of message catalogs.
106 setlocale(LC_MESSAGES, "C");
107 textdomain("amanda");
112 set_pname("selfcheck");
114 /* Don't die when child closes pipe */
115 signal(SIGPIPE, SIG_IGN);
117 erroutput_type = (ERR_INTERACTIVE|ERR_SYSLOG);
118 dbopen(DBG_SUBDIR_CLIENT);
120 dbprintf(_("version %s\n"), version());
122 if(argc > 2 && strcmp(argv[1], "amandad") == 0) {
123 amandad_auth = stralloc(argv[2]);
126 config_init(CONFIG_INIT_CLIENT, NULL);
127 /* (check for config errors comes later) */
129 check_running_as(RUNNING_AS_CLIENT_LOGIN);
131 our_features = am_init_feature_set();
132 our_feature_string = am_feature_to_string(our_features);
134 /* handle all service requests */
137 for(; (line = agets(stdin)) != NULL; free(line)) {
142 if(strncmp_const(line, "OPTIONS ") == 0) {
143 g_options = parse_g_options(line+8, 1);
144 if(!g_options->hostname) {
145 g_options->hostname = alloc(MAX_HOSTNAME_LENGTH+1);
146 gethostname(g_options->hostname, MAX_HOSTNAME_LENGTH);
147 g_options->hostname[MAX_HOSTNAME_LENGTH] = '\0';
150 g_printf("OPTIONS ");
151 if(am_has_feature(g_options->features, fe_rep_options_features)) {
152 g_printf("features=%s;", our_feature_string);
154 if(am_has_feature(g_options->features, fe_rep_options_hostname)) {
155 g_printf("hostname=%s;", g_options->hostname);
160 if (g_options->config) {
161 /* overlay this configuration on the existing (nameless) configuration */
162 config_init(CONFIG_INIT_CLIENT | CONFIG_INIT_EXPLICIT_NAME | CONFIG_INIT_OVERLAY,
165 dbrename(get_config_name(), DBG_SUBDIR_CLIENT);
168 /* check for any config errors now */
169 if (config_errors(&errlist) >= CFGERR_ERRORS) {
170 char *errstr = config_errors_to_error_string(errlist);
171 g_printf("%s\n", errstr);
176 if (am_has_feature(g_options->features, fe_req_xml)) {
186 skip_whitespace(s, ch); /* find program name */
188 goto err; /* no program */
190 dle->program = s - 1;
191 skip_non_whitespace(s, ch);
192 s[-1] = '\0'; /* terminate the program name */
194 dle->program_is_application_api = 0;
195 if(strcmp(dle->program,"APPLICATION")==0) {
196 dle->program_is_application_api = 1;
197 skip_whitespace(s, ch); /* find dumper name */
199 goto err; /* no program */
201 dle->program = s - 1;
202 skip_non_whitespace(s, ch);
203 s[-1] = '\0'; /* terminate the program name */
206 if(strncmp_const(dle->program, "CALCSIZE") == 0) {
207 skip_whitespace(s, ch); /* find program name */
209 goto err; /* no program */
211 dle->program = s - 1;
212 skip_non_whitespace(s, ch);
220 skip_whitespace(s, ch); /* find disk name */
222 goto err; /* no disk */
225 skip_quoted_string(s, ch);
226 s[-1] = '\0'; /* terminate the disk name */
227 dle->disk = unquote_string(qdisk);
229 skip_whitespace(s, ch); /* find the device or level */
231 goto err; /* no device or level */
233 if(!isdigit((int)s[-1])) {
235 skip_quoted_string(s, ch);
236 s[-1] = '\0'; /* terminate the device */
237 qamdevice = stralloc(fp);
238 dle->device = unquote_string(qamdevice);
239 skip_whitespace(s, ch); /* find level number */
242 dle->device = stralloc(dle->disk);
243 qamdevice = stralloc(qdisk);
246 /* find level number */
247 if (ch == '\0' || sscanf(s - 1, "%d", &level) != 1) {
248 goto err; /* bad level */
250 dle->level = g_slist_append(dle->level, GINT_TO_POINTER(level));
253 skip_whitespace(s, ch);
254 if (ch && strncmp_const_skip(s - 1, "OPTIONS ", s, ch) == 0) {
255 skip_whitespace(s, ch); /* find the option string */
257 goto err; /* bad options string */
260 skip_quoted_string(s, ch);
261 s[-1] = '\0'; /* terminate the options */
262 parse_options(optstr, dle, g_options->features, 1);
269 } else if (ch == '\0') {
270 /* check all since no option */
283 need_compress_path=1;
289 goto err; /* bad syntax */
293 if (g_options == NULL) {
294 g_printf(_("ERROR [Missing OPTIONS line in selfcheck input]\n"));
295 error(_("Missing OPTIONS line in selfcheck input\n"));
299 if (am_has_feature(g_options->features, fe_req_xml)) {
303 dles = amxml_parse_node_FILE(stdin, &errmsg);
308 for (dle = dles; dle != NULL; dle = dle->next) {
309 run_client_scripts(EXECUTE_ON_PRE_HOST_AMCHECK, g_options, dle,
312 for (dle = dles; dle != NULL; dle = dle->next) {
314 run_client_scripts(EXECUTE_ON_PRE_DLE_AMCHECK, g_options, dle,
317 run_client_scripts(EXECUTE_ON_POST_DLE_AMCHECK, g_options, dle,
320 for (dle = dles; dle != NULL; dle = dle->next) {
321 run_client_scripts(EXECUTE_ON_POST_HOST_AMCHECK, g_options, dle,
329 amfree(our_feature_string);
330 am_release_feature_set(our_features);
332 free_g_options(g_options);
339 g_printf(_("ERROR [FORMAT ERROR IN REQUEST PACKET %s]\n"), err_extra);
340 dbprintf(_("REQ packet is bogus: %s\n"), err_extra);
342 g_printf(_("ERROR [FORMAT ERROR IN REQUEST PACKET]\n"));
343 dbprintf(_("REQ packet is bogus\n"));
354 if (dle->calcsize == 1) {
358 if (strcmp(dle->program,"GNUTAR") == 0) {
360 if(dle->device[0] == '/' && dle->device[1] == '/') {
361 if(dle->exclude_file && dle->exclude_file->nb_element > 1) {
362 g_printf(_("ERROR [samba support only one exclude file]\n"));
364 if (dle->exclude_list && dle->exclude_list->nb_element > 0 &&
365 dle->exclude_optional==0) {
366 g_printf(_("ERROR [samba does not support exclude list]\n"));
368 if (dle->include_file && dle->include_file->nb_element > 0) {
369 g_printf(_("ERROR [samba does not support include file]\n"));
371 if (dle->include_list && dle->include_list->nb_element > 0 &&
372 dle->include_optional==0) {
373 g_printf(_("ERROR [samba does not support include list]\n"));
379 char *file_exclude = NULL;
380 char *file_include = NULL;
382 if (dle->exclude_file) nb_exclude += dle->exclude_file->nb_element;
383 if (dle->exclude_list) nb_exclude += dle->exclude_list->nb_element;
384 if (dle->include_file) nb_include += dle->include_file->nb_element;
385 if (dle->include_list) nb_include += dle->include_list->nb_element;
387 if (nb_exclude > 0) file_exclude = build_exclude(dle, 1);
388 if (nb_include > 0) file_include = build_include(dle, 1);
390 amfree(file_exclude);
391 amfree(file_include);
397 if (strcmp(dle->program,"DUMP") == 0) {
398 if (dle->exclude_file && dle->exclude_file->nb_element > 0) {
399 g_printf(_("ERROR [DUMP does not support exclude file]\n"));
401 if (dle->exclude_list && dle->exclude_list->nb_element > 0) {
402 g_printf(_("ERROR [DUMP does not support exclude list]\n"));
404 if (dle->include_file && dle->include_file->nb_element > 0) {
405 g_printf(_("ERROR [DUMP does not support include file]\n"));
407 if (dle->include_list && dle->include_list->nb_element > 0) {
408 g_printf(_("ERROR [DUMP does not support include list]\n"));
416 if (strcmp(amname_to_fstype(dle->device), "advfs") == 0)
423 if (dle->create_index)
430 if (strcmp(amname_to_fstype(dle->device), "xfs") == 0)
437 if (dle->create_index)
444 if (strcmp(amname_to_fstype(dle->device), "vxfs") == 0)
450 if (dle->create_index)
457 if (dle->create_index)
461 /* AIX backup program */
463 if (dle->create_index)
467 if ((dle->compress == COMP_BEST) || (dle->compress == COMP_FAST)
468 || (dle->compress == COMP_CUST)) {
469 need_compress_path=1;
471 if (dle->auth && amandad_auth) {
472 if (strcasecmp(dle->auth, amandad_auth) != 0) {
473 g_fprintf(stdout,_("ERROR [client configured for auth=%s while server requested '%s']\n"),
474 amandad_auth, dle->auth);
475 if (strcmp(dle->auth, "ssh") == 0) {
476 g_fprintf(stderr, _("ERROR [The auth in ~/.ssh/authorized_keys "
477 "should be \"--auth=ssh\", or use another auth "
481 g_fprintf(stderr, _("ERROR [The auth in the inetd/xinetd configuration "
482 " must be the same as the DLE]\n"));
492 char *device = stralloc("nodevice");
494 char *user_and_password = NULL;
496 char *share = NULL, *subdir = NULL;
501 char *extra_info = NULL;
502 char *qdisk = quote_string(dle->disk);
503 char *qamdevice = quote_string(dle->device);
504 char *qdevice = NULL;
506 dbprintf(_("checking disk %s\n"), qdisk);
507 if (dle->calcsize == 1) {
508 if (dle->device[0] == '/' && dle->device[1] == '/') {
509 err = vstrallocf(_("Can't use CALCSIZE for samba estimate, use CLIENT: %s"),
515 if (strcmp(dle->program, "GNUTAR")==0) {
516 if(dle->device[0] == '/' && dle->device[1] == '/') {
518 int nullfd, checkerr;
532 parsesharename(dle->device, &share, &subdir);
534 err = vstrallocf(_("cannot parse for share/subdir disk entry %s"), dle->device);
537 if ((subdir) && (SAMBA_VERSION < 2)) {
538 err = vstrallocf(_("subdirectory specified for share '%s' but, samba is not v2 or better"),
542 if ((user_and_password = findpass(share, &domain)) == NULL) {
543 err = vstrallocf(_("cannot find password for %s"), dle->device);
546 lpass = strlen(user_and_password);
547 if ((pwtext = strchr(user_and_password, '%')) == NULL) {
548 err = vstrallocf(_("password field not \'user%%pass\' for %s"), dle->device);
552 pwtext_len = (size_t)strlen(pwtext);
554 if ((device = makesharename(share, 0)) == NULL) {
555 err = vstrallocf(_("cannot make share name of %s"), share);
559 if ((nullfd = open("/dev/null", O_RDWR)) == -1) {
560 err = vstrallocf(_("Cannot access /dev/null : %s"), strerror(errno));
564 if (pwtext_len > 0) {
565 pw_fd_env = "PASSWD_FD";
567 pw_fd_env = "dummy_PASSWD_FD";
569 checkpid = pipespawn(SAMBA_CLIENT, STDERR_PIPE|PASSWD_PIPE, 0,
570 &nullfd, &nullfd, &checkerr,
571 pw_fd_env, &passwdfd,
574 *user_and_password ? "-U" : skip_argument,
575 *user_and_password ? user_and_password : skip_argument,
577 domain ? "-W" : skip_argument,
578 domain ? domain : skip_argument,
579 #if SAMBA_VERSION >= 2
580 subdir ? "-D" : skip_argument,
581 subdir ? subdir : skip_argument,
589 && full_write(passwdfd, pwtext, pwtext_len) < pwtext_len) {
590 err = vstrallocf(_("password write failed: %s: %s"),
591 dle->device, strerror(errno));
596 memset(user_and_password, '\0', (size_t)lpass);
597 amfree(user_and_password);
599 ferr = fdopen(checkerr, "r");
601 g_printf(_("ERROR [Can't fdopen: %s]\n"), strerror(errno));
602 error(_("Can't fdopen: %s"), strerror(errno));
607 for(sep = ""; (line = agets(ferr)) != NULL; free(line)) {
610 strappend(extra_info, sep);
611 strappend(extra_info, line);
613 if(strstr(line, "ERRDOS") != NULL) {
621 while ((wpid = wait(&retstat)) != -1) {
622 if (!WIFEXITED(retstat) || WEXITSTATUS(retstat) != 0) {
623 char *exitstr = str_exit_status("smbclient", retstat);
625 strappend(err, exitstr);
632 if (errdos != 0 || rc != 0) {
634 err = newvstrallocf(err,
635 _("samba access error: %s: %s %s"),
636 dle->device, extra_info, err);
639 err = newvstrallocf(err, _("samba access error: %s: %s"),
644 err = vstrallocf(_("This client is not configured for samba: %s"),
651 device = amname_to_dirname(dle->device);
652 } else if (strcmp(dle->program, "DUMP") == 0) {
653 if(dle->device[0] == '/' && dle->device[1] == '/') {
655 _("The DUMP program cannot handle samba shares, use GNUTAR: %s"),
661 if (strcmp(amname_to_fstype(dle->device), "advfs") == 0)
667 device = amname_to_dirname(dle->device);
673 device = amname_to_devname(dle->device);
681 else { /* program_is_application_api==1 */
682 pid_t application_api_pid;
683 backup_support_option_t *bsu;
687 bsu = backup_support_option(dle->program, g_options, dle->disk,
688 dle->device, &errarray);
693 for (i=0; i < errarray->len; i++) {
694 line = g_ptr_array_index(errarray, i);
695 fprintf(stdout, _("ERROR Application '%s': %s\n"),
699 err = vstrallocf(_("Application '%s': can't run support command"),
704 if (dle->calcsize && !bsu->calcsize) {
705 g_printf("ERROR application %s doesn't support calcsize estimate\n",
708 if (dle->include_file && dle->include_file->nb_element > 0 &&
709 !bsu->include_file) {
710 g_printf("ERROR application %s doesn't support include-file\n",
713 if (dle->include_list && dle->include_list->nb_element > 0 &&
714 !bsu->include_list) {
715 g_printf("ERROR application %s doesn't support include-list\n",
718 if (dle->include_optional && !bsu->include_optional) {
719 g_printf("ERROR application %s doesn't support optional include\n",
722 if (dle->exclude_file && dle->exclude_file->nb_element > 0 &&
723 !bsu->exclude_file) {
724 g_printf("ERROR application %s doesn't support exclude-file\n",
727 if (dle->exclude_list && dle->exclude_list->nb_element > 0 &&
728 !bsu->exclude_list) {
729 g_printf("ERROR application %s doesn't support exclude-list\n",
732 if (dle->exclude_optional && !bsu->exclude_optional) {
733 g_printf("ERROR application %s doesn't support optional exclude\n",
736 fflush(stdout);fflush(stderr);
738 if (pipe(app_err) < 0) {
739 err = vstrallocf(_("Application '%s': can't create pipe"),
744 switch (application_api_pid = fork()) {
746 err = vstrallocf(_("fork failed: %s"), strerror(errno));
751 char **argvchild, **arg;
752 char *cmd = vstralloc(APPLICATION_DIR, "/", dle->program, NULL);
762 k = application_property_argv_size(dle);
763 for (scriptlist = dle->scriptlist; scriptlist != NULL;
764 scriptlist = scriptlist->next) {
765 script = (script_t *)scriptlist->data;
766 if (script->result && script->result->proplist) {
767 k += property_argv_size(script->result->proplist);
770 argvchild = g_new0(char *, 18 + k);
771 argvchild[j++] = dle->program;
772 argvchild[j++] = "selfcheck";
773 if (bsu->message_line == 1) {
774 argvchild[j++] = "--message";
775 argvchild[j++] = "line";
777 if (g_options->config != NULL && bsu->config == 1) {
778 argvchild[j++] = "--config";
779 argvchild[j++] = g_options->config;
781 if (g_options->hostname != NULL && bsu->host == 1) {
782 argvchild[j++] = "--host";
783 argvchild[j++] = g_options->hostname;
785 if (dle->disk != NULL && bsu->disk == 1) {
786 argvchild[j++] = "--disk";
787 argvchild[j++] = dle->disk;
789 argvchild[j++] = "--device";
790 argvchild[j++] = dle->device;
791 if (dle->create_index && bsu->index_line == 1) {
792 argvchild[j++] = "--index";
793 argvchild[j++] = "line";
795 if (dle->record && bsu->record == 1) {
796 argvchild[j++] = "--record";
798 if (dle->calcsize && bsu->calcsize == 1) {
799 argvchild[j++] = "--calcsize";
801 j += application_property_add_to_argv(&argvchild[j], dle, bsu);
803 for (scriptlist = dle->scriptlist; scriptlist != NULL;
804 scriptlist = scriptlist->next) {
805 script = (script_t *)scriptlist->data;
806 if (script->result && script->result->proplist) {
807 j += property_add_to_argv(&argvchild[j],
808 script->result->proplist);
812 argvchild[j++] = NULL;
814 cmdline = stralloc(cmd);
815 for(arg = argvchild; *arg != NULL; arg++) {
816 char *quoted = quote_string(*arg);
817 cmdline = vstrextend(&cmdline, " ", quoted, NULL);
820 dbprintf(_("Spawning \"%s\" in pipeline\n"), cmdline);
824 execve(cmd, argvchild, safe_env());
825 g_printf(_("ERROR [Can't execute %s: %s]\n"), cmd, strerror(errno));
828 default: /* parent */
835 app_stderr = fdopen(app_err[0], "r");
836 while((line = agets(app_stderr)) != NULL) {
837 if (strlen(line) > 0) {
838 fprintf(stdout, "ERROR Application '%s': %s\n",
840 dbprintf("ERROR %s\n", line);
845 if (waitpid(application_api_pid, &status, 0) < 0) {
846 err = vstrallocf(_("waitpid failed: %s"),
849 } else if (!WIFEXITED(status)) {
850 err = vstrallocf(_("Application '%s': exited with signal %d"),
851 dle->program, WTERMSIG(status));
853 } else if (WEXITSTATUS(status) != 0) {
854 err = vstrallocf(_("Application '%s': exited with status %d"),
855 dle->program, WEXITSTATUS(status));
861 fflush(stdout);fflush(stderr);
868 qdevice = quote_string(device);
869 dbprintf(_("device %s\n"), qdevice);
871 /* skip accessability test if this is an AFS entry */
872 if(strncmp_const(device, "afs:") != 0) {
873 #ifdef CHECK_FOR_ACCESS_WITH_OPEN
874 access_result = open(device, O_RDONLY);
875 access_type = "open";
877 access_result = access(device, amode);
878 access_type = "access";
880 if(access_result == -1) {
881 err = vstrallocf(_("Could not access %s (%s): %s"),
882 qdevice, qdisk, strerror(errno));
884 #ifdef CHECK_FOR_ACCESS_WITH_OPEN
885 aclose(access_result);
892 qdevice = quote_string(device);
896 if(user_and_password) {
897 memset(user_and_password, '\0', (size_t)lpass);
898 amfree(user_and_password);
903 g_printf(_("ERROR %s\n"), err);
904 dbprintf(_("%s\n"), err);
907 g_printf("OK %s\n", qdisk);
908 dbprintf(_("disk %s OK\n"), qdisk);
909 g_printf("OK %s\n", qamdevice);
910 dbprintf(_("amdevice %s OK\n"), qamdevice);
911 g_printf("OK %s\n", qdevice);
912 dbprintf(_("device %s OK\n"), qdevice);
915 dbprintf(_("extra info: %s\n"), extra_info);
923 /* XXX perhaps do something with level: read dumpdates and sanity check */
932 char *gnutar_list_dir;
933 int need_amandates = 0;
937 cmd = vstralloc(amlibexecdir, "/", "runtar", versionsuffix(), NULL);
938 check_file(cmd,X_OK);
945 cmd = vstralloc(amlibexecdir, "/", "rundump", versionsuffix(), NULL);
946 check_file(cmd,X_OK);
953 check_file(DUMP, X_OK);
955 g_printf(_("ERROR [DUMP program not available]\n"));
961 check_file(RESTORE, X_OK);
963 g_printf(_("ERROR [RESTORE program not available]\n"));
969 check_file(VDUMP, X_OK);
971 g_printf(_("ERROR [VDUMP program not available]\n"));
975 if ( need_vrestore ) {
977 check_file(VRESTORE, X_OK);
979 g_printf(_("ERROR [VRESTORE program not available]\n"));
985 check_file(XFSDUMP, F_OK);
987 g_printf(_("ERROR [XFSDUMP program not available]\n"));
991 if( need_xfsrestore ) {
993 check_file(XFSRESTORE, X_OK);
995 g_printf(_("ERROR [XFSRESTORE program not available]\n"));
1001 check_file(VXDUMP, X_OK);
1003 g_printf(_("ERROR [VXDUMP program not available]\n"));
1007 if( need_vxrestore ) {
1009 check_file(VXRESTORE, X_OK);
1011 g_printf(_("ERROR [VXRESTORE program not available]\n"));
1017 check_file(GNUTAR, X_OK);
1019 g_printf(_("ERROR [GNUTAR program not available]\n"));
1021 gnutar_list_dir = getconf_str(CNF_GNUTAR_LIST_DIR);
1022 if (strlen(gnutar_list_dir) == 0)
1023 gnutar_list_dir = NULL;
1024 if (gnutar_list_dir) {
1025 /* make sure our listed-incremental dir is ready */
1026 check_dir(gnutar_list_dir, R_OK|W_OK);
1028 /* no listed-incremental dir, so check that amandates is ready */
1033 if( need_calcsize ) {
1036 cmd = vstralloc(amlibexecdir, "/", "calcsize", versionsuffix(), NULL);
1038 check_file(cmd, X_OK);
1042 /* calcsize uses amandates */
1046 if (need_amandates) {
1047 char *amandates_file;
1048 amandates_file = getconf_str(CNF_AMANDATES);
1049 check_file(amandates_file, R_OK|W_OK);
1054 check_file(SAMBA_CLIENT, X_OK);
1056 g_printf(_("ERROR [SMBCLIENT program not available]\n"));
1058 testfd = open("/etc/amandapass", R_OK);
1060 if(fstat(testfd, &buf) == 0) {
1061 if ((buf.st_mode & 0x7) != 0) {
1062 g_printf(_("ERROR [/etc/amandapass is world readable!]\n"));
1064 g_printf(_("OK [/etc/amandapass is readable, but not by all]\n"));
1067 g_printf(_("OK [unable to stat /etc/amandapass: %s]\n"),
1072 g_printf(_("ERROR [unable to open /etc/amandapass: %s]\n"),
1077 if (need_compress_path )
1078 check_file(COMPRESS_PATH, X_OK);
1080 if (need_dump || need_xfsdump ) {
1081 if (check_file_exist("/etc/dumpdates")) {
1082 check_file("/etc/dumpdates",
1091 if (access("/etc", R_OK|W_OK) == -1) {
1092 g_printf(_("ERROR [dump will not be able to create the /etc/dumpdates file: %s]\n"), strerror(errno));
1099 if (check_file_exist("/etc/vdumpdates")) {
1100 check_file("/etc/vdumpdates", F_OK);
1104 check_access("/dev/null", R_OK|W_OK);
1105 check_space(AMANDA_TMPDIR, (off_t)64); /* for amandad i/o */
1107 #ifdef AMANDA_DBGDIR
1108 check_space(AMANDA_DBGDIR, (off_t)64); /* for amandad i/o */
1111 check_space("/etc", (off_t)64); /* for /etc/dumpdates writing */
1119 struct fs_usage fsusage;
1120 char *quoted = quote_string(dir);
1123 if(get_fs_usage(dir, NULL, &fsusage) == -1) {
1124 g_printf(_("ERROR [cannot get filesystem usage for %s: %s]\n"), quoted, strerror(errno));
1129 /* do the division first to avoid potential integer overflow */
1130 kb_avail = fsusage.fsu_bavail / 1024 * fsusage.fsu_blocksize;
1132 if (fsusage.fsu_bavail_top_bit_set || fsusage.fsu_bavail == 0) {
1133 g_printf(_("ERROR [dir %s needs %lldKB, has nothing available.]\n"), quoted,
1135 } else if (kb_avail < kbytes) {
1136 g_printf(_("ERROR [dir %s needs %lldKB, only has %lldKB available.]\n"), quoted,
1138 (long long)kb_avail);
1140 g_printf(_("OK %s has more than %lldKB available.\n"),
1141 quoted, (long long)kbytes);
1150 struct stat stat_buf;
1152 if (stat(filename, &stat_buf) != 0) {
1153 if(errno == ENOENT) {