summaryrefslogtreecommitdiff
path: root/src/basic
AgeCommit message (Collapse)Author
2015-08-05hostname-util: add relax parameter to hostname_is_validZbigniew Jędrzejewski-Szmek
Tests are modified to check behaviour with relax and without relax. New tests are added for hostname_cleanup(). Tests are moved a new file (test-hostname-util) because there's now a bunch of them. New parameter is not used anywhere, except in tests, so there should be no observable change.
2015-07-24Merge pull request #704 from richardmaw-codethink/empty-arg-unquoteDaniel Mack
unquote_first_word: parse ` '' ` as an empty argument instead of no arg
2015-07-24unquote_first_word: parse ` '' ` as an empty argument instead of no argumentRichard Maw
2015-07-24exit-status: add a missing string for EXIT_SMACK_PROCESS_LABELSungbae Yoo
2015-07-24Merge pull request #694 from poettering/fileio-fixesDaniel Mack
Fileio fixes
2015-07-23process: an empty environment block should be returned as suchLennart Poettering
An empty env block is completely valid, hence return it as such, and don't turn it into an error.
2015-07-23process: return ESRCH when a PID is not valid anymoreLennart Poettering
so far, when we read something from /proc/$PID we would pass on the ENOENT from the kernel as error, if the process was missing. With this change we systematically convert this to ESRCH, which is the more appropriate error code, and what all the other glibc/syscalls like kill() use. All code that calls these functions should be fine with this change. In fact, one invocation of get_process_exe() in bus-creds.c already assumed ESRCH would be returned if a process is missing, and this assumption is now validated after the change.
2015-07-23fileio: get_status_field() don't clobber arg on OOMLennart Poettering
According to our coding style guidelines we shouldn't clobber pass-by-ref arguments on failure, hence don't do so here either.
2015-07-23Merge pull request #692 from poettering/fd-copy-directory-allDaniel Mack
copy: when we recursively copy a directory tree, copy everything
2015-07-23copy: when we recursively copy a directory tree, copy everythingLennart Poettering
Don't ignore hidden files and directories. Fixes #386
2015-07-23Merge pull request #678 from eworm-de/oracle-kvmLennart Poettering
Oracle kvm
2015-07-23virt: handle Virtualbox 5.0 with kvm hypervisorChristian Hesse
Virtualbox 5.0 now supports kvm hypervisor. In this case cpuid identidies as "kvm", which breaks units depending on ConditionVirtualization=oracle. So return "oracle" even with kvm hypervisor.
2015-07-23Merge pull request #682 from ssahani/bridgeLennart Poettering
networkd: add bridge link properties
2015-07-23bitmap: various clean-upsLennart Poettering
a) use memcmp() to compare bitmaps efficiently b) use UINT64_C() macro instead of ULL suffixes to get right suffix for uint64_t constants c) add a few assert()s d) when comparing integers with 0 we generally try to make this explicit with "!= 0". e) remove redundant bitmap_isset() if check, as we don't have it in bitmap_isset() either. f) It should be fine to invoke bitmap_unset() on a NULL bitmap
2015-07-23Add bridge NL params to missing.hSusant Sahani
2015-07-23Merge pull request #677 from zonque/bitmap2Tom Gundersen
basic: bitmap: use uint64_t instead if long long unsigned
2015-07-23Merge pull request #537 from poettering/nss-mymachines-usernsDavid Herrmann
Hook up container userns with nss-mymachines
2015-07-23basic: bitmap: use uint64_t instead if long long unsignedDaniel Mack
long long unsigned is always 64 bit wide, so use a more readable type.
2015-07-23bitmap: bitmap_clear()Lennart Poettering
No need to actually reset the bitmap, we can just truncate it back zero size. That not only makes bitmap_clear() quicker, but also subsequent bitmap_isclear().
2015-07-22Merge pull request #660 from michich/in-setMichal Schmidt
improve IN_SET macro
2015-07-22basic: more optimizable IN_SET macroMichal Schmidt
Making the array static allows gcc -O2 to generate smaller code: "size systemd" before: text data bss dec hex filename 1377286 128608 2632 1508526 1704ae systemd After: text data bss dec hex filename 1374326 128572 2664 1505562 16f91a systemd (IN_SET still results in worse generated code than using "x == FOO || x == BAR || ...". I don't think we'll be able to match that with the C preprocessor.) This change limits the use of IN_SET to sets with constant elements. All present callers use constants. The compiler would report an "initializer element is not constant" error otherwise.
2015-07-22basic: better readable IN_SET macroMichal Schmidt
Putting the set elements in an array variable and using ELEMENTSOF makes it clearer what's going on. Incidentally, it also makes gcc -O2 generate slightly smaller code: "size systemd", before: text data bss dec hex filename 1378318 128608 2632 1509558 1708b6 systemd After: text data bss dec hex filename 1377286 128608 2632 1508526 1704ae systemd
2015-07-22Tunnel NL params: Add to missing.hSusant Sahani
2015-07-20add NL parameters to missing.hSusant Sahani
2015-07-17basic: bitmap - complete fix for bitshift overflowTom Gundersen
The bug found by David existed in several places, fix them all. Also extend the tests to cover these cases.
2015-07-17bitmap: avoid 32bit integer overflow in shiftDavid Herrmann
We really must use 64bit integers to calculate long-long shifts. Otherwise, we will never get higher masks than 2^31.
2015-07-17bitmap: allow bitmap_iterate() on NULL bitmapDavid Herrmann
Make sure we properly treat NULL bitmaps as empty. Right now, we don't (which really looks like a typo).
2015-07-16bitmap: use external iteratorTom Gundersen
Reuse the Iterator object from hashmap.h and expose a similar API. This allows us to do { Iterator i; unsigned n; BITMAP_FOREACH(n, b, i) { Iterator j; unsigned m; BITMAP_FOREACH(m, b, j) { ... } } } without getting confused. Requested by David.
2015-07-15Merge pull request #588 from teg/resolved-nsecDaniel Mack
resolved: add basic NSEC and NSEC3 support
2015-07-14basic: util - add base32hexmem() function similar to hexmem()Tom Gundersen
This implements more of RFC4648.
2015-07-14basic: add a Bitmap implementationTom Gundersen
For when a Hashmap is overkill.
2015-07-14basic: util - fix memleak on error in unbase64mem()Tom Gundersen
2015-07-12basic: util - add base64mem() function similar to hexmem()Tom Gundersen
This implements RFC4648 for a slightly more compact representation of binary data compared to hex (6 bits per character rather than 4).
2015-07-12basic: util - fix errorhandling in unhexmem()Tom Gundersen
We were ignoring failures from unhexchar, which meant that invalid hex characters were being turned into garbage rather than the string rejected. Fix this by making unhexmem return an error code, also change the API slightly, to return the size of the returned memory, reflecting the fact that the memory is a binary blob,and not a string. For convenience, still append a trailing NULL byte to the returned memory (not included in the returned size), allowing callers to treat it as a string without doing a second copy.
2015-07-11Merge pull request #551 from poettering/fopen-temporary-noerrnoDaniel Mack
util: make sure we don't clobber errno in error path
2015-07-11basic: simplify path_is_mount_point() a bitLennart Poettering
This removes two uses of the ternary operator.
2015-07-11util: make sure we don't clobber errno in error pathLennart Poettering
2015-07-09nss-mymachines: map userns users of containers to real user namesLennart Poettering
Given a container "foo", that maps user id $UID to container user, using user namespaces, this NSS module extenstion will now map the $UID to a name "vu-foo-$TUID" for the translated UID $UID. Similar, userns groups are mapped to "vg-foo-$TGID" for translated GIDs of $GID. This simple change should make userns users more discoverable. Also, given that many tools like "adduser" check NSS before allocating a UID, should lower the chance of UID range conflicts between tools.
2015-07-09basic/util.c fopen_temporary(): close fd if failedcee1
2015-07-08Merge pull request #500 from zonque/fileioLennart Poettering
fileio: consolidate write_string_file*()
2015-07-07Remove repeated 'the'sZbigniew Jędrzejewski-Szmek
2015-07-06tree-wide: fix write_string_file() user that should not create filesDaniel Mack
The latest consolidation cleanup of write_string_file() revealed some users of that helper which should have used write_string_file_no_create() in the past but didn't. Basically, all existing users that write to files in /sys and /proc should not expect to write to a file which is not yet existant.
2015-07-06fileio: consolidate write_string_file*()Daniel Mack
Merge write_string_file(), write_string_file_no_create() and write_string_file_atomic() into write_string_file() and provide a flags mask that allows combinations of atomic writing, newline appending and automatic file creation. Change all users accordingly.
2015-07-06fileio: add 'enforce_newline' argument to write_string_stream()Daniel Mack
Add a flag to control whether write_string_stream() should always enforce a trailing newline character in the file.
2015-07-06get_process_environ: exit early when there is nothing to readKay Sievers
2015-07-06networkd: be more defensive when writing to ipv4/ipv6 forwarding settingsLennart Poettering
1) never bother with setting the flag for loopback devices 2) if we fail to write the flag due to EROFS (which is likely to happen in containers where /proc/sys is read-only) or any other error, check if the flag already has the right value. If so, don't complain. Closes #469
2015-07-03Merge pull request #473 from ↵Lennart Poettering
richardmaw-codethink/machinectl-import-earlier-than-3-15 util: fall back in rename_noreplace when renameat2 isn't implemented
2015-07-02util: fall back in rename_noreplace when renameat2 isn't implementedRichard Maw
According to README we only need 3.7, and while it may also make sense to bump that requirement when appropriate, it's trivial to fall back when renameat2 is not available.
2015-07-01socket: Set SO_REUSEPORT before bind()Christos Trochalakis
bind() fails if it is called before setting SO_REUSEPORT and another process is already binded to the same addess. A new reuse_port option has been introduced to socket_address_listen() to set the option as part of socket initialization.
2015-06-28util: fix incorrect escape sequence in string_is_safe()Eric Biggers