summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-01-09 10:34:08 +0200
committerPanu Matilainen <pmatilai@redhat.com>2008-01-09 10:34:08 +0200
commit88c020f771f477aa70b7251dde762cd8fb6fbf0d (patch)
tree22a06c5dc46b92cc308c9daf2e826e684b0af730 /lib
parenta97100ba1dae7849571f30075d7564fb0124dc91 (diff)
downloadlibrpm-tizen-88c020f771f477aa70b7251dde762cd8fb6fbf0d.tar.gz
librpm-tizen-88c020f771f477aa70b7251dde762cd8fb6fbf0d.tar.bz2
librpm-tizen-88c020f771f477aa70b7251dde762cd8fb6fbf0d.zip
Avoid access(2) quirks querying symlinks, lstat(2) instead (#60288)
Ported from rpm5.org work of Jeff Johnson
Diffstat (limited to 'lib')
-rw-r--r--lib/query.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/lib/query.c b/lib/query.c
index d90be3233..0fb6bccd0 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -586,7 +586,6 @@ int rpmQueryVerify(QVA_t qva, rpmts ts, const char * arg)
}
case RPMQV_PATH:
{ char * fn;
- int myerrno = 0;
for (s = arg; *s != '\0'; s++)
if (!(*s == '.' || *s == '/'))
@@ -595,10 +594,7 @@ int rpmQueryVerify(QVA_t qva, rpmts ts, const char * arg)
if (*s == '\0') {
char fnbuf[PATH_MAX];
fn = realpath(arg, fnbuf);
- if (fn)
- fn = xstrdup(fn);
- else
- fn = xstrdup(arg);
+ fn = xstrdup( (fn != NULL ? fn : arg) );
} else if (*arg != '/') {
char *curDir = currentDirectory();
fn = (char *) rpmGetPath(curDir, "/", arg, NULL);
@@ -608,19 +604,16 @@ int rpmQueryVerify(QVA_t qva, rpmts ts, const char * arg)
(void) rpmCleanPath(fn);
qva->qva_mi = rpmtsInitIterator(ts, RPMTAG_BASENAMES, fn, 0);
- if (qva->qva_mi == NULL) {
- if (access(fn, F_OK) != 0)
- myerrno = errno;
- else if (!provides_checked)
- qva->qva_mi = rpmtsInitIterator(ts, RPMTAG_PROVIDENAME, fn, 0);
- }
+ if (qva->qva_mi == NULL && !provides_checked)
+ qva->qva_mi = rpmtsInitIterator(ts, RPMTAG_PROVIDENAME, fn, 0);
- if (myerrno != 0) {
- rpmlog(RPMLOG_ERR, _("file %s: %s\n"), fn, strerror(myerrno));
- res = 1;
- } else if (qva->qva_mi == NULL) {
- rpmlog(RPMLOG_NOTICE,
- _("file %s is not owned by any package\n"), fn);
+ if (qva->qva_mi == NULL) {
+ struct stat sb;
+ if (lstat(fn, &sb) != 0)
+ rpmlog(RPMLOG_ERR, _("file %s: %s\n"), fn, strerror(errno));
+ else
+ rpmlog(RPMLOG_NOTICE,
+ _("file %s is not owned by any package\n"), fn);
res = 1;
} else
res = rpmcliShowMatches(qva, ts);