The death of lib/ftp.c, merged into lib/rpmio.c.
Start composting the rpmio API. Preliminary (not working) support for HTTP PUT. build.c: Check fd for NULL and use Ferror() for Fopen return. build/parseSpec.c: ditto build/pack.c: Use fdGetFP() rather than fpio->ffileno(). build/parseSpec.c: ditto build/pack.c: Use Stat/Mkdir wrappers. build/pack.c: Do Fflush before fdDup so that writes can remain buffered. lib/install.c: ditto build/parsePrep.c: Skip over URL leadin when writing %prep scriptlet. lib/misc.c: Rewrite to use simpler urlPath(). Restore checks on local fs. lib/rpmchecksig.c: Open with "r+" rather than "w" to avoid truncation. lib/url.c: Do lazy malloc of u->buf in rpmio.c checkResponse(). lib/rpmio.c: Make persist/contentLength per-fd rather than per-url. lib/rpmio.c: Add wr_chunked method for HTTP PUT (still broken). lib/rpmio.c: ftpAbort() should use timedRead. lib/rpmio.c: Add Fflush(). lib/url.c: urlPath() should return something ("/") on url = NULL (paranoia). lib/url.c: urlSplit() should return something ("/") on url w/o path. CVS patchset: 3429 CVS date: 1999/11/18 18:07:46
This commit is contained in:
parent
3a6118d419
commit
1f6614e61e
3
build.c
3
build.c
|
@ -60,8 +60,7 @@ static int isSpecFile(const char *specfile)
|
|||
int checking;
|
||||
|
||||
fd = Fopen(specfile, "r.ufdio");
|
||||
if (Ferror(fd)) {
|
||||
/* XXX Fstrerror */
|
||||
if (fd == NULL || Ferror(fd)) {
|
||||
fprintf(stderr, _("Unable to open spec file %s: %s\n"), specfile, Fstrerror(fd));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ int doScript(Spec spec, int what, const char *name, StringBuf sb, int test)
|
|||
int pid;
|
||||
int status;
|
||||
char buf[BUFSIZ];
|
||||
FILE * fp = NULL;
|
||||
|
||||
switch (what) {
|
||||
case RPMBUILD_PREP:
|
||||
|
@ -93,29 +94,30 @@ int doScript(Spec spec, int what, const char *name, StringBuf sb, int test)
|
|||
#else
|
||||
xfd = Fdopen(fd, "w.fpio");
|
||||
#endif
|
||||
fp = fdGetFp(fd);
|
||||
|
||||
strcpy(buf, _preScriptEnvironment);
|
||||
expandMacros(spec, spec->macros, buf, sizeof(buf));
|
||||
strcat(buf, "\n");
|
||||
fputs(buf, fpio->ffileno(xfd));
|
||||
fputs(buf, fp);
|
||||
|
||||
fprintf(fpio->ffileno(xfd), rpmIsVerbose() ? "set -x\n\n" : "exec > /dev/null\n\n");
|
||||
fprintf(fp, rpmIsVerbose() ? "set -x\n\n" : "exec > /dev/null\n\n");
|
||||
|
||||
/* XXX umask 022; cd %{_builddir} */
|
||||
strcpy(buf, _preScriptChdir);
|
||||
expandMacros(spec, spec->macros, buf, sizeof(buf));
|
||||
fputs(buf, fpio->ffileno(xfd));
|
||||
fputs(buf, fp);
|
||||
|
||||
if (what != RPMBUILD_PREP && what != RPMBUILD_RMBUILD) {
|
||||
if (spec->buildSubdir)
|
||||
fprintf(fpio->ffileno(xfd), "cd %s\n", spec->buildSubdir);
|
||||
fprintf(fp, "cd %s\n", spec->buildSubdir);
|
||||
}
|
||||
if (what == RPMBUILD_RMBUILD) {
|
||||
if (spec->buildSubdir)
|
||||
fprintf(fpio->ffileno(xfd), "rm -rf %s\n", spec->buildSubdir);
|
||||
fprintf(fp, "rm -rf %s\n", spec->buildSubdir);
|
||||
} else
|
||||
fprintf(fpio->ffileno(xfd), "%s", getStringBuf(sb));
|
||||
fprintf(fpio->ffileno(xfd), "\nexit 0\n");
|
||||
fprintf(fp, "%s", getStringBuf(sb));
|
||||
fprintf(fp, "\nexit 0\n");
|
||||
|
||||
Fclose(xfd);
|
||||
|
||||
|
|
|
@ -137,10 +137,10 @@ int packageBinaries(Spec spec)
|
|||
const char *dn;
|
||||
*binDir = '\0';
|
||||
dn = rpmGetPath("%{_rpmdir}/", binRpm, NULL);
|
||||
if (stat(dn, &st) < 0) {
|
||||
if (Stat(dn, &st) < 0) {
|
||||
switch(errno) {
|
||||
case ENOENT:
|
||||
if (mkdir(dn, 0755) == 0)
|
||||
if (Mkdir(dn, 0755) == 0)
|
||||
break;
|
||||
/*@fallthrough@*/
|
||||
default:
|
||||
|
@ -433,6 +433,7 @@ static int cpio_doio(FD_t fdo, CSA_t * csa, const char * fmode)
|
|||
int rc;
|
||||
const char *failedFile = NULL;
|
||||
|
||||
(void) Fflush(fdo);
|
||||
#ifndef DYING
|
||||
cfd = Fdopen(fdDup(Fileno(fdo)), fmode);
|
||||
#else
|
||||
|
|
|
@ -276,9 +276,14 @@ static int doSetupMacro(Spec spec, char *line)
|
|||
poptFreeContext(optCon);
|
||||
|
||||
/* cd to the build dir */
|
||||
strcpy(buf, "cd %{_builddir}");
|
||||
expandMacros(spec, spec->macros, buf, sizeof(buf));
|
||||
appendLineStringBuf(spec->prep, buf);
|
||||
{ const char * buildURL = rpmGenPath(spec->rootdir, "%{_builddir}", "");
|
||||
const char *buildDir;
|
||||
|
||||
(void) urlPath(buildURL, &buildDir);
|
||||
sprintf(buf, "cd %s", buildDir);
|
||||
appendLineStringBuf(spec->prep, buf);
|
||||
xfree(buildURL);
|
||||
}
|
||||
|
||||
/* delete any old sources */
|
||||
if (!leaveDirs) {
|
||||
|
|
|
@ -169,7 +169,8 @@ int readLine(Spec spec, int strip)
|
|||
retry:
|
||||
/* Make sure the current file is open */
|
||||
if (ofi->fd == NULL) {
|
||||
if ((ofi->fd = Fopen(ofi->fileName, "r.fpio")) == NULL) {
|
||||
ofi->fd = Fopen(ofi->fileName, "r.fpio");
|
||||
if (ofi->fd == NULL || Ferror(ofi->fd)) {
|
||||
/* XXX Fstrerror */
|
||||
rpmError(RPMERR_BADSPEC, _("Unable to open %s: %s\n"),
|
||||
ofi->fileName, Fstrerror(ofi->fd));
|
||||
|
@ -180,7 +181,7 @@ retry:
|
|||
|
||||
/* Make sure we have something in the read buffer */
|
||||
if (!(ofi->readPtr && *(ofi->readPtr))) {
|
||||
if (!fgets(ofi->readBuf, BUFSIZ, fpio->ffileno(ofi->fd))) {
|
||||
if (!fgets(ofi->readBuf, BUFSIZ, fdGetFp(ofi->fd))) {
|
||||
/* EOF */
|
||||
if (spec->readStack->next) {
|
||||
rpmError(RPMERR_UNMATCHEDIF, _("Unclosed %%if"));
|
||||
|
|
|
@ -25,7 +25,7 @@ mylibs= $(top_builddir)/lib/.libs/librpm.a \
|
|||
lib_LTLIBRARIES = librpm.la
|
||||
librpm_la_SOURCES = \
|
||||
cpio.c dbindex.c depends.c falloc.c \
|
||||
formats.c fprint.c fs.c ftp.c hash.c header.c install.c \
|
||||
formats.c fprint.c fs.c hash.c header.c install.c \
|
||||
lookup.c macro.c md5.c md5sum.c \
|
||||
messages.c misc.c oldheader.c package.c problems.c query.c \
|
||||
rebuilddb.c rpmchecksig.c rpmdb.c rpmerr.c rpminstall.c \
|
||||
|
|
663
lib/ftp.c
663
lib/ftp.c
|
@ -1,663 +0,0 @@
|
|||
#include "system.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#if !defined(HAVE_CONFIG_H)
|
||||
#define HAVE_MACHINE_TYPES_H 1
|
||||
#define HAVE_ALLOCA_H 1
|
||||
#define HAVE_NETINET_IN_SYSTM_H 1
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
#endif
|
||||
|
||||
#if ! HAVE_HERRNO
|
||||
extern int h_errno;
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __LCLINT__
|
||||
#define ntohl(_x) (_x)
|
||||
#define ntohs(_x) (_x)
|
||||
#define htonl(_x) (_x)
|
||||
#define htons(_x) (_x)
|
||||
typedef unsigned int uint32_t;
|
||||
#define INADDR_ANY ((uint32_t) 0x00000000)
|
||||
#define IPPROTO_IP 0
|
||||
extern int h_errno;
|
||||
|
||||
#else /* __LCLINT__ */
|
||||
|
||||
#if HAVE_MACHINE_TYPES_H
|
||||
# include <machine/types.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_NETINET_IN_SYSTM_H
|
||||
# include <sys/types.h>
|
||||
# include <netinet/in_systm.h>
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/telnet.h>
|
||||
#endif /* __LCLINT__ */
|
||||
|
||||
#include <rpmlib.h>
|
||||
|
||||
#if !defined(HAVE_INET_ATON)
|
||||
int inet_aton(const char *cp, struct in_addr *inp);
|
||||
#endif
|
||||
|
||||
#if defined(USE_ALT_DNS) && USE_ALT_DNS
|
||||
#include "dns.h"
|
||||
#endif
|
||||
|
||||
#include <rpmurl.h>
|
||||
/*@access urlinfo@*/
|
||||
|
||||
#ifdef __MINT__
|
||||
# ifndef EAGAIN
|
||||
# define EAGAIN EWOULDBLOCK
|
||||
# endif
|
||||
# ifndef O_NONBLOCK
|
||||
# define O_NONBLOCK O_NDELAY
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int _ftp_debug = 0;
|
||||
#define DBG(_f, _x) if ((_ftp_debug | (_f))) fprintf _x
|
||||
|
||||
static int checkResponse(urlinfo u, /*@out@*/ int *ecp, /*@out@*/ char ** str)
|
||||
{
|
||||
char *buf;
|
||||
size_t bufAlloced;
|
||||
int bufLength = 0;
|
||||
const char *s;
|
||||
char *se;
|
||||
int ec = 0;
|
||||
int moretodo = 1;
|
||||
char errorCode[4];
|
||||
|
||||
URLSANE(u);
|
||||
buf = u->buf;
|
||||
bufAlloced = u->bufAlloced;
|
||||
*buf = '\0';
|
||||
|
||||
errorCode[0] = '\0';
|
||||
|
||||
do {
|
||||
int rc;
|
||||
|
||||
/*
|
||||
* Read next line from server.
|
||||
*/
|
||||
se = buf + bufLength;
|
||||
*se = '\0';
|
||||
rc = fdRdline(u->ctrl, se, (bufAlloced - bufLength));
|
||||
if (rc < 0) {
|
||||
ec = FTPERR_BAD_SERVER_RESPONSE;
|
||||
continue;
|
||||
} else if (rc == 0 || fdWritable(u->ctrl, 0) < 1)
|
||||
moretodo = 0;
|
||||
|
||||
/*
|
||||
* Process next line from server.
|
||||
*/
|
||||
for (s = se; *s != '\0'; s = se) {
|
||||
const char *e;
|
||||
|
||||
while (*se && *se != '\n') se++;
|
||||
|
||||
if (se > s && se[-1] == '\r')
|
||||
se[-1] = '\0';
|
||||
if (*se == '\0')
|
||||
break;
|
||||
|
||||
DBG(0, (stderr, "<- %s\n", s));
|
||||
|
||||
/* HTTP: header termination on empty line */
|
||||
if (*s == '\0') {
|
||||
moretodo = 0;
|
||||
break;
|
||||
}
|
||||
*se++ = '\0';
|
||||
|
||||
/* HTTP: look for "HTTP/1.1 123 ..." */
|
||||
if (!strncmp(s, "HTTP", sizeof("HTTP")-1)) {
|
||||
u->httpContentLength = -1;
|
||||
if ((e = strchr(s, '.')) != NULL) {
|
||||
e++;
|
||||
u->httpVersion = *e - '0';
|
||||
if (u->httpVersion < 1 || u->httpVersion > 2)
|
||||
u->httpPersist = u->httpVersion = 0;
|
||||
else
|
||||
u->httpPersist = 1;
|
||||
}
|
||||
if ((e = strchr(s, ' ')) != NULL) {
|
||||
e++;
|
||||
if (strchr("0123456789", *e))
|
||||
strncpy(errorCode, e, 3);
|
||||
errorCode[3] = '\0';
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* HTTP: look for "token: ..." */
|
||||
for (e = s; *e && !(*e == ' ' || *e == ':'); e++)
|
||||
;
|
||||
if (e > s && *e++ == ':') {
|
||||
size_t ne = (e - s);
|
||||
while (*e && *e == ' ') e++;
|
||||
#if 0
|
||||
if (!strncmp(s, "Date:", ne)) {
|
||||
} else
|
||||
if (!strncmp(s, "Server:", ne)) {
|
||||
} else
|
||||
if (!strncmp(s, "Last-Modified:", ne)) {
|
||||
} else
|
||||
if (!strncmp(s, "ETag:", ne)) {
|
||||
} else
|
||||
#endif
|
||||
if (!strncmp(s, "Accept-Ranges:", ne)) {
|
||||
if (!strcmp(e, "bytes"))
|
||||
u->httpHasRange = 1;
|
||||
if (!strcmp(e, "none"))
|
||||
u->httpHasRange = 0;
|
||||
} else
|
||||
if (!strncmp(s, "Content-Length:", ne)) {
|
||||
if (strchr("0123456789", *e))
|
||||
u->httpContentLength = atoi(e);
|
||||
} else
|
||||
if (!strncmp(s, "Connection:", ne)) {
|
||||
if (!strcmp(e, "close"))
|
||||
u->httpPersist = 0;
|
||||
} else
|
||||
#if 0
|
||||
if (!strncmp(s, "Content-Type:", ne)) {
|
||||
} else
|
||||
if (!strncmp(s, "Transfer-Encoding:", ne)) {
|
||||
} else
|
||||
if (!strncmp(s, "Allow:", ne)) {
|
||||
} else
|
||||
#endif
|
||||
;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* HTTP: look for "<TITLE>501 ... </TITLE>" */
|
||||
if (!strncmp(s, "<TITLE>", sizeof("<TITLE>")-1))
|
||||
s += sizeof("<TITLE>") - 1;
|
||||
|
||||
/* FTP: look for "123-" and/or "123 " */
|
||||
if (strchr("0123456789", *s)) {
|
||||
if (errorCode[0]) {
|
||||
if (!strncmp(s, errorCode, sizeof("123")-1) && s[3] == ' ')
|
||||
moretodo = 0;
|
||||
} else {
|
||||
strncpy(errorCode, s, sizeof("123")-1);
|
||||
errorCode[3] = '\0';
|
||||
if (s[3] != '-')
|
||||
moretodo = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (moretodo && se > s) {
|
||||
bufLength = se - s - 1;
|
||||
if (s != buf)
|
||||
memcpy(buf, s, bufLength);
|
||||
} else {
|
||||
bufLength = 0;
|
||||
}
|
||||
} while (moretodo && ec == 0);
|
||||
|
||||
if (str) *str = buf;
|
||||
if (ecp) *ecp = atoi(errorCode);
|
||||
|
||||
return ec;
|
||||
}
|
||||
|
||||
int ftpCheckResponse(urlinfo u, /*@out@*/ char ** str)
|
||||
{
|
||||
int ec = 0;
|
||||
int rc;
|
||||
|
||||
URLSANE(u);
|
||||
rc = checkResponse(u, &ec, str);
|
||||
|
||||
switch (ec) {
|
||||
case 550:
|
||||
return FTPERR_FILE_NOT_FOUND;
|
||||
/*@notreached@*/ break;
|
||||
case 552:
|
||||
return FTPERR_NIC_ABORT_IN_PROGRESS;
|
||||
/*@notreached@*/ break;
|
||||
default:
|
||||
if (ec >= 400 && ec <= 599)
|
||||
return FTPERR_BAD_SERVER_RESPONSE;
|
||||
break;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
int ftpCommand(urlinfo u, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int len = 0;
|
||||
const char * s, * t;
|
||||
char * te;
|
||||
int rc;
|
||||
|
||||
URLSANE(u);
|
||||
va_start(ap, u);
|
||||
while ((s = va_arg(ap, const char *)) != NULL) {
|
||||
if (len) len++;
|
||||
len += strlen(s);
|
||||
}
|
||||
len += sizeof("\r\n")-1;
|
||||
va_end(ap);
|
||||
|
||||
t = te = alloca(len + 1);
|
||||
|
||||
va_start(ap, u);
|
||||
while ((s = va_arg(ap, const char *)) != NULL) {
|
||||
if (te > t) *te++ = ' ';
|
||||
te = stpcpy(te, s);
|
||||
}
|
||||
te = stpcpy(te, "\r\n");
|
||||
va_end(ap);
|
||||
|
||||
DBG(0, (stderr, "-> %s", t));
|
||||
if (fdio->write(u->ctrl, t, (te-t)) != (te-t))
|
||||
return FTPERR_SERVER_IO_ERROR;
|
||||
|
||||
rc = ftpCheckResponse(u, NULL);
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if !defined(USE_ALT_DNS) || !USE_ALT_DNS
|
||||
static int mygethostbyname(const char * host, struct in_addr * address)
|
||||
{
|
||||
struct hostent * hostinfo;
|
||||
|
||||
hostinfo = /*@-unrecog@*/ gethostbyname(host) /*@=unrecog@*/;
|
||||
if (!hostinfo) return 1;
|
||||
|
||||
memcpy(address, hostinfo->h_addr_list[0], sizeof(*address));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int getHostAddress(const char * host, struct in_addr * address)
|
||||
{
|
||||
if (isdigit(host[0])) {
|
||||
if (! /*@-unrecog@*/ inet_aton(host, address) /*@=unrecog@*/ ) {
|
||||
return FTPERR_BAD_HOST_ADDR;
|
||||
}
|
||||
} else {
|
||||
if (mygethostbyname(host, address)) {
|
||||
errno = h_errno;
|
||||
return FTPERR_BAD_HOSTNAME;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tcpConnect(FD_t ctrl, const char *host, int port)
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
int fdno = -1;
|
||||
int rc;
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(port);
|
||||
sin.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
do {
|
||||
if ((rc = getHostAddress(host, &sin.sin_addr)) < 0)
|
||||
break;
|
||||
|
||||
if ((fdno = socket(sin.sin_family, SOCK_STREAM, IPPROTO_IP)) < 0) {
|
||||
rc = FTPERR_FAILED_CONNECT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (connect(fdno, (struct sockaddr *) &sin, sizeof(sin))) {
|
||||
rc = FTPERR_FAILED_CONNECT;
|
||||
break;
|
||||
}
|
||||
} while (0);
|
||||
|
||||
if (rc < 0)
|
||||
goto errxit;
|
||||
|
||||
DBG(0, (stderr,"++ connect %s:%d on fdno %d\n",
|
||||
/*@-unrecog@*/ inet_ntoa(sin.sin_addr) /*@=unrecog@*/ ,
|
||||
ntohs(sin.sin_port), fdno));
|
||||
|
||||
return fdno;
|
||||
|
||||
errxit:
|
||||
fdSetSyserrno(ctrl, errno, ftpStrerror(rc));
|
||||
if (fdno >= 0)
|
||||
close(fdno);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int httpOpen(urlinfo u, FD_t ctrl, const char *httpcmd)
|
||||
{
|
||||
const char *host;
|
||||
const char *path;
|
||||
int port;
|
||||
int rc;
|
||||
char *req;
|
||||
size_t len;
|
||||
int retrying = 0;
|
||||
|
||||
URLSANE(u);
|
||||
assert(ctrl != NULL);
|
||||
|
||||
if (((host = (u->proxyh ? u->proxyh : u->host)) == NULL))
|
||||
return FTPERR_BAD_HOSTNAME;
|
||||
|
||||
if ((port = (u->proxyp > 0 ? u->proxyp : u->port)) < 0) port = 80;
|
||||
path = (u->proxyh || u->proxyp > 0) ? u->url : u->path;
|
||||
|
||||
reopen:
|
||||
if (fdio->fileno(ctrl) >= 0 && (rc = fdWritable(ctrl, 0)) < 1) {
|
||||
if (_ftp_debug)
|
||||
fprintf(stderr, "*** httpOpen closing ctrl fdno %d rc %d\n", fdio->fileno(ctrl), rc);
|
||||
fdio->close(ctrl);
|
||||
}
|
||||
|
||||
if (fdio->fileno(ctrl) < 0) {
|
||||
rc = tcpConnect(ctrl, host, port);
|
||||
fdSetFdno(ctrl, (rc >= 0 ? rc : -1));
|
||||
if (rc < 0)
|
||||
goto errxit2;
|
||||
|
||||
ctrl = fdLink(ctrl, "open ctrl (httpOpen)");
|
||||
}
|
||||
|
||||
len = sizeof("\
|
||||
req x HTTP/1.0\r\n\
|
||||
User-Agent: rpm/3.0.4\r\n\
|
||||
Host: y:z\r\n\
|
||||
Accept: text/plain\r\n\
|
||||
\r\n\
|
||||
") + strlen(httpcmd) + strlen(path) + sizeof(VERSION) + strlen(host) + 20;
|
||||
|
||||
req = alloca(len);
|
||||
*req = '\0';
|
||||
|
||||
sprintf(req, "\
|
||||
%s %s HTTP/1.%d\r\n\
|
||||
User-Agent: rpm/%s\r\n\
|
||||
Host: %s:%d\r\n\
|
||||
Accept: text/plain\r\n\
|
||||
\r\n\
|
||||
", httpcmd, path, (u->httpVersion ? 1 : 0), VERSION, host, port);
|
||||
|
||||
DBG(0, (stderr, "-> %s", req));
|
||||
|
||||
if (fdio->write(ctrl, req, len) != len) {
|
||||
rc = FTPERR_SERVER_IO_ERROR;
|
||||
goto errxit;
|
||||
}
|
||||
|
||||
{ int ec = 0;
|
||||
rc = checkResponse(u, &ec, NULL);
|
||||
|
||||
if (_ftp_debug && !(rc == 0 && ec == 200))
|
||||
fprintf(stderr, "*** httpOpen: rc %d ec %d\n", rc, ec);
|
||||
|
||||
switch (rc) {
|
||||
case 0:
|
||||
if (ec == 200)
|
||||
break;
|
||||
/*@fallthrough@*/
|
||||
default:
|
||||
if (!retrying) { /* not HTTP_OK */
|
||||
if (_ftp_debug)
|
||||
fprintf(stderr, "*** httpOpen ctrl %p reopening ...\n", ctrl);
|
||||
retrying = 1;
|
||||
fdio->close(ctrl);
|
||||
goto reopen;
|
||||
}
|
||||
rc = FTPERR_FILE_NOT_FOUND;
|
||||
goto errxit;
|
||||
/*@notreached@*/ break;
|
||||
}
|
||||
}
|
||||
|
||||
ctrl = fdLink(ctrl, "open data (httpOpen)");
|
||||
return fdio->fileno(ctrl);
|
||||
|
||||
errxit:
|
||||
fdSetSyserrno(ctrl, errno, ftpStrerror(rc));
|
||||
errxit2:
|
||||
if (fdio->fileno(ctrl) >= 0)
|
||||
fdio->close(ctrl);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int ftpOpen(urlinfo u)
|
||||
{
|
||||
const char * host;
|
||||
const char * user;
|
||||
const char * password;
|
||||
int port;
|
||||
int rc;
|
||||
|
||||
URLSANE(u);
|
||||
if (((host = (u->proxyh ? u->proxyh : u->host)) == NULL)) {
|
||||
rc = FTPERR_BAD_HOSTNAME;
|
||||
goto errxit;
|
||||
}
|
||||
|
||||
if ((port = (u->proxyp > 0 ? u->proxyp : u->port)) < 0) port = IPPORT_FTP;
|
||||
|
||||
if ((user = (u->proxyu ? u->proxyu : u->user)) == NULL)
|
||||
user = "anonymous";
|
||||
|
||||
if ((password = u->password) == NULL) {
|
||||
if (getuid()) {
|
||||
struct passwd * pw = getpwuid(getuid());
|
||||
char *myp = alloca(strlen(pw->pw_name) + sizeof("@"));
|
||||
strcpy(myp, pw->pw_name);
|
||||
strcat(myp, "@");
|
||||
password = myp;
|
||||
} else {
|
||||
password = "root@";
|
||||
}
|
||||
}
|
||||
|
||||
if (fdio->fileno(u->ctrl) >= 0 && fdWritable(u->ctrl, 0) < 1)
|
||||
fdio->close(u->ctrl);
|
||||
|
||||
if (fdio->fileno(u->ctrl) < 0) {
|
||||
rc = tcpConnect(u->ctrl, host, port);
|
||||
fdSetFdno(u->ctrl, (rc >= 0 ? rc : -1));
|
||||
if (rc < 0)
|
||||
goto errxit2;
|
||||
}
|
||||
|
||||
if ((rc = ftpCheckResponse(u, NULL)))
|
||||
goto errxit;
|
||||
|
||||
if ((rc = ftpCommand(u, "USER", user, NULL)))
|
||||
goto errxit;
|
||||
|
||||
if ((rc = ftpCommand(u, "PASS", password, NULL)))
|
||||
goto errxit;
|
||||
|
||||
if ((rc = ftpCommand(u, "TYPE", "I", NULL)))
|
||||
goto errxit;
|
||||
|
||||
u->ctrl = fdLink(u->ctrl, "open ctrl");
|
||||
return fdio->fileno(u->ctrl);
|
||||
|
||||
errxit:
|
||||
fdSetSyserrno(u->ctrl, errno, ftpStrerror(rc));
|
||||
errxit2:
|
||||
if (fdio->fileno(u->ctrl) >= 0)
|
||||
fdio->close(u->ctrl);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int ftpFileDone(urlinfo u, FD_t data)
|
||||
{
|
||||
int rc = 0;
|
||||
int ftpFileDoneNeeded;
|
||||
|
||||
URLSANE(u);
|
||||
ftpFileDoneNeeded = fdGetFtpFileDoneNeeded(data);
|
||||
assert(ftpFileDoneNeeded);
|
||||
|
||||
if (ftpFileDoneNeeded) {
|
||||
fdSetFtpFileDoneNeeded(data, 0);
|
||||
u->ctrl = fdFree(u->ctrl, "open data (ftpFileDone)");
|
||||
u->ctrl = fdFree(u->ctrl, "grab data (ftpFileDone)");
|
||||
rc = ftpCheckResponse(u, NULL);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
int ftpFileDesc(urlinfo u, const char *cmd, FD_t data)
|
||||
{
|
||||
struct sockaddr_in dataAddress;
|
||||
int cmdlen;
|
||||
char * passReply;
|
||||
char * chptr;
|
||||
int rc;
|
||||
int ftpFileDoneNeeded;
|
||||
|
||||
URLSANE(u);
|
||||
if (cmd == NULL)
|
||||
return FTPERR_UNKNOWN; /* XXX W2DO? */
|
||||
|
||||
cmdlen = strlen(cmd);
|
||||
|
||||
/*
|
||||
* XXX When ftpFileDesc() is called, there may be a lurking
|
||||
* XXX transfer complete message (if ftpFileDone() was not
|
||||
* XXX called to clear that message). Detect that condition now.
|
||||
*/
|
||||
ftpFileDoneNeeded = fdGetFtpFileDoneNeeded(data);
|
||||
assert(ftpFileDoneNeeded == 0);
|
||||
|
||||
/*
|
||||
* Get the ftp version of the Content-Length.
|
||||
*/
|
||||
if (!strncmp(cmd, "RETR", 4)) {
|
||||
char * req = strcpy(alloca(cmdlen + 1), cmd);
|
||||
unsigned cl;
|
||||
|
||||
memcpy(req, "SIZE", 4);
|
||||
DBG(0, (stderr, "-> %s", req));
|
||||
if (fdio->write(u->ctrl, req, cmdlen) != cmdlen) {
|
||||
rc = FTPERR_SERVER_IO_ERROR;
|
||||
goto errxit;
|
||||
}
|
||||
if ((rc = ftpCheckResponse(u, &passReply)))
|
||||
goto errxit;
|
||||
if (sscanf(passReply, "%d %u", &rc, &cl) != 2) {
|
||||
rc = FTPERR_BAD_SERVER_RESPONSE;
|
||||
goto errxit;
|
||||
}
|
||||
rc = 0;
|
||||
u->httpContentLength = cl;
|
||||
}
|
||||
|
||||
DBG(0, (stderr, "-> PASV\n"));
|
||||
if (fdio->write(u->ctrl, "PASV\r\n", 6) != 6) {
|
||||
rc = FTPERR_SERVER_IO_ERROR;
|
||||
goto errxit;
|
||||
}
|
||||
|
||||
if ((rc = ftpCheckResponse(u, &passReply))) {
|
||||
rc = FTPERR_PASSIVE_ERROR;
|
||||
goto errxit;
|
||||
}
|
||||
|
||||
chptr = passReply;
|
||||
while (*chptr && *chptr != '(') chptr++;
|
||||
if (*chptr != '(') return FTPERR_PASSIVE_ERROR;
|
||||
chptr++;
|
||||
passReply = chptr;
|
||||
while (*chptr && *chptr != ')') chptr++;
|
||||
if (*chptr != ')') return FTPERR_PASSIVE_ERROR;
|
||||
*chptr-- = '\0';
|
||||
|
||||
while (*chptr && *chptr != ',') chptr--;
|
||||
if (*chptr != ',') return FTPERR_PASSIVE_ERROR;
|
||||
chptr--;
|
||||
while (*chptr && *chptr != ',') chptr--;
|
||||
if (*chptr != ',') return FTPERR_PASSIVE_ERROR;
|
||||
*chptr++ = '\0';
|
||||
|
||||
/* now passReply points to the IP portion, and chptr points to the
|
||||
port number portion */
|
||||
|
||||
{ int i, j;
|
||||
dataAddress.sin_family = AF_INET;
|
||||
if (sscanf(chptr, "%d,%d", &i, &j) != 2) {
|
||||
rc = FTPERR_PASSIVE_ERROR;
|
||||
goto errxit;
|
||||
}
|
||||
dataAddress.sin_port = htons((((unsigned)i) << 8) + j);
|
||||
}
|
||||
|
||||
chptr = passReply;
|
||||
while (*chptr++) {
|
||||
if (*chptr == ',') *chptr = '.';
|
||||
}
|
||||
|
||||
if (!inet_aton(passReply, &dataAddress.sin_addr)) {
|
||||
rc = FTPERR_PASSIVE_ERROR;
|
||||
goto errxit;
|
||||
}
|
||||
|
||||
rc = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
||||
fdSetFdno(data, (rc >= 0 ? rc : -1));
|
||||
if (rc < 0) {
|
||||
rc = FTPERR_FAILED_CONNECT;
|
||||
goto errxit;
|
||||
}
|
||||
data = fdLink(data, "open data (ftpFileDesc)");
|
||||
|
||||
/* XXX setsockopt SO_LINGER */
|
||||
/* XXX setsockopt SO_KEEPALIVE */
|
||||
/* XXX setsockopt SO_TOS IPTOS_THROUGHPUT */
|
||||
|
||||
while (connect(fdio->fileno(data), (struct sockaddr *) &dataAddress,
|
||||
sizeof(dataAddress)) < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
rc = FTPERR_FAILED_DATA_CONNECT;
|
||||
goto errxit;
|
||||
}
|
||||
|
||||
DBG(0, (stderr, "-> %s", cmd));
|
||||
if (fdio->write(u->ctrl, cmd, cmdlen) != cmdlen) {
|
||||
rc = FTPERR_SERVER_IO_ERROR;
|
||||
goto errxit;
|
||||
}
|
||||
|
||||
if ((rc = ftpCheckResponse(u, NULL))) {
|
||||
goto errxit;
|
||||
}
|
||||
|
||||
fdSetFtpFileDoneNeeded(data, 1);
|
||||
u->ctrl = fdLink(u->ctrl, "grab data (ftpFileDesc)");
|
||||
u->ctrl = fdLink(u->ctrl, "open data (ftpFileDesc)");
|
||||
return 0;
|
||||
|
||||
errxit:
|
||||
fdSetSyserrno(u->ctrl, errno, ftpStrerror(rc));
|
||||
errxit2:
|
||||
if (fdio->fileno(data) >= 0)
|
||||
fdio->close(data);
|
||||
return rc;
|
||||
}
|
|
@ -348,7 +348,12 @@ static int installArchive(FD_t fd, struct fileInfo * files,
|
|||
(void)notify(h, RPMCALLBACK_INST_PROGRESS, 0, archiveSize, pkgKey,
|
||||
notifyData);
|
||||
|
||||
(void) Fflush(fd);
|
||||
#ifndef DYING
|
||||
cfd = Fdopen(fdDup(Fileno(fd)), "r.gzdio");
|
||||
#else
|
||||
cfd = Fdopen(fd, "r.gzdio");
|
||||
#endif
|
||||
rc = cpioInstallArchive(cfd, map, mappedFiles,
|
||||
((notify && archiveSize) || specFile) ? callback : NULL,
|
||||
&info, &failedFile);
|
||||
|
|
76
lib/misc.c
76
lib/misc.c
|
@ -355,10 +355,11 @@ char * gidToGname(gid_t gid) {
|
|||
}
|
||||
|
||||
int makeTempFile(const char * prefix, const char ** fnptr, FD_t * fdptr) {
|
||||
const char * tempfn;
|
||||
const char * tfn;
|
||||
int temput;
|
||||
FD_t fd;
|
||||
int ran;
|
||||
struct stat sb, sb2;
|
||||
|
||||
if (!prefix) prefix = "";
|
||||
|
||||
|
@ -372,35 +373,24 @@ int makeTempFile(const char * prefix, const char ** fnptr, FD_t * fdptr) {
|
|||
|
||||
do {
|
||||
char tfnbuf[64];
|
||||
const char * tempfn;
|
||||
#ifndef NOTYET
|
||||
sprintf(tfnbuf, "rpm-tmp.%d", ran++);
|
||||
if (tfn) xfree(tfn);
|
||||
tfn = tempfn = rpmGetPath("%{_tmppath}/", tfnbuf, NULL);
|
||||
tempfn = rpmGenPath(prefix, "%{_tmppath}/", tfnbuf);
|
||||
#else
|
||||
strcpy(tfnbuf, "rpm-tmp.XXXXXX");
|
||||
if (tfn) xfree(tfn);
|
||||
tfn = tempfn = rpmGetPath("%{_tmppath}/", mktemp(tfnbuf), NULL);
|
||||
tempfn = rpmGenPath(prefix, "%{_tmppath}/", mktemp(tfnbuf));
|
||||
#endif
|
||||
|
||||
switch (urlIsURL(tempfn)) {
|
||||
case URL_IS_PATH:
|
||||
tfn += sizeof("file://") - 1;
|
||||
tfn = strchr(tfn, '/');
|
||||
/*@fallthrough@*/
|
||||
case URL_IS_UNKNOWN:
|
||||
if (prefix && prefix[strlen(prefix) - 1] == '/')
|
||||
while (*tfn == '/') tfn++;
|
||||
tfn = rpmGetPath( (prefix ? prefix : ""), tfn, NULL);
|
||||
xfree(tempfn);
|
||||
break;
|
||||
case URL_IS_FTP:
|
||||
temput = urlPath(tempfn, &tfn);
|
||||
switch (temput) {
|
||||
case URL_IS_HTTP:
|
||||
case URL_IS_DASH:
|
||||
goto errxit;
|
||||
/*@notreached@*/ break;
|
||||
default:
|
||||
xfree(tempfn);
|
||||
return 1;
|
||||
/*@notreached@*/
|
||||
break;
|
||||
}
|
||||
|
||||
/* XXX FIXME: build/build.c Fdopen assertion failure, makeTempFile uses fdio */
|
||||
|
@ -411,38 +401,42 @@ int makeTempFile(const char * prefix, const char ** fnptr, FD_t * fdptr) {
|
|||
#endif
|
||||
} while ((fd == NULL || Ferror(fd)) && errno == EEXIST);
|
||||
|
||||
if (!Stat(tfn, &sb) && S_ISLNK(sb.st_mode)) {
|
||||
rpmError(RPMERR_SCRIPT, _("error creating temporary file %s"), tfn);
|
||||
xfree(tfn);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (sb.st_nlink != 1) {
|
||||
rpmError(RPMERR_SCRIPT, _("error creating temporary file %s"), tfn);
|
||||
xfree(tfn);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef NOTYET
|
||||
if (fstat(Fileno(fd), &sb2) == 0)
|
||||
#else
|
||||
if (Stat(tfn, &sb2) == 0)
|
||||
#endif
|
||||
{
|
||||
if (sb2.st_ino != sb.st_ino || sb2.st_dev != sb.st_dev) {
|
||||
switch(temput) {
|
||||
struct stat sb, sb2;
|
||||
case URL_IS_PATH:
|
||||
case URL_IS_UNKNOWN:
|
||||
if (!stat(tfn, &sb) && S_ISLNK(sb.st_mode)) {
|
||||
rpmError(RPMERR_SCRIPT, _("error creating temporary file %s"), tfn);
|
||||
xfree(tfn);
|
||||
return 1;
|
||||
goto errxit;
|
||||
}
|
||||
|
||||
if (sb.st_nlink != 1) {
|
||||
rpmError(RPMERR_SCRIPT, _("error creating temporary file %s"), tfn);
|
||||
goto errxit;
|
||||
}
|
||||
|
||||
if (fstat(Fileno(fd), &sb2) == 0) {
|
||||
if (sb2.st_ino != sb.st_ino || sb2.st_dev != sb.st_dev) {
|
||||
rpmError(RPMERR_SCRIPT, _("error creating temporary file %s"), tfn);
|
||||
goto errxit;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (fnptr)
|
||||
*fnptr = tfn;
|
||||
else
|
||||
xfree(tfn);
|
||||
xfree(tempfn);
|
||||
*fdptr = fd;
|
||||
|
||||
return 0;
|
||||
|
||||
errxit:
|
||||
xfree(tempfn);
|
||||
return 1;
|
||||
}
|
||||
|
||||
char * currentDirectory(void) {
|
||||
|
|
|
@ -26,7 +26,7 @@ static int manageFile(FD_t *fdp, const char **fnp, int flags, int rc)
|
|||
|
||||
/* open a file and set *fdp */
|
||||
if (*fdp == NULL && fnp && *fnp) {
|
||||
fd = Fopen(*fnp, ((flags & O_RDONLY) ? "r.ufdio" : "w.ufdio"));
|
||||
fd = Fopen(*fnp, ((flags & O_RDONLY) ? "r.ufdio" : "r+.ufdio"));
|
||||
if (fd == NULL || Ferror(fd)) {
|
||||
fprintf(stderr, _("%s: open failed: %s\n"), *fnp,
|
||||
Fstrerror(fd));
|
||||
|
|
31
lib/rpmio.h
31
lib/rpmio.h
|
@ -70,6 +70,7 @@ int Fclose ( /*@killref@*/ FD_t fd);
|
|||
FD_t Fdopen (FD_t fd, const char * fmode);
|
||||
FD_t Fopen (const char * path, const char * fmode);
|
||||
|
||||
int Fflush (FD_t fd);
|
||||
int Ferror (FD_t fd);
|
||||
int Fileno (FD_t fd);
|
||||
|
||||
|
@ -102,9 +103,6 @@ void fdSetIo (FD_t fd, FDIO_t io);
|
|||
|
||||
int fdGetRdTimeoutSecs(FD_t fd);
|
||||
|
||||
int fdGetFtpFileDoneNeeded(FD_t fd);
|
||||
void fdSetFtpFileDoneNeeded(FD_t fd, int ftpFileDoneNeeded);
|
||||
|
||||
long int fdGetCpioPos(FD_t fd);
|
||||
void fdSetCpioPos(FD_t fd, long int cpioPos);
|
||||
|
||||
|
@ -129,12 +127,35 @@ extern /*@null@*/ FILE *fdFdopen( /*@only@*/ void * cookie, const char * mode);
|
|||
#define fdOpen fdio->open
|
||||
#endif
|
||||
|
||||
int fdWritable(FD_t fd, int secs);
|
||||
int fdReadable(FD_t fd, int secs);
|
||||
|
||||
/*@observer@*/ extern FDIO_t fdio;
|
||||
/*@observer@*/ extern FDIO_t fpio;
|
||||
|
||||
/*
|
||||
* Support for FTP and HTTP I/O.
|
||||
*/
|
||||
#ifndef IPPORT_FTP
|
||||
#define IPPORT_FTP 21
|
||||
#endif
|
||||
#ifndef IPPORT_HTTP
|
||||
#define IPPORT_HTTP 80
|
||||
#endif
|
||||
|
||||
#define FTPERR_BAD_SERVER_RESPONSE -1
|
||||
#define FTPERR_SERVER_IO_ERROR -2
|
||||
#define FTPERR_SERVER_TIMEOUT -3
|
||||
#define FTPERR_BAD_HOST_ADDR -4
|
||||
#define FTPERR_BAD_HOSTNAME -5
|
||||
#define FTPERR_FAILED_CONNECT -6
|
||||
#define FTPERR_FILE_IO_ERROR -7
|
||||
#define FTPERR_PASSIVE_ERROR -8
|
||||
#define FTPERR_FAILED_DATA_CONNECT -9
|
||||
#define FTPERR_FILE_NOT_FOUND -10
|
||||
#define FTPERR_NIC_ABORT_IN_PROGRESS -11
|
||||
#define FTPERR_UNKNOWN -100
|
||||
|
||||
/*@dependent@*/ /*@null@*/ void * ufdGetUrlinfo(FD_t fd);
|
||||
/*@observer@*/ const char * urlStrerror(const char * url);
|
||||
|
||||
|
@ -162,10 +183,6 @@ const char *const ftpStrerror(int errorNumber);
|
|||
#define ufdUnlink ufdio->unlink
|
||||
#endif
|
||||
|
||||
int fdWritable(FD_t fd, int secs);
|
||||
int fdReadable(FD_t fd, int secs);
|
||||
int fdRdline(FD_t fd, /*@out@*/ char * buf, size_t len);
|
||||
|
||||
int timedRead(FD_t fd, /*@out@*/ void * bufptr, int length);
|
||||
#define timedRead ufdio->read
|
||||
|
||||
|
|
30
lib/rpmurl.h
30
lib/rpmurl.h
|
@ -3,26 +3,6 @@
|
|||
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef IPPORT_FTP
|
||||
#define IPPORT_FTP 21
|
||||
#endif
|
||||
#ifndef IPPORT_HTTP
|
||||
#define IPPORT_HTTP 80
|
||||
#endif
|
||||
|
||||
#define FTPERR_BAD_SERVER_RESPONSE -1
|
||||
#define FTPERR_SERVER_IO_ERROR -2
|
||||
#define FTPERR_SERVER_TIMEOUT -3
|
||||
#define FTPERR_BAD_HOST_ADDR -4
|
||||
#define FTPERR_BAD_HOSTNAME -5
|
||||
#define FTPERR_FAILED_CONNECT -6
|
||||
#define FTPERR_FILE_IO_ERROR -7
|
||||
#define FTPERR_PASSIVE_ERROR -8
|
||||
#define FTPERR_FAILED_DATA_CONNECT -9
|
||||
#define FTPERR_FILE_NOT_FOUND -10
|
||||
#define FTPERR_NIC_ABORT_IN_PROGRESS -11
|
||||
#define FTPERR_UNKNOWN -100
|
||||
|
||||
typedef enum {
|
||||
URL_IS_UNKNOWN = 0,
|
||||
URL_IS_DASH = 1,
|
||||
|
@ -54,8 +34,6 @@ typedef /*@abstract@*/ /*@refcounted@*/ struct urlinfo {
|
|||
int openError; /* Type of open failure */
|
||||
int httpVersion;
|
||||
int httpHasRange;
|
||||
int httpContentLength;
|
||||
int httpPersist;
|
||||
int magic;
|
||||
} *urlinfo;
|
||||
|
||||
|
@ -63,13 +41,7 @@ typedef /*@abstract@*/ /*@refcounted@*/ struct urlinfo {
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
int ftpCheckResponse(urlinfo u, /*@out@*/ char ** str);
|
||||
int ftpCommand(urlinfo u, ...);
|
||||
|
||||
int httpOpen(urlinfo u, FD_t ctrl, const char * httpcmd);
|
||||
int ftpOpen(urlinfo u);
|
||||
int ftpFileDone(urlinfo u, FD_t data);
|
||||
int ftpFileDesc(urlinfo u, const char * cmd, FD_t data);
|
||||
extern int url_iobuf_size;
|
||||
|
||||
urlinfo urlLink(urlinfo u, const char * msg);
|
||||
urlinfo XurlLink(urlinfo u, const char * msg, const char * file, unsigned line);
|
||||
|
|
24
lib/url.c
24
lib/url.c
|
@ -16,6 +16,7 @@
|
|||
/*@access urlinfo@*/
|
||||
|
||||
#define URL_IOBUF_SIZE 4096
|
||||
int url_iobuf_size = URL_IOBUF_SIZE;
|
||||
|
||||
#define RPMURL_DEBUG_IO 0x40000000
|
||||
#define RPMURL_DEBUG_REFS 0x20000000
|
||||
|
@ -50,8 +51,7 @@ urlinfo XurlNew(const char *msg, const char *file, unsigned line)
|
|||
u->bufAlloced = 0;
|
||||
u->buf = NULL;
|
||||
u->httpHasRange = 1;
|
||||
u->httpContentLength = 0;
|
||||
u->httpPersist = u->httpVersion = 0;
|
||||
u->httpVersion = 0;
|
||||
u->nrefs = 0;
|
||||
u->magic = URLMAGIC;
|
||||
return XurlLink(u, msg, file, line);
|
||||
|
@ -190,8 +190,6 @@ static void urlFind(urlinfo *uret, int mustAsk)
|
|||
uCache = xmalloc(sizeof(*uCache));
|
||||
}
|
||||
uCache[i] = urlLink(u, "uCache (miss)");
|
||||
u->bufAlloced = URL_IOBUF_SIZE;
|
||||
u->buf = xcalloc(u->bufAlloced, sizeof(char));
|
||||
u = urlFree(u, "urlSplit (urlFind miss)");
|
||||
} else {
|
||||
/* XXX Swap original url and path into the cached structure */
|
||||
|
@ -313,9 +311,17 @@ urltype urlIsURL(const char * url) {
|
|||
|
||||
int urlPath(const char * url, const char ** pathp)
|
||||
{
|
||||
const char *path = url;
|
||||
int urltype = urlIsURL(url);
|
||||
const char *path;
|
||||
int urltype;
|
||||
|
||||
if (url == NULL) { /* XXX paranoia */
|
||||
if (pathp)
|
||||
*pathp = xstrdup("/");
|
||||
return URL_IS_UNKNOWN;
|
||||
}
|
||||
|
||||
path = url;
|
||||
urltype = urlIsURL(url);
|
||||
switch (urltype) {
|
||||
case URL_IS_FTP:
|
||||
path += sizeof("ftp://") - 1;
|
||||
|
@ -364,14 +370,16 @@ int urlSplit(const char * url, urlinfo *uret)
|
|||
while (1) {
|
||||
/* Point to end of next item */
|
||||
while (*se && *se != '/') se++;
|
||||
#ifdef DYING
|
||||
if (*se == '\0') {
|
||||
/* XXX can't find path */
|
||||
if (myurl) free(myurl);
|
||||
u = urlFree(u, "urlSplit (error #2)");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
/* Item was service. Save service and go for the rest ...*/
|
||||
if ((se != s) && se[-1] == ':' && se[0] == '/' && se[1] == '/') {
|
||||
if (*se && (se != s) && se[-1] == ':' && se[0] == '/' && se[1] == '/') {
|
||||
se[-1] = '\0';
|
||||
u->service = xstrdup(s);
|
||||
se += 2; /* skip over "//" */
|
||||
|
@ -380,7 +388,7 @@ int urlSplit(const char * url, urlinfo *uret)
|
|||
}
|
||||
|
||||
/* Item was everything-but-path. Save path and continue parse on rest */
|
||||
u->path = xstrdup(se);
|
||||
u->path = xstrdup((*se ? se : "/"));
|
||||
*se = '\0';
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ lib/falloc.c
|
|||
lib/formats.c
|
||||
lib/fprint.c
|
||||
lib/fs.c
|
||||
lib/ftp.c
|
||||
lib/hash.c
|
||||
lib/header.c
|
||||
lib/install.c
|
||||
|
|
185
po/rpm.pot
185
po/rpm.pot
|
@ -6,7 +6,7 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 1999-11-15 18:45-0500\n"
|
||||
"POT-Creation-Date: 1999-11-18 12:30-0500\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -23,102 +23,101 @@ msgstr ""
|
|||
msgid "failed build dependencies:\n"
|
||||
msgstr ""
|
||||
|
||||
#. XXX Fstrerror
|
||||
#: build.c:65
|
||||
#: build.c:64
|
||||
#, c-format
|
||||
msgid "Unable to open spec file %s: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:121 build.c:134
|
||||
#: build.c:120 build.c:133
|
||||
#, c-format
|
||||
msgid "Failed to open tar pipe: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#. Give up
|
||||
#: build.c:142
|
||||
#: build.c:141
|
||||
#, c-format
|
||||
msgid "Failed to read spec file from %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:170
|
||||
#: build.c:169
|
||||
#, c-format
|
||||
msgid "Failed to rename %s to %s: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:208
|
||||
#: build.c:207
|
||||
#, c-format
|
||||
msgid "File is not a regular file: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:214
|
||||
#: build.c:213
|
||||
#, c-format
|
||||
msgid "File %s does not appear to be a specfile.\n"
|
||||
msgstr ""
|
||||
|
||||
#. parse up the build operators
|
||||
#: build.c:271
|
||||
#: build.c:270
|
||||
#, c-format
|
||||
msgid "Building target platforms: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:286
|
||||
#: build.c:285
|
||||
#, c-format
|
||||
msgid "Building for target %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:336
|
||||
#: build.c:335
|
||||
msgid "buildroot already specified"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:343
|
||||
#: build.c:342
|
||||
msgid "--buildarch has been obsoleted. Use the --target option instead.\n"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:347
|
||||
#: build.c:346
|
||||
msgid "--buildos has been obsoleted. Use the --target option instead.\n"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:368
|
||||
#: build.c:367
|
||||
msgid "override build architecture"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:370
|
||||
#: build.c:369
|
||||
msgid "override build operating system"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:372
|
||||
#: build.c:371
|
||||
msgid "override build root"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:374 rpm.c:490
|
||||
#: build.c:373 rpm.c:490
|
||||
msgid "remove build tree when done"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:376
|
||||
#: build.c:375
|
||||
msgid "do not execute any stages of the build"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:378
|
||||
#: build.c:377
|
||||
msgid "do not accept I18N msgstr's from specfile"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:380
|
||||
#: build.c:379
|
||||
msgid "remove sources when done"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:382
|
||||
#: build.c:381
|
||||
msgid "remove specfile when done"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:384 rpm.c:488
|
||||
#: build.c:383 rpm.c:488
|
||||
msgid "skip straight to specified stage (only for c,i)"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:386
|
||||
#: build.c:385
|
||||
msgid "override target platform"
|
||||
msgstr ""
|
||||
|
||||
#: build.c:388
|
||||
#: build.c:387
|
||||
msgid "lookup I18N strings in specfile catalog"
|
||||
msgstr ""
|
||||
|
||||
|
@ -1235,21 +1234,21 @@ msgstr ""
|
|||
msgid "cannot re-open payload: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: build/build.c:84 build/pack.c:270
|
||||
#: build/build.c:85 build/pack.c:270
|
||||
msgid "Unable to open temp file"
|
||||
msgstr ""
|
||||
|
||||
#: build/build.c:127
|
||||
#: build/build.c:129
|
||||
#, c-format
|
||||
msgid "Executing: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: build/build.c:147
|
||||
#: build/build.c:149
|
||||
#, c-format
|
||||
msgid "Exec of %s failed (%s)"
|
||||
msgstr ""
|
||||
|
||||
#: build/build.c:153
|
||||
#: build/build.c:155
|
||||
#, c-format
|
||||
msgid "Bad exit status from %s (%s)"
|
||||
msgstr ""
|
||||
|
@ -1417,7 +1416,7 @@ msgstr ""
|
|||
msgid "Could not open %%files file %s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/files.c:1191 build/pack.c:495
|
||||
#: build/files.c:1191 build/pack.c:496
|
||||
#, c-format
|
||||
msgid "line: %s"
|
||||
msgstr ""
|
||||
|
@ -1545,47 +1544,47 @@ msgstr ""
|
|||
msgid "Wrote: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: build/pack.c:444
|
||||
#: build/pack.c:445
|
||||
#, c-format
|
||||
msgid "create archive failed on file %s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/pack.c:463
|
||||
#: build/pack.c:464
|
||||
#, c-format
|
||||
msgid "cpio_copy write failed: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/pack.c:470
|
||||
#: build/pack.c:471
|
||||
#, c-format
|
||||
msgid "cpio_copy read failed: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/pack.c:551
|
||||
#: build/pack.c:552
|
||||
#, c-format
|
||||
msgid "Could not open PreIn file: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/pack.c:558
|
||||
#: build/pack.c:559
|
||||
#, c-format
|
||||
msgid "Could not open PreUn file: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/pack.c:565
|
||||
#: build/pack.c:566
|
||||
#, c-format
|
||||
msgid "Could not open PostIn file: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/pack.c:572
|
||||
#: build/pack.c:573
|
||||
#, c-format
|
||||
msgid "Could not open PostUn file: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/pack.c:580
|
||||
#: build/pack.c:581
|
||||
#, c-format
|
||||
msgid "Could not open VerifyScript file: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/pack.c:596
|
||||
#: build/pack.c:597
|
||||
#, c-format
|
||||
msgid "Could not open Trigger script file: %s"
|
||||
msgstr ""
|
||||
|
@ -1798,31 +1797,31 @@ msgstr ""
|
|||
msgid "line %d: Bad %%setup option %s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/parsePrep.c:376
|
||||
#: build/parsePrep.c:381
|
||||
msgid "line %d: Need arg to %%patch -b: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/parsePrep.c:384
|
||||
#: build/parsePrep.c:389
|
||||
msgid "line %d: Need arg to %%patch -z: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/parsePrep.c:396
|
||||
#: build/parsePrep.c:401
|
||||
msgid "line %d: Need arg to %%patch -p: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/parsePrep.c:402
|
||||
#: build/parsePrep.c:407
|
||||
msgid "line %d: Bad arg to %%patch -p: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/parsePrep.c:409
|
||||
#: build/parsePrep.c:414
|
||||
msgid "Too many patches!"
|
||||
msgstr ""
|
||||
|
||||
#: build/parsePrep.c:413
|
||||
#: build/parsePrep.c:418
|
||||
msgid "line %d: Bad arg to %%patch: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/parsePrep.c:449
|
||||
#: build/parsePrep.c:454
|
||||
msgid "line %d: second %%prep"
|
||||
msgstr ""
|
||||
|
||||
|
@ -1878,44 +1877,44 @@ msgid "line %d: %s"
|
|||
msgstr ""
|
||||
|
||||
#. XXX Fstrerror
|
||||
#: build/parseSpec.c:174
|
||||
#: build/parseSpec.c:175
|
||||
#, c-format
|
||||
msgid "Unable to open %s: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: build/parseSpec.c:186
|
||||
#: build/parseSpec.c:187
|
||||
msgid "Unclosed %%if"
|
||||
msgstr ""
|
||||
|
||||
#: build/parseSpec.c:245
|
||||
#: build/parseSpec.c:246
|
||||
#, c-format
|
||||
msgid "%s:%d: parseExpressionBoolean returns %d"
|
||||
msgstr ""
|
||||
|
||||
#. Got an else with no %if !
|
||||
#: build/parseSpec.c:253
|
||||
#: build/parseSpec.c:254
|
||||
msgid "%s:%d: Got a %%else with no if"
|
||||
msgstr ""
|
||||
|
||||
#. Got an end with no %if !
|
||||
#: build/parseSpec.c:264
|
||||
#: build/parseSpec.c:265
|
||||
msgid "%s:%d: Got a %%endif with no if"
|
||||
msgstr ""
|
||||
|
||||
#: build/parseSpec.c:278 build/parseSpec.c:287
|
||||
#: build/parseSpec.c:279 build/parseSpec.c:288
|
||||
msgid "malformed %%include statement"
|
||||
msgstr ""
|
||||
|
||||
#: build/parseSpec.c:368
|
||||
#: build/parseSpec.c:369
|
||||
#, c-format
|
||||
msgid "Timecheck value must be an integer: %s"
|
||||
msgstr ""
|
||||
|
||||
#: build/parseSpec.c:451
|
||||
#: build/parseSpec.c:452
|
||||
msgid "No buildable architectures"
|
||||
msgstr ""
|
||||
|
||||
#: build/parseSpec.c:498
|
||||
#: build/parseSpec.c:499
|
||||
msgid "Package has no %%description: %s"
|
||||
msgstr ""
|
||||
|
||||
|
@ -2227,86 +2226,86 @@ msgstr ""
|
|||
|
||||
#. this would probably be a good place to check if disk space
|
||||
#. was used up - if so, we should return a different error
|
||||
#: lib/install.c:361
|
||||
#: lib/install.c:366
|
||||
#, c-format
|
||||
msgid "unpacking of archive failed%s%s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:362
|
||||
#: lib/install.c:367
|
||||
msgid " on file "
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:405
|
||||
#: lib/install.c:410
|
||||
msgid "installing a source package\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:416
|
||||
#: lib/install.c:421
|
||||
#, c-format
|
||||
msgid "cannot create %s: %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:424 lib/install.c:446
|
||||
#: lib/install.c:429 lib/install.c:451
|
||||
#, c-format
|
||||
msgid "cannot write to %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:428
|
||||
#: lib/install.c:433
|
||||
#, c-format
|
||||
msgid "sources in: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:439
|
||||
#: lib/install.c:444
|
||||
#, c-format
|
||||
msgid "cannot create %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:450
|
||||
#: lib/install.c:455
|
||||
#, c-format
|
||||
msgid "spec file in: %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:484 lib/install.c:512
|
||||
#: lib/install.c:489 lib/install.c:517
|
||||
msgid "source package contains no .spec file"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:534
|
||||
#: lib/install.c:539
|
||||
#, c-format
|
||||
msgid "renaming %s to %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:536 lib/install.c:815 lib/uninstall.c:27
|
||||
#: lib/install.c:541 lib/install.c:820 lib/uninstall.c:27
|
||||
#, c-format
|
||||
msgid "rename of %s to %s failed: %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:627
|
||||
#: lib/install.c:632
|
||||
msgid "source package expected, binary found"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:684
|
||||
#: lib/install.c:689
|
||||
#, c-format
|
||||
msgid "package: %s-%s-%s files test = %d\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:745
|
||||
#: lib/install.c:750
|
||||
msgid "stopping install as we're running --test\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:750
|
||||
#: lib/install.c:755
|
||||
msgid "running preinstall script (if any)\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:775
|
||||
#: lib/install.c:780
|
||||
#, c-format
|
||||
msgid "warning: %s created as %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:811
|
||||
#: lib/install.c:816
|
||||
#, c-format
|
||||
msgid "warning: %s saved as %s"
|
||||
msgstr ""
|
||||
|
||||
#: lib/install.c:885
|
||||
#: lib/install.c:890
|
||||
msgid "running postinstall scripts (if any)\n"
|
||||
msgstr ""
|
||||
|
||||
|
@ -2413,7 +2412,7 @@ msgstr ""
|
|||
msgid "internal error (rpm bug?): "
|
||||
msgstr ""
|
||||
|
||||
#: lib/misc.c:415 lib/misc.c:421 lib/misc.c:433
|
||||
#: lib/misc.c:409 lib/misc.c:414 lib/misc.c:420
|
||||
#, c-format
|
||||
msgid "error creating temporary file %s"
|
||||
msgstr ""
|
||||
|
@ -2844,7 +2843,7 @@ msgstr ""
|
|||
msgid "opening database mode 0x%x in %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmdb.c:155 lib/url.c:449
|
||||
#: lib/rpmdb.c:155 lib/url.c:457
|
||||
#, c-format
|
||||
msgid "failed to open %s: %s\n"
|
||||
msgstr ""
|
||||
|
@ -3038,59 +3037,59 @@ msgstr ""
|
|||
msgid "Installing %s\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmio.c:463
|
||||
#: lib/rpmio.c:675
|
||||
msgid "Success"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmio.c:466
|
||||
#: lib/rpmio.c:678
|
||||
msgid "Bad server response"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmio.c:469
|
||||
#: lib/rpmio.c:681
|
||||
msgid "Server IO error"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmio.c:472
|
||||
#: lib/rpmio.c:684
|
||||
msgid "Server timeout"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmio.c:475
|
||||
#: lib/rpmio.c:687
|
||||
msgid "Unable to lookup server host address"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmio.c:478
|
||||
#: lib/rpmio.c:690
|
||||
msgid "Unable to lookup server host name"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmio.c:481
|
||||
#: lib/rpmio.c:693
|
||||
msgid "Failed to connect to server"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmio.c:484
|
||||
#: lib/rpmio.c:696
|
||||
msgid "Failed to establish data connection to server"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmio.c:487
|
||||
#: lib/rpmio.c:699
|
||||
msgid "IO error to local file"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmio.c:490
|
||||
#: lib/rpmio.c:702
|
||||
msgid "Error setting remote server to passive mode"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmio.c:493
|
||||
#: lib/rpmio.c:705
|
||||
msgid "File not found on server"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmio.c:496
|
||||
#: lib/rpmio.c:708
|
||||
msgid "Abort in progress"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmio.c:500
|
||||
#: lib/rpmio.c:712
|
||||
msgid "Unknown or unexpected error"
|
||||
msgstr ""
|
||||
|
||||
#: lib/rpmio.c:552
|
||||
#: lib/rpmio.c:1243
|
||||
#, c-format
|
||||
msgid "logging into %s as %s, pw %s\n"
|
||||
msgstr ""
|
||||
|
@ -3385,7 +3384,7 @@ msgstr ""
|
|||
msgid "removing database entry\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/uninstall.c:400
|
||||
#: lib/uninstall.c:394
|
||||
msgid "execution of script failed"
|
||||
msgstr ""
|
||||
|
||||
|
@ -3404,22 +3403,22 @@ msgstr ""
|
|||
msgid "warning: uCache[%d] %p nrefs(%d) != 1 (%s %s)\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/url.c:224
|
||||
#: lib/url.c:222
|
||||
#, c-format
|
||||
msgid "Password for %s@%s: "
|
||||
msgstr ""
|
||||
|
||||
#: lib/url.c:249 lib/url.c:275
|
||||
#: lib/url.c:247 lib/url.c:273
|
||||
#, c-format
|
||||
msgid "error: %sport must be a number\n"
|
||||
msgstr ""
|
||||
|
||||
#: lib/url.c:413
|
||||
#: lib/url.c:421
|
||||
msgid "url port must be a number\n"
|
||||
msgstr ""
|
||||
|
||||
#. XXX Fstrerror
|
||||
#: lib/url.c:472
|
||||
#: lib/url.c:480
|
||||
#, c-format
|
||||
msgid "failed to create %s: %s\n"
|
||||
msgstr ""
|
||||
|
|
Loading…
Reference in New Issue