Commit Graph

1132 Commits

Author SHA1 Message Date
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
W. Trevor King
64f9a6a630 python: .update-copyright.conf: update to pipe separators.
This brings the config file up to speed with the following
update-copyright commit:

  commit 3c68a1a48419d8b2bbc2ce0e7f1700b996ec30e9
  Author: W. Trevor King <wking@tremily.us>
  Date:   Fri Oct 19 21:52:48 2012 -0400

    project: for consistency, also separate ignored paths with pipes.
2014-03-25 00:34:16 -03:00
W. Trevor King
8e8e24bcbd python: .update-copyright.conf: add MANIFEST.in to ignored files. 2014-03-25 00:34:16 -03:00
W. Trevor King
ac24814360 python: .update-copyright.conf: add Red Hat alias for Andy Grover.
He seems to be assigning copyright of files he writes to Red Hat.
Avoiding .mailmap so the git log will still attribute changes to him.
I'm not sure which name should go in the AUTHORS file.
2014-03-25 00:34:16 -03:00
W. Trevor King
5a39a9d988 python: .update-copyright.conf: add README.rst to ignored files. 2014-03-25 00:34:16 -03:00
W. Trevor King
3c65e333f7 python: .mailmap: consolidate Andy Grover email addresses. 2014-03-25 00:34:15 -03:00
W. Trevor King
6745a4a7da python: .update-copyright.conf: add copyright configuration.
Use my external update-copyright package to maintain copyright blurbs.

http://pypi.python.org/pypi/update-copyright/
2014-03-25 00:34:15 -03:00
W. Trevor King
0a2fab2b32 python: module: fix versions -> info typo in Module._info_get() error message. 2014-03-25 00:34:15 -03:00
W. Trevor King
d9c0c63eb7 python: Initialize Kmod.mod_dir to None in __cinit__(). 2014-03-25 00:34:15 -03:00
W. Trevor King
caee9c10c5 python: Use an OrderedDict for Module.info (preserving modinfo ordering). 2014-03-25 00:34:15 -03:00
W. Trevor King
81c1a4e840 python: Add Module.info attribute. 2014-03-25 00:34:15 -03:00