1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-14 05:15:11 -05:00
Commit Graph

2592 Commits

Author SHA1 Message Date
Allan McRae
fac4831a09 Fix memory leak in remove_notify_needed_optdepends
Also add pactest which captures this leak when run under valgrind.

Reported-by: Sergey Petrenko
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-03 20:38:13 +10:00
Ivy Foster
e28c5803bb Replace CURLOPT_PROGRESSFUNCTION with CURLOPT_XFERINFOFUNCTION
Curl 7.32.0 added CURLOPT_XFERINFOFUNCTION, which deprecates
CURLOPT_PROGRESSFUNCTION and means less casting doubles to size_ts for
alpm. This change has no user-facing nor frontend-facing effects.

Signed-off-by: Ivy Foster <ivy.foster@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-31 13:01:07 +10:00
Ivy Foster
58140dba74 Normalize alpm download callback's frontend cb arguments
When curl calls alpm's dlcb, alpm calls the frontend's cb with the
following (dlsize, totalsize) arguments:

0, -1: initialize
0, 0: no change since last call
x {x>0, x<y}, y {y>0}: data downloaded, total size known
x {x>0}, x: download finished

If total size is not known, do not call frontend cb (no change to
original behavior); alpm's callback shouldn't be called if there is a
download error.

See agregory's original spec here:
https://wiki.archlinux.org/index.php/User:Apg#download_callback

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Allan McRae
5b839c58ee Add newline to the end of error messages for signature format issues
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Andrew Gregory
be1ffedaf6 hook.c: replace fstatat with stat
macOS < 10.10 do not provide fstatat.  We were constructing the full
path to the hook file for all other operations anyway, so there was no
real benefit to using fstatat.

Fixes FS#49771

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Andrew Gregory
c981f5ad76 hook.c: replace readdir_r with readdir
glibc 2.24 deprecates readdir_r.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Tobias Stoeckmann
5fcd60e264 Reject files larger than 16384 bytes in read_sigfile.
If signature files are larger than SIZE_MAX, not enough memory could
be allocated for this file. The script repo-add rejects files which
are larger than 16384 bytes, therefore handle these as errors here,
too.

While at it, I also rearranged the code to avoid a quite harmless
TOCTOU race condition between stat() and fopen().

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Tobias Stoeckmann
681509fd44 Release resources on error paths.
Some resources (memory or file descriptors) are not released on all
error paths.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Tobias Stoeckmann
80d97fcf75 Always use proper error code in alpm_initialize.
In out of memory conditions, an undefined error value is written
into *err, because myerr is never explicitly set in these cases.

I have also converted a calloc into a MALLOC call, because the memory
will be properly filled by the snprintf call right after it.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Andrew Gregory
6ac2ee21b3 recursedeps: include cyclic dependencies
Cyclic dependencies (A depends on B, B depends on A) were not selected
because neither package could be removed individually, so
can_remove_package would always return false for both.  By preselecting
all dependencies then filtering back out any dependencies still required
by any packages that will not be uninstalled, groups of unneeded cyclic
dependencies can be found.

Fixes FS#41031

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-08-30 18:10:40 +10:00
Allan McRae
3729ef7a9a Avoid logical OR duplication warning from gcc-6
The value EAGAIN is allowed by POSIX to be the same as EWOULDBLOCK, but this is
not guaranteed. Thus on some systems (e.g. glibc Linux), we get a warning that
the logical OR is being performed on two expressions of the same type. We can
not get rid of this test in case any system defines these as unique values.

Suggested-by: Dave Reisner
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Allan McRae
5b9bc6024c Prevent wrapping of enum items
GCC-6 points out that the value we use for the sentinal in enums is actually
too large for the integer type. Reduce the bitshift by one to fix this.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Eric Engestrom
2694d17ad9 fix spelling mistakes
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-05-05 13:52:23 +10:00
Allan McRae
3da06c3519 Use versions specified in optdepends
Checking install status and if a package is optionally required on removal
now considers the version of the optdepend.

Fixes FS#44957.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:18:43 +10:00
Allan McRae
59112e186b Consider provides when warning about optdepnd removal
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26 15:18:43 +10:00
Allan McRae
9375715ae4 Regenerate translations for 5.0.1 2016-02-23 13:09:39 +10:00
Allan McRae
5c136d85db Pull translation updates from Transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 12:56:40 +10:00
Andrew Gregory
a724235b61 make alpm_unlock and trans_interrupt async safe
RET_ERR calls _alpm_log which includes calls that are not safe for use
in asynchronous signal handlers (see signal(7)).  Replace it in
functions called from our signal handlers with a new macro
RET_ERR_ASYNC_SAFE which is identical except that it lacks the call to
_alpm_log.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2016-02-23 12:41:36 +10:00
Andrew Gregory
1d6583a58d alpm_run_chroot: always connect parent2child pipe
Commit e374e6829c closed stdin before
running scripts/hooks.  This left the exec'd process with no file
descriptor 0.  If the process subsequently opened a file it would be
assigned fd 0, and could potentially be confused for stdin.  Connecting
and immediately closing the parent2child pipe ensures that the child has
an fd 0 and that it is empty.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 12:33:04 +10:00
Andrew Gregory
ce1f453b74 ensure gpgdir has a trailing slash
init_gpgme checks for various paths under gpgdir by concatenating them
directly, giving warning messages incorrectly if gpgdir does not end
with '/'.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 12:32:54 +10:00
Andrew Gregory
2ee7a8d89a do not rely on localdb for hook matching
Relying on localdb to determine which trigger operations should match is
completely broken for PostTransaction hooks because the localdb has
already been updated.  Store a copy of the old version of any packages
being updated to use instead.

Fixes FS#47996

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-23 12:15:43 +10:00
Andrew Gregory
fd936c9e73 only remove pacnew file if it is new
Check if we overwrote an exiting pacnew file before unlinking it.
Otherwise, updating to a version with an unchanged file would delete
existing pacnew files.

FS#47993

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-21 17:10:11 +10:00
Olivier Brunel
a1a8d067e0 Log to file when running hooks
Useful if there's some output (to know where it comes from), or in case of
failure.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-20 14:01:53 +10:00
Alastair Hughes
50a2db4834 Add the missing limits.h include to hook.c
PATH_MAX is only defined in limits.h in musl libc, so ensure that it is
included. Presumably this is also required on other platforms.

Signed-off-by: Alastair Hughes <hobbitalastair@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-20 14:01:53 +10:00
Allan McRae
e910d45ac0 Update translations
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-30 10:13:55 +10:00
Allan McRae
ad65462a05 Pull translations updates from Transifex
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-17 13:39:02 +10:00
Allan McRae
8d9890d3f4 Cast events to void* before passing to callback
Silence warnings from clang about typecasting alignment.

Reported-by: Rikard Falkeborn
Original-patch-by: Olivier Brunel
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-15 14:52:05 +10:00
Andrew Gregory
ab50864a75 add alpm_list_append
alpm_list_add always returns the provided list making it impossible for
callers to check whether or not the operation actually succeeded without
manually comparing the list length before and after.  alpm_list_append
instead returns a pointer to the newly created list item so that success
can be checked.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-15 14:47:36 +10:00
Rikard Falkeborn
875c017e4d Make alpm_graph state signedness explicit
The signedness of char is implementation defined. Since the
alpm_graph state is clearly meant to be signed, make the
signedness explicit.

This fixes bugs on systems where char is unsigned, in comparissons
of the following type:

  if(v.state == -1)

which, if state is unsigned, will never be true due to integer
promotion rules.

Fixes failing test/pacman/tests/sync012.py when compiling with -funsigned-char.

Fixes two warnings [-Wtype-limits] for comparissons with -1 when compiling
with -funsigned-char.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 13:59:19 +10:00
Allan McRae
4742f5929d Update copyright years for 2016
make update-copyright OLD=2015 NEW=2016

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 13:27:08 +10:00
Allan McRae
774c7eb24d Do not warn about missing files in NoExtract
The CheckSpace option checks the size of all files in a package being replaced
and gives a warning when it can not read the file.  However, files in NoExtract
are expected to be missing and should not be warned about.

Fixes FS#47470.

Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04 13:27:08 +10:00
Olivier Brunel
eadf389607 alpm: Abort ASAP on failure in pre-transaction hooks
There is no need to run any/remaining pre-transaction hooks as soon as a failure
has occured, which will lead to aborting the transaction.

So if an error occured during the first phase (reading directories/parsing
files), or as soon as a hook flagged abort_on_fail does fail, we stop processing
them and return.

(For post-transaction hooks, all hooks are run regardless since there's no
aborting.)

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 20:33:26 +10:00
Allan McRae
d721bae443 alpm-hooks: add Description field
The "Description" field allows a hook to provide a some text for frontends
to use in describing what the hook is doing.  For example:

Description = updating info page directory

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 20:15:02 +10:00
Allan McRae
760bea5432 Show progress processing hooks
Introduces the ALPM_EVENT_HOOK_RUN_{START,DONE} events that are triggered
at the start and end of running an individual hook.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 20:12:23 +10:00
Allan McRae
8d3bd4ec13 Add ALPM_EVENT_TRANSACTION_{START,DONE} events
This provides a way to detect when the processing of package changes starts,
allowing pacman to delineate hook output and package installation/removal
output.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 15:12:32 +10:00
Olivier Brunel
132ec4c3b9 Add events ALPM_EVENT_HOOK_{START,DONE}
Add events to let frontends know when hooks are being processed (and when it's
done), as that might be useful to update the UI.

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
2015-12-15 15:09:28 +10:00
Allan McRae
3802cab563 Collect all triggered hooks before running them
Having a first pass that checks which hooks are triggered followed by a
second pass of the triggered hooks allows us to only provide output when
a hook is actually triggered.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-15 15:03:14 +10:00
Allan McRae
f98541400b Pull translations from Transifex and prepare for next release
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-09 16:11:58 +10:00
Andrew Gregory
2015f0d1d9 alpm_run_chroot: remove dead code
Removes a leftover error message from when fdopen and fgets were used to
read from the pipe.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-06 10:34:31 +10:00
David Macek
71f9de64c6 alpm_initialize: Fix double slash in sys hook dir path
The path of the default system hook directory was created
by concatenating `myhandle->root` (usually "/"), and
SYSHOOKDIR (usually "/usr/share/libalpm/hooks/"), resulting
in "//usr/share/libalpm/hooks/". Fix this by skipping the
initial slash from SYSHOOKDIR.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-06 00:22:40 +10:00
Andrew Gregory
8ee084dbb3 db_update: always clear db flags after update
Signature downloading and DB validation was being based on the most
recent download status for the DB.  If a DB successfully downloaded but
a signature did not, db_update would move to the next server.  If the
next server tried does not have a more recent copy of the DB, db_update
would not download the DB again and would forget that the DB had
previously been updated.  In this case it would skip validation
entirely, leaving an updated DB with the original validation status.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-06 00:15:35 +10:00
Andrew Gregory
7b6f7bbe09 add and expose alpm_unlock
alpm_unlock is a limited version of alpm_release that does nothing but
the actual unlinking of the lock file and is therefore safe to call from
signal handlers.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 17:53:37 +10:00
Andrew Gregory
16623a7ea5 handle_unlock: return 0 if lockfile == NULL
Returning -1 is useless since we don't provide any way
to determine why it failed.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 17:52:16 +10:00
Andrew Gregory
4838d250e5 skip conflicts resolved by file replacement
When replacing a file with a directory, any files inside the new
directory cannot possibly exist on the filesystem and can be skipped.
This allows cross-package symlink-to-directory transitions when there
are files with the same name under both the symlinked directory and the
new directory.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 17:46:22 +10:00
Andrew Gregory
bb5e6c3b76 always unlink files before extraction
libarchive will not extract a directory over an existing directory
symlink, making it impossible to replace a symlink with a directory
across packages.  Adding the ARCHIVE_EXTRACT_UNLINK and
ARCHIVE_EXTRACT_SECURE_SYMLINKS causes libarchive to unlink the existing
symlink and prevents it from extracting any paths that contain
a symlink, which we should not be doing anyway.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-05 17:46:12 +10:00
Allan McRae
088649534e Add large file support CFLAGS to pkgconfig file
Large file support is enabled by our configure script as required.  If anything
linking to libalpm does not also define large file support, there will be
differences in the size of off_t which are not caught until runtime.

Add the required CFLAGS to the pkg-config file so that users of libalpm know
what flags are required.

Signed-off-by: Allan McRae <allan@archlinux.org>
2015-12-04 11:06:49 +10:00
Andrew Gregory
dfa4dcb16d run_chroot: always clear script output buffer
If the script output does not end in a newline there could still be data
in the buffer after the poll loop.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-29 08:12:44 +10:00
Andrew Gregory
5312e683fc hooks: pass matched targets to hooks
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-28 22:53:24 +10:00
Andrew Gregory
8ad893732d allow specifying input to scriptlets
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-28 22:52:11 +10:00
Andrew Gregory
b42d0852f3 allow arguments in hook Exec fields
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-28 16:26:51 +10:00