summaryrefslogtreecommitdiff
path: root/src/basic/socket-util.c
diff options
context:
space:
mode:
authorEvgeny Vereshchagin <evvers@ya.ru>2016-10-06 23:43:08 +0300
committerGitHub <noreply@github.com>2016-10-06 23:43:08 +0300
commit36264e0de596d9b0264ae08b53832495a78c779c (patch)
tree658b2caae552a9a7be6810dab6b44e653a89fef9 /src/basic/socket-util.c
parente057995bb1314a94ce460d8e5a2a20e73c0e2ad4 (diff)
parent97f0e76f18d322d29bcfbc4ab6bb9cd67a1cdd54 (diff)
Merge pull request #4299 from poettering/variety
ioctl socket fixes, sd-bus error updates, resolved error addition, PAM stub process priv fix
Diffstat (limited to 'src/basic/socket-util.c')
-rw-r--r--src/basic/socket-util.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c
index 5c829e0e7e..1662c04705 100644
--- a/src/basic/socket-util.c
+++ b/src/basic/socket-util.c
@@ -1060,3 +1060,20 @@ struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t leng
return NULL;
}
+
+int socket_ioctl_fd(void) {
+ int fd;
+
+ /* Create a socket to invoke the various network interface ioctl()s on. Traditionally only AF_INET was good for
+ * that. Since kernel 4.6 AF_NETLINK works for this too. We first try to use AF_INET hence, but if that's not
+ * available (for example, because it is made unavailable via SECCOMP or such), we'll fall back to the more
+ * generic AF_NETLINK. */
+
+ fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
+ if (fd < 0)
+ fd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_GENERIC);
+ if (fd < 0)
+ return -errno;
+
+ return fd;
+}