Commit graph

7446 commits

Author SHA1 Message Date
Allan McRae
479f4d574a Prevent buffer overflow when using a scriptlet shell with a long path
Observed in Nixpkgs.  Fixes #157.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-06-19 07:41:11 +10:00
Remi Gacogne
9f8f94c056 Add --disable-sandbox and DisableSandbox
Signed-off-by: Remi Gacogne <rgacogne@archlinux.org>
2024-06-17 11:01:42 +10:00
Remi Gacogne
eacadbcc41
Restrict filesystem access to the download process whenever possible
Signed-off-by: Remi Gacogne <rgacogne@archlinux.org>
2024-06-14 09:30:20 +02:00
Remi Gacogne
24304c6df0 Fix up-to-date repo databases being redownloaded when sandboxed
Signed-off-by: Remi Gacogne <rgacogne@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-06-10 19:48:20 +10:00
Allan McRae
f0a7f85dbb libmakepkg: make configured BUILDENV readonly
PKGBUILDs should not be directly adjusting this variable

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-05-31 16:15:54 +00:00
Allan McRae
b013ca4221 makepkg: provide environment variable to disable PKGBUILD linting
On Windows based systems (e.g. msys), running PKGBUILD linting is very
slow due to time taken spawning bash subshells.  Additionally, some packages
have extreme amounts of (usually procedurally generated) splitting, which
also causes linting to be extremely slow.  Provide an environment variable
to disable PKGBUILD linting.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-06-01 02:12:23 +10:00
Diego Viola
44b9a53b2d Fix spelling of environment 2024-05-31 16:11:07 +00:00
Diego Viola
24455cc5b2 editorconfig: update url
Use https and lowercase characters.

Signed-off-by: Diego Viola <diego.viola@gmail.com>
2024-05-27 02:31:30 -03:00
Diego Viola
7bbfc17f3c Fix typos
Signed-off-by: Diego Viola <diego.viola@gmail.com>
2024-05-20 02:30:50 -03:00
Allan McRae
d74d7ec32c makepkg: remove GITFLAGS support
Supporting git source fragments (branch, commit, tag) is difficult in
conjunction with GITFLAGS usage - particularly with the most common
use cases that reduce the amount of data cloned from the upstream repo.

Leaving GITFLAGS in place an documenting that various git source features
are not supported when GITFLAGS are in used is not an ideal 'solution'.
Instead, remove GITFLAGS support.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-05-20 00:18:43 +00:00
Allan McRae
76e1cb1bf1 Revert "Prepare git src with git worktree"
This causes issues when repeatedly building a package using the same
git checkout.  There is also ambiguity of the default checkout when
trying to build from HEAD. See #142 and #143.

This reverts commit 85c421f1cb.
2024-05-20 10:15:33 +10:00
Allan McRae
0f2417f919 doc/makepkg.8: Improve --cleanbuild documentation
Fixes #45.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-05-12 03:33:01 +00:00
Allan McRae
e1df19ee6f makepkg: drop sudo permissions after use
Add the -k parameter to the sudo call to prevent caching of credientials.
This would (potentailly) stop a rogue sudo use within a PKGBUILD.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-05-12 03:30:06 +00:00
Allan McRae
6d85d9ae08 Document makepkg.conf.d/ drop-in configuration
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-05-12 03:25:42 +00:00
EnnoxHD
8aba032de4 makepkg: make 'not a clone of' visible with a new error code
Add a new error code to expose the 'not a clone of' error state of some source
providers (git and fossil). This allows other tools integrating further and
handle this specific error state.

One usecase evolves around frequently changing source locations in PKGBUILDs
of packages in the AUR.
2024-05-05 12:24:56 +10:00
Daan De Meyer
bcd4aad16c Stop redirecting stderr of bsdtar to /dev/null
It's extremely hard to figure out what's going from when bsdtar fails
here when we expect it to succeed. Stop tunneling stderr to /dev/null
to help users figure out what's going on when this fails.
2024-05-05 02:10:30 +00:00
Tom "Ravi" Hale
85c421f1cb Prepare git src with git worktree 2024-05-04 22:28:57 +10:00
Allan McRae
9f78628f6c Update RELEASE documentation for website deployment via gitlab CI
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-05-04 11:21:26 +00:00
Allan McRae
60d517107b Deploy website using gitlab pages
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-05-04 11:21:26 +00:00
Wiktor Kwapisiewicz
7fc080c582 Remove --use-agent from the manpages of makepkg and repo-add 2024-05-04 21:19:56 +10:00
Christoph Reiter
15a2338656 meson: use the custom meson provided intl dependency
Let meson deal with the system differences instead of handling
it manually.

The custom dependency was added in meson 0.59, then gained
static support with 0.60, and static support for cygwin with 0.61,
which is why the meson requirement is bumped to 0.61.

Debian bullseye ships meson 0.56, so switch to bookworm which
has 1.0.1
2024-05-04 21:05:48 +10:00
Chih-Hsuan Yen
9548d6cc76 Fix unstable git checksums
Closes https://gitlab.archlinux.org/pacman/pacman/-/issues/131
2024-05-04 10:14:11 +00:00
Allan McRae
792df078fa libmakepkg: add fortran buildenv to meson sources array
Fixes #132.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-05-04 10:10:23 +00:00
lilydjwg
8e30cd4e38 makepkg: fix git checksumming depends on user config 2024-04-22 04:48:19 +00:00
Allan McRae
03d884d7ff repo-add: handle lack of newline at end of .PKGINFO
Work around the final line not being parsed in .PKGINFO if there was a lack
of newline at the end of the file.  This could occur due to utilising a tool
other than makepkg to create packages.

The missed line created a difference in the parsing of .PKGINFO between
repo-add and pacman, causing packages to be seen as invalidwith pacman-6.1.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-22 04:46:30 +00:00
Allan McRae
7dcf9a2b49 libmakepkg: do not unset CHOST with !buildflags
Also ensure CHOST and MAKEFLAGS are exported.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-20 11:37:54 +10:00
Allan McRae
4dc21b965b _alpm_archive_fgets(): bail early if reached end of block
Bailing early when there are 0 blocks remaining means that we do not call
memchr on a NULL string (although with a 0 size parameter).  Fixes issues
reported using -fsanitise=address,undefined

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-08 10:34:10 +00:00
Allan McRae
936eff63bf Add guidelines for managing release branches
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-05 12:02:40 +10:00
Allan McRae
f86c15e780 unlink_file: restore trailing slash on directory before checking mountpoint
The dir_is_mountpoint() function has the explicit requirement that the
trailing slash of the directory is present.  We strip the trailing slash
in unlink_file() to handle directories replaced with symlinks, but that
then affects the dir_is_mountpoint() check.

Add the trailing slash when we have established we are dealing with a
directory. Note this may fail in the case of a file managed by pacmane
with name length of PATH_MAX that has been replaced by a directory on the
file system. Bail on this unlikely scenario.

In addtion, be less fancy with adjusting length of the file char array.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-05 00:51:13 +00:00
Allan McRae
49ebd856ec pacman-key: fix permission checks for non-root operations
Removing lock-never from the default gpg.conf file exposed a couple of bugs
in the permission checks in pacman-key.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-05 00:47:45 +00:00
Allan McRae
027ecbc7b8 libmakepkg: remove MAKEFLAGS from buildenv_vars
MAKEFLAGS should not be cleared by options=(!buildenv).

Regression introduced in commit 09e82f01ea

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-05 00:43:57 +00:00
Allan McRae
f763ff774a Fix leak in total progress bar
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-05 00:39:29 +00:00
Allan McRae
0ccb584262 Do not pass NULL paramenter to bsearch with empty filelist
A filelist can be non-NULL but empty (particularly with a lot of
NoExtract entries). Handle this in alpm_filelist_contains()

Identified using the undefined behaviour sanitizer.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-05 00:35:08 +00:00
Allan McRae
27eba85594 Fix typo in cb_progress
Introduced in 74deada511.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-02 23:18:34 +10:00
Remi Gacogne
cfa68f7b26 Restore partially downloaded files to the temporary directory
This allows downloads to be continued.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-01 20:52:55 +00:00
Remi Gacogne
e1a7b83e8e Download to a temporary directory owned by the Download user
Signed-off-by: Remi Gacogne <rgacogne@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-01 20:52:55 +00:00
Andrew Gregory
11c8eca9a6 pactest: test database downloads with optional signatures
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-01 20:52:55 +00:00
Andrew Gregory
0b6df551b5 pactest: Add basic sandboxed download tests
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-01 20:52:55 +00:00
Remi Gacogne
5e9bff6216 Stop trusting the Content-Disposition HTTP header 2024-04-01 20:52:55 +00:00
Allan McRae
26b7b35307 Remove random_partfile from payload struct
It is not used any more due to filling the payload structure earlier.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-01 20:52:55 +00:00
Allan McRae
04d04381bc libalpm: fill in more payload information before passing to downloader
Filling in more of the payload fields before passing to the downloader ensures
that the these fields do not get lost during sandboxed operations.

It also fixes the use of -U with XferCommand, but testsuite still fails due to
"404" page being downloaded for the signature. Given we can not identify this
as being a non-signature download with the XferCommand, we can just turn off
signature checking in this test.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-01 20:52:55 +00:00
Remi Gacogne
49d512267e Document DownloadUser
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-01 20:52:55 +00:00
Remi Gacogne
cf359b0da4 Add support for DownloadUser with XferCommand
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-01 20:52:55 +00:00
Remi Gacogne
93a796aa27 Add sandboxed download for the internal downloader
If the SandboxUser configure option is set, the internal downloader
will fork of a child process and drop to the specified user to download
the files.

Signed-off-by: Remi Gacogne <rgacogne@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-01 20:52:55 +00:00
Allan McRae
9667bc6b12 Expose _alpm_reset_signals() to library
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-01 20:52:55 +00:00
Remi Gacogne
62c6874689 Add callbacks for sandboxed operations
Add log and download callbacks to use within a sandbox.  These are
designed to be passed from the sandbox to the parent through a file
descriptor and then processed into alpm callbacks to be passed to the
frontend.

Note, only callbacks used in libalpm are added. Other callbacks should
be set to NULL in the child process.
2024-04-01 20:52:55 +00:00
Remi Gacogne
ce83cf6361 Provide function for switching user in child processes
Add alpm_sandbox_child() function that will be used for switching to a
less priviledged user to run child processes.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-01 20:52:55 +00:00
Remi Gacogne
56eb87287e Add DownloadUser configuration option
The DownloadUser option will be used to drop privledges to the
specified user when downloading files.

The intention is for this to be extended in the future  to a more
general sandbox configuration to cover operating on package and
database files prior to verification.

Add this option to pacman configuration and the various accessors into
the libalpm backend.

Signed-off-by: Allan McRae <allan@archlinux.org>
2024-04-01 20:52:55 +00:00
Vladislav Nepogodin
01e64e8b6a use snprintf instead of sprintf
sprintf does not check for buffer overflows (CWE-120)

	modified:   src/pacman/callback.c
2024-03-25 13:24:41 +10:00
Allan McRae
b2bb2e2482 makepkg: Fix missing end of line in -D documentaiton
Signed-off-by: Allan McRae <allan@archlinux.org>
2024-03-20 21:39:41 +10:00