summaryrefslogtreecommitdiff
path: root/src/shared
AgeCommit message (Collapse)Author
2014-10-22resolved: simplify detection of packets from the loopback deviceLennart Poettering
We can simplify our code quite a bit if we explicitly check for the ifindex being 1 on Linux as a loopback check. Apparently, this is hardcoded on Linux on the kernel, and effectively exported to userspace via rtnl and such, hence we should be able to rely on it.
2014-10-21strv: use realloc_multiply() to check for multiplication overflowMichal Schmidt
This could overflow on 32bit, where size_t is the same as unsigned.
2014-10-21strv: add an additional overflow check when enlarging strv()sLennart Poettering
https://bugs.freedesktop.org/show_bug.cgi?id=76745
2014-10-21shared: remove unused functionsRonny Chevalier
- mkdir_p_prefix: It has never been used - mkdir_parents_prefix_label: Unused since 1434ae6fd49f8377b0ddbd4c675736e0d3226ea6
2014-10-21util: avoid duplication of TIME_T_MAXRonny Chevalier
2014-10-17systemd: continue switch-root even if umount failsZbigniew Jędrzejewski-Szmek
Leaving the old root around seems better than aborting the switch.
2014-10-17environment: append unit_id to error messages regarding EnvironmentFileLukas Nykryn
2014-10-17missing: remove fanotifyZbigniew Jędrzejewski-Szmek
It was only used in readahead.
2014-10-15selinux: fix potential double free crash in child processMichal Sekletar
Before returning from function we should reset ret to NULL, thus cleanup function is nop. Also context_str() returns pointer to a string containing context but not a copy, hence we must make copy it explicitly.
2014-10-09util: avoid double close of fdThomas Hindoe Paaboel Andersen
We could end with a double close if we close the fd loop and flush_fd fails. That would make us goto fail and there we close the fd once again. This patch sets the fd to the return value for safe_close: -1 A fd with negative value will be ignored by the next call to safe_close. CID#996223
2014-10-08time: functions named "internal" really shouldn't be exportedLennart Poettering
Also, let's try to make function names descriptive, instead of using bools for flags.
2014-10-08systemctl: add add-wants and add-requires verbsLukas Nykryn
2014-10-08unit: move UnitDependency to unit-nameLukas Nykryn
2014-10-07core: don't allow enabling if unit is maskedJan Synacek
2014-10-05build-sys: use linux/memfd.h if availableZbigniew Jędrzejewski-Szmek
linux/memfd.h was added linux 3.17, so it might not be widely available for a while. Also, check if memfd_create is defined, for the HAVE_LINUX_MEMFD_H check to have a chance of succeeding. Also, collapse all ifdefs for memfd-related stuff, because they were all added together so there's no need to check separately.
2014-10-05ask-password: Add --echo to enable echoing the user inputDavid Sommerseth
Programs such as OpenVPN may use ask-password for not only retrieving passwords, but also usernames. Masking usernames with * seems just silly. v2 - Don't mess with termios flags, instead print the input instead of an asterix. Resolves issues with backspace and TAB input. v3 - Renamed 'do_echo' variables and argument to 'echo'. Also modified the ask_password_{tty,agent,auto} API instead of additional wrapper functions. [zj: undo changes to ask_password_auto, since no callers were using the new argument.]
2014-10-03pty: optimize read loopDavid Herrmann
As it turns out, I can actually send data to the pty faster than the terminal can read. Therefore, make sure we read as much data as possible but bail out early enough to not cause starvation. Kernel TTY buffers are 4k, so reduce the overall buffer size, but read more than once if possible (up to 8 times sounds reasonable).
2014-10-03fileio-label: return error when writing failsZbigniew Jędrzejewski-Szmek
The status of actually writing the file was totally ignored.
2014-10-03journalctl: make --utc work everywhereJan Synacek
The --utc option was introduced by commit 9fd290443f5f99fca0dcd4216b1de70f7d3b8db1. Howerver, the implementation was incomplete.
2014-10-02virt: detect that we are running inside the docker containerMichal Sekletar
2014-10-02Fix order and document user unit dirsZbigniew Jędrzejewski-Szmek
Fixup for 718880ba0d 'add a transient user unit directory'.
2014-10-02Rename user_runtime to user_runtime_dirZbigniew Jędrzejewski-Szmek
This makes this function name similar to user_config_home() and makes it match the name of the environment variable.
2014-10-02add a transient user unit directorySteven Allen
This patch adds a transient user unit directory under `$XDG_RUNTIME_DIR/systemd/user/` and stores transient user-instance units (such as those created by `systemd-run --user`) under there instead of putting them in $XDG_CONFIG_HOME/systemd/user/. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=67331
2014-10-02journalctl: add --utc optionJan Synacek
Introduce option to display time in UTC.
2014-10-02barrier: fix up constructor error handlingDavid Herrmann
We cannot rely on "errno" to be non-zero on failure, if we perform multiple glibc calls. That is, if the first eventfd() call fails, but the second succeeds, we cleanup the barrier but return 0. Fix this by always testing the return value immediately. This should also fix all the coverity warnings.
2014-10-01Remove repeated includesThomas Hindoe Paaboel Andersen
In pty.c there was both an include of our pty.h and the system installed pty.h. The latter contains only two functions openpty and forkpty. We use neither so I assume it was a typo and removed it. We still compile and pass all tests.
2014-10-01shared: util - use nicer idiom to silence CoverityZbigniew Jędrzejewski-Szmek
Change the other spot too.
2014-09-30shared: util - use nicer idiom to silence CoverityTom Gundersen
Suggested by Zbigniew.
2014-09-29util: silence coverityTom Gundersen
Make it clear in the code that ignoring a failed safe_ato?() is intentional.
2014-09-29Do not format USEC_INFINITY as NULLZbigniew Jędrzejewski-Szmek
systemctl would print 'CPUQuotaPerSecUSec=(null)' for no limit. This does not look right. Since USEC_INFINITY is one of the valid values, format_timespan() could return NULL, and we should wrap every use of it in strna() or similar. But most callers didn't do that, and it seems more robust to return a string ("infinity") that makes sense most of the time, even if in some places the result will not be grammatically correct.
2014-09-26make utmp/wtmp support configurableEmil Renner Berthing
This adds --disable-utmp option to configure. If it is used, all utmp-related functionality, including querying runlevel support, is removed.
2014-09-25shared: path-util - try to make PATH_FORECH_PREFIX look less wrongTom Gundersen
We replace the idiom "X && !(*foo = 0)" with "X && ((*foo = 0), true)". This is not a functional change, but should hopefully make it less likely that people and static analyzers believe there is a typo here (i.e., to make it clear that the intention was not "X && *foo != 0"). Thanks to David Herrmann for the suggestion.
2014-09-25localectl: print warning when there are options given on kernel cmdlineMichal Sekletar
2014-09-25fileio: make parse_env_file() return number of parsed itemsMichal Sekletar
This commit introduces possibility to call parse_env_file_internal() and hand over extra argument where we will accumulate how many items were successfully parsed and pushed by callback. We make use of this in parse_env_file() and return number of parsed items on success instead of always returning zero. As a side-effect this commit should fix bug that locale settings in /etc/locale.conf are not overriden by options passed via kernel command line.
2014-09-23Fix warning about unused variable with !SELINUXZbigniew Jędrzejewski-Szmek
src/shared/label.c:255:15: warning: unused variable 'l' [-Wunused-variable] char *l = NULL; ^
2014-09-22util: avoid non-portable __WORDSIZEEmil Renner Berthing
Lets not unnecessarily rely on __WORDSIZE, which is not clearly specified by any spec. Use explicit size comparisons if we're not interested in the WORDSIZE, anyway. (David: adjust commit message to explain why we do this)
2014-09-22exit-status.c: bring EXIT_BUS_ENDPOINT label in line with othersZbigniew Jędrzejewski-Szmek
2014-09-22util: add alloca_align()David Herrmann
The alloca_align() helper is the alloca() equivalent of posix_memalign(). As there is no such function provided by glibc, we simply account for additional memory and return a pointer offset into the allocated memory to grant the alignment. Furthermore, alloca0_align() is added, which simply clears the allocated memory.
2014-09-19socket: introduce SELinuxContextFromNet optionMichal Sekletar
This makes possible to spawn service instances triggered by socket with MLS/MCS SELinux labels which are created based on information provided by connected peer. Implementation of label_get_child_mls_label derived from xinetd. Reviewed-by: Paul Moore <pmoore@redhat.com>
2014-09-19shared: wtmp-utmp - don't clear store_wtmp in utmp_put_dead_process()Tom Gundersen
Also modernize a few other things and add comments to explain CID #1237503 and CID #1237504.
2014-09-19shared/sparse-endian.h: add missing byteswap.h includeEmil Renner Berthing
2014-09-19shared/label.h: add missing stdio.h includeEmil Renner Berthing
2014-09-19pty: include linux/ioctl.h for TIOCSIGDavid Herrmann
TIOCSIG is linux specific, so include the linux ioctl header to make sure it's defined. We currently rely on some rather non-obvious recursive includes. Make sure its always defined regardless of the system headers.
2014-09-18shared: conf-parser - don't leak memory on error in DEFINE_CONFIG_PARSE_ENUMVTom Gundersen
Found by Coverity. Fixes CID #1237746.
2014-09-17shared: conf-parserTom Gundersen
Check memory allocation. Found by Coverity. Fixes CID #1237644.
2014-09-16util: remove a unnecessary checkThomas Hindoe Paaboel Andersen
We only break out of the previous loop if fd >= 0 so there is no use in checking it again. Found by coverity. Fixes: CID#1237577
2014-09-16shared: fix resource leak in config_parse_default_instanceAndreas Henriksson
The recently allocated "printed" is not freed on error path. Found by coverity. Fixes: CID#1237745
2014-09-16missing: memfd_create takes unsigned int flags in final versionCristian Rodríguez
2014-09-15hashmap: minor hashmap_replace optimizationMichal Schmidt
When hashmap_replace detects no such key exists yet, it calls hashmap_put that performs the same check again. Avoid that by splitting the core of hashmap_put into a separate function.
2014-09-15hashmap, set: remove unused functionsMichal Schmidt
The following hashmap_* and set_* functions/macros have never had any users in systemd's history: *_iterate_backwards *_iterate_skip *_last *_FOREACH_BACKWARDS Remove this dead code.