summaryrefslogtreecommitdiff
path: root/src/shared/socket-util.h
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2012-10-30 14:29:38 +0100
committerMichal Schmidt <mschmidt@redhat.com>2012-10-30 15:41:15 +0100
commitf8b69d1dfc307562a353f6aa923b7c2b915aaddb (patch)
tree79a9776e85e7f9ad9ca944665cc428be480789f3 /src/shared/socket-util.h
parent26acfdae44e3605788420432d28a7264214d1213 (diff)
shared, core: do not always accept numbers in string lookups
The behaviour of the common name##_from_string conversion is surprising. It accepts not only the strings from name##_table but also any number that falls within the range of the table. The order of items in most of our tables is an internal affair. It should not be visible to the user. I know of a case where the surprising numeric conversion leads to a crash. We will allow the direct numeric conversion only for the tables where the mapping of strings to numeric values has an external meaning. This holds for the following lookup tables: - netlink_family, ioprio_class, ip_tos, sched_policy - their numeric values are stable as they are defined by the Linux kernel interface. - log_level, log_facility_unshifted - the well-known syslog interface. We allow the user to use numeric values whose string names systemd does not know. For instance, the user may want to test a new kernel featuring a scheduling policy that did not exist when his systemd version was released. A slightly unpleasant effect of this is that the name##_to_string conversion cannot return pointers to constant strings anymore. The strings have to be allocated on demand and freed by the caller.
Diffstat (limited to 'src/shared/socket-util.h')
-rw-r--r--src/shared/socket-util.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/shared/socket-util.h b/src/shared/socket-util.h
index 7cca2f53c6..04cfb83f5a 100644
--- a/src/shared/socket-util.h
+++ b/src/shared/socket-util.h
@@ -93,7 +93,7 @@ bool socket_address_needs_mount(const SocketAddress *a, const char *prefix);
const char* socket_address_bind_ipv6_only_to_string(SocketAddressBindIPv6Only b);
SocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *s);
-const char* netlink_family_to_string(int b);
+int netlink_family_to_string_alloc(int b, char **s);
int netlink_family_from_string(const char *s);
bool socket_ipv6_is_supported(void);