socket-label.c revision 54255c64e6d223deb7d3863e426e78c443fda37c
/*-*- 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 <string.h>
#include <unistd.h>
#include <errno.h>
#include <stddef.h>
#include "macro.h"
#include "util.h"
#include "mkdir.h"
#include "missing.h"
#include "selinux-util.h"
#include "socket-util.h"
const SocketAddress *a,
int flags,
int backlog,
const char *bind_to_device,
bool reuse_port,
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) {
if (r < 0)
return r;
}
if (label)
if (r < 0)
return r;
return -errno;
}
if (bind_to_device)
return -errno;
if (reuse_port) {
one = 1;
}
if (free_bind) {
one = 1;
}
if (transparent) {
one = 1;
}
}
one = 1;
return -errno;
/* Create parents */
/* Enforce the right access mode for the socket */
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) {
log_error("Failed to parse socket address \"%s\": %s",
return r;
}
_cleanup_free_ char *p = NULL;
r = socket_address_print(&a, &p);
if (r < 0)
return log_error_errno(r, "socket_address_print(): %m");
if (fd < 0)
else
}
return fd;
}