Commit 4c60b22d authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

zdtm: check unconnected unix sockets

https://bugzilla.openvz.org/show_bug.cgi?id=2408Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent e5a80657
...@@ -39,6 +39,7 @@ static/sock_opts01 ...@@ -39,6 +39,7 @@ static/sock_opts01
static/sockets_spair static/sockets_spair
static/sockets_dgram static/sockets_dgram
static/socket_queues static/socket_queues
static/sk-unix-unconn
static/pid00 static/pid00
static/pstree static/pstree
static/caps00 static/caps00
......
...@@ -49,6 +49,7 @@ TST_NOFILE = \ ...@@ -49,6 +49,7 @@ TST_NOFILE = \
socket-tcpbuf \ socket-tcpbuf \
sock_opts00 \ sock_opts00 \
sock_opts01 \ sock_opts01 \
sk-unix-unconn \
ipc_namespace \ ipc_namespace \
selfexe00 \ selfexe00 \
sem \ sem \
......
#include <unistd.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include "zdtmtst.h"
const char *test_doc = "Check unconnected unix sockets";
const char *test_author = "Vagin Andrew <avagin@parallels.com>";
int main(int argc, char ** argv)
{
int sk, skc;
int ret;
char path[PATH_MAX];
struct sockaddr_un addr;
socklen_t addrlen;
test_init(argc, argv);
sk = socket(AF_UNIX, SOCK_STREAM, 0);
if (sk == -1) {
err("socket\n");
return 1;
}
skc = socket(AF_UNIX, SOCK_STREAM, 0);
if (skc == -1) {
err("socket\n");
return 1;
}
snprintf(path, sizeof(path), "X/zdtm-%s-%d", argv[0], getpid());
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, path, sizeof(addr.sun_path));
addrlen = sizeof(addr.sun_family) + strlen(path);
addr.sun_path[0] = 0;
ret = bind(sk, (struct sockaddr *) &addr, addrlen);
if (ret) {
fail("bind\n");
return 1;
}
test_daemon();
test_waitsig();
if (listen(sk, 1) == -1) {
err("listen");
return 1;
}
if (connect(skc, (struct sockaddr *) &addr, addrlen) == -1) {
fail("Unable to connect");
return 1;
}
pass();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment