| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a glob yields no matches, try accessing a file named like the
literal pattern before finally giving up. Do this for any globs
supplied by the user, be it on the CLI or through a %files section.
We already do this with regular files in %files, this commit just
extends the same logic to the remaining places, namely special files
(%doc or %license) and package files passed on the CLI in install or
query mode (either directly or indirectly through a manifest).
This makes globbing in RPM consistent and more shell-like as Bash does
the same by default.
Do this by treating globs as filenames that may or may not expand into
multiple ones. That way, both cases can be handled by the same code
path.
We don't need to check for the existence of the literal pattern since
that's eventually taken care of in the rpmGlob() caller, such as in
addFile(). As a nice side effect, error reporting for missing glob and
non-glob filenames is now also unified, see the updated tests.
Preserve the public signature of rpmGlob(), though, by adding a new,
more general wrapper that also takes flags. The name is chosen to fit
the pre-existing scheme of rpm*Path() functions in rpmfileutil.h.
|
|
|
|
|
| |
No functional change, just shuffle some lines around for better
readability.
|
|
|
|
|
|
|
|
|
|
|
|
| |
As per GNU glob(3), GLOB_ONLYDIR does not guarantee the matches are in
fact directories, that's why we check them with lstat(2).
That may lead to the match list being empty even after a successful
glob() run (rc == 0), so for consistency, return GLOB_NOMATCH in that
case, just like we would for a missing file.
No functional change since we don't check for the exact return code in
the callers, only whether it's positive or not.
|
|
|
|
|
|
| |
Do set *argcPtr even if the actual count is 0, rather than leaving it
unchanged and thus possibly undefined in the caller. This is also
consistent with how glob(3) works.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
By definition, glob(3) matches pathnames on the file system, so no
pattern starting with a URL protocol (e.g. http:// or file://) will ever
produce any meaningful results when passed to it, it will just fail with
GLOB_NOMATCH.
This wasn't always the case, we used to call a custom Glob() function
here in the past, which knew how to handle URLs, but that was axed in
commit 9cbf0349b84fb19c6dddbe4f7a3246d4c949ad09 some 15 years ago.
To this day, however, we somewhat continue the legacy by letting
URL_IS_PATH (file://) patterns pass through glob(3) if they contain
magic chars, with the only possible outcome of failing afterwards. Drop
this special case and simply consider any known URL pattern as non-local
(int local = 0) and return it immediately. Also remove the no-op URL
code while at it.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Instead of constructing a new list from scratch and returning that, just
extend the passed list. This makes it easier to use this function
incrementally when expanding multiple patterns in a loop, such as during
package manifest parsing which we adapt here right away.
Preserve the ability to pass NULL as argvPtr and still get a match count
via argcPtr, by keeping the local argv around for that case.
No functional change.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now that we directly use GLOB_NOMAGIC to implement a fallthrough for
non-glob patterns since commit 9e541c6a7da076bc1c1beb1ee45fd5fdd735358c,
we may ironically end up subjecting such patterns to the lstat(2) check
at the end if they're directories, and thus possibly not return them.
While the actual impact on our codebase seems to be minimal, mostly in
terms of pushing the point of failure elsewhere and possibly printing a
different error message, for the sake of consistency with the idea of
GLOB_NOMAGIC, fix this by bringing back the short-circuit check.
While at it, make it a bit simpler than the original rpmIsGlob() by
leaving out the well-formedness check (i.e. if a bracket/brace has a
closing counterpart) as that's not what GLOB_NOMAGIC does either.
Remove the now unused next_brace_sub() as part of that.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Make sure any quoted metacharacters in a pattern are unescaped before
it's passed to addFile() and subsequently lstat(2). Do this by always
letting such patterns through rpmGlob() which now handles backslashes
properly since commit 4030062f2bf16d7a4540c78c1e61706f3810fe9b. Don't
expand globs twice in processSpecialDir(), though.
Axe the public rpmIsGlob() which is no longer needed, we'll be bumping
the soname in 4.19.
Construct absolute file names directly without going through
rpmGenPath() so that literal (double) percent signs are not expanded
twice and can be used the same way as in other parts of a spec file.
This means URLs are not handled anymore but we're dealing with local
files here so that should be fine.
Add the "cp" binary to the test environment, it's needed for the %doc
directives which copy stuff around.
Fixes: #1749
|
|
|
|
|
|
|
|
|
| |
Unindent the block touched in the previous commit and move declarations
to the beginning, dropping the now redundant gflags in the process.
Best served with "git show --ignore-all-space".
No functional change.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We currently accept a space-separated list of patterns here so any
backslash, whether it belongs to a space char or not, gets consumed by
poptParseArgvString() before the string is passed to glob(3), requiring
callers to double-escape anything they wish to keep literal.
Fix that by only accepting one pattern. Adapt the one caller which
relies on this actually being a list, in rpmReadPackageManifest(), and
those callers where we preserve spaces by escaping them which is no
longer needed.
Replace our own heuristic emulating GLOB_NOMAGIC with the actual flag to
glob(3) so that literal (double) backslashes are also handled properly.
Keep the indentation of the original for loop to make the diff easier to
read, next commit will fix that.
No immediate effect within RPM since we currently avoid passing escaped
patterns to rpmGlob(), this is just a prerequisite for the following
commits. External users of rpmGlob(), as unlikely as they are, might,
in theory, notice this subtle change but we'll be bumping the soname in
4.19 so that's covered.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
glibc 2.2 (or thereabouts) changed glob() and fnmatch() to not return
dangling symlinks as matches, which gravely affects rpmbuild in particular.
Because of this, rpm has carried a bundled copies of glibc 2.1 functions
for close to 22 years now (commit bed2a465fe49ce05f9678e619d016a2d26649c98).
glibc 2.27 in 2018 thankfully finally reverted that particular braindamage,
I think we've carried the compatibility babbage long enough to excuse
ourselves with a little shorter grace period in this case.
Nukes away, add a blurb about the version requirement on glibc
based systems.
This still leaves our internal glob_pattern_p() intact as unlike glob()
itself, that's not portable.
No functional changes as such.
|
|
|
|
|
|
|
|
| |
dirent.h and struct dirent are actually standard on this millenium, the
only thing that isn't is d_type member for which we have and retain
a specific test in configure.ac. Include <dirent.h> where needed,
relatively few places do which makes it even a bigger insult to have
this included from system.h.
|
|
|
|
|
| |
Similar to 8dda888e14df323e1dc1e76a42851e68980658cd but this one
noticed by covscan: not enough space for the terminating \0.
|
|
|
|
|
| |
Inspired by a similar change in glibc:
https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=686f2ea18374a541d203cfcc0e1dfba1666f49c2
|
|
|
|
|
|
|
|
| |
The missing space style-error has been recently coming common enough
somebody might think that IS the expected style, its not. Some of these
are actually very old, but fix across the board for consistency..
Strictly white-space only change.
|
|
|
|
|
|
| |
Happens with eg pattern "~0//0", easily visible if alloca() is changed
to malloc(). Reported as a security concern, dunno about that but a bug
it is anyway.
|
|
|
|
|
|
|
|
|
| |
Our implementation of glob() is copied from glibc (2.1 probably) which
has buggy implementation of next_brace_sub(). It is fixed in the newer
version of glibc. Now next_brace_sub() is modified according to newer
(fixed) version of glic. We didn't reveal this bug sooner because brace
expansion was disabled in rpm but we enabled brace expansion in
commit d14ecfe587efbe80e5534161dbd3a4f7158b4e2b.
|
|
|
|
|
|
|
| |
Now rpmIsGlob() checks if braces expansion pattern is well formed and
not only if it contains opening and closing brace. The checking
procedure is same as procedure in glob() so rpmIsGlob() and glob() are
now compatible.
|
| |
|
|
|
|
|
| |
- Obvious yes, but how come this didn't barf on my other rather
identical system? Meh.
|
| |
|
| |
|
|
|
|
|
| |
- Flags available to our internal glob implementation do not depend on
posix/gnu/bsd defines
|
|
|
|
| |
- We'll never run on these platforms, we just dont care...
|
| |
|
| |
|
|
|
|
|
| |
- We dont particularly care if rpmGlob() is thread-safe or not,
just use the simpler code-path
|
|
|
|
|
| |
- Provide a local copy of the trivial mempcpy() function so we can always
use the shorter code-path, eliminate now unnecessary ifdef goo.
|
|
|
|
| |
- We require a C99 compiler anyway so these conditionals are not needed
|
|
|
|
|
| |
- No doubt important bits in glibc but unnecessary goo for our
internal implementation.
|
|
|
|
|
| |
- rpm style isn't exactly K&R but close enuf for goverment work
and prevent sore eyes now that this is a "real" part of rpm.
|
|
|
|
|
|
| |
- Lump glob.h and glob.c into rpmglob.c in all their g(l)ory libc
decorations and make everything static to stop overriding system
library symbols with our own glob().
|
|
|
|
| |
- Further preliminaries to hiding the glob() implementation
|
|
- As a preliminary step to hiding our internal glob implementation,
split our only glob() user to a source of its own.
|