Stub in URL_IS_HTTPS everywhere.

CVS patchset: 7536
CVS date: 2004/11/04 13:29:11
This commit is contained in:
jbj 2004-11-04 13:29:11 +00:00
parent 99012f2fab
commit afeddbf68d
15 changed files with 327 additions and 93 deletions

View File

@ -200,6 +200,8 @@ fprintf(stderr, "*** rootURL %s buildDirURL %s\n", rootURL, buildDirURL);
/*@=boundsread@*/
if (u != NULL) {
switch (u->urltype) {
case URL_IS_HTTPS:
case URL_IS_HTTP:
case URL_IS_FTP:
if (_build_debug)
fprintf(stderr, "*** addMacros\n");
@ -208,7 +210,6 @@ fprintf(stderr, "*** addMacros\n");
if (strcmp(rootDir, "/"))
addMacro(spec->macros, "_remroot", NULL, rootDir, RMIL_SPEC);
break;
case URL_IS_HTTP:
default:
break;
}
@ -250,8 +251,9 @@ exit:
}
if (u != NULL) {
switch (u->urltype) {
case URL_IS_FTP:
case URL_IS_HTTPS:
case URL_IS_HTTP:
case URL_IS_FTP:
if (_build_debug)
fprintf(stderr, "*** delMacros\n");
delMacro(spec->macros, "_remsh");

View File

@ -113,6 +113,7 @@ static int checkOwners(const char * urlfn)
fn = NULL;
urltype = urlPath(urlfn, &fn);
switch (urltype) {
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
@ -217,6 +218,7 @@ static int checkOwners(const char * urlfn)
fn = NULL;
urltype = urlPath(urlfn, &fn);
switch (urltype) {
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:

View File

@ -28,8 +28,9 @@ rpmRC rpmMkdirPath (const char * dpath, const char * dname)
if (errno != ENOENT)
break;
/*@fallthrough@*/
case URL_IS_FTP:
case URL_IS_HTTPS:
case URL_IS_HTTP:
case URL_IS_FTP:
rc = Mkdir(dpath, 0755);
break;
case URL_IS_DASH:
@ -163,10 +164,12 @@ int makeTempFile(const char * prefix, const char ** fnptr, FD_t * fdptr)
if (*tfn == '\0') goto errxit;
switch (temput) {
case URL_IS_HTTP:
case URL_IS_DASH:
goto errxit;
/*@notreached@*/ /*@switchbreak@*/ break;
case URL_IS_HTTPS:
case URL_IS_HTTP:
case URL_IS_FTP:
default:
/*@switchbreak@*/ break;
}

View File

@ -972,6 +972,9 @@ static rpmRC runScript(rpmpsm psm, Header h, const char * sln,
xx = execv(argv[0], (char *const *)argv);
/*@=nullstate@*/
break;
case URL_IS_HTTPS:
case URL_IS_HTTP:
case URL_IS_FTP:
default:
break;
}

View File

@ -416,8 +416,9 @@ if (fileURL[0] == '=') {
#endif
switch (urlIsURL(fileURL)) {
case URL_IS_FTP:
case URL_IS_HTTPS:
case URL_IS_HTTP:
case URL_IS_FTP:
{ const char *tfn;
if (rpmIsVerbose())

View File

@ -194,8 +194,9 @@ int domd5(const char * fn, unsigned char * digest, int asAscii, size_t *fsizep)
break;
} /*@fallthrough@*/
#endif
case URL_IS_FTP:
case URL_IS_HTTPS:
case URL_IS_HTTP:
case URL_IS_FTP:
case URL_IS_DASH:
default:
/* Either use the pipe to prelink -y or open the URL. */

View File

@ -3467,8 +3467,9 @@ static int rpmioFileExists(const char * urlfn)
if (*fn == '\0') fn = "/";
/*@=branchstate@*/
switch (urltype) {
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
case URL_IS_UNKNOWN:
if (Stat(fn, &buf)) {

View File

@ -193,6 +193,7 @@ Fts_open(char * const * argv, int options,
/*@=boundswrite@*/
goto mem3;
/*@notreached@*/ /*@switchbreak@*/ break;
case URL_IS_HTTPS:
case URL_IS_HTTP:
case URL_IS_FTP:
SET(FTS_NOCHDIR);

View File

@ -1741,6 +1741,7 @@ fprintf(stderr, "*** rpmGlob argv[%d] \"%s\"\n", argc, argv[argc]);
globURL = globRoot = xmalloc(maxb);
switch (ut) {
case URL_IS_HTTPS:
case URL_IS_HTTP:
case URL_IS_PATH:
case URL_IS_DASH:

View File

@ -105,6 +105,16 @@ static int ftpTimeoutSecs = TIMEOUT_SECS;
/*@unchecked@*/
static int httpTimeoutSecs = TIMEOUT_SECS;
/**
*/
/*@unchecked@*/
int _rpmio_debug = 0;
/**
*/
/*@unchecked@*/
int _av_debug = 0;
/**
*/
/*@unchecked@*/
@ -113,7 +123,7 @@ int _ftp_debug = 0;
/**
*/
/*@unchecked@*/
int _rpmio_debug = 0;
int _dav_debug = 0;
/**
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
@ -209,8 +219,9 @@ DBGIO(0, (stderr, "==>\tfdSize(%p) rc %ld\n", fd, (long)rc));
if (fstat(Fileno(fd), &sb) == 0)
rc = sb.st_size;
/*@fallthrough@*/
case URL_IS_FTP:
case URL_IS_HTTPS:
case URL_IS_HTTP:
case URL_IS_FTP:
case URL_IS_DASH:
break;
}
@ -695,8 +706,9 @@ const char *urlStrerror(const char *url)
const char *retstr;
/*@-branchstate@*/
switch (urlIsURL(url)) {
case URL_IS_FTP:
case URL_IS_HTTPS:
case URL_IS_HTTP:
case URL_IS_FTP:
{ urlinfo u;
/* XXX This only works for httpReq/ftpLogin/ftpReq failures */
if (urlSplit(url, &u) == 0) {
@ -1390,6 +1402,10 @@ static int urlConnect(const char * url, /*@out@*/ urlinfo * uret)
}
}
}
#ifdef NOTYET
if (u->urltype == URL_IS_HTTPS) {
}
#endif
/*@-boundswrite@*/
if (uret != NULL)
@ -1816,9 +1832,10 @@ static inline int ufdSeek(void * cookie, _libio_pos_t pos, int whence)
case URL_IS_UNKNOWN:
case URL_IS_PATH:
break;
case URL_IS_DASH:
case URL_IS_FTP:
case URL_IS_HTTPS:
case URL_IS_HTTP:
case URL_IS_FTP:
case URL_IS_DASH:
default:
return -2;
/*@notreached@*/ break;
@ -1896,6 +1913,7 @@ int ufdClose( /*@only@*/ void * cookie)
}
/* XXX Why not (u->urltype == URL_IS_HTTP) ??? */
/* XXX Why not (u->urltype == URL_IS_HTTPS) ??? */
if (u->service != NULL && !strcmp(u->service, "http")) {
if (fd->wr_chunked) {
int rc;
@ -2025,6 +2043,7 @@ static /*@null@*/ FD_t httpOpen(const char * url, /*@unused@*/ int flags,
fd->url = urlLink(u, "url (httpOpen)");
fd = fdLink(fd, "grab data (httpOpen)");
fd->urlType = URL_IS_HTTP;
/* XXX URL_IS_HTTPS */
}
exit:
@ -2073,6 +2092,7 @@ fprintf(stderr, "*** ufdOpen(%s,0x%x,0%o)\n", url, (unsigned)flags, (unsigned)mo
fd->wr_chunked = 0;
}
break;
case URL_IS_HTTPS:
case URL_IS_HTTP:
fd = httpOpen(url, flags, mode, &u);
if (fd == NULL || u == NULL)
@ -2978,6 +2998,7 @@ fprintf(stderr, "*** Fopen fdio path %s fmode %s\n", path, fmode);
/* XXX gzdio and bzdio here too */
switch (urlIsURL(path)) {
case URL_IS_HTTPS:
case URL_IS_HTTP:
isHTTP = 1;
/*@fallthrough@*/

View File

@ -181,11 +181,21 @@ struct _FD_s {
extern int _rpmio_debug;
/*@=redecl@*/
/*@-redecl@*/
/*@unchecked@*/
extern int _av_debug;
/*@=redecl@*/
/*@-redecl@*/
/*@unchecked@*/
extern int _ftp_debug;
/*@=redecl@*/
/*@-redecl@*/
/*@unchecked@*/
extern int _dav_debug;
/*@=redecl@*/
#define DBG(_f, _m, _x) \
/*@-modfilesys@*/ \
if ((_rpmio_debug | ((_f) ? ((FD_t)(_f))->flags : 0)) & (_m)) fprintf _x \

View File

@ -16,6 +16,19 @@
/*@access FD_t @*/
/*@access urlinfo @*/
/**
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
* @param p memory to free
* @retval NULL always
*/
/*@unused@*/ static inline /*@null@*/ void *
_free(/*@only@*/ /*@null@*/ /*@out@*/ const void * p)
/*@modifies p@*/
{
if (p != NULL) free((void *)p);
return NULL;
}
/* =============================================================== */
static int ftpMkdir(const char * path, /*@unused@*/ mode_t mode)
/*@globals h_errno, fileSystem, internalState @*/
@ -75,6 +88,7 @@ int Mkdir (const char * path, mode_t mode)
case URL_IS_FTP:
return ftpMkdir(path, mode);
/*@notreached@*/ break;
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
path = lpath;
@ -98,6 +112,7 @@ int Chdir (const char * path)
case URL_IS_FTP:
return ftpChdir(path);
/*@notreached@*/ break;
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
path = lpath;
@ -121,6 +136,7 @@ int Rmdir (const char * path)
case URL_IS_FTP:
return ftpRmdir(path);
/*@notreached@*/ break;
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
path = lpath;
@ -148,8 +164,9 @@ int Rename (const char * oldpath, const char * newpath)
oldut = urlPath(oldpath, &oe);
switch (oldut) {
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
case URL_IS_UNKNOWN:
break;
@ -169,6 +186,7 @@ fprintf(stderr, "*** rename old %*s new %*s\n", (int)(oe - oldpath), oldpath, (i
return -2;
return ftpRename(oldpath, newpath);
/*@notreached@*/ break;
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
oldpath = oe;
@ -192,8 +210,9 @@ int Link (const char * oldpath, const char * newpath)
oldut = urlPath(oldpath, &oe);
switch (oldut) {
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
case URL_IS_UNKNOWN:
break;
@ -205,6 +224,7 @@ int Link (const char * oldpath, const char * newpath)
newut = urlPath(newpath, &ne);
switch (newut) {
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
@ -236,6 +256,7 @@ int Unlink(const char * path) {
case URL_IS_FTP:
return ftpUnlink(path);
/*@notreached@*/ break;
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
path = lpath;
@ -1097,14 +1118,149 @@ struct __dirstream {
# define DT_LNK 10
# define DT_SOCK 12
# define DT_WHT 14
typedef struct __dirstream * FTPDIR;
typedef struct __dirstream * AVDIR;
#else
typedef DIR * FTPDIR;
typedef DIR * AVDIR;
#endif
/*@unchecked@*/
static int ftpmagicdir = 0x8440291;
#define ISFTPMAGIC(_dir) (!memcmp((_dir), &ftpmagicdir, sizeof(ftpmagicdir)))
static int avmagicdir = 0x3607113;
#define ISAVMAGIC(_dir) (!memcmp((_dir), &avmagicdir, sizeof(avmagicdir)))
/**
* Close an argv directory.
* @param dir argv DIR
* @return 0 always
*/
static int avClosedir(/*@only@*/ DIR * dir)
/*@globals fileSystem @*/
/*@modifies dir, fileSystem @*/
{
AVDIR avdir = (AVDIR)dir;
if (_av_debug)
fprintf(stderr, "*** avClosedir(%p)\n", avdir);
#if defined(HAVE_PTHREAD_H)
(void) pthread_mutex_destroy(&avdir->lock);
#endif
avdir = _free(avdir);
return 0;
}
/**
* Return next entry from an argv directory.
* @param dir argv DIR
* @return next entry
*/
/*@dependent@*/ /*@null@*/
static struct dirent * avReaddir(DIR * dir)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
AVDIR avdir = (AVDIR)dir;
struct dirent * dp;
const char ** av;
unsigned char * dt;
int ac;
int i;
if (avdir == NULL || !ISAVMAGIC(avdir) || avdir->data == NULL) {
/* XXX TODO: EBADF errno. */
return NULL;
}
dp = (struct dirent *) avdir->data;
av = (const char **) (dp + 1);
ac = avdir->size;
dt = (char *) (av + (ac + 1));
i = avdir->offset + 1;
/*@-boundsread@*/
if (i < 0 || i >= ac || av[i] == NULL)
return NULL;
/*@=boundsread@*/
avdir->offset = i;
/* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */
/*@-type@*/
dp->d_ino = i + 1; /* W2DO? */
dp->d_reclen = 0; /* W2DO? */
#if !defined(hpux) && !defined(sun)
dp->d_off = 0; /* W2DO? */
/*@-boundsread@*/
dp->d_type = dt[i];
/*@=boundsread@*/
#endif
/*@=type@*/
strncpy(dp->d_name, av[i], sizeof(dp->d_name));
if (_av_debug)
fprintf(stderr, "*** avReaddir(%p) %p \"%s\"\n", (void *)avdir, dp, dp->d_name);
return dp;
}
/**
* Create an argv directory from URL collection.
* @param path URL for collection path
* @return argv DIR
*/
/*@null@*/
static DIR * avOpendir(const char * path)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{
AVDIR avdir;
struct dirent * dp;
size_t nb = 0;
const char ** av;
unsigned char * dt;
char * t;
int ac;
if (_av_debug)
fprintf(stderr, "*** avOpendir(%s)\n", path);
nb = sizeof(".") + sizeof("..");
ac = 2;
nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1);
avdir = xcalloc(1, nb);
/*@-abstract@*/
dp = (struct dirent *) (avdir + 1);
av = (const char **) (dp + 1);
dt = (char *) (av + (ac + 1));
t = (char *) (dt + ac + 1);
/*@=abstract@*/
avdir->fd = avmagicdir;
/*@-usereleased@*/
avdir->data = (char *) dp;
/*@=usereleased@*/
avdir->allocation = nb;
avdir->size = ac;
avdir->offset = -1;
avdir->filepos = 0;
#if defined(HAVE_PTHREAD_H)
(void) pthread_mutex_init(&avdir->lock, NULL);
#endif
ac = 0;
/*@-dependenttrans -unrecog@*/
dt[ac] = DT_DIR; av[ac++] = t; t = stpcpy(t, "."); t++;
dt[ac] = DT_DIR; av[ac++] = t; t = stpcpy(t, ".."); t++;
/*@=dependenttrans =unrecog@*/
av[ac] = NULL;
/*@-kepttrans@*/
return (DIR *) avdir;
/*@=kepttrans@*/
}
/*@-boundswrite@*/
/*@null@*/
@ -1112,7 +1268,7 @@ static DIR * ftpOpendir(const char * path)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{
FTPDIR mydir;
AVDIR avdir;
struct dirent * dp;
size_t nb;
const char * s, * sb, * se;
@ -1160,23 +1316,27 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path);
}
}
nb += sizeof(*mydir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1);
mydir = xcalloc(1, nb);
nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1);
avdir = xcalloc(1, nb);
/*@-abstract@*/
dp = (struct dirent *) (mydir + 1);
dp = (struct dirent *) (avdir + 1);
av = (const char **) (dp + 1);
dt = (char *) (av + (ac + 1));
t = (char *) (dt + ac + 1);
/*@=abstract@*/
mydir->fd = ftpmagicdir;
avdir->fd = avmagicdir;
/*@-usereleased@*/
mydir->data = (char *) dp;
avdir->data = (char *) dp;
/*@=usereleased@*/
mydir->allocation = nb;
mydir->size = ac;
mydir->offset = -1;
mydir->filepos = 0;
avdir->allocation = nb;
avdir->size = ac;
avdir->offset = -1;
avdir->filepos = 0;
#if defined(HAVE_PTHREAD_H)
(void) pthread_mutex_init(&avdir->lock, NULL);
#endif
ac = 0;
/*@-dependenttrans -unrecog@*/
@ -1241,77 +1401,70 @@ fprintf(stderr, "*** ftpOpendir(%s)\n", path);
av[ac] = NULL;
/*@-kepttrans@*/
return (DIR *) mydir;
return (DIR *) avdir;
/*@=kepttrans@*/
}
/*@=boundswrite@*/
/*@dependent@*/ /*@null@*/
static struct dirent * ftpReaddir(DIR * dir)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
/*@-boundswrite@*/
/*@null@*/
static DIR * davOpendir(const char * path)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies fileSystem, internalState @*/
{
FTPDIR mydir = (FTPDIR)dir;
AVDIR avdir;
struct dirent * dp;
size_t nb;
const char ** av;
unsigned char * dt;
char * t;
int ac;
int i;
if (mydir == NULL || !ISFTPMAGIC(mydir) || mydir->data == NULL) {
/* XXX TODO: EBADF errno. */
return NULL;
}
if (_dav_debug)
fprintf(stderr, "*** davOpendir(%s)\n", path);
dp = (struct dirent *) mydir->data;
/* XXX read dav collection. */
nb = sizeof(".") + sizeof("..");
ac = 2;
nb += sizeof(*avdir) + sizeof(*dp) + ((ac + 1) * sizeof(*av)) + (ac + 1);
avdir = xcalloc(1, nb);
/*@-abstract@*/
dp = (struct dirent *) (avdir + 1);
av = (const char **) (dp + 1);
ac = mydir->size;
dt = (char *) (av + (ac + 1));
i = mydir->offset + 1;
t = (char *) (dt + ac + 1);
/*@=abstract@*/
/*@-boundsread@*/
if (i < 0 || i >= ac || av[i] == NULL)
return NULL;
/*@=boundsread@*/
avdir->fd = avmagicdir;
/*@-usereleased@*/
avdir->data = (char *) dp;
/*@=usereleased@*/
avdir->allocation = nb;
avdir->size = ac;
avdir->offset = -1;
avdir->filepos = 0;
mydir->offset = i;
/* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */
/*@-type@*/
dp->d_ino = i + 1; /* W2DO? */
dp->d_reclen = 0; /* W2DO? */
#if !defined(hpux) && !defined(sun)
dp->d_off = 0; /* W2DO? */
/*@-boundsread@*/
dp->d_type = dt[i];
/*@=boundsread@*/
#if defined(HAVE_PTHREAD_H)
(void) pthread_mutex_init(&avdir->lock, NULL);
#endif
/*@=type@*/
strncpy(dp->d_name, av[i], sizeof(dp->d_name));
if (_ftp_debug)
fprintf(stderr, "*** ftpReaddir(%p) %p \"%s\"\n", (void *)mydir, dp, dp->d_name);
return dp;
}
static int ftpClosedir(/*@only@*/ DIR * dir)
/*@globals fileSystem @*/
/*@modifies dir, fileSystem @*/
{
FTPDIR mydir = (FTPDIR)dir;
if (_ftp_debug)
fprintf(stderr, "*** ftpClosedir(%p)\n", (void *)mydir);
if (mydir == NULL || !ISFTPMAGIC(mydir)) {
/* XXX TODO: EBADF errno. */
return -1;
}
free((void *)mydir);
mydir = NULL;
return 0;
ac = 0;
/*@-dependenttrans -unrecog@*/
dt[ac] = DT_DIR; av[ac++] = t; t = stpcpy(t, "."); t++;
dt[ac] = DT_DIR; av[ac++] = t; t = stpcpy(t, ".."); t++;
/*@=dependenttrans =unrecog@*/
/* XXX load dav collection. */
av[ac] = NULL;
/*@-kepttrans@*/
return (DIR *) avdir;
/*@=kepttrans@*/
}
/*@=boundswrite@*/
int Stat(const char * path, struct stat * st)
{
@ -1324,6 +1477,7 @@ fprintf(stderr, "*** Stat(%s,%p)\n", path, st);
case URL_IS_FTP:
return ftpStat(path, st);
/*@notreached@*/ break;
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
path = lpath;
@ -1349,6 +1503,7 @@ fprintf(stderr, "*** Lstat(%s,%p)\n", path, st);
case URL_IS_FTP:
return ftpLstat(path, st);
/*@notreached@*/ break;
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
path = lpath;
@ -1372,6 +1527,7 @@ int Readlink(const char * path, char * buf, size_t bufsiz)
case URL_IS_FTP:
return ftpReadlink(path, buf, bufsiz);
/*@notreached@*/ break;
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
path = lpath;
@ -1396,8 +1552,9 @@ int Access(const char * path, int amode)
if (_rpmio_debug)
fprintf(stderr, "*** Access(%s,%d)\n", path, amode);
switch (ut) {
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_FTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
path = lpath;
/*@fallthrough@*/
@ -1468,6 +1625,7 @@ if (_rpmio_debug)
fprintf(stderr, "*** Glob(%s,0x%x,%p,%p)\n", pattern, (unsigned)flags, (void *)errfunc, pglob);
/*@=castfcnptr@*/
switch (ut) {
case URL_IS_HTTPS:
case URL_IS_FTP:
/*@-type@*/
pglob->gl_closedir = Closedir;
@ -1513,6 +1671,9 @@ fprintf(stderr, "*** Opendir(%s)\n", path);
case URL_IS_FTP:
return ftpOpendir(path);
/*@notreached@*/ break;
case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */
return davOpendir(path);
/*@notreached@*/ break;
case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */
case URL_IS_PATH:
path = lpath;
@ -1533,8 +1694,10 @@ struct dirent * Readdir(DIR * dir)
{
if (_rpmio_debug)
fprintf(stderr, "*** Readdir(%p)\n", (void *)dir);
if (dir == NULL || ISFTPMAGIC(dir))
return ftpReaddir(dir);
if (dir == NULL)
return NULL;
if (ISAVMAGIC(dir))
return avReaddir(dir);
return readdir(dir);
}
@ -1542,7 +1705,9 @@ int Closedir(DIR * dir)
{
if (_rpmio_debug)
fprintf(stderr, "*** Closedir(%p)\n", (void *)dir);
if (dir == NULL || ISFTPMAGIC(dir))
return ftpClosedir(dir);
if (dir == NULL)
return 0;
if (ISAVMAGIC(dir))
return avClosedir(dir);
return closedir(dir);
}

View File

@ -15,7 +15,8 @@ typedef enum urltype_e {
URL_IS_DASH = 1, /*!< stdin/stdout */
URL_IS_PATH = 2, /*!< file://... */
URL_IS_FTP = 3, /*!< ftp://... */
URL_IS_HTTP = 4 /*!< http://... */
URL_IS_HTTP = 4, /*!< http://... */
URL_IS_HTTPS = 5 /*!< https://... */
} urltype;
#define URLMAGIC 0xd00b1ed0

View File

@ -9,10 +9,12 @@
static int _debug = 0;
#define FTPPATH "ftp://porkchop/mnt/redhat/beehive/comps/dist/7.2-rpm"
#define DIRPATH "/mnt/redhat/beehive/comps/dist/7.2-rpm"
static char * dirpath = DIRPATH;
#define HTTPPATH "https://wellfleet.jbj.org/rawhide/test/"
#define FTPPATH "ftp://wellfleet.jbj.org/pub/rawhide/packages/test/"
#define DIRPATH "/var/ftp/pub/rawhide/packages/test"
static char * httppath = HTTPPATH;
static char * ftppath = FTPPATH;
static char * dirpath = DIRPATH;
static void printDir(const char * path)
{
@ -69,8 +71,12 @@ main(int argc, const char *argv[])
rpmIncreaseVerbosity();
}
_av_debug = -1;
_ftp_debug = -1;
_dav_debug = -1;
printDir(dirpath);
printDir(ftppath);
printDir(httppath);
return 0;
}

View File

@ -21,6 +21,9 @@
#ifndef IPPORT_HTTP
#define IPPORT_HTTP 80
#endif
#ifndef IPPORT_HTTPS
#define IPPORT_HTTPS 443
#endif
/**
*/
@ -299,7 +302,7 @@ static void urlFind(/*@null@*/ /*@in@*/ /*@out@*/ urlinfo * uret, int mustAsk)
}
/* Perform one-time HTTP initialization */
if (u->urltype == URL_IS_HTTP) {
if (u->urltype == URL_IS_HTTP || u->urltype == URL_IS_HTTPS) {
if (u->proxyh == NULL) {
const char *proxy = rpmExpand("%{_httpproxy}", NULL);
@ -341,6 +344,7 @@ static struct urlstring {
{ "file://", URL_IS_PATH },
{ "ftp://", URL_IS_FTP },
{ "http://", URL_IS_HTTP },
{ "https://", URL_IS_HTTPS },
{ "-", URL_IS_DASH },
{ NULL, URL_IS_UNKNOWN }
};
@ -378,12 +382,21 @@ urltype urlPath(const char * url, const char ** pathp)
path = strchr(url, '/');
if (path == NULL) path = url + strlen(url);
break;
case URL_IS_HTTP:
case URL_IS_PATH:
url += sizeof("file://") - 1;
path = strchr(url, '/');
if (path == NULL) path = url + strlen(url);
break;
case URL_IS_HTTP:
url += sizeof("http://") - 1;
path = strchr(url, '/');
if (path == NULL) path = url + strlen(url);
break;
case URL_IS_HTTPS:
url += sizeof("https://") - 1;
path = strchr(url, '/');
if (path == NULL) path = url + strlen(url);
break;
case URL_IS_UNKNOWN:
if (path == NULL) path = "";
break;
@ -489,6 +502,8 @@ int urlSplit(const char * url, urlinfo *uret)
u->port = IPPORT_FTP;
else if (u->urltype == URL_IS_HTTP)
u->port = IPPORT_HTTP;
else if (u->urltype == URL_IS_HTTPS)
u->port = IPPORT_HTTPS;
}
myurl = _free(myurl);
@ -542,8 +557,9 @@ fprintf(stderr, "*** urlGetFile sfd %p %s tfd %p %s\n", sfd, url, (tfd ? tfd : N
}
switch (urlType) {
case URL_IS_FTP:
case URL_IS_HTTPS:
case URL_IS_HTTP:
case URL_IS_FTP:
case URL_IS_PATH:
case URL_IS_DASH:
case URL_IS_UNKNOWN: