Commit Graph

1292 Commits

Author SHA1 Message Date
Lucas De Marchi ae58de0fcb kmod 18 2014-06-14 12:46:38 -03:00
Lucas De Marchi a5a41f8dbb testsuite: Fix macro missing format string 2014-06-14 11:14:58 -03:00
Lucas De Marchi 5963c36da3 testsuite: Add basic tests for hash implementation
Far from complete, but already covers all internal APIs.
2014-06-06 02:24:39 -03:00
Lucas De Marchi 30471c80a4 testsuite: Add assert_return
Add assert_return to use in testcases instead of assert. The issues
with assert are:
	1) It's disabled when NDEBUG is defined
	2) Even if it's well supported by testsuite (the parent will
	   report the child died) it can't output any meaningful
	   error message
2014-06-06 02:19:28 -03:00
Lucas De Marchi f988e25c68 testsuite: separate testcases on log 2014-06-05 17:54:41 -03:00
Lucas De Marchi 7a2d0e6187 testsuite: check for correct error message in detect-loop 2014-05-30 10:26:17 -03:00
Lucas De Marchi d7293a1628 testsuite: Fix expected_fail parsing
If a test has expected_fail=true, it means the return code must be
different from 0 *and* the outputs must match. This way it's possible to
check if the error messages are printed as they should.
2014-05-30 10:23:05 -03:00
Lucas De Marchi f429113a47 testsuite: Add braces 2014-05-30 10:20:19 -03:00
Lucas De Marchi c89d219884 depmod: Add better error messages when facing loops
Since now depmod fails when there are module loops, let's at least give
better error messages, printing the loops we found. Since we may have
more than 1 loop, just printing the modules that are in loop is not
very clear.

Assuming as an example 2 independent loops, this is how the new messages
compare to the old ones:

Before:
	depmod: ERROR: Found 5 modules in dependency cycles!
	depmod: ERROR: /tmp/test-kmod//lib/modules/3.14.4-1-ARCH/kernel/moduleE.ko in dependency cycle!
	depmod: ERROR: /tmp/test-kmod//lib/modules/3.14.4-1-ARCH/kernel/moduleB.ko in dependency cycle!
	depmod: ERROR: /tmp/test-kmod//lib/modules/3.14.4-1-ARCH/kernel/moduleC.ko in dependency cycle!
	depmod: ERROR: /tmp/test-kmod//lib/modules/3.14.4-1-ARCH/kernel/moduleD.ko in dependency cycle!
	depmod: ERROR: /tmp/test-kmod//lib/modules/3.14.4-1-ARCH/kernel/moduleA.ko in dependency cycle!

After:
	depmod: ERROR: Found 5 modules in dependency cycles!
	depmod: ERROR: Cycle detected: moduleE -> moduleD -> moduleE
	depmod: ERROR: Cycle detected: moduleB -> moduleC -> moduleA -> moduleB
2014-05-30 09:43:30 -03:00
Lucas De Marchi 8183cfa9da testsuite: add test to fail depmod on module loops 2014-05-30 09:36:56 -03:00
Lucas De Marchi a873f2350f depmod: Rename variable to clarify its meaning
In mod->modnamelen we were actually including the '\0', i.e.
strlen(modname) + 1. So rename it to modnamesz and add a comment in
depmod_module_is_higher_priority() to notice why it's correct since the
new one is really using strlen(modname).
2014-05-30 09:03:33 -03:00
Lukas Anzinger 86e19e9acd Fix use-after-free in hash implementation.
If a value is added to the hash under a key that already exists the new value
replaces the old value for that key. Since key can be a pointer to data that
is part of value and freed by hash->free_value(), the key must be also
replaced and not only the value. Otherwise key potentially points to freed data.
2014-05-18 16:04:50 -03:00
Leandro Pereira 30bfd48aef Close /sys/module/$NAME directory if opening /proc/module fails. 2014-05-14 20:24:19 -03:00
Leandro Pereira c1bc88c98e Free abspath if kmod_module_new_from_path() fails. 2014-05-14 20:21:20 -03:00
Leandro Pereira e84d912bd7 Free realnames if kmod_lookup_alias_from_alias_bin() fails 2014-05-14 20:19:52 -03:00
Leandro Pereira b6d985c61a Ensure read_long() reads the correct number of bytes from the index 2014-05-14 20:18:00 -03:00
Leandro Pereira d36c886aed Bail out of index_mm_open() if fstat() fails 2014-05-14 20:17:30 -03:00
Lucas De Marchi c48b269d64 depmod: Make dependency loops be fatal
Since the beginning depmod just warned about dependency loops and upon
creation of modules.dep{,.bin} it skipped the modules that were part of
a loop. However just skipping the modules may come as a surprise to
kernel module developers: they will need to try to load the module (or
to pay attention to the log messages) to notice thavt the module has not
been put in the index. Also, differently from module-init-tools we were
not skipping modules that depend on modules with dependency loops,
leading to a segfault in depmod.

So this is a summary of the change in behavior with this patch:

Loop 1)
    A -> B -> C -
    ^           |
    '------------

    Before:
        depmod: WARNING: found 3 modules in dependency cycles!
        depmod: WARNING: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleB.ko in dependency cycle!
        depmod: WARNING: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleC.ko in dependency cycle!
        depmod: WARNING: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleA.ko in dependency cycle!

        return code: 0

    After:
        depmod: ERROR: Found 3 modules in dependency cycles!
        depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleB.ko in dependency cycle!
        depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleC.ko in dependency cycle!
        depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleA.ko in dependency cycle!

        return code: 2

Loop 2)
    A -> B -> C -
         ^      |
         '-------

    Before:
        depmod: WARNING: found 2 modules in dependency cycles!
        depmod: WARNING: /tmp/test-kmod//lib/modules/3.14.2-1-ARCH/kernel/moduleB.ko in dependency cycle!
        depmod: WARNING: /tmp/test-kmod//lib/modules/3.14.2-1-ARCH/kernel/moduleC.ko in dependency cycle!
        Segmentation fault (core dumped)

    After:
        depmod: ERROR: Found 2 modules in dependency cycles!
        depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleB.ko in dependency cycle!
        depmod: ERROR: /tmp/test-kmod/lib/modules/3.14.2-1-ARCH/kernel/moduleC.ko in dependency cycle!

        return code: 2

The segfault above could be fixed, but let's just fail everything
because dependency cycles should be fixed in the modules rather than
just be skipped in the index.
2014-05-14 20:05:12 -03:00
Joe Lawrence 445e51c57d man: fixup spacing/parens in modprobe.d(5) 2014-05-13 14:45:15 -03:00
Lucas De Marchi b8b990f47d Add gitignore to module playground 2014-05-09 08:43:32 -03:00
Marco d'Itri 1008a2d5ba Remove references to systemd from the bash completion file
And restore the original LGPL disclaimer text.
2014-05-05 01:52:04 -03:00
Lucas De Marchi 3f8dd30a76 testsuite: Add module playground dir 2014-05-02 12:57:17 -03:00
Lucas De Marchi f5cdd574a5 Make sure there's NUL byte at the end of strndupa
Since strcpy() doesn't ensure we have a NUL byte in the resulting
string, use alloca() + memcpy(). Also make sure we don't evaluate "s"
twice.
2014-04-07 12:30:04 -03:00
Lucas De Marchi 04c0956e20 Add strndupa to missing.h 2014-04-07 11:00:24 -03:00
Lucas De Marchi 29bc329f55 Update .travis.yml
- Add cython to the dependencies, so it can compile the python bindings
 - Remove unecessary -Wno-error since now we don't use -Werror anymore.
2014-04-07 10:55:47 -03:00
Lucas De Marchi 49d8e0b590 kmod 17 2014-04-06 17:52:44 -03:00
Lucas De Marchi 3e68b2c455 testsuite: Remove duplicate test
This partially reverts ad7f175 ("Add test for depmod using search dirs
with same prefix"). Testing it twice in the inverted order doesn't
ensure we get the bug with wrong ordering.

As put by Anssi Hannula <anssi@mageia.org>:

	So the bug is triggered only if the shorter name is higher-prio _and_
	shorter name is traversed first. If the long name is traversed first,
	the bug don't trigger with either "search" directive order (and on my
	"make check" runs this is the case).
2014-04-06 17:46:45 -03:00
Lucas De Marchi 6ca7c0926f build-sys: enable python in bootstrap-configure 2014-04-06 17:14:23 -03:00
Michal Marek 9324bb52f3 testsuite: Warn if sysconfdir is not /etc 2014-04-04 13:06:05 +02:00
Michal Marek 81bf88d6c4 testsuite: Do not run tests with *.ko.gz if zlib is not enabled 2014-04-04 13:05:49 +02:00
Michal Marek 73476ec5cb testsuite: Uncompress most modules
Only keep test-depmod/modules-order-compressed to test compressed module
support.
2014-04-04 12:32:16 +02:00
Tom Gundersen 8240333b25 config: also parse softdeps from modules
This information can be found in /lib/modules/`uname -r`/modules.softdep, and
has only recently been exported by the kernel.

Also remove the advice about copying modules.softdep to /lib/modules as it is
not clear how to do this correctly with several kernels installed with
potentially conflicting soft dependencies.
2014-04-01 08:13:54 -03:00
Michal Marek 450bd1b429 libkmod: Ignore errors from softdeps
Before we had softdeps, the usual idiom was

install foo /sbin/modprobe bar; /sbin/modprobe --ignore-install foo

ignoring errors from the first modprobe invocation. This also matches
the behavior of module-init-tools' implementation of softdep.
2014-04-01 07:40:37 -03:00
Lucas De Marchi 3a33a7a566 build-sys: add hooks to build python bindings
Add --enable-python configure switch so we build the python bindings. We
also pass version.py through SED_PROCESS macro, so the version is kept
in sync with kmod.

Acked-by: Andy Grover <agrover@redhat.com>
2014-03-26 22:30:56 -03:00
Lucas De Marchi 5ad36e5222 python: Remove unused files from import
Acked-by: Andy Grover <agrover@redhat.com>
2014-03-26 22:30:49 -03:00
Lucas De Marchi 299a3adfe8 Merge branch 'master' of python-kmod
This is python-kmod is found in git@github.com:agrover/kmod.git
d5b6f22639c077b86659828bcc78dcedc9daaa94

Its history has being rewritten to prepare for a merge:

	- Every commit has been prefixed with "python: " in its commit
	  message
	- s-o-b's have been removed
	- Every file has been moved to libkmod/python directory

Some files don't make much sense anymore and are being removed
in this merge.

Acked-by: Andy Grover <agrover@redhat.com>
2014-03-26 22:30:31 -03:00
Guy Rozendorn c03dfbd5a7 python: Issue #15: resovled by using setuptools_cython 2014-03-25 00:34:16 -03:00
Guy Rozendorn 60ce23e707 python: Issue #15: Cython needs to be in setup_requires
We need Cython BEFORE installing kmod (done with setup_requires),
and AFTER installation - during runtime (done with install_requires)
2014-03-25 00:34:16 -03:00
Guy Rozendorn 1f9c5a04f7 python: Issue #15 Cython is now a dependency 2014-03-25 00:34:16 -03:00
Andy Grover 57a8efdf92 python: update version to 0.9.1 2014-03-25 00:34:16 -03:00
Guy Rozendorn 17b69ada6f python: Issue #13 skipping building extensions on non-Linux platforms 2014-03-25 00:34:16 -03:00
Andy Grover e4a57f6828 python: Make kmod.modprobe() raise an error if no modules found
Add 'quiet' option to override.

Add docstring.
2014-03-25 00:34:16 -03:00
Andy Grover 891e0756e7 python: Add self as maintainer to setup.py 2014-03-25 00:34:16 -03:00
Andy Grover 8e73a86d6e python: Correct building for python 2.6
Reported-by: Oz Nahum Tiram <nahumoz@gmail.com>
2014-03-25 00:34:16 -03:00
Oz f0d6f3701a python: add docstring to insert and remove methods 2014-03-25 00:34:16 -03:00
Oz 240c0f4694 python: add docstring to rmmod 2014-03-25 00:34:16 -03:00
Andy Grover b32900f4e8 python: update version to 0.9 2014-03-25 00:34:16 -03:00
Andy Grover 9ebfb9c198 python: Update README
Last update changed API slightly:
* loaded_modules renamed to modules
* returns a module object instead of (name, size)
2014-03-25 00:34:16 -03:00
W. Trevor King 26105c168f python: MANIFEST.in: add AUTHORS to distibuted source files. 2014-03-25 00:34:16 -03:00
W. Trevor King c8b5c51ed6 python: Ran update-copyright.py. 2014-03-25 00:34:16 -03:00