Hi rpm5 guys, Attachment is the patch fixes the bug of installing rpm over internet.
Thanks, Firo
From 7cf65b66e936a2c6bcfa70173ae2c8d84f071b23 Mon Sep 17 00:00:00 2001 From: Firo Yang <yongming.y...@windriver.com> Date: Thu, 5 Nov 2015 10:53:32 +0800 Subject: [PATCH 1/1] rpm-install: Fix Bug for installing rpm package over the Internet rpmio/rpmio.c: Use ufd-functions to manuplate the RPM package specified by HTTP, HTTPS and FTP url. rpmio/rpmio.c Set the opath member of FD_t to url-path in function httpOpen(). The opath will be used by Fstat() to get the stat info. Signed-off-by: Firo Yang <yongming.y...@windriver.com> --- rpmio/rpmdav.c | 1 + rpmio/rpmio.c | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/rpmio/rpmdav.c b/rpmio/rpmdav.c index fd85240..e66c731 100644 --- a/rpmio/rpmdav.c +++ b/rpmio/rpmdav.c @@ -2237,6 +2237,7 @@ FD_t httpOpen(const char * url, /*@unused@*/ int flags, if (fd) { fdSetIo(fd, ufdio); + fdSetOpen(fd, url, flags, mode); fd->ftpFileDoneNeeded = 0; fd->rd_timeoutsecs = rpmioHttpReadTimeoutSecs; fd->contentLength = fd->bytesRemain = -1; diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c index ea96611..4335753 100644 --- a/rpmio/rpmio.c +++ b/rpmio/rpmio.c @@ -2826,9 +2826,24 @@ DBGIO(fd, (stderr, "<== Fdopen(%p,\"%s\") returns fd %p %s\n", ofd, fmode, (fd ? /*@=refcounttrans =retalias =usereleased @*/ } +static int is_rpm_via_http_ftp(urltype ut) +{ + int rv = 0; + switch (ut) { + case URL_IS_HTTP: + case URL_IS_HTTPS: + case URL_IS_FTP: + rv = 1; + break; + default: + rv = 0; + } + return rv; +} + FD_t Fopen(const char *path, const char *_fmode) { - const char * fmode = NULL; + char *fmode = NULL, *backup; char stdio[20], other[20]; const char *end = NULL; mode_t perms = 0666; @@ -2839,8 +2854,12 @@ FD_t Fopen(const char *path, const char *_fmode) goto exit; /*@-globs -mods@*/ fmode = rpmExpand(_fmode, NULL); + backup = fmode; /*@=globs =mods@*/ + if (is_rpm_via_http_ftp(urlIsURL(path)) && (fmode[0] == 'r')) { + fmode = "r.ufdio"; + } if (_rpmio_debug) fprintf(stderr, "==> Fopen(%s, %s)\n", path, fmode); @@ -2848,7 +2867,7 @@ fprintf(stderr, "==> Fopen(%s, %s)\n", path, fmode); cvtfmode(fmode, stdio, sizeof(stdio), other, sizeof(other), &end, &flags); if (stdio[0] == '\0') goto exit; - + if (end == NULL || !strcmp(end, "fdio")) { fd = fdOpen(path, flags, perms); if (fdFileno(fd) < 0) { @@ -2905,7 +2924,7 @@ exit: if (_rpmio_debug) fprintf(stderr, "<== Fopen(%s, %s) fd %p\n", path, fmode, fd); - fmode = _free(fmode); + fmode = _free(backup); return fd; } -- 1.9.1