Commit Graph

1095 Commits

Author SHA1 Message Date
Yu Watanabe a168792c2d udev: drop collect 2018-09-10 18:27:36 +09:00
Thomas Haller 3301f9eb97 link: allocate correct number of bytes in ethtool_set_features()
sfeatures is a "struct ethtool_sfeatures". Use sizeof() on the correct
data type.

Since "struct ethtool_gstrings" is larger than "struct ethtool_sfeatures",
this had no serious consequences.

Fixes: 50725d10e3
2018-08-27 14:14:30 +02:00
Yu Watanabe 152d0efa2b udev: move udev cleanup functions from udev-util.h to udev.h 2018-08-23 04:57:39 +09:00
Yu Watanabe 51517f9e09 network: replace udev_device by sd_device 2018-08-23 04:57:39 +09:00
Yu Watanabe 3938f568a2 libudev: accept NULL as the argument 'struct udev*' for udev_monitor_new() or friends
As udev_monitor struct or friends are now almost independent of udev
struct. So, generating these objects without udev struct is reasonable.
2018-08-23 04:57:39 +09:00
Zbigniew Jędrzejewski-Szmek 7692fed98b
Merge pull request #9783 from poettering/get-user-creds-flags
beef up get_user_creds() a bit and other improvements
2018-08-21 10:09:33 +02:00
Lennart Poettering fafff8f1ff user-util: rework get_user_creds()
Let's fold get_user_creds_clean() into get_user_creds(), and introduce a
flags argument for it to select "clean" behaviour. This flags parameter
also learns to other new flags:

- USER_CREDS_SYNTHESIZE_FALLBACK: in this mode the user records for
  root/nobody are only synthesized as fallback. Normally, the synthesized
  records take precedence over what is in the user database.  With this
  flag set this is reversed, and the user database takes precedence, and
  the synthesized records are only used if they are missing there. This
  flag should be set in cases where doing NSS is deemed safe, and where
  there's interest in knowing the correct shell, for example if the
  admin changed root's shell to zsh or suchlike.

- USER_CREDS_ALLOW_MISSING: if set, and a UID/GID is specified by
  numeric value, and there's no user/group record for it accept it
  anyway. This allows us to fix #9767

This then also ports all users to set the most appropriate flags.

Fixes: #9767

[zj: remove one isempty() call]
2018-08-20 15:58:21 +02:00
Lennart Poettering 37ec0fdd34 tree-wide: add clickable man page link to all --help texts
This is a bit like the info link in most of GNU's --help texts, but we
don't do info but man pages, and we make them properly clickable on
terminal supporting that, because awesome.

I think it's generally advisable to link up our (brief) --help texts and
our (more comprehensive) man pages a bit, so this should be an easy and
straight-forward way to do it.
2018-08-20 11:33:04 +02:00
Thomas Haller cc2ff878fa link: fix type for link-config's "features" array of tristates
The "features" fields is parsed as a tristate value. The values
are thus not of type NetDevFeature enum but int. The NetDevFeature
enum is instead the index for the features array.

Adjust the type. In practice, this had no impact because NetDevFeature
enum commonly has size of int.

Also, don't use memset() 0xFF to initilize the int with -1. While
it works correctly in practice, it feels ugly.
2018-08-07 15:40:39 +02:00
Evgeni Golov eefe36e64c udev: net_id: document predictable names for SR-IOV virtual devices 2018-07-31 16:41:32 +09:00
Daniel 14a6aee050 changed exit(4) to asynchronous-safe _exit(4) in signal handler sig_alrm 2018-07-26 14:47:38 +02:00
Yu Watanabe f330408d62 tree-wide: drop empty lines in comments 2018-07-23 08:44:24 +02:00
Zbigniew Jędrzejewski-Szmek 4fdf69078a udev-builtin-kmod: adjust logging
I guess the one about "execute" was from the time when modprobe was called
directly.
2018-07-19 18:28:21 +02:00
Zbigniew Jędrzejewski-Szmek c3ad978633 udev-builtin-kmod: use the generic module_load() function
There should be no functional change.
2018-07-19 18:28:21 +02:00
Zbigniew Jędrzejewski-Szmek 6ae97a514b tree-wide: drop some leftover header for Lennart Poettering
Follow-up for 0c69794138.
2018-07-03 01:32:36 +02:00
Yu Watanabe afb76fdbff tree-wide: drop double newline 2018-06-29 11:02:17 +09:00
Zbigniew Jędrzejewski-Szmek 25612ecba4 tree-wide: drop copyright lines for more authors
Acks in https://github.com/systemd/systemd/issues/9320.
2018-06-22 16:39:45 +02:00
Roland Kammerer fee854ee8c udev: exclude DRBD from block device ownership event locking
It does not make sense for udev to even open DRBD block devices
(/dev/drbdX). It is on one hand not necessary as DRBD is controlled by
something else in the stack (e.g., pacemaker), and it even can get
cumbersome in various scenarios (e.g., DRBD9 auto-promote).

Closes: #9371

Signed-off-by: Roland Kammerer <roland.kammerer@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
2018-06-21 14:46:27 +02:00
Zbigniew Jędrzejewski-Szmek d9b02e1697 tree-wide: drop copyright headers from frequent contributors
Fixes #9320.

for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do
  git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms'
done
2018-06-20 11:58:53 +02:00
Hannes Reinecke c0373eb019 scsi_id: Fixup prefix for pre-SPC inquiry reply
The prefix for EMC Symmetrix pre-SPC VPD inquiry reply
is always SCSI_ID_NAA, so we need to hardcode it to
avoid false values here.

Signed-off-by: Hannes Reinecke <hare@suse.com>
2018-06-19 12:46:24 +02:00
Zbigniew Jędrzejewski-Szmek 50d1760d26 Drop more license boilerplate
$ git grep -e 'This program is free software' -l |grep -v LICENSE | \
  xargs perl -i -0pe 's/ \* This program.*?for more details.\s*\*\n( \* You should have.*licenses.>.\n)?//gms'

For some reason they were missed previously. All those files seem to
have proper SDPX tags.
2018-06-14 13:05:41 +02:00
Zbigniew Jędrzejewski-Szmek 0cd41d4dff Drop my copyright headers
perl -i -0pe 's/\s*Copyright © .... Zbigniew Jędrzejewski.*?\n/\n/gms' man/*xml
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/(#\n)?# +Copyright © [0-9, -]+ Zbigniew Jędrzejewski.*?\n//gms'
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s*\/\*\*\*\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*?\s*\*\*\*\/\s*/\n\n/gms'
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*//gms'
2018-06-14 13:03:20 +02:00
Lennart Poettering 96b2fb93c5 tree-wide: beautify remaining copyright statements
Let's unify an beautify our remaining copyright statements, with a
unicode ©. This means our copyright statements are now always formatted
the same way. Yay.
2018-06-14 10:20:21 +02:00
Lennart Poettering 0c69794138 tree-wide: remove Lennart's copyright lines
These lines are generally out-of-date, incomplete and unnecessary. With
SPDX and git repository much more accurate and fine grained information
about licensing and authorship is available, hence let's drop the
per-file copyright notice. Of course, removing copyright lines of others
is problematic, hence this commit only removes my own lines and leaves
all others untouched. It might be nicer if sooner or later those could
go away too, making git the only and accurate source of authorship
information.
2018-06-14 10:20:20 +02:00
Lennart Poettering 810adae9e9 tree-wide: use proper unicode © instead of (C) where we can
Let's use a proper unicode copyright symbol where we can, it's prettier.

This important patch is very important.
2018-06-14 10:20:20 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Filipe Brandenburger 3ad9705824 scsi_id: use _cleanup_free_ on buffer allocated by get_file_options
This simplifies the code a bit and hopefully fixes Coverity finding
CID 1382966. There was not actually a resource leak here (Coverity
seemed to be confused by thinking log_oom() could actually return 0),
but the fix doesn't hurt and should make this code more resilient to
future refactorings.

Tested: builds fine, manually called scsi_id, seems to work ok.
2018-06-08 15:15:02 +02:00
Filipe Brandenburger 9d635f50b8 udev-builtin-usb_id: Check full range of size returned by read()
This shouldn't be necessary, since read() should never return a size
larger than the size of the buffer passed in, but Coverity doesn't seem
to understand that.

We could possibly fix this with a model file for Coverity, but given
changing the code is not that much of a biggie, let's just do that
instead.

Fixes CID 996458: Overflowed or truncated value (or a value computed
from an overflowed or truncated value) `pos` used as array index.

Tested: `ninja -C build/ test`, builds without warnings, test cases pass.
2018-06-08 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek d94a24ca2e Add macro for checking if some flags are set
This way we don't need to repeat the argument twice.
I didn't replace all instances. I think it's better to leave out:
- asserts
- comparisons like x & y == x, which are mathematically equivalent, but
  here we aren't checking if flags are set, but if the argument fits in the
  flags.
2018-06-04 11:50:44 +02:00
Lennart Poettering 41b9d436b2 mtd: some basic code cleanups
While looking at our exit() invocations I noticed that the mtd_probe
stuff uses 'exit(-1)' at various places, which is not really a good
idea, as exit codes of processes on Linux are supposed to be in the
range of 0…255.

This patch cleans that up a bit, and fixes a number of other things:

1. Let's always let main() exit, nothing intermediary. We generally
   don't like code that invokes exit() on its own.

2. Close the file descriptors opened.

3. Some logging for errors is added, mostly on debug level.

Please review this with extra care. As I don't have the right hardware
to test this patch I only did superficial testing.
2018-05-10 11:02:33 -07:00
Zbigniew Jędrzejewski-Szmek 03d3a9d5be udevadm: fix null dererefence on allocation error
CID #1390936.
2018-05-10 01:49:01 +02:00
Zbigniew Jędrzejewski-Szmek f5ce2e764f
Merge pull request #8689 from davide125/static
meson: add support for building static libsystemd and libudev
2018-05-10 00:39:36 +02:00
Yu Watanabe 0fbddd042c network,udev: sort included headers 2018-05-09 12:00:27 +09:00
Yu Watanabe e90d037411 network,udev: make MACAddress= in [Match] section take multiple MAC addresses 2018-05-09 11:59:18 +09:00
Zbigniew Jędrzejewski-Szmek 975464e0d4 meson: recompile all sources for install_libudev_static and install_libsystemd_static
This means that when those targets are built, all the sources are built again,
instead of reusing the work done to create libbasic.a and other convenience static
libraries. It would be nice to not do this, but there seems to be no support in
our toolchain for joining multiple static libraries into one. When linking
a static library, any -l arguments are simply ignored by ar/gcc-ar, and .a
libraries given as positional arguments are copied verbatim into the archive
so they objects in them cannot be accessed.

https://stackoverflow.com/questions/2157629/linking-static-libraries-to-other-static-libraries
suggests either unzipping all the archives and putting them back togather,
or using a linker script. Unzipping and zipping back together seems ugly.
The other option is not very nice. The linker script language does not
allow "+" to appear in the filenames, and filenames that meson generates
use that, so files would have to be renamed before a linker script was used.
And we would have to generate the linker script on the fly. Either way, this
doesn't seem attractive. Since those static libraries are a niche use case,
it seems reasonable to just go with the easiest and safest solution and
recompile all the source files. Thanks to ccache, this is probably almost as
cheap as actually reusing the convenience .a libraries.

test-libsystemd-sym.c and test-libudev-sym.c compile fine with the generated
static libs, so it seems that they indeed provide all the symbols they should.
2018-05-08 17:33:04 +02:00
Davide Cavalca 20f3d32d8d meson: only build test-lib{systemd,udev}-static-sym for pic 2018-05-08 17:33:04 +02:00
Davide Cavalca 70848ecfc6 meson: add support for building static libsystemd and libudev 2018-05-08 17:33:04 +02:00
Susant Sahani 5f94520221 link: Add support to configure channels of the specified network device (#8882)
closes #8856
2018-05-08 13:03:41 +02:00
Susant Sahani 801d2c9f5d ethtool: get_glinksettings Fix copy (#8889)
It should be other way around.
2018-05-03 17:20:56 +02:00
Yu Watanabe fb702dd7dd udev: do not mark ari_enabled true when its sysattr value is 0 (#8870)
Fixes #8869.
2018-05-02 16:21:30 +02:00
Lennart Poettering 7b72fe21a6 link: follow our rule of suffix settings with = in log messages 2018-04-26 13:51:44 +02:00
Lennart Poettering 4e964aa05c networkd,udev: clean up MTU handling
This cleans up handling of MTU values across the codebase. Previously
MTU values where stored sometimes in uint32_t, sometimes in uint16_t,
sometimes unsigned and sometimes in size_t. This now unifies this to
uint32_t across the codebase, as that's what netlink spits out, and what
the majority was already using.

Also, all MTU parameters are now parsed with config_parse_mtu() and
config_parse_ipv6_mtu() is dropped as it is now unneeded.

(Note there is one exception for the MTU typing: in the DCHPv4 code we
continue to process the MTU as uint16_t value, as it is encoded like
that in the protocol, and it's probably better stay close to the
protocol there.)
2018-04-26 13:51:44 +02:00
Lennart Poettering 8e766630f0 tree-wide: drop redundant _cleanup_ macros (#8810)
This drops a good number of type-specific _cleanup_ macros, and patches
all users to just use the generic ones.

In most recent code we abstained from defining type-specific macros, and
this basically removes all those added already, with the exception of
the really low-level ones.

Having explicit macros for this is not too useful, as the expression
without the extra macro is generally just 2ch wider. We should generally
emphesize generic code, unless there are really good reasons for
specific code, hence let's follow this in this case too.

Note that _cleanup_free_ and similar really low-level, libc'ish, Linux
API'ish macros continue to be defined, only the really high-level OO
ones are dropped. From now on this should really be the rule: for really
low-level stuff, such as memory allocation, fd handling and so one, go
ahead and define explicit per-type macros, but for high-level, specific
program code, just use the generic _cleanup_() macro directly, in order
to keep things simple and as readable as possible for the uninitiated.

Note that before this patch some of the APIs (notable libudev ones) were
already used with the high-level macros at some places and with the
generic _cleanup_ macro at others. With this patch we hence unify on the
latter.
2018-04-25 12:31:45 +02:00
Nicolas Boichat dd6f840e36 udevadm/hwdb: Return non-zero exit code on error when --strict is used
- Add a new flag --strict to tell udevadm hwdb to return a
   non-zero code on error.
 - Make udevadm hwdb --update return an error when any parsing
   error occurs (only if strict flag is set).
2018-04-23 07:53:33 +08:00
Lennart Poettering 5d13a15b1d tree-wide: drop spurious newlines (#8764)
Double newlines (i.e. one empty lines) are great to structure code. But
let's avoid triple newlines (i.e. two empty lines), quadruple newlines,
quintuple newlines, …, that's just spurious whitespace.

It's an easy way to drop 121 lines of code, and keeps the coding style
of our sources a bit tigther.
2018-04-19 12:13:23 +02:00
Lennart Poettering 4d09e1c8ba
Merge pull request #8676 from keszybz/drop-license-boilerplate
Drop license boilerplate
2018-04-10 14:53:31 +02:00
Martin Wilck e438c57a64 systemd-udevd: limit children-max by available memory (#8668)
Udev workers consume typically 50-100MiB virtual memory.
On systems with lots of CPUs and relatively low memory, that may
easily cause workers to be OOM-killed.

This patch limits the number of workers to 8 per GiB memory.
But don't let the limit drop below the smallest value we had
without this patch (8 + 1 * 2 = 10); on small systems, udev's
memory footprint is likely lower.
2018-04-07 17:33:48 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00
Yu Watanabe 1cc6c93a95 tree-wide: use TAKE_PTR() and TAKE_FD() macros 2018-04-05 14:26:26 +09:00
Lennart Poettering 54479bf407
Merge pull request #8140 from stuarthayes/new
udev: network device naming improvements (sr-iov, npar, slots)
2018-03-28 13:33:06 +02:00