mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-11 20:05:07 -05:00
dload.c : various fixes
- fix one memleak if get_filename failed - cleanup according to Joerg's feedback: "url_for_string: If fetchParseURL returned successful, you should always have a scheme set. The logic for anonftp should only be needed for very broken server -- do you know of any such? download_internal: Specifying 'p' is now a nop -- it is tried by default first with fall-back to active FTP." Signed-off-by: Xavier Chantry <shiningxc@gmail.com> [Dan: remove from pacman.conf and pacman.conf.5] Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
7bb9c4098b
commit
7dae79e7b9
1
README
1
README
@ -57,7 +57,6 @@ library is initialized.
|
||||
* dbpath: The toplevel database directory (Default: /var/lib/pacman)
|
||||
* logfile: The base path to pacman's log file (Default: /var/log/pacman.log)
|
||||
* usesyslog: Log to syslog instead of `logfile` for file-base logging.
|
||||
* nopassiveftp: Do not use passive FTP commands for ftp connections.
|
||||
|
||||
The following options also have `alpm_option_{add,remove}_*` functions, as the
|
||||
values are list structures.
|
||||
|
@ -108,9 +108,6 @@ Options
|
||||
http/ftp support, or need the more advanced proxy support that comes with
|
||||
utilities like wget.
|
||||
|
||||
*NoPassiveFtp*::
|
||||
Disables passive ftp connections when downloading packages. (aka Active Mode)
|
||||
|
||||
*NoUpgrade =* file ...::
|
||||
All files listed with a `NoUpgrade` directive will never be touched during
|
||||
a package install/upgrade, and the new files will be installed with a
|
||||
|
@ -28,7 +28,6 @@ SyncFirst = pacman
|
||||
#NoExtract =
|
||||
|
||||
# Misc options (all disabled by default)
|
||||
#NoPassiveFtp
|
||||
#UseSyslog
|
||||
#ShowSize
|
||||
#UseDelta
|
||||
|
@ -151,8 +151,6 @@ void alpm_option_add_ignoregrp(const char *grp);
|
||||
void alpm_option_set_ignoregrps(alpm_list_t *ignoregrps);
|
||||
int alpm_option_remove_ignoregrp(const char *grp);
|
||||
|
||||
unsigned short alpm_option_get_nopassiveftp();
|
||||
void alpm_option_set_nopassiveftp(unsigned short nopasv);
|
||||
void alpm_option_set_usedelta(unsigned short usedelta);
|
||||
|
||||
pmdb_t *alpm_option_get_localdb();
|
||||
|
@ -76,30 +76,6 @@ static char *get_tempfile(const char *path, const char *filename) {
|
||||
return(tempfile);
|
||||
}
|
||||
|
||||
/* Build a 'struct url' from an url. */
|
||||
static struct url *url_for_string(const char *url)
|
||||
{
|
||||
struct url *ret = NULL;
|
||||
ret = fetchParseURL(url);
|
||||
if(!ret) {
|
||||
_alpm_log(PM_LOG_ERROR, _("url '%s' is invalid\n"), url);
|
||||
RET_ERR(PM_ERR_SERVER_BAD_URL, NULL);
|
||||
}
|
||||
|
||||
/* if no URL scheme specified, assume HTTP */
|
||||
if(strlen(ret->scheme) == 0) {
|
||||
_alpm_log(PM_LOG_WARNING, _("url scheme not specified, assuming HTTP\n"));
|
||||
strcpy(ret->scheme, SCHEME_HTTP);
|
||||
}
|
||||
/* add a user & password for anonymous FTP */
|
||||
if(strcmp(ret->scheme,SCHEME_FTP) == 0 && strlen(ret->user) == 0) {
|
||||
strcpy(ret->user, "anonymous");
|
||||
strcpy(ret->pwd, "libalpm@guest");
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static int download_internal(const char *url, const char *localpath,
|
||||
time_t mtimeold, time_t *mtimenew) {
|
||||
fetchIO *dlf = NULL;
|
||||
@ -110,17 +86,20 @@ static int download_internal(const char *url, const char *localpath,
|
||||
size_t dl_thisfile = 0, nread = 0;
|
||||
char *tempfile, *destfile, *filename;
|
||||
struct sigaction new_action, old_action;
|
||||
struct url *fileurl = url_for_string(url);
|
||||
struct url *fileurl;
|
||||
char buffer[PM_DLBUF_LEN];
|
||||
|
||||
if(!fileurl) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
filename = get_filename(url);
|
||||
if(!filename) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
fileurl = fetchParseURL(url);
|
||||
if(!fileurl) {
|
||||
_alpm_log(PM_LOG_ERROR, _("url '%s' is invalid\n"), url);
|
||||
RET_ERR(PM_ERR_SERVER_BAD_URL, -1);
|
||||
}
|
||||
|
||||
destfile = get_destfile(localpath, filename);
|
||||
tempfile = get_tempfile(localpath, filename);
|
||||
|
||||
@ -161,7 +140,7 @@ static int download_internal(const char *url, const char *localpath,
|
||||
sigaction(SIGPIPE, NULL, &old_action);
|
||||
sigaction(SIGPIPE, &new_action, NULL);
|
||||
|
||||
dlf = fetchXGet(fileurl, &ust, (handle->nopassiveftp ? "i" : "pi"));
|
||||
dlf = fetchXGet(fileurl, &ust, "i");
|
||||
|
||||
if(fetchLastErrCode == FETCH_UNCHANGED) {
|
||||
_alpm_log(PM_LOG_DEBUG, "mtimes are identical, skipping %s\n", filename);
|
||||
|
@ -213,15 +213,6 @@ alpm_list_t SYMEXPORT *alpm_option_get_ignoregrps()
|
||||
return handle->ignoregrp;
|
||||
}
|
||||
|
||||
unsigned short SYMEXPORT alpm_option_get_nopassiveftp()
|
||||
{
|
||||
if (handle == NULL) {
|
||||
pm_errno = PM_ERR_HANDLE_NULL;
|
||||
return -1;
|
||||
}
|
||||
return handle->nopassiveftp;
|
||||
}
|
||||
|
||||
pmdb_t SYMEXPORT *alpm_option_get_localdb()
|
||||
{
|
||||
if (handle == NULL) {
|
||||
@ -529,11 +520,6 @@ int SYMEXPORT alpm_option_remove_ignoregrp(const char *grp)
|
||||
return(0);
|
||||
}
|
||||
|
||||
void SYMEXPORT alpm_option_set_nopassiveftp(unsigned short nopasv)
|
||||
{
|
||||
handle->nopassiveftp = nopasv;
|
||||
}
|
||||
|
||||
void SYMEXPORT alpm_option_set_usedelta(unsigned short usedelta)
|
||||
{
|
||||
handle->usedelta = usedelta;
|
||||
|
@ -58,7 +58,6 @@ typedef struct _pmhandle_t {
|
||||
|
||||
/* options */
|
||||
unsigned short usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */
|
||||
unsigned short nopassiveftp; /* Don't use PASV ftp connections */
|
||||
unsigned short usedelta; /* Download deltas if possible */
|
||||
} pmhandle_t;
|
||||
|
||||
|
@ -787,10 +787,7 @@ static int _parseconfig(const char *file, const char *givensection,
|
||||
}
|
||||
if(ptr == NULL && strcmp(section, "options") == 0) {
|
||||
/* directives without settings, all in [options] */
|
||||
if(strcmp(key, "NoPassiveFtp") == 0) {
|
||||
alpm_option_set_nopassiveftp(1);
|
||||
pm_printf(PM_LOG_DEBUG, "config: nopassiveftp\n");
|
||||
} else if(strcmp(key, "UseSyslog") == 0) {
|
||||
if(strcmp(key, "UseSyslog") == 0) {
|
||||
alpm_option_set_usesyslog(1);
|
||||
pm_printf(PM_LOG_DEBUG, "config: usesyslog\n");
|
||||
} else if(strcmp(key, "ILoveCandy") == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user