socket-label.c revision e0aa3726103448097e5ad7cc6f427e142103a321
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <assert.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include "macro.h"
#include "util.h"
#include "mkdir.h"
#include "socket-util.h"
#include "missing.h"
#include "label.h"
const SocketAddress *a,
int flags,
int backlog,
const char *bind_to_device,
bool free_bind,
bool transparent,
const char *label) {
int r, one;
assert(a);
r = socket_address_verify(a);
if (r < 0)
return r;
return -EAFNOSUPPORT;
if (label) {
r = label_socket_set(label);
if (r < 0)
return r;
}
if (label)
if (r < 0)
return r;
return -errno;
}
if (bind_to_device)
return -errno;
if (free_bind) {
one = 1;
log_warning("IP_FREEBIND failed: %m");
}
if (transparent) {
one = 1;
log_warning("IP_TRANSPARENT failed: %m");
}
}
one = 1;
return -errno;
/* Create parents */
/* Enforce the right access mode for the socket */
/* Include the original umask in our mask */
if (r < 0 && errno == EADDRINUSE) {
/* Unlink and try again */
}
} else
if (r < 0)
return -errno;
if (socket_address_can_accept(a))
return -errno;
r = fd;
fd = -1;
return r;
}
int fd, r;
r = socket_address_parse(&a, address);
if (r < 0) {
return r;
}
char _cleanup_free_ *p = NULL;
r = socket_address_print(&a, &p);
if (r < 0) {
return r;
}
if (fd < 0)
else
}
return fd;
}