summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/rpm
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/rpm')
-rw-r--r--meta/recipes-devtools/rpm/rpm/rpm-check-rootpath-reasonableness.patch96
-rw-r--r--meta/recipes-devtools/rpm/rpm_5.4.14.bb1
2 files changed, 97 insertions, 0 deletions
diff --git a/meta/recipes-devtools/rpm/rpm/rpm-check-rootpath-reasonableness.patch b/meta/recipes-devtools/rpm/rpm/rpm-check-rootpath-reasonableness.patch
new file mode 100644
index 0000000000..3986030667
--- /dev/null
+++ b/meta/recipes-devtools/rpm/rpm/rpm-check-rootpath-reasonableness.patch
@@ -0,0 +1,96 @@
1rpm: check if the argument(rootpath) exists or be writable
2
3When user execute the command "rpm -qai --root=$dir",if $dir doesn't
4exist or is unwritable as result of making a typo in rootpath,then
5it will create dirent $dir and subdirectory.
6So we should add the check function to fix it before creating relational
7subdirectory,and warn the incorrect rootpath to user. It just checks the
8rootpath reasonableness when the user input the argument(--root=/-r=).
9
10Upstream-Status: Pending
11
12Signed-off-by: Zhixiong Chi <zchi@windriver.com>
13---
14 rpmqv.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
15 1 file changed, 45 insertions(+)
16
17diff --git a/rpmqv.c b/rpmqv.c
18index 40c42bd..88d85ab 100644
19--- a/rpmqv.c
20+++ b/rpmqv.c
21@@ -206,6 +206,8 @@ static struct poptOption optionsTable[] = {
22 POPT_TABLEEND
23 };
24
25+static int _rpmqv_rootpath_state = 0;
26+
27 #ifdef __MINT__
28 /* MiNT cannot dynamically increase the stack. */
29 long _stksize = 64 * 1024L;
30@@ -427,6 +429,41 @@ static void integrity_check(const char *progname, enum modes progmode_num)
31 }
32 #endif
33
34+/*check if the rootdir is writable or exists */
35+int access_file(const char *rootdir)
36+{
37+ int ret,rootdir_len;
38+
39+ if(rootdir == NULL) {
40+ return;
41+ }
42+
43+ rootdir_len = strlen(rootdir);
44+ /*make sure that dirent argument trailing is "/" */
45+ if(!(rootdir_len && rootdir[rootdir_len - 1] == '/')){
46+ char *t = (char *)malloc(rootdir_len + 2);
47+ *t = '\0';
48+ (void)stpcpy(stpcpy(t,rootdir),"/");
49+ ret = access(t,F_OK|W_OK);
50+ free(t);
51+ }else{
52+ ret = access(rootdir,F_OK|W_OK);
53+ }
54+ return ret;
55+}
56+
57+/*check if input the argument "--root/-r" */
58+void check_argument_root(int argc,char * const argv[])
59+{
60+ int i;
61+ for (i = 0; i < argc; i++) {
62+ if(strncmp(argv[i],"--root=",7) == 0 || strncmp(argv[i],"-r=",3) == 0) {
63+ _rpmqv_rootpath_state = 1;
64+ break;
65+ }
66+ }
67+}
68+
69 /*@-bounds@*/ /* LCL: segfault */
70 /*@-mods@*/ /* FIX: shrug */
71 #if !defined(__GLIBC__) && !defined(__LCLINT__)
72@@ -476,6 +513,8 @@ int main(int argc, const char ** argv)
73 int xx;
74 #endif
75
76+ check_argument_root(argc,(char *const *)argv);
77+
78 #if !defined(__GLIBC__) && !defined(__LCLINT__)
79 environ = envp;
80 #else
81@@ -715,6 +754,12 @@ int main(int argc, const char ** argv)
82 argerror(_("arguments to --root (-r) must begin with a /"));
83 break;
84 }
85+ if (_rpmqv_rootpath_state) {
86+ if (access_file(rpmioRootDir)) {
87+ fprintf(stderr, _("Invalid directory:%s, ensure it exists or be writable\n"),rpmioRootDir);
88+ exit(EXIT_FAILURE);
89+ }
90+ }
91 }
92
93 #if defined(RPM_VENDOR_OPENPKG) /* integrity-checking */
94--
951.9.1
96
diff --git a/meta/recipes-devtools/rpm/rpm_5.4.14.bb b/meta/recipes-devtools/rpm/rpm_5.4.14.bb
index fb81f12a1f..2e17a91137 100644
--- a/meta/recipes-devtools/rpm/rpm_5.4.14.bb
+++ b/meta/recipes-devtools/rpm/rpm_5.4.14.bb
@@ -93,6 +93,7 @@ SRC_URI = "http://www.rpm5.org/files/rpm/rpm-5.4/rpm-5.4.14-0.20131024.src.rpm;e
93 file://0001-using-poptParseArgvString-to-parse-the-_gpg_check_pa.patch \ 93 file://0001-using-poptParseArgvString-to-parse-the-_gpg_check_pa.patch \
94 file://no-ldflags-in-pkgconfig.patch \ 94 file://no-ldflags-in-pkgconfig.patch \
95 file://rpm-lua-fix-print.patch \ 95 file://rpm-lua-fix-print.patch \
96 file://rpm-check-rootpath-reasonableness.patch \
96 " 97 "
97 98
98# Uncomment the following line to enable platform score debugging 99# Uncomment the following line to enable platform score debugging