Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | chroot: realpath is required before expanding _dbpath |
| 2 | |
| 3 | _usr turned out to be a relative path to support dyanmic config, but it's |
| 4 | being used somewhere as a indicator to locate substrings, so we must get |
| 5 | the real path of it in advance. |
| 6 | |
| 7 | Upstream-Status: Inappropriate (OpenEmbedded specific) |
| 8 | |
| 9 | Signed-off-by: Ming Liu <ming.liu@windriver.com> |
| 10 | |
| 11 | diff -urpN a/rpmio/rpmrpc.c b/rpmio/rpmrpc.c |
| 12 | --- a/rpmio/rpmrpc.c |
| 13 | +++ b/rpmio/rpmrpc.c |
| 14 | @@ -257,7 +257,9 @@ int Open(const char * path, int flags, m |
| 15 | /* XXX if the open(2) fails, try to strip a possible chroot(2) prefix. */ |
| 16 | if (fdno < 0 && errno == ENOENT) { |
| 17 | const char *dbpath = rpmExpand("%{?_dbpath}/", NULL); |
| 18 | - const char * fn = strstr(path + 1, dbpath); |
| 19 | + char resolved_dbpath[PATH_MAX]; |
| 20 | + realpath(dbpath, resolved_dbpath); |
| 21 | + const char * fn = strstr(path + 1, resolved_dbpath); |
| 22 | if (fn) |
| 23 | fdno = open(fn, flags, mode); |
| 24 | dbpath = _free(dbpath); |