summaryrefslogtreecommitdiff
path: root/src/shared
AgeCommit message (Collapse)Author
2014-10-26src/shared/mkdir-label.c: move and rename mkdir_label()Anthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-26src/shared/label.c: move and rename symlink_label()Anthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-26src/shared/virt.c: add docker to container namespaceAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-26src/shared/selinux-util.c: add path_is_absolute() checkAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-26label: move is_dir() to util.cLennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25label: don't try to create labelled directories more than onceLennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25selinux: clean up selinux label function namingLennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25selinux: simplify and unify loggingLennart Poettering
Normally we shouldn#t log from "library" functions, but SELinux is weird, hence upgrade security messages uniformly to LOG_ERR when in enforcing mode. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25selinux: rework label query APIsLennart Poettering
APIs that query and return something cannot silently fail, they must either return something useful, or an error. Fix that. Also, properly rollback socket unit fd creation when something goes wrong with the security framework. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25smack: we don't need the special labels exported, hence don'tLennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25selinux: drop 3 unused function prototypesLennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25smack: rework SMACK label fixing code to follow more closely the semantics ↵Lennart Poettering
of the matching selinux code Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25smack: never follow symlinks when relabellingLennart Poettering
previously mac_smack_apply(path, NULL) would operate on the symlink itself while mac_smack_apply(path, "foo") would follow the symlink. Let's clean this up an always operate on the symlink, which appears to be the safer option. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25smack: rework smack APIs a bitLennart Poettering
a) always return negative errno error codes b) always become a noop if smack is off c) always take a NULL label as a request to remove it Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25mac: rename all calls that apply a label mac_{selinux|smack}_apply_xyz(), ↵Lennart Poettering
and all that reset it to defaults mac_{selinux|smack}_fix() Let's clean up the naming schemes a bit and use the same one for SMACK and for SELINUX. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25selinux: make use of cleanup gcc magicLennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25hashmap: introduce hashmap_reserve()Michal Schmidt
With the current hashmap implementation that uses chaining, placing a reservation can serve two purposes: - To optimize putting of entries if the number of entries to put is known. The reservation allocates buckets, so later resizing can be avoided. - To avoid having very long bucket chains after using hashmap_move(_one). In an alternative hashmap implementation it will serve an additional purpose: - To guarantee a subsequent hashmap_move(_one) will not fail with -ENOMEM (this never happens in the current implementation). Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25hashmap: return more information from resize_buckets()Michal Schmidt
Return 0 if no resize was needed, 1 if successfully resized and negative on error. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25shared: split mempool implementation from hashmapsMichal Schmidt
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25time: don't do comparison twiceLennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25mac: also rename use_{smack,selinux,apparmor}() calls so that they share the ↵Lennart Poettering
new mac_{smack,selinux,apparmor}_xyz() convention Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25mac: rename apis with mac_{selinux/smack}_ prefixWaLyong Cho
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25src/shared/util.h: import realloc_multiply() from upstreamAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25label: rearrange mandatory access control(MAC) apisWaLyong Cho
move label apis to selinux-util.ch or smack-util.ch appropriately. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-25shared/log: add log_trace as compile-time optional debuggingZbigniew Jędrzejewski-Szmek
Repetetive messages can be annoying when running with SYSTEMD_LOG_LEVEL=debug, but they are sometimes very useful when debugging problems. Add log_trace which is like log_debug but becomes a noop unless LOG_TRACE is defined during compilation. This makes it easy to enable very verbose logging for a subset of programs when compiling from source. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-22strv: add an additional overflow check when enlarging strv()sLennart Poettering
https://bugs.freedesktop.org/show_bug.cgi?id=76745 This also adds: strv: use realloc_multiply() to check for multiplication overflow by Michal Schmidt <mschmidt@redhat.com> This could overflow on 32bit, where size_t is the same as unsigned. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-13src/shared/util.c: remove unneeded error check, following upstreamAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-13src/shared/util.c: final cosmetic changeAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-13src/shared/util.c: more cosmetic changesAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-10-13src/shared/util.c: cosmetic changes to more easily follow upstreamAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-09-30Do 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. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-09-18src: minor code cleanupAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-09-18src/shared: import upstream code needed for recent commitsAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-09-15src/shared/set.h: remove unnecessary function declarationAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-09-15hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt
It is redundant to store 'hash' and 'compare' function pointers in struct Hashmap separately. The functions always comprise a pair. Store a single pointer to struct hash_ops instead. systemd keeps hundreds of hashmaps, so this saves a little bit of memory. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-09-02src/shared/label.c: include selinux headersAmadeusz Sławiński
Signed-off-by: Amadeusz Sławiński <amade@asmblr.net>
2014-08-27shared: make container_of() use unique variable namesDavid Herrmann
If you stack container_of() macros, you will get warnings due to shadowing variables of the parent context. To avoid this, use unique names for variables. Two new helpers are added: UNIQ: This evaluates to a truly unique value never returned by any evaluation of this macro. It's a shortcut for __COUNTER__. UNIQ_T: Takes two arguments and concatenates them. It is a shortcut for CONCATENATE, but meant to defined typed local variables. As you usually want to use variables that you just defined, you need to reference the same unique value at least two times. However, UNIQ returns a new value on each evaluation, therefore, you have to pass the unique values into the macro like this: #define my_macro(a, b) __max_macro(UNIQ, UNIQ, (a), (b)) #define __my_macro(uniqa, uniqb, a, b) ({ typeof(a) UNIQ_T(A, uniqa) = (a); typeof(b) UNIQ_T(B, uniqb) = (b); MY_UNSAFE_MACRO(UNIQ_T(A, uniqa), UNIQ_T(B, uniqb)); }) This way, MY_UNSAFE_MACRO() can safely evaluate it's arguments multiple times as they are local variables. But you can also stack invocations to the macro my_macro() without clashing names. This is the same as if you did: #define my_macro(a, b) __max_macro(__COUNTER__, __COUNTER__, (a), (b)) #define __my_macro(prefixa, prefixb, a, b) ({ typeof(a) CONCATENATE(A, prefixa) = (a); typeof(b) CONCATENATE(B, prefixb) = (b); MY_UNSAFE_MACRO(CONCATENATE(A, prefixa), CONCATENATE(B, prefixb)); }) ...but in my opinion, the first macro is easier to write and read. This patch starts by converting container_of() to use this new helper. Other macros may follow (like MIN, MAX, CLAMP, ...). Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-08-22util: change return value of startswith() to non-consteudev/v1.10Lennart Poettering
This way we can use it on non-const strings, and don't end up with a const'ified result. This is similar to libc's strstr() which also takes a const string but returns a non-const one. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-08-22util: change return value of startswith() to non-constLennart Poettering
This way we can use it on non-const strings, and don't end up with a const'ified result. This is similar to libc's strstr() which also takes a const string but returns a non-const one. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-08-17src/shared/mkdir.h: add missing func prototypeAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-08-14src/shared/path-util.c: revert change from realpath to canonicalize_file_nameAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-08-14src/shared: some stylistic changesAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-08-14src/shared: import more code cleanups from upstreamAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-08-14src/shared: import many code cleanups from upstreamAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-08-13src/shared/cgroup-util.c: code cleanup following upstreamAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-08-12udev: modernize net_id builtin a bitLennart Poettering
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-08-05src/shared: refactor shared codeAnthony G. Basile
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2012-11-17Rename src/shared to src/include, a saner nameAnthony G. Basile
2012-11-17src/test: disable for now to get a full buildAnthony G. Basile
2012-11-17src/udev: continue restoring needed depsAnthony G. Basile