X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=application-src%2Famstar.c;h=bcd9988b267e68dd2ff3b3ce5f2a721f45e8fbda;hb=b116e9366c7b2ea2c2eb53b0a13df4090e176235;hp=2f8b17c26f9f80c23c25fbdeb9398dbd610f4bb1;hpb=fd48f3e498442f0cbff5f3606c7c403d0566150e;p=debian%2Famanda diff --git a/application-src/amstar.c b/application-src/amstar.c index 2f8b17c..bcd9988 100644 --- a/application-src/amstar.c +++ b/application-src/amstar.c @@ -124,6 +124,7 @@ static void amstar_validate(application_argument_t *argument); static GPtrArray *amstar_build_argv(application_argument_t *argument, int level, int command); +static int check_device(application_argument_t *argument); static char *star_path; static char *star_tardumps; @@ -440,6 +441,11 @@ amstar_selfcheck( check_file(amandates_file, R_OK|W_OK); } + set_root_privs(1); + if (argument->dle.device) { + check_dir(argument->dle.device, R_OK); + } + set_root_privs(0); } static void @@ -485,6 +491,10 @@ amstar_estimate( fprintf(stderr, "ERROR exclude-list not supported for backup\n"); } + if (check_device(argument) == 0) { + return; + } + qdisk = quote_string(argument->dle.disk); if (argument->calcsize) { char *dirname; @@ -984,3 +994,39 @@ static GPtrArray *amstar_build_argv( return(argv_ptr); } + +static int +check_device( + application_argument_t *argument) +{ + char *qdevice; + struct stat stat_buf; + + qdevice = quote_string(argument->dle.device); + set_root_privs(1); + if(!stat(argument->dle.device, &stat_buf)) { + if (!S_ISDIR(stat_buf.st_mode)) { + set_root_privs(0); + g_fprintf(stderr, _("ERROR %s is not a directory\n"), qdevice); + amfree(qdevice); + return 0; + } + } else { + set_root_privs(0); + g_fprintf(stderr, _("ERROR can not stat %s: %s\n"), qdevice, + strerror(errno)); + amfree(qdevice); + return 0; + } + if (access(argument->dle.device, R_OK|X_OK) == -1) { + set_root_privs(0); + g_fprintf(stderr, _("ERROR can not access %s: %s\n"), + argument->dle.device, strerror(errno)); + amfree(qdevice); + return 0; + } + set_root_privs(0); + amfree(qdevice); + return 1; +} +