Added dbpath validation
This commit is contained in:
parent
4488058900
commit
8028a1124a
1 changed files with 7 additions and 1 deletions
|
@ -26,6 +26,8 @@
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
@ -33,7 +35,6 @@
|
||||||
#include <malloc/malloc.h>
|
#include <malloc/malloc.h>
|
||||||
#elif defined(__OpenBSD__) || defined(__APPLE__)
|
#elif defined(__OpenBSD__) || defined(__APPLE__)
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#elif defined(CYGWIN)
|
#elif defined(CYGWIN)
|
||||||
#include <libgen.h> /* basename */
|
#include <libgen.h> /* basename */
|
||||||
#else
|
#else
|
||||||
|
@ -279,6 +280,7 @@ static int parseargs(int argc, char *argv[])
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
char root[PATH_MAX];
|
char root[PATH_MAX];
|
||||||
|
struct stat st = {0};
|
||||||
|
|
||||||
while((opt = getopt_long(argc, argv, "ARUFQSTDYr:b:vkhscVfmnoldepiuwyg", opts, &option_index))) {
|
while((opt = getopt_long(argc, argv, "ARUFQSTDYr:b:vkhscVfmnoldepiuwyg", opts, &option_index))) {
|
||||||
if(opt < 0) {
|
if(opt < 0) {
|
||||||
|
@ -323,6 +325,10 @@ static int parseargs(int argc, char *argv[])
|
||||||
config->op_d_vertest = 1;
|
config->op_d_vertest = 1;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
|
if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) {
|
||||||
|
pm_fprintf(stderr, NL, _("error: '%s' is not a valid db path\n"), optarg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
alpm_option_set_dbpath(optarg);
|
alpm_option_set_dbpath(optarg);
|
||||||
config->dbpath = alpm_option_get_dbpath(optarg);
|
config->dbpath = alpm_option_get_dbpath(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue