Merge pull request #7759 from yuwata/dbus-api

DBus-API: add more options in transient units
This commit is contained in:
Lennart Poettering
2018-01-03 18:41:32 +01:00
committed by GitHub
32 changed files with 2071 additions and 1769 deletions
+4
View File
@@ -20,6 +20,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdbool.h>
/*
* MAX_ERRNO is defined as 4095 in linux/err.h
* We use the same value here.
@@ -28,3 +29,6 @@
const char *errno_to_name(int id);
int errno_from_name(const char *name);
static inline bool errno_is_valid(int n) {
return n > 0 && n <= ERRNO_MAX;
}
+2 -1
View File
@@ -283,7 +283,8 @@ int parse_errno(const char *t) {
if (r < 0)
return r;
if (e < 0 || e > ERRNO_MAX)
/* 0 is also allowed here */
if (!errno_is_valid(e) && e != 0)
return -ERANGE;
return e;
+7
View File
@@ -137,6 +137,13 @@ static inline bool pid_is_valid(pid_t p) {
return p > 0;
}
static inline int sched_policy_to_string_alloc_with_check(int n, char **s) {
if (!sched_policy_is_valid(n))
return -EINVAL;
return sched_policy_to_string_alloc(n, s);
}
int ioprio_parse_priority(const char *s, int *ret);
pid_t getpid_cached(void);
+8
View File
@@ -24,6 +24,14 @@
int secure_bits_to_string_alloc(int i, char **s);
int secure_bits_from_string(const char *s);
static inline bool secure_bits_is_valid(int i) {
return ((SECURE_ALL_BITS | SECURE_ALL_LOCKS) & i) == i;
}
static inline int secure_bits_to_string_alloc_with_check(int n, char **s) {
if (!secure_bits_is_valid(n))
return -EINVAL;
return secure_bits_to_string_alloc(n, s);
}
+7
View File
@@ -55,3 +55,10 @@ static inline void block_signals_reset(sigset_t *ss) {
static inline bool SIGNAL_VALID(int signo) {
return signo > 0 && signo < _NSIG;
}
static inline const char* signal_to_string_with_check(int n) {
if (!SIGNAL_VALID(n))
return NULL;
return signal_to_string(n);
}
+12
View File
@@ -821,6 +821,18 @@ static const char* const socket_address_bind_ipv6_only_table[_SOCKET_ADDRESS_BIN
DEFINE_STRING_TABLE_LOOKUP(socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
SocketAddressBindIPv6Only parse_socket_address_bind_ipv6_only_or_bool(const char *n) {
int r;
r = parse_boolean(n);
if (r > 0)
return SOCKET_ADDRESS_IPV6_ONLY;
if (r == 0)
return SOCKET_ADDRESS_BOTH;
return socket_address_bind_ipv6_only_from_string(n);
}
bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b) {
assert(a);
assert(b);
+1
View File
@@ -120,6 +120,7 @@ int getnameinfo_pretty(int fd, char **ret);
const char* socket_address_bind_ipv6_only_to_string(SocketAddressBindIPv6Only b) _const_;
SocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *s) _pure_;
SocketAddressBindIPv6Only parse_socket_address_bind_ipv6_only_or_bool(const char *s);
int netlink_family_to_string_alloc(int b, char **s);
int netlink_family_from_string(const char *s) _pure_;