* University of Maryland at College Park
*/
/*
- * $Id: selfcheck.c,v 1.95 2006/08/29 11:21:00 martinea Exp $
+ * $Id: selfcheck.c,v 1.95.2.2 2007/01/19 01:03:34 martinea Exp $
*
* do self-check and send back any error messages
*/
static void check_disk(char *program, char *calcprog, char *disk, char *amdevice, int level, char *optstr);
static void check_overall(void);
static void check_access(char *filename, int mode);
+static int check_file_exist(char *filename);
static void check_file(char *filename, int mode);
static void check_dir(char *dirname, int mode);
static void check_suid(char *filename);
amode = F_OK;
amfree(device);
device = amname_to_dirname(amdevice);
- } else if (strcmp(program, "DUMP") == 0) {
+ } else if (strcmp(myprogram, "DUMP") == 0) {
if(amdevice[0] == '/' && amdevice[1] == '/') {
err = vstralloc("The DUMP program cannot handle samba shares,",
" use GNUTAR: ",
}
}
- if( need_compress_path )
+ if (need_compress_path )
check_file(COMPRESS_PATH, X_OK);
- if( need_dump || need_xfsdump )
- check_file("/etc/dumpdates",
+ if (need_dump || need_xfsdump ) {
+ if (check_file_exist("/etc/dumpdates")) {
+ check_file("/etc/dumpdates",
#ifdef USE_RUNDUMP
- F_OK
+ F_OK
#else
- R_OK|W_OK
+ R_OK|W_OK
#endif
- );
+ );
+ } else {
+#ifndef USE_RUNDUMP
+ if (access("/etc", R_OK|W_OK) == -1) {
+ printf("ERROR [dump will not be able to create the /etc/dumpdates file: %s]\n", strerror(errno));
+ }
+#endif
+ }
+ }
- if (need_vdump)
- check_file("/etc/vdumpdates", F_OK);
+ if (need_vdump) {
+ if (check_file_exist("/etc/vdumpdates")) {
+ check_file("/etc/vdumpdates", F_OK);
+ }
+ }
check_access("/dev/null", R_OK|W_OK);
check_space(AMANDA_TMPDIR, (off_t)64); /* for amandad i/o */
amfree(quoted);
}
+static int
+check_file_exist(
+ char *filename)
+{
+ struct stat stat_buf;
+
+ if (stat(filename, &stat_buf) != 0) {
+ if(errno == ENOENT) {
+ return 0;
+ }
+ }
+ return 1;
+}
+
static void
check_file(
char * filename,