summaryrefslogtreecommitdiffstats
path: root/src/shared (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* use memzero(foo, length); for all memset(foo, 0, length); callsGreg KH2014-01-312-3/+3
| | | | | | | | In trying to track down a stupid linker bug, I noticed a bunch of memset() calls that should be using memzero() to make it more "obvious" that the options are correct (i.e. 0 is not the length, but the data to set). So fix up all current calls to memset(foo, 0, length) to memzero(foo, length).
* shared: net - use u32ctz to compute prefixlenTom Gundersen2014-01-301-10/+1
|
* util: add u32ctz() call for determining ctz of uint32_tLennart Poettering2014-01-301-0/+12
|
* sd-dhcp-client/net-util: make netmask_to_prefixlen genericTom Gundersen2014-01-302-0/+18
| | | | | This was originally included in the dhcp-client at my request, but it is not really dhcp-specific and useful outside of it, so let's pull it out.
* net-util: verify the address familyTom Gundersen2014-01-301-6/+14
| | | | | Error out if the address family is already set to something incompatible with the address being parsed.
* utmp: make sure we don't write the utmp reboot record twice on each bootLennart Poettering2014-01-301-33/+26
| | | | (Also, only send the audit msg once, too)
* Base mkostemp_safe on mkostempZbigniew Jędrzejewski-Szmek2014-01-292-33/+6
| | | | | It is nice to wrap umask handling and return convention, but glibc's mkostemp is async-signal-safe already.
* Get rid of write_safeZbigniew Jędrzejewski-Szmek2014-01-291-18/+0
| | | | | | Current glibc implementation is safe. Kernel does this atomically, and write is actually implemented through writev. So if write is async-signal-safe, than writev pretty much must be too.
* always use the same code for creating temporary filesLennart Poettering2014-01-282-6/+7
| | | | Let's unify our code here, and also always specifiy O_CLOEXEC.
* util: pick slightly safer open() flags when creating temporary filesLennart Poettering2014-01-281-2/+5
|
* util: define O_TMPFILE on x86/x86-64, where the generic value is usedLennart Poettering2014-01-281-0/+16
| | | | | On other archs we'll not define it so that open_tmpfile() falls back to unguessable name + unlink.
* util: pass original flags value to mkostemp(), in open_tmpfile()Lennart Poettering2014-01-281-3/+5
|
* util: simplify mkostemp_safe()Lennart Poettering2014-01-281-12/+19
| | | | Make it use dev_urandom() and endswith().
* util: introduce new dev_urandom() call that is like random_bytes() but ↵Lennart Poettering2014-01-282-13/+26
| | | | doesn't fall back to PRNG
* util: modernize loop_read() and loop_write() a bitLennart Poettering2014-01-281-52/+23
| | | | Let's make use of fd_wait_for_event() here, instead of rolling our own.
* manager: add systemd.show_status=auto modeZbigniew Jędrzejewski-Szmek2014-01-284-0/+59
| | | | | | | | | | | | | When set to auto, status will shown when the first ephemeral message is shown (a job has been running for five seconds). Then until the boot or shutdown ends, status messages will be shown. No indication about the switch is done: I think it should be clear for the user that first the cylon eye and the ephemeral messages appear, and afterwards messages are displayed. The initial arming of the event source was still wrong, but now should really be fixed.
* journal: guarantee async-signal-safety in sd_journald_sendvZbigniew Jędrzejewski-Szmek2014-01-284-11/+63
| | | | | | | | | | | | | | | | | | signal(7) provides a list of functions which may be called from a signal handler. Other functions, which only call those functions and don't access global memory and are reentrant are also safe. sd_j_sendv was mostly OK, but would call mkostemp and writev in a fallback path, which are unsafe. Being able to call sd_j_sendv in a async-signal-safe way is important because it allows it be used in signal handlers. Safety is achieved by replacing mkostemp with open(O_TMPFILE) and an open-coded writev replacement which uses write. Unfortunately, O_TMPFILE is only available on kernels >= 3.11. When O_TMPFILE is unavailable, an open-coded mkostemp is used. https://bugzilla.gnome.org/show_bug.cgi?id=722889
* Replace mkostemp+unlink with open(O_TMPFILE)Zbigniew Jędrzejewski-Szmek2014-01-282-0/+24
| | | | | This will only work on Linux >= 3.11, and probably not on all filesystems. Fallback code is provided.
* bus: add API calls for connecting to starter busLennart Poettering2014-01-271-8/+10
| | | | | | | Add new calls sd_bus_open() and sd_bus_default() for connecting to the starter bus a service was invoked for, or -- if the process is not a bus-activated service -- the appropriate bus for the scope the process has been started in.
* resolve: update sd-resolve to match the other APIs in style and functionalityLennart Poettering2014-01-271-2/+5
|
* DEFINE_STRING_TABLE_LOOKUP: return _INVALID_* rather than assert on NULL stringTom Gundersen2014-01-221-1/+2
|
* exec: introduce PrivateDevices= switch to provide services with a private /devLennart Poettering2014-01-203-9/+13
| | | | | | Similar to PrivateNetwork=, PrivateTmp= introduce PrivateDevices= that sets up a private /dev with only the API pseudo-devices like /dev/null, /dev/zero, /dev/random, but not any physical devices in them.
* core: clean up environment block for --user instances a bitLennart Poettering2014-01-122-1/+39
|
* journald: do not free space when disk space runs lowZbigniew Jędrzejewski-Szmek2014-01-111-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | Before, journald would remove journal files until both MaxUse= and KeepFree= settings would be satisfied. The first one depends (if set automatically) on the size of the file system and is constant. But the second one depends on current use of the file system, and a spike in disk usage would cause journald to delete journal files, trying to reach usage which would leave 15% of the disk free. This behaviour is surprising for the user who doesn't expect his logs to be purged when disk usage goes above 85%, which on a large disk could be some gigabytes from being full. In addition attempting to keep 15% free provides an attack vector where filling the disk sufficiently disposes of almost all logs. Instead, obey KeepFree= only as a limit on adding additional files. When replacing old files with new, ignore KeepFree=. This means that if journal disk usage reached some high point that at some later point start to violate the KeepFree= constraint, journald will not add files to go above this point, but it will stay (slightly) below it. When journald is restarted, it forgets the previous maximum usage value, and sets the limit based on the current usage, so if disk remains to be filled, journald might use one journal-file-size less on each restart, if restarts happen just after rotation. This seems like a reasonable compromise between implementation complexity and robustness.
* No need to canonicalize fixed pathsZbigniew Jędrzejewski-Szmek2014-01-092-3/+3
|
* shared/install: use char** convention for strvsZbigniew Jędrzejewski-Szmek2014-01-052-14/+14
|
* strv: multiple cleanupsSimon Peeters2014-01-053-195/+52
| | | | | | | | | | - turn strv_merge into strv_extend_strv. appending strv b to the end of strv a instead of creating a new strv - strv_append: remove in favor of strv_extend and strv_push. - strv_remove: write slightly more elegant - strv_remove_prefix: remove unused function - strv_overlap: use strv_contains - strv_printf: STRV_FOREACH handles NULL correctly
* shared: util.c: unify split and split_quotedSimon Peeters2014-01-052-67/+36
|
* util.c: use read_one_line_file where possibleSimon Peeters2014-01-051-33/+15
|
* shared: procfs_file_alloca: handle pid==0Simon Peeters2014-01-054-43/+17
| | | | when pid is set to 0 use /proc/self
* Revert "net-util: add support for Type=ethernet"Tom Gundersen2014-01-041-1/+1
| | | | | | | This reverts commit 4cd1214db6cf4b262e8ce6381bc710091b375c96. This may still be fixed in the kernel, revert this for now until we see how it all shakes out.
* net-util: add support for Type=ethernetTom Gundersen2014-01-031-1/+1
| | | | | When DEVTYPE is not set for a nic, it means it is a wired/ethernet device.
* Introduce cleanup functions for cap_freeZbigniew Jędrzejewski-Szmek2014-01-032-18/+18
| | | | | Unfortunately a different cleanup function is necessary per type, because cap_t** and char** are incompatible with void**.
* Use format patterns for usec_t, pid_t, nsec_t, usec_tZbigniew Jędrzejewski-Szmek2014-01-032-1/+20
| | | | | | | | It is nicer to predefine patterns using configure time check instead of using casts everywhere. Since we do not need to use any flags, include "%" in the format instead of excluding it like PRI* macros.
* Move bus path definitions to def.hZbigniew Jędrzejewski-Szmek2014-01-031-0/+12
|
* networkd: improve loggingTom Gundersen2014-01-021-35/+10
| | | | Remove redundant messages, add some debugging ones and make wording more uniform.
* sleep-config: fix double freeZbigniew Jędrzejewski-Szmek2013-12-311-18/+20
| | | | | | | | | Before 34a3baa4d 'sleep-config: Dereference pointer before check for NULL' oom conditions would not be detected properly. After that commit, a double free was performed. Rework the whole function to be easier to understand, and also replace strv_split_nulstr with strv_new, since we know the strings anyway.
* sleep-config: Dereference pointer before check for NULLStefan Beller2013-12-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a bug pointed out by http://css.csail.mit.edu/stack/ (Optimization-unstable code) It is a similar fix as f146f5e159 (2013-12-30, core: Forgot to dereference pointer when checking for NULL) To explain this bug consider the following similar, but simpler code: if (!p) free(*p) Assume the if condition evaluates to true, then we will access *p, which means the compiler can assume p is a valid pointer, so it could dereference p and use the value *p. Assuming p as a valid pointer, !p will be false. But initally we assumed the condition evaluates to true. By this reasoning the optimizing compiler can deduce, we have dead code. ("The if will never be taken, as *p must be valid, because otherwise accessing *p inside the if would segfault") This led to an error message of the static code checker, so I checked the code in question. As we access *modes and *states before the check in the changed line of this patch, I assume the line to be wrong and we actually wanted to check for *modes and *states being both non null.
* shared: add simplistic XML parser for usage in the D-Bus policy language ↵Lennart Poettering2013-12-282-0/+250
| | | | compat parser
* Use enums to make it obvious what boolean params meanZbigniew Jędrzejewski-Szmek2013-12-264-21/+33
| | | | Suggested-by: Russ Allbery <rra@debian.org>
* systemctl: allow globbing in commands which take multiple unit namesZbigniew Jędrzejewski-Szmek2013-12-263-14/+27
|
* bus: rename message "serial" to "cookie"Lennart Poettering2013-12-253-8/+8
| | | | | | Even if the lower-leveld dbus1 protocol calls it "serial", let's expose the word "cookie" for this instead, as this is what kdbus uses and since it doesn't imply monotonicity the same way "serial" does.
* shared: fix getpeername_pretty() for AF_UNIX socketsLennart Poettering2013-12-251-1/+1
|
* unit: include peer identity in description of per-connection ↵Lennart Poettering2013-12-251-6/+2
| | | | socket-activated services
* sleep-config: fix useless check for swapfile typeDave Reisner2013-12-241-7/+3
| | | | | | | | | Since 0c6f1f4ea49 the check was useless, because the kernel will ever only write "partition" or "file" there. OTOH, it is possible that "\\040(deleted)" (escaped " (deleted)") will be added for removed files. This should not happen, so add a warning to detect those cases.
* bus: properly shift cgroup data returned from kdbus by the container's root ↵Lennart Poettering2013-12-242-16/+37
| | | | before parsing
* log: log_error() and friends add a newline after each line anyway, so avoid ↵Lennart Poettering2013-12-241-1/+1
| | | | including it in the log strings
* util: don't accept an empty peer label as validLennart Poettering2013-12-241-0/+5
|
* util: unify SO_PEERCRED/SO_PEERSEC invocationsLennart Poettering2013-12-243-3/+66
| | | | | | Introduce new call getpeercred() which internally just uses SO_PEERCRED but checks if the returned data is actually useful due to namespace quirks.
* bus: when getting a kdbus connection into a container wait first for child, ↵Lennart Poettering2013-12-231-4/+4
| | | | | | | then read message There's no EOF generated for AF_UNIX/SOCK_DGRAM sockets, hence let's wait for the child first to see if it succeeded, only then read the socket.