summaryrefslogtreecommitdiff
path: root/src/basic
AgeCommit message (Collapse)Author
2015-08-05Merge branch 'hostnamectl-dot-v2'Zbigniew Jędrzejewski-Szmek
Manual merge of https://github.com/systemd/systemd/pull/751.
2015-08-05hostname-util: ignore case when checking if hostname is localhostZbigniew Jędrzejewski-Szmek
2015-08-05hostname-util: get rid of unused parameter of hostname_cleanup()Zbigniew Jędrzejewski-Szmek
All users are now setting lowercase=false.
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-08-05Merge pull request #877 from crawford/dhcp-private-options-v4Lennart Poettering
networkd: save private-zone DHCP options
2015-08-04Use getxpid syscall on alpha for raw_getpid()Matt Turner
Alpha does not have a getpid syscall, but rather has getxpid to match OSF/1.
2015-08-04smack-util: revise smack-util apis and add read smack attr apisWaLyong Cho
- Add smack xattr lookup table - Unify all of mac_smack_apply_xxx{_fd}() to mac_smack_apply() and mac_smack_apply_fd(). - Add smack xattr read apis similar with apply apis as mac_smack_read{_fd}().
2015-08-04util: add getxattr helper apisWaLyong Cho
To get xattr of given path or fd on newly allocated buffer, add new helper api getxattr_malloc() and fgetxattr_malloc().
2015-08-04basic: add LIST_INSERT_BEFOREAlex Crawford
Similar in function to LIST_INSERT_AFTER, this will insert a new element into the list before the specified position. If the specified position is NULL, the element is added as the tail of the list.
2015-08-03Merge pull request #845 from poettering/terminal-o-nonblockDaniel Mack
add O_NONBLOCK to terminal handling
2015-08-03tree-wide: convert some more mfree() candidatesDaniel Mack
2015-08-03terminal-util: no real reason to assert on O_CREATLennart Poettering
That's just handle this as a normal error.
2015-08-03terminal-util: cast a couple of ioctl()s to voidLennart Poettering
2015-08-03terminal-util: when resetting terminals, don't wait for carrierLennart Poettering
In case of non-CLOCAL lines (i.e. those with carrier detect configured) we shouldnt wait for a carrier if all we try to do is reset the TTY. Hence, whenever we open such a TTY pass O_NONBLOCK. Note that we continue to open ttys we intend to write to without O_ONBLOCK, we only add it in cases we invoke ioctl()s or other terminal operations without reading or writing to the device. Fixes #835.
2015-07-31Merge pull request #814 from dvdhrm/mfreeDaniel Mack
tree-wide: introduce mfree()
2015-07-31tree-wide: introduce mfree()David Herrmann
Pretty trivial helper which wraps free() but returns NULL, so we can simplify this: free(foobar); foobar = NULL; to this: foobar = mfree(foobar);
2015-07-31Merge pull request #811 from namhyung/busctl-misc-v2Daniel Mack
busctl: Misc cleanups and a fix (v2)
2015-08-01busctl: add and use strcmp_ptr()Namhyung Kim
In member_compare_func(), it compares interface, type and name of members. But as it can contain NULL pointer, it needs to check them before calling strcmp(). So make it as a separate strcmp_ptr function (named after streq_ptr) so that it can be used by others. Also let streq_ptr() to use it in order to make the code simpler.
2015-07-31bitmap: make bitmap_clear free the bitmap arrayMartin Mikkelsen
Given two bitmaps and the following code: Bitmap *a = bitmap_new(), *b = bitmap_new(); bitmap_set(a, 1); bitmap_clear(a); bitmap_set(a, 0); bitmap_set(b, 0); These two bitmaps should now have the same bits set and they should be equal but bitmap_equal() will return false in this case because while bitmap_clear() resets the number of elements in the array it does not clear the array and bitmap_set() expects the array to be cleared. GREEDY_REALLOC0 looks at the allocated size and not the actual size so it does not clear any memory. Fix this by freeing the allocated memory and resetting the whole Bitmap to an initial state in bitmap_clear(). This also adds test code for this issue.
2015-07-31bitmap: fix bitmap_equal on bitmaps with unset bitsMartin Mikkelsen
Given two bitmaps and the following code: Bitmap *a = bitmap_new(), *b = bitmap_new(); bitmap_set(a, 0); bitmap_unset(a, 0); These two bitmaps should now have the same bits set and they should be equal but bitmap_equal() will return false in this case because the bitmaps array in a is larger because of the bit which was previously set. Fix this by comparing only the bits which exists in both bitmaps and then check that the rest of the bits (if any) is all zero. This also adds test code for this issue.
2015-07-31basic: fix error/memleak in socket-utilDavid Herrmann
Probably a typo, checking 'ret' instead of the return value 'p'. This might cause the function to return failure, even though it succeeded. Furthermore, it might leak resources.
2015-07-30unit-name: fix memory leakDaniel Mack
Fix a memory leak introduced by 2fc09a9c. 's' is used twice in this function, and if free_and_strdup() fails, the pointer is left untouched.
2015-07-30tree-wide: use free_and_strdup()Daniel Mack
Use free_and_strdup() where appropriate and replace equivalent, open-coded versions.
2015-07-29tree-wide: port everything over to fflush_and_check()Lennart Poettering
Some places invoked fflush() directly with their own manual error checking, let's unify all that by using fflush_and_check(). This also unifies the general error paths of fflush()+rename() file writers.
2015-07-29socket-util: library calls shouldn't log on their ownLennart Poettering
Instead, make sure that all callers log properly.
2015-07-27util: base32hex - explain distinction with base32Tom Gundersen
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.