Commit Graph

467 Commits

Author SHA1 Message Date
Enno Boland
a5bfc59203 prepare release 2018-07-30 13:47:08 +02:00
Juan RP
512d39d591 Merge pull request #248 from ebfe/abspath
lib/package_unpack.c: refuse to unpack to absolute paths
2017-10-25 09:18:47 +02:00
Agustin Chiappe Berrini
2cd0dc688f Fix compilation of initend for gcc 7
This is a trickier situation.

The original message:

```
initend.c:423:10: error: ‘%s’ directive output may be truncated writing 15 bytes into a region of size between 1 and 512 [-Werror=format-truncation=]
       "%s%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "",
          ^~
initend.c:422:3: note: ‘snprintf’ output between 16 and 527 bytes into a destination of size 512
   snprintf(xhp->confdir, sizeof(xhp->confdir),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       "%s%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "",
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       XBPS_SYSCONF_PATH);
       ~~~~~~~~~~~~~~~~~~
initend.c:429:7: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation ]
       "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf);
       ^~~~~~~
initend.c:428:3: note: ‘snprintf’ output 2 or more bytes (assuming 513) into a destination of size 512
   snprintf(xhp->confdir, sizeof(xhp->confdir),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf);
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
initend.c:434:9: error: ‘%s’ directive output may be truncated writing 17 bytes into a region of size between 1 and 512 [-Werror=format-truncation=]
      "%s%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "",
         ^~
initend.c:433:2: note: ‘snprintf’ output between 18 and 529 bytes into a destination of size 512
  snprintf(sysconfdir, sizeof(sysconfdir),
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "%s%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "",
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      XBPS_SYSDEFCONF_PATH);
      ~~~~~~~~~~~~~~~~~~~~~
initend.c:455:11: error: ‘%s’ directive output may be truncated writing 14 bytes into a region of size between 0 and 511 [-Werror=format-truncation=]
       "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "",
           ^~
initend.c:454:3: note: ‘snprintf’ output between 16 and 527 bytes into a destination of size 512
   snprintf(xhp->cachedir, sizeof(xhp->cachedir),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "",
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       XBPS_CACHE_PATH);
       ~~~~~~~~~~~~~~~~
initend.c:461:7: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation ]
       "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf);
       ^~~~~~~
initend.c:460:3: note: ‘snprintf’ output 2 or more bytes (assuming 513) into a destination of size 512
   snprintf(xhp->cachedir, sizeof(xhp->cachedir),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf);
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
initend.c:467:11: error: ‘%s’ directive output may be truncated writing 12 bytes into a region of size between 0 and 511 [-Werror=format-truncation=]
       "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "",
           ^~
initend.c:466:3: note: ‘snprintf’ output between 14 and 525 bytes into a destination of size 512
   snprintf(xhp->metadir, sizeof(xhp->metadir),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "",
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       XBPS_META_PATH);
       ~~~~~~~~~~~~~~~
initend.c:473:7: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation ]
       "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf);
       ^~~~~~~
initend.c:472:3: note: ‘snprintf’ output 2 or more bytes (assuming 513) into a destination of size 512
   snprintf(xhp->metadir, sizeof(xhp->metadir),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       "%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf);
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
```

It's basically warning about dangerous operations on strings. And as
far as I could tell, is a valid warning and not a false alarm!

This fix makes the concept of `XBPS_MAXPATH` lose a little bit of sense
as now it doesn't necessarily represent the max size of the paths used
by xbps, but instead the max allowed size of the path configured.

I think this change is ok, but I wasn't able to find any reference to
why it was chosen to be 512. POSIX mandates at least 256, so I'm not
breaking anything that wasn't broken already, and Linux seems to have
a maximum size of 4096, which is pretty safe.

Therefore, this changes should be harmless. I think.
2017-08-22 18:35:45 -04:00
Michael Gehring
a2aec39d74 lib/package_unpack.c: refuse to unpack to absolute paths 2017-07-13 17:17:12 +00:00
Enno Boland
7ce66edc57 lib/util_hash.c: add xbps_file_hash_raw method
this function does not mmap the target file and therefore
avoids out of memory exceptions on 32bit systems.
2016-06-16 06:51:10 +02:00
Juan RP
35ad10ccbd Fix 29765271e correctly.
xbps_find_virtualpkg_in_conf() needs to look at the vpkgs set up in
configuration files, not from those set by pkgdb.

As a result of this the two test cases that were failing yesterday are now
fixed.
2016-03-24 10:23:20 +01:00
Enno Boland
fa635399f0 Merge pull request #156 from Gottox/atomic-rindex-a
xbps-rindex: check for consistent shlibs
2016-03-24 07:11:53 +01:00
Juan RP
29765271e9 xbps.d(5): 'virtualpkg' can now be used to map any pkg to another.
See NEWS for more information.
2016-03-23 12:46:52 +01:00
Enno Boland
4d1ee3b01d xbps-rindex: check for consistent shlibs
When adding packages to the index, xbps-rindex will check if the
consistency of shlibs is broken by a package. If so, rindex will create
a stage file and commit the packages there. Once the consistency is restored,
rindex -a will commit the stage area back to the public repo and delete the
stage file.
2016-03-21 08:31:18 +01:00
Enno Boland
897ac238c4 Revert "xbps-rindex: check for consistent shlibs"
This reverts commit 5f4e1ad43e which was
accidently checked in in the master branch.
2016-03-20 21:40:22 +01:00
Enno Boland
5f4e1ad43e xbps-rindex: check for consistent shlibs
When adding packages to the index, xbps-rindex will check if the
consistency of shlibs is broken by a package. If so, rindex will create
a stage repository and commit the packages there. Once the consistency
is restored, rindex -a will commit the stage area back to the public
repo and delete the stage file.
2016-03-20 21:36:30 +01:00
Juan RP
0d4906e1ae xbps_xasprintf: use __attribute__(format printf) too. 2016-02-06 09:46:52 +01:00
Juan RP
baf909caeb xbps.h: bump XBPS_APIVER due to xbps_handle::native_arch change. 2016-02-06 09:18:00 +01:00
Juan RP
42994ada07 Fix xbps_dbg_printf arguments by using __attribute__((format, printf)).
Patch provided by Michael Ghering in #148.

Close #148
2016-02-06 09:13:38 +01:00
Juan RP
c91b942a45 xbps.h: increase xbps_handle::native_arch to 64.
Requested by @chneukirchen.
2016-02-05 11:43:22 +01:00
Juan RP
35718e676c Document alternatives in the API. 2015-10-30 13:18:32 +01:00
Juan RP
cb857dfc27 Alternatives framework for xbps (2/2).
See xbps-alternatives(1) for more information.

Thanks to all who helped to design this and for fixing grammar in
the manual page.
2015-10-30 12:24:46 +01:00
Juan RP
a13a7fa896 Implemented reverse conflicts for pkgs in pkgdb and transaction. 2015-10-28 05:23:42 +01:00
Juan RP
0067cf6612 apidocs: sync with reality. 2015-10-20 11:37:29 +02:00
Juan RP
faeff38ca2 Alternatives framework (1/2) (WIP). 2015-10-18 10:38:35 +02:00
Juan RP
8081751f86 libxbps: print in verbose mode what pkgs are added to the transaction.
Useful to know why a transaction cannot be completed when there are
unresolved reverse dependencies.

Requested by @chris2.
2015-09-02 18:56:20 +02:00
Juan RP
07e8330936 xbps-install(1): added -U --unpack-only to only unpack pkgs, skips configuration. 2015-06-03 11:15:11 +02:00
Juan RP
769a997afb Introduce xbps_plist_{array,dictionary}_from_file().
Those are a wrapper around xbps_{array,dictionary}_internalize_from_zfile()
that prints a debugging msg when the plist file cannot be internalized.

Update xbps to use these wrappers.
2015-05-28 10:15:05 +02:00
Juan RP
e9b8ff7360 Added support to specify --dbdir to customize path to pkgdb. 2015-05-05 16:00:04 +02:00
Juan RP
c9d77d7b9c include/xbps.h: increase libfetch global cache limit to 32.
32 global connections and 16 per host cached connections seems to be a good
default. 8 global cached connections was insanely low.
2015-04-13 12:11:21 +02:00
Juan RP
9a16283575 Introduce xbps_repo_{un,}lock() to serialize write access to repodata.
We use a simple file lock that is created with O_CREAT|O_EXCL.
This should fix the concurrency issues with multiple processes
running xbps-rindex -a/-c on the same repository/arch combo.
2015-03-25 12:00:59 +01:00
Juan RP
441f147f05 Fix reinstallation of pkgs in repolock mode.
At the time we've been searching for the pkg in a repo, no repos
were registered resulting in EINVAL. While here, if there's no
declared repos return ENOENT instead.
2015-03-05 21:23:58 +01:00
Juan RP
ae8ce64542 Restore pkg file timestamps while unpacking as regular user.
Requested by @dominikh.
2015-02-21 16:52:27 +01:00
Juan RP
a05e039cce Revert "Stop converting relative symlinks to absolute."
This reverts commit 9ae3638429.

This change is ok, but cannot be used right now because all existing
binpkgs were created with an old xbps-create(8).
2015-02-19 11:11:58 +01:00
Juan RP
9ae3638429 Stop converting relative symlinks to absolute.
There's no reason to make them absolute, simply store in the metadata
the target file as is. This vastly simplifies the code and makes all
test pass correctly.
2015-02-19 11:04:34 +01:00
Juan RP
67eba7d912 Improve detection of target file in relative symlinks.
If xbps-create(8) did not guess the target file of relative symlinks for
some reason, just compare the current symlink and what's stored as is,
without converting it to absolute.

This might happen with dangling relative symlinks or existing binary
packages that were not created with a newer xbps-create(8).
2015-02-19 10:24:24 +01:00
Juan RP
05f879ec09 Introduce xbps_symlink_target() and use it in two places.
This code is now shared by xbps-pkgdb and libxbps/xbps-remove.
2015-02-19 09:47:09 +01:00
Juan RP
1722635e08 Introduce xbps_sanitize_path() to fix #78 properly.
This removes multiple slashes of a path and returns you a buffer with
the sanitized string.
2015-02-18 15:12:39 +01:00
Juan RP
d607655371 libxbps: globally check for unresolved reverse dependencies.
Close #46. See NEWS for more information.
2015-02-03 10:20:13 +01:00
Juan RP
b23855f692 xbps_repo_close: only unlock the file lock if repo was opened as such.
If xbps_repo_open() was called with the lock arg set, xbps_repo_close()
will now unlock the repo file lock, without the need to set it.

This avoids the need to always unlock the file lock even if it wasn't
locked previously. This also introduceds an ABI/API break, but this
way it's cleaner.
2015-01-11 09:11:38 +01:00
Juan RP
7dea05f507 xbps_pkgdb_update: added 3rd bool arg "update", not update in memory pkgdb.
If true, the in memory pkgdb dict will be updated with data from the on-disk pkgdb.
2015-01-10 19:42:09 +01:00
Juan RP
ee175a2a68 Improve xbps_end() and use it before exit(3)ing.
- Simplify xbps_repo_open::repo_get_dict().
- Use xbps_end() in the utils where necessary.
- Make xbps_end() call xbps_pkgdb_unlock() if necessary.
- Make xbps_end() release rpool resources.
- Make xbps_end() release resources from xbps_handle.
- Fixed 90% of reported leaks (still reachable at exit) from valgrind.

That was to silence valgrind's memcheck with --leak-check=full.
2015-01-10 19:11:31 +01:00
Juan RP
b09faadebc xbps-{install,query}: --repository now accepts relative paths in local repos. 2015-01-10 11:59:31 +01:00
Juan RP
eee895c6d8 Fixed a regression in vpkgs and improve xbps.d(5) virtualpkg declarations.
See the NEWS file for more information.
2014-12-31 08:51:45 +01:00
Juan RP
c8ecf4ac6c xbps-reconfigure(8): new option -i, --ignore to ignore pkgs with -a, --all.
-i, --ignore can be specified multiple times and can be used to
ignore configuration of those packages while configuration of all
packages is being performed.

Close #67
2014-12-09 13:10:48 +01:00
Juan RP
fe9a795995 xbps-{install,query}: added -M --memory-sync option.
This explicitly enables the in memory fetch/store of remote repository
data archives mode, ignoring existing on-disk repodata archives.

This changes the previous behaviour of falling back to this mode if no
on-disk repodata archives were found.

Thanks to @Gottox and @dominikh for comments.
2014-11-27 10:42:05 +01:00
Juan RP
7401ea3e64 Added support to fetch remote repodata on the fly.
See the NEWS file for more information.
2014-11-26 16:07:16 +01:00
Juan RP
89d11e871f xbps-{install,query}: added -i to ignore repos defined in xbps.d.
See the NEWS file for more information.
2014-11-21 10:56:41 +01:00
Juan RP
1789e527a9 Gratuitous ABI break: xbps_binpkg_get_xxx() -> xbps_archive_fetch_xxx(). 2014-11-21 09:51:57 +01:00
Juan RP
1bae26606e Introduce xbps_{pkgdb,rpool}_get_pkg_fulldeptree().
These routines return a xbps_array_t with a full sorted dependency graph
for the target pkg, by querying pkgdb or rpool.

Update xbps-query(8) to use the new libxbps API.
2014-11-20 09:23:51 +01:00
Juan RP
77c6c3e504 Introduce xbps_binpkg_get_file_into_fd() and use it for xbps-query(8) --cat.
This allows you to print to stdout any file stored in a binary package,
locally or remotely!

$ xbps-query -R --cat=/usr/bin/ls coreutils > ls
$ file ls
ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=7a195fc46d1d5cdca32bfccd3b30f81784e342ed, stripped
$
2014-11-17 18:43:08 +01:00
Juan RP
a6516505e9 xbps-query(8: added --cat=FILE mode support.
- This mode prints to stdout the matching FILE stored in a binary package.
- ABI break: renamed xbps_get_pkg_plist_from_binpkg() xbps_binpkg_get_plist().
- Added xbps_binpkg_get_file() as a generic way to get pkg file contents.
- Removed useless comments from xbps_api_impl.h.
2014-11-17 15:45:46 +01:00
Juan RP
3afb9d709d Get rid of repodata index-files; the archive is now 8x smaller.
See the NEWS file for more information.
2014-11-13 17:09:43 +01:00
Juan RP
43c9497feb Introduce xbps_array_add_first() to insert obj at the head of array.
The behaviour of this routine mimics the existing xbps_array_add() with
the difference that stored objects are moved to the right to insert
our object as the first element on the array.

Use this to add replaced packages in the transaction array at the head
rather than at the end, to preserve the proper sorting order.
2014-11-13 15:18:21 +01:00
Juan RP
53f13d579e Added the "bestmatching" configuration keyword to enable pkg best matching.
See the NEWS file for more information.
2014-11-07 10:07:51 +01:00