chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
systemctl: add to command for virtualizing the dependency tree with graphviz
[elogind.git]
/
src
/
socket-util.c
diff --git
a/src/socket-util.c
b/src/socket-util.c
index 4a1b3d8b515536e97fd0b186ceeed5d8ab276a32..e6e3784bc5774a351d702b84376beabd481d2f01 100644
(file)
--- a/
src/socket-util.c
+++ b/
src/socket-util.c
@@
-33,6
+33,7
@@
#include "macro.h"
#include "util.h"
#include "socket-util.h"
#include "macro.h"
#include "util.h"
#include "socket-util.h"
+#include "missing.h"
int socket_address_parse(SocketAddress *a, const char *s) {
int r;
int socket_address_parse(SocketAddress *a, const char *s) {
int r;
@@
-100,7
+101,7
@@
int socket_address_parse(SocketAddress *a, const char *s) {
a->sockaddr.un.sun_family = AF_UNIX;
memcpy(a->sockaddr.un.sun_path+1, s+1, l);
a->sockaddr.un.sun_family = AF_UNIX;
memcpy(a->sockaddr.un.sun_path+1, s+1, l);
- a->size = sizeof(s
truct sockaddr_un)
;
+ a->size = sizeof(s
a_family_t) + 1 + l
;
} else {
} else {
@@
-197,11
+198,7
@@
int socket_address_verify(const SocketAddress *a) {
if (a->size > sizeof(sa_family_t)) {
if (a->size > sizeof(sa_family_t)) {
- if (a->sockaddr.un.sun_path[0] == 0) {
- /* abstract */
- if (a->size != sizeof(struct sockaddr_un))
- return -EINVAL;
- } else {
+ if (a->sockaddr.un.sun_path[0] != 0) {
char *e;
/* path */
char *e;
/* path */
@@
-305,6
+302,7
@@
int socket_address_listen(
int backlog,
SocketAddressBindIPv6Only only,
const char *bind_to_device,
int backlog,
SocketAddressBindIPv6Only only,
const char *bind_to_device,
+ bool free_bind,
mode_t directory_mode,
mode_t socket_mode,
int *ret) {
mode_t directory_mode,
mode_t socket_mode,
int *ret) {
@@
-330,6
+328,12
@@
int socket_address_listen(
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, bind_to_device, strlen(bind_to_device)+1) < 0)
goto fail;
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, bind_to_device, strlen(bind_to_device)+1) < 0)
goto fail;
+ if (free_bind) {
+ one = 1;
+ if (setsockopt(fd, IPPROTO_IP, IP_FREEBIND, &one, sizeof(one)) < 0)
+ log_warning("IP_FREEBIND failed: %m");
+ }
+
one = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) < 0)
goto fail;
one = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) < 0)
goto fail;
@@
-429,7
+433,7
@@
bool socket_address_equal(const SocketAddress *a, const SocketAddress *b) {
if (strncmp(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path, sizeof(a->sockaddr.un.sun_path)) != 0)
return false;
} else {
if (strncmp(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path, sizeof(a->sockaddr.un.sun_path)) != 0)
return false;
} else {
- if (memcmp(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path,
sizeof(a->sockaddr.un.sun_path)
) != 0)
+ if (memcmp(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path,
a->size
) != 0)
return false;
}
return false;
}