diff options
author | Aaron Griffin <aaron@archlinux.org> | 2006-12-05 07:55:52 +0100 |
---|---|---|
committer | Aaron Griffin <aaron@archlinux.org> | 2006-12-05 07:55:52 +0100 |
commit | 8028a1124abd585e5570cce95e8901eee15237be (patch) | |
tree | 76abe38c2537043e5e0573d4559251ddbb3625ba | |
parent | 448805890080756ee28615bff2ae6fd2a4fa42b6 (diff) | |
download | pacman-8028a1124abd585e5570cce95e8901eee15237be.tar.gz pacman-8028a1124abd585e5570cce95e8901eee15237be.tar.xz |
Added dbpath validation
-rw-r--r-- | src/pacman/pacman.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 42cd2f85..3e6854c5 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -26,6 +26,8 @@ #include <getopt.h> #include <string.h> #include <signal.h> +#include <sys/types.h> +#include <sys/stat.h> #include <unistd.h> #include <libintl.h> #include <locale.h> @@ -33,7 +35,6 @@ #include <malloc/malloc.h> #elif defined(__OpenBSD__) || defined(__APPLE__) #include <sys/malloc.h> -#include <sys/types.h> #elif defined(CYGWIN) #include <libgen.h> /* basename */ #else @@ -279,6 +280,7 @@ static int parseargs(int argc, char *argv[]) {0, 0, 0, 0} }; char root[PATH_MAX]; + struct stat st = {0}; while((opt = getopt_long(argc, argv, "ARUFQSTDYr:b:vkhscVfmnoldepiuwyg", opts, &option_index))) { if(opt < 0) { @@ -323,6 +325,10 @@ static int parseargs(int argc, char *argv[]) config->op_d_vertest = 1; break; 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); config->dbpath = alpm_option_get_dbpath(optarg); break; |