summaryrefslogtreecommitdiff
path: root/methods/ftp.cc
Commit message (Collapse)AuthorAgeFilesLines
* Implement encoded URI handling in all methodsDavid Kalnischkies2020-12-181-5/+5
| | | | | | | | Every method opts in to getting the encoded URI passed along while keeping compat in case we are operated by an older acquire system. Effectively this is just a change for the http-based methods as the others just decode the URI as they work with files directly.
* apt-pkg: URI: Add 'explicit' to single argument constructorJulian Andres Klode2019-04-301-3/+3
| | | | | This needs a fair amount of changes elsewhere in the code, hence this is separate from the previous commits.
* Lower default timeout from 120s to 30sJulian Andres Klode2018-05-241-1/+1
| | | | | 120s is an insanely high default time out, lower it to 30s to make things a bit nicer.
* Remove obsolete RCS keywordsGuillem Jover2018-05-071-1/+0
| | | | Prompted-by: Jakub Wilk <jwilk@debian.org>
* report transient errors as transient errorsDavid Kalnischkies2017-12-131-36/+72
| | | | | | | | | | | | The Fail method for acquire methods has a boolean parameter indicating the transient-nature of a reported error. The problem with this is that Fail is called very late at a point where it is no longer easily identifiable if an error is indeed transient or not, so some calls were and some weren't and the acquire system would later mostly ignore the transient flag and guess by using the FailReason instead. Introducing a tri-state enum we can pass the information about fatal or transient errors through the callstack to generate the correct fails.
* Sandbox methods with seccomp-BPF; except cdrom, gpgv, rshJulian Andres Klode2017-10-221-0/+1
| | | | | | | | | | | | This reduces the number of syscalls to about 140 from about 350 or so, significantly reducing security risks. Also change prepare-release to ignore the architecture lists in the build dependencies when generating the build-depends package for travis. We might want to clean up things a bit more and/or move it somewhere else.
* allow the auth.conf to be root:root ownedDavid Kalnischkies2017-07-261-2/+2
| | | | | | | | | | | Opening the file before we drop privileges in the methods allows us to avoid chowning in the acquire main process which can apply to the wrong file (imagine Binary scoped settings) and surprises users as their permission setup is overridden. There are no security benefits as the file is open, so an evil method could as before read the contents of the file, but it isn't worse than before and we avoid permission problems in this setup.
* reimplement and document auth.confDavid Kalnischkies2017-07-261-2/+1
| | | | | | | | | | | | | | | | | | We have support for an netrc-like auth.conf file since 0.7.25 (closing 518473), but it was never documented in apt that it even exists and netrc seems to have fallen out of usage as a manpage for it no longer exists making the feature even more arcane. On top of that the code was a bit of a mess (as it is written in c-style) and as a result the matching of machine tokens to URIs also a bit strange by checking for less specific matches (= without path) first. We now do a single pass over the stanzas. In practice early adopters of the undocumented implementation will not really notice the differences and the 'new' behaviour is simpler to document and more usual for an apt user. Closes: #811181
* fail early in http if server answer is too small as wellDavid Kalnischkies2017-07-261-1/+1
| | | | | | | | | Failing on too much data is good, but we can do better by checking for exact filesizes as we know with hashsums how large a file should be, so if we get a file which has a size we do not expect we can drop it directly, regardless of if the file is larger or smaller than what we expect which should catch most cases which would end up as hashsum errors later now a lot sooner.
* fail earlier if server answers with too much dataDavid Kalnischkies2017-07-261-2/+2
| | | | | | | | | We tend to operate on rather large static files, which means we usually get Content-Length information from the server. If we combine this information with the filesize we are expecting (factoring in pipelining) we can avoid reading a bunch of data we are ending up rejecting anyhow by just closing the connection saving bandwidth and time both for the server as well as the client.
* Reformat and sort all includes with clang-formatJulian Andres Klode2017-07-121-10/+10
| | | | | | | | | | | | | This makes it easier to see which headers includes what. The changes were done by running git grep -l '#\s*include' \ | grep -E '.(cc|h)$' \ | xargs sed -i -E 's/(^\s*)#(\s*)include/\1#\2 include/' To modify all include lines by adding a space, and then running ./git-clang-format.sh.
* methods: connect: Switch from int fds to new MethodFdJulian Andres Klode2017-06-281-13/+12
| | | | | | | | Use std::unique_ptr<MethodFd> everywhere we used an integer-based file descriptor before. This allows us to implement stuff like TLS support easily. Gbp-Dch: ignore
* methods: connect: Change PkgAcqMethod to aptMethodJulian Andres Klode2017-06-281-1/+1
| | | | | | | This will allow us to access ConfigFind() and stuff which makes it possible for us to implement TLS support. Gbp-Dch: ignore
* fix various typos reported by spellintianDavid Kalnischkies2017-01-191-2/+2
| | | | | | | | Most of them in (old) code comments. The two instances of user visible string changes the po files of the manpages are fixed up as well. Gbp-Dch: Ignore Reported-By: spellintian
* methods/ftp: Cope with weird PASV responsesJulian Andres Klode2016-06-271-2/+15
| | | | | | | | | | | | wu-ftpd sends the response without parens, whereas we expect them. I did not test the patch, but it should work. I added another return true if Pos is still npos after the second find to make sure we don't add npos to the string. Thanks: Lukasz Stelmach for the initial patch Closes: #420940
* use std::locale::global instead of setlocaleDavid Kalnischkies2016-05-281-8/+2
| | | | | | We use a wild mixture of C and C++ ways of generating output, so having a consistent world-view in both styles sounds like a good idea and should help in preventing regressions.
* allow acquire method specific options via Binary scopeDavid Kalnischkies2015-11-051-6/+3
| | | | | | | | Allows users who know what they are getting themselves into with this trick to e.g. disable privilege dropping for e.g. file:// until they can fix up the permissions on those repositories. It helps also the test framework and people with a similar setup (= me) to run in less modified environments.
* wrap every unlink call to check for != /dev/nullDavid Kalnischkies2015-11-041-1/+1
| | | | | | | | | | | | | | | | Unlinking /dev/null is bad, we shouldn't do that. Also, we should print at least a warning if we tried to unlink a file but didn't manage to pull it of (ignoring the case were the file is /dev/null or doesn't exist in the first place). This got triggered by a relatively unlikely to cause problem in pkgAcquire::Worker::PrepareFiles which would while temporary uncompressed files (which are set to keep compressed) figure out that to files are the same and prepare for sharing by deleting them. Bad move. That also shows why not printing a warning is a bad idea as this hide the error for in non-root test runs. Git-Dch: Ignore
* fix various typos reported by codespellDavid Kalnischkies2015-08-271-1/+1
| | | | Reported-By: codespell
* Make apt compile with clang++ againMichael Vogt2015-08-141-1/+1
| | | | | This allows us to run the clang static analyzer and to run the testsuite with the clang MemorySanitizer.
* add c++11 override marker to overridden methodsDavid Kalnischkies2015-08-101-1/+0
| | | | | | | | | C++11 adds the 'override' specifier to mark that a method is overriding a base class method and error out if not. We hide it in the APT_OVERRIDE macro to ensure that we keep compiling in pre-c++11 standards. Reported-By: clang-modernize -add-override -override-macros Git-Dch: Ignore
* calculate only expected hashes in methodsDavid Kalnischkies2015-04-191-1/+1
| | | | | | | | | | | | | | Methods get told which hashes are expected by the acquire system, which means we can use this list to restrict what we calculate in the methods as any extra we are calculating is wasted effort as we can't compare it with anything anyway. Adding support for a new hash algorithm is therefore 'free' now and if a algorithm is no longer provided in a repository for a file, we automatically stop calculating it. In practice this results in a speed-up in Debian as we don't have SHA512 here (so far), so we practically stop calculating it.
* reimplement the last uses of sprintfDavid Kalnischkies2015-04-101-7/+9
| | | | | | | | Working with strings c-style is complicated and error-prune, so by converting to c++ style we gain some simplicity and avoid buffer overflows by later extensions. Git-Dch: Ignore
* Fix backward compatiblity of the new pkgAcquireMethod::DropPrivsOrDie()Michael Vogt2014-10-131-3/+4
| | | | | | | | Do not drop privileges in the methods when using a older version of libapt that does not support the chown magic in partial/ yet. To do this DropPrivileges() now will ignore a empty Apt::Sandbox::User. Cleanup all hardcoded _apt along the way.
* Send "Fail-Reason: MaximumSizeExceeded" from the methodMichael Vogt2014-10-071-2/+6
| | | | | Communicate the fail reason from the methods to the parent and Rename() failed files.
* make expected-size a maximum-size check as this is what we want at this pointMichael Vogt2014-10-071-4/+4
|
* add ftp expected size checkMichael Vogt2014-10-071-3/+7
|
* fix: Member variable 'X' is not initialized in the constructor.David Kalnischkies2014-09-271-2/+3
| | | | | Reported-By: cppcheck Git-Dch: Ignore
* methods: Fail if we cannot drop privilegesJulian Andres Klode2014-09-241-3/+3
|
* Drop Privileges to "Debian-apt" in most acquire methodsMichael Vogt2014-09-241-0/+3
| | | | | | | | | Add a new "Debian-apt" user that owns the /var/lib/apt/lists and /var/cache/apt/archive directories. The methods http, https, ftp, gpgv, gzip switch to this user when they start. Thanks to Julian and "ioerror" and tors "switch_id()" code.
* cleanup headers and especially #includes everywhereDavid Kalnischkies2014-03-131-0/+5
| | | | | | | | Beside being a bit cleaner it hopefully also resolves oddball problems I have with high levels of parallel jobs. Git-Dch: Ignore Reported-By: iwyu (include-what-you-use)
* warning: unused parameter ‘foo’ [-Wunused-parameter]David Kalnischkies2014-03-131-1/+1
| | | | | Reported-By: gcc -Wunused-parameter Git-Dch: Ignore
* fix -Wmissing-field-initializers warningsDavid Kalnischkies2014-03-131-2/+2
| | | | | Reported-By: gcc Git-Dch: Ignore
* Fix typos in documentation (codespell)Michael Vogt2014-02-221-2/+2
|
* use utimes instead of utimensat/futimensDavid Kalnischkies2014-02-111-9/+9
| | | | | | | | | | | cppcheck complains about the obsolete utime as it was removed in POSIX1.2008 and recommends usage of utimensat/futimens instead as those are in POSIX and so commit 9ce3cfc9 switched to them. It is just that they aren't as portable as the standard suggests: At least our kFreeBSD and Hurd ports stumble over it at runtime. So to make both, the ports and cppcheck happy, we use utimes instead. Closes: 738567
* correct some style/performance/warnings from cppcheckDavid Kalnischkies2014-01-161-23/+26
| | | | | | | | The most "visible" change is from utime to utimensat/futimens as the first one isn't part of POSIX anymore. Reported-By: cppcheck Git-Dch: Ignore
* fix missing va_end()Michael Vogt2013-07-261-0/+1
|
* fix two "(style) Variable 'Res' is assigned a value that is never used"David Kalnischkies2012-03-041-4/+2
|
* fix "(error) Possible null pointer dereference: BindAddr" by ensuringDavid Kalnischkies2012-03-041-2/+2
| | | | that BindAddr isn't NULL after getaddrinfo()
* fix a bunch of cppcheck "(warning) Member variable '<#>' is notDavid Kalnischkies2012-03-041-0/+1
| | | | initialized in the constructor." messages (no functional change)
* try to avoid direct usage of .Fd() if possible and do read()s and coDavid Kalnischkies2011-12-171-1/+1
| | | | on the FileFd instead
* use forward declaration in headers if possible instead of includesDavid Kalnischkies2011-09-191-0/+1
|
* merge with debian/experimentalDavid Kalnischkies2011-09-131-2/+3
|\
| * follow the recommendation of cppcheck to make some method methods (scnr)David Kalnischkies2011-08-111-1/+2
| | | | | | | | const and initial mostly Debug member values in the constructors
| * cppcheck complains about some possible speed improvements which could beDavid Kalnischkies2011-08-111-1/+1
| | | | | | | | | | | | done on the mirco-optimazation level, so lets fix them: (performance) Possible inefficient checking for emptiness. (performance) Prefer prefix ++/-- operators for non-primitive types.
* | Support large files in the complete toolset. Indexes of thisDavid Kalnischkies2011-09-131-6/+6
| | | | | | | | size are pretty unlikely for now, but we need it for deb packages which could become bigger than 4GB now (LP: #815895)
* | reorder includes: add <config.h> if needed and include it at firstDavid Kalnischkies2011-09-131-1/+3
|/
* move the users away from the deprecated StrToTime() methodDavid Kalnischkies2010-06-091-2/+1
|
* add ftp support, basic debuggingMichael Vogt2009-10-161-0/+1
|
* add maybe_add_auth for ftp as wellMichael Vogt2009-10-161-1/+3
|