summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2015-04-25 05:31:52 +0000
committerngie <ngie@FreeBSD.org>2015-04-25 05:31:52 +0000
commit613943f9f120ccf49b2c7002eaa09327a281f367 (patch)
tree54e284e7948f0a2e0c71ebdebb00f28185894621 /tools
parent70eb2d81410b8dedf542c6b3ef6793bed481c88e (diff)
downloadFreeBSD-src-613943f9f120ccf49b2c7002eaa09327a281f367.zip
FreeBSD-src-613943f9f120ccf49b2c7002eaa09327a281f367.tar.gz
MFC r261550,r281354,r281355,r281356,r281358,r281359,r281360,r281361,r281362,r281391,r281392,r281393,r281394,r281395,r281397,r281398,r281399,r281400,r281401,r281402,r281403,r281404,r281407,r281408,r281409,r281410,r281411:
r261550 (by glebius): Add test case for kern/181741. Right now test fails. PR: 181741 Sponsored by: Nginx, Inc. r281354: Fix warnings, fix a typo in a testcase description, bump WARNS to 3 - Remove argc/argv (-Wunused) - Cast len in comparison to size_t (-Wsign-compare) Sponsored by: EMC / Isilon Storage Division r281355: Fix -Wunused warnings, bump WARNS to 6 The testcase fails today on subtest # 9 The output is still broken if prove -rv is run and the testcase aborts prematurely (the testcase doesn't really conform to TAP protocol properly, except when it completes fully) Sponsored by: EMC / Isilon Storage Division r281356: Fix -Wunused warnings, bump WARNS to 6 The output is still broken if prove -rv is run and the testcase aborts prematurely with fail_assertion (the testcase doesn't really conform to TAP protocol properly, except when it completes fully) Sponsored by: EMC / Isilon Storage Division r281358: - Parameterize out the number of accept/connect attempts - Randomize the bind port to allow 2+ consecutive calls in < 10 minutes, and to also not fail if (for instance) there's a server already listening on port 8080 - Don't leak the listening socket / fds into the child process - Fix warnings: -- Remove argc/argv (-Wunused) -- Mark sig __unused (-Wunused) -- Mark quit static (-Wmissing-variable-declarations) Sponsored by: EMC / Isilon Storage Division r281359: Remove argc/argv (-Wunused) Sponsored by: EMC / Isilon Storage Division r281360: Fix warnings - Remove argc/argv (-Wunused) - Mark some parameters to socket_listen_update __unused (-Wunused) Sponsored by: EMC / Isilon Storage Division r281361: Remove argc/argv (-Wunused) Sponsored by: EMC / Isilon Storage Division r281362: Use _exit, not exit in forked process Sponsored by: EMC / Isilon Storage Division r281391: - Use static buffers for temporary file paths instead of strdup of constant strings - Don't use /tmp because it's outside ATF's prescribed sandbox - Use mkstemp instead of mktemp to eliminate warning Sponsored by: EMC / Isilon Storage Division r281392: - Garbage collect argc/argv (-Wunused) - Bump WARNS to 6 Sponsored by: EMC / Isilon Storage Division r281393: Fix warnings and bump WARNS to 6 - Garbage collect argc/argv (-Wunused) - sleep(3) will always return an unsigned int; don't check for return codes <0 (-Wsign-compare) Sponsored by: EMC / Isilon Storage Division r281394: - Don't use /tmp because it's outside ATF's prescribed sandbox - Replace a hardcoded PATH_MAX value with sizeof(path) - Use path like an array, not a pointer, and always try to unlink it in cleanup Sponsored by: EMC / Isilon Storage Division r281395: Fix a -Wuninitialized warning by setting the socket to -1 and bump WARNS to 6 Sponsored by: EMC / Isilon Storage Division r281397: Mark signum unused in signal_handler; bump WARNS to 6 Sponsored by: EMC / Isilon Storage Division r281398: Garbage collect argc/argv and bump WARNS to 6 Sponsored by: EMC / Isilon Storage Division r281399: Fix warnings and bump WARNS to 6 - Staticize variables as needed - Garbage collect argc/argv - Fix -Wsign-compare warnings by casting small sizeof to (int) Sponsored by: EMC / Isilon Storage Division r281400: - Garbage collect argc/argv; bump WARNS to 6 - Make the socket path random and move it out of /tmp as that's outside ATF's prescribed path Sponsored by: EMC / Isilon Storage Division r281401: - Garbage collect argc/argv - Use random paths instead of one in /tmp Sponsored by: EMC / Isilon Storage Division r281402: Garbage collect argc/argv and bump WARNS to 6 Sponsored by: EMC / Isilon Storage Division r281403: Garbage collect argc/argv and bump WARNS to 6 Sponsored by: EMC / Isilon Storage Division r281404: Generate temporary files with mkstemp instead of mktemp Sponsored by: EMC / Isilon Storage Division r281407: Fix the knob twiddling to work properly per src.opts.mk Sponsored by: EMC / Isilon Storage Division r281408: - Remove the .t wrapper and put the "magic" of determining the number of testcases into the .c file - Require root for now because it fails with SOCK_RAW without root privileges - Increment the test count properly on socket create failure Sponsored by: EMC / Isilon Storage Division r281409: Fix warnings, bump WARNS to 6, and use a temporary socket instead of one in /tmp Sponsored by: EMC / Isilon Storage Division r281410: Fix more warnings I didn't catch in the first go-around Sponsored by: EMC / Isilon Storage Division r281411: Fix even more warnings.. Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/sockets/accept_fd_leak/Makefile4
-rw-r--r--tools/regression/sockets/accept_fd_leak/accept_fd_leak.c52
-rw-r--r--tools/regression/sockets/accf_data_attach/Makefile4
-rw-r--r--tools/regression/sockets/accf_data_attach/accf_data_attach.c2
-rw-r--r--tools/regression/sockets/fstat/Makefile2
-rw-r--r--tools/regression/sockets/fstat/fstat.c2
-rw-r--r--tools/regression/sockets/kqueue/Makefile1
-rw-r--r--tools/regression/sockets/kqueue/kqueue.c4
-rw-r--r--tools/regression/sockets/listen_backlog/Makefile2
-rw-r--r--tools/regression/sockets/listen_backlog/listen_backlog.c5
-rw-r--r--tools/regression/sockets/listenclose/Makefile2
-rw-r--r--tools/regression/sockets/listenclose/listenclose.c2
-rw-r--r--tools/regression/sockets/pr_atomic/Makefile2
-rw-r--r--tools/regression/sockets/pr_atomic/pr_atomic.c14
-rw-r--r--tools/regression/sockets/reconnect/Makefile2
-rw-r--r--tools/regression/sockets/reconnect/reconnect.c36
-rw-r--r--tools/regression/sockets/rtsocket/Makefile2
-rw-r--r--tools/regression/sockets/rtsocket/rtsocket.c2
-rw-r--r--tools/regression/sockets/sblock/Makefile2
-rw-r--r--tools/regression/sockets/sblock/sblock.c12
-rw-r--r--tools/regression/sockets/sendfile/sendfile.c8
-rw-r--r--tools/regression/sockets/shutdown/Makefile2
-rw-r--r--tools/regression/sockets/shutdown/shutdown.c2
-rw-r--r--tools/regression/sockets/sigpipe/Makefile2
-rw-r--r--tools/regression/sockets/sigpipe/sigpipe.c2
-rw-r--r--tools/regression/sockets/so_setfib/Makefile10
-rw-r--r--tools/regression/sockets/so_setfib/so_setfib.c11
-rw-r--r--tools/regression/sockets/so_setfib/so_setfib.t59
-rw-r--r--tools/regression/sockets/socketpair/Makefile2
-rw-r--r--tools/regression/sockets/socketpair/socketpair.c2
-rw-r--r--tools/regression/sockets/unix_bindconnect/Makefile2
-rw-r--r--tools/regression/sockets/unix_bindconnect/unix_bindconnect.c10
-rw-r--r--tools/regression/sockets/unix_close_race/Makefile2
-rw-r--r--tools/regression/sockets/unix_close_race/unix_close_race.c15
-rw-r--r--tools/regression/sockets/unix_passfd/Makefile2
-rw-r--r--tools/regression/sockets/unix_passfd/unix_passfd.c106
-rw-r--r--tools/regression/sockets/unix_sendtorace/Makefile2
-rw-r--r--tools/regression/sockets/unix_sendtorace/unix_sendtorace.c23
-rw-r--r--tools/regression/sockets/unix_socket/Makefile2
-rw-r--r--tools/regression/sockets/unix_socket/unix_socket.c2
-rw-r--r--tools/regression/sockets/unix_sorflush/Makefile2
-rw-r--r--tools/regression/sockets/unix_sorflush/unix_sorflush.c2
-rw-r--r--tools/regression/sockets/zerosend/zerosend.c6
43 files changed, 228 insertions, 202 deletions
diff --git a/tools/regression/sockets/accept_fd_leak/Makefile b/tools/regression/sockets/accept_fd_leak/Makefile
index 208df0d..e9bfba6 100644
--- a/tools/regression/sockets/accept_fd_leak/Makefile
+++ b/tools/regression/sockets/accept_fd_leak/Makefile
@@ -4,8 +4,6 @@
PROG= accept_fd_leak
MAN=
-
-regress:
- ./accept_fd_leak
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/accept_fd_leak/accept_fd_leak.c b/tools/regression/sockets/accept_fd_leak/accept_fd_leak.c
index 32d4edf..659c22d 100644
--- a/tools/regression/sockets/accept_fd_leak/accept_fd_leak.c
+++ b/tools/regression/sockets/accept_fd_leak/accept_fd_leak.c
@@ -26,7 +26,7 @@
* $FreeBSD$
*/
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/socket.h>
#include <sys/wait.h>
@@ -41,13 +41,16 @@
#include <string.h>
#include <unistd.h>
+#define BIND_ATTEMPTS 10
#define LOOPS 500
+#define NUM_ATTEMPTS 1000
-volatile int quit;
+static volatile int quit;
static void
-child_died(int sig)
+child_died(int sig __unused)
{
+
quit = 1;
}
@@ -59,13 +62,12 @@ child_died(int sig)
* briefly before beginning (not 100% reliable, but a good start).
*/
int
-main(int argc, char *argv[])
+main(void)
{
struct sockaddr_in sin;
socklen_t size;
pid_t child;
- int fd1, fd2, fd3, i, s;
- int status;
+ int fd1, fd2, fd3, i, listen_port, s, status;
printf("1..2\n");
@@ -85,10 +87,22 @@ main(int argc, char *argv[])
sin.sin_len = sizeof(sin);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- sin.sin_port = htons(8080);
- if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) != 0)
- errx(-1, "bind: %s", strerror(errno));
+ srandomdev();
+
+ for (i = 0; i < BIND_ATTEMPTS; i++) {
+ /* Pick a random unprivileged port 1025-65535 */
+ listen_port = MAX((int)random() % 65535, 1025);
+ sin.sin_port = htons(listen_port);
+ if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) == 0)
+ break;
+ warn("bind with %d failed", listen_port);
+ usleep(1000);
+ }
+ if (i >= BIND_ATTEMPTS) {
+ printf("Bail out!\n");
+ exit(1);
+ }
if (listen(s, -1) != 0)
errx(-1, "listen: %s", strerror(errno));
@@ -134,16 +148,20 @@ main(int argc, char *argv[])
errx(-1, "fork: %s", strerror(errno));
/*
- * Child process does 1000 connect's.
+ * Child process does `NUM_ATTEMPTS` connects.
*/
if (child == 0) {
+ close(fd1);
+ close(fd2);
+ close(s);
+
bzero(&sin, sizeof(sin));
sin.sin_len = sizeof(sin);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- sin.sin_port = htons(8080);
+ sin.sin_port = htons(listen_port);
- for (i = 0; i < 1000; i++) {
+ for (i = 0; i < NUM_ATTEMPTS; i++) {
s = socket(PF_INET, SOCK_STREAM, 0);
if (s == -1)
errx(-1, "socket: %s", strerror(errno));
@@ -152,7 +170,7 @@ main(int argc, char *argv[])
errx(-1, "connect: %s", strerror(errno));
close(s);
}
- exit(0);
+ _exit(0);
}
/* Reset back to a blocking socket. */
@@ -167,9 +185,9 @@ main(int argc, char *argv[])
errx(-1, "ioctl(F_GETFL): %s", strerror(errno));
if (i & O_NONBLOCK)
errx(-1, "Failed to clear O_NONBLOCK (i=0x%x)\n", i);
-
- /* Do 1000 accept's with an invalid pointer. */
- for (i = 0; !quit && i < 1000; i++) {
+
+ /* Do `NUM_ATTEMPTS` accepts with an invalid pointer. */
+ for (i = 0; !quit && i < NUM_ATTEMPTS; i++) {
size = sizeof(sin);
if (accept(s, (struct sockaddr *)(uintptr_t)(0x100),
&size) != -1)
@@ -182,7 +200,7 @@ main(int argc, char *argv[])
errx(-1, "waitpid: %s", strerror(errno));
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
warnx("child process died");
-
+
/*
* Allocate a file descriptor and make sure it's fd2+2. 2 because
* we allocate an fd for the socket.
diff --git a/tools/regression/sockets/accf_data_attach/Makefile b/tools/regression/sockets/accf_data_attach/Makefile
index 75ed46b..4d33728 100644
--- a/tools/regression/sockets/accf_data_attach/Makefile
+++ b/tools/regression/sockets/accf_data_attach/Makefile
@@ -4,8 +4,6 @@
PROG= accf_data_attach
MAN=
-
-accf_data_attach: accf_data_attach.c
- gcc -Wall -o accf_data_attach accf_data_attach.c
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/accf_data_attach/accf_data_attach.c b/tools/regression/sockets/accf_data_attach/accf_data_attach.c
index 369481e..59ea68c 100644
--- a/tools/regression/sockets/accf_data_attach/accf_data_attach.c
+++ b/tools/regression/sockets/accf_data_attach/accf_data_attach.c
@@ -58,7 +58,7 @@
* make sure it is removed.
*/
int
-main(int argc, char *argv[])
+main(void)
{
struct accept_filter_arg afa;
struct sockaddr_in sin;
diff --git a/tools/regression/sockets/fstat/Makefile b/tools/regression/sockets/fstat/Makefile
index 28282ca..a583166 100644
--- a/tools/regression/sockets/fstat/Makefile
+++ b/tools/regression/sockets/fstat/Makefile
@@ -4,6 +4,6 @@
PROG= fstat
MAN=
-WARNS?= 2
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/fstat/fstat.c b/tools/regression/sockets/fstat/fstat.c
index 2534f78..6ea931d 100644
--- a/tools/regression/sockets/fstat/fstat.c
+++ b/tools/regression/sockets/fstat/fstat.c
@@ -57,7 +57,7 @@ dotest(int domain, int type, int protocol)
}
int
-main(int argc, char *argv[])
+main(void)
{
dotest(PF_INET, SOCK_DGRAM, 0);
diff --git a/tools/regression/sockets/kqueue/Makefile b/tools/regression/sockets/kqueue/Makefile
index e37eadf..6771d25 100644
--- a/tools/regression/sockets/kqueue/Makefile
+++ b/tools/regression/sockets/kqueue/Makefile
@@ -4,5 +4,6 @@
PROG= kqueue
MAN=
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/kqueue/kqueue.c b/tools/regression/sockets/kqueue/kqueue.c
index d46db96..f73704a 100644
--- a/tools/regression/sockets/kqueue/kqueue.c
+++ b/tools/regression/sockets/kqueue/kqueue.c
@@ -250,9 +250,9 @@ test_evfilt_write(int kq, int fd[2], const char *socktype)
* sockets, and confirm that we can register for various events on them.
*/
int
-main(int argc, char *argv[])
+main(void)
{
- int i, kq, sv[2];
+ int kq, sv[2];
printf("1..49\n");
diff --git a/tools/regression/sockets/listen_backlog/Makefile b/tools/regression/sockets/listen_backlog/Makefile
index c7171ec..e2eb135 100644
--- a/tools/regression/sockets/listen_backlog/Makefile
+++ b/tools/regression/sockets/listen_backlog/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$
PROG= listen_backlog
-WARNS?= 3
MAN=
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/listen_backlog/listen_backlog.c b/tools/regression/sockets/listen_backlog/listen_backlog.c
index be170ab..2276393 100644
--- a/tools/regression/sockets/listen_backlog/listen_backlog.c
+++ b/tools/regression/sockets/listen_backlog/listen_backlog.c
@@ -218,7 +218,8 @@ test_defaults(void)
* the first and second listen().
*/
static int
-socket_listen_update(int domain, int type, int protocol, int backlog,
+socket_listen_update(int domain __unused, int type __unused,
+ int protocol __unused, int backlog,
int update_backlog, int listen_backlog_assertion,
int update_backlog_assertion, int *sockp, const char *domainstring,
const char *typestring, const char *testclass, const char *test)
@@ -365,7 +366,7 @@ test_set_qlimit(void)
}
int
-main(int argc, char *argv[])
+main(void)
{
size_t len;
diff --git a/tools/regression/sockets/listenclose/Makefile b/tools/regression/sockets/listenclose/Makefile
index 1e146dc..8f4dc4e 100644
--- a/tools/regression/sockets/listenclose/Makefile
+++ b/tools/regression/sockets/listenclose/Makefile
@@ -4,6 +4,6 @@
PROG= listenclose
MAN=
-WARNS?= 2
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/listenclose/listenclose.c b/tools/regression/sockets/listenclose/listenclose.c
index 425e39f..f920846 100644
--- a/tools/regression/sockets/listenclose/listenclose.c
+++ b/tools/regression/sockets/listenclose/listenclose.c
@@ -52,7 +52,7 @@
*/
int
-main(int argc, char *argv[])
+main(void)
{
int listen_sock, connect_sock;
struct sockaddr_in sin;
diff --git a/tools/regression/sockets/pr_atomic/Makefile b/tools/regression/sockets/pr_atomic/Makefile
index b7ed9a6..1dc85ff 100644
--- a/tools/regression/sockets/pr_atomic/Makefile
+++ b/tools/regression/sockets/pr_atomic/Makefile
@@ -2,6 +2,6 @@
PROG= pr_atomic
MAN=
-WARNS?= 3
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/pr_atomic/pr_atomic.c b/tools/regression/sockets/pr_atomic/pr_atomic.c
index 69bbac7..e902cf7 100644
--- a/tools/regression/sockets/pr_atomic/pr_atomic.c
+++ b/tools/regression/sockets/pr_atomic/pr_atomic.c
@@ -42,31 +42,31 @@
#include <errno.h>
#include <unistd.h>
-#define TEST_SOCKET "/tmp/test_socket"
+static char socket_path[] = "tmp.XXXXXX";
static jmp_buf myjmpbuf;
-void handle_sigalrm(int signo);
-
-void handle_sigalrm(int signo)
+static void handle_sigalrm(int signo __unused)
{
longjmp(myjmpbuf, 1);
}
int
-main(int argc, char *argv[])
+main(void)
{
struct sockaddr_un un;
pid_t pid;
int s;
+ if (mkstemp(socket_path) == -1)
+ err(1, "mkstemp");
s = socket(PF_LOCAL, SOCK_DGRAM, 0);
if (s == -1)
errx(-1, "socket");
memset(&un, 0, sizeof(un));
un.sun_family = AF_LOCAL;
- unlink(TEST_SOCKET);
- strcpy(un.sun_path, TEST_SOCKET);
+ unlink(socket_path);
+ strcpy(un.sun_path, socket_path);
if (bind(s, (struct sockaddr *)&un, sizeof(un)) == -1)
errx(-1, "bind");
pid = fork();
diff --git a/tools/regression/sockets/reconnect/Makefile b/tools/regression/sockets/reconnect/Makefile
index edd6b47..d8fa5e0 100644
--- a/tools/regression/sockets/reconnect/Makefile
+++ b/tools/regression/sockets/reconnect/Makefile
@@ -4,6 +4,6 @@
PROG= reconnect
MAN=
-WARNS?= 2
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/reconnect/reconnect.c b/tools/regression/sockets/reconnect/reconnect.c
index 02922bf..27f32cc 100644
--- a/tools/regression/sockets/reconnect/reconnect.c
+++ b/tools/regression/sockets/reconnect/reconnect.c
@@ -45,12 +45,12 @@
#include <string.h>
#include <unistd.h>
-static char *uds_name1 = NULL;
-static char *uds_name2 = NULL;
+static char uds_name1[] = "reconnect.XXXXXXXX";
+static char uds_name2[] = "reconnect.XXXXXXXX";
#define sstosa(ss) ((struct sockaddr *)(ss))
-void
+static void
prepare_ifsun(struct sockaddr_un *ifsun, const char *path)
{
@@ -62,7 +62,7 @@ prepare_ifsun(struct sockaddr_un *ifsun, const char *path)
strcpy(ifsun->sun_path, path);
}
-int
+static int
create_uds_server(const char *path)
{
struct sockaddr_un ifsun;
@@ -82,7 +82,7 @@ create_uds_server(const char *path)
return sock;
}
-void
+static void
connect_uds_server(int sock, const char *path)
{
struct sockaddr_un ifsun;
@@ -95,14 +95,12 @@ connect_uds_server(int sock, const char *path)
err(1, "can't connect to a socket");
}
-void
+static void
cleanup(void)
{
- if (uds_name1 != NULL)
- unlink(uds_name1);
- if (uds_name2 != NULL)
- unlink(uds_name2);
+ unlink(uds_name1);
+ unlink(uds_name2);
}
int
@@ -112,20 +110,14 @@ main()
atexit(cleanup);
- uds_name1 = strdup("/tmp/reconnect.XXXXXX");
- if (uds_name1 == NULL)
- err(1, "can't allocate memory");
- uds_name1 = mktemp(uds_name1);
- if (uds_name1 == NULL)
- err(1, "mktemp(3) failed");
+ if (mkstemp(uds_name1) == -1)
+ err(1, "mkstemp");
+ unlink(uds_name1);
s_sock1 = create_uds_server(uds_name1);
- uds_name2 = strdup("/tmp/reconnect.XXXXXX");
- if (uds_name2 == NULL)
- err(1, "can't allocate memory");
- uds_name2 = mktemp(uds_name2);
- if (uds_name2 == NULL)
- err(1, "mktemp(3) failed");
+ if (mkstemp(uds_name2) == -1)
+ err(1, "mkstemp");
+ unlink(uds_name2);
s_sock2 = create_uds_server(uds_name2);
c_sock = socket(PF_LOCAL, SOCK_DGRAM, 0);
diff --git a/tools/regression/sockets/rtsocket/Makefile b/tools/regression/sockets/rtsocket/Makefile
index 13a1238..f68b6c3 100644
--- a/tools/regression/sockets/rtsocket/Makefile
+++ b/tools/regression/sockets/rtsocket/Makefile
@@ -2,6 +2,6 @@
PROG= rtsocket
MAN=
-WARNS?= 3
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/rtsocket/rtsocket.c b/tools/regression/sockets/rtsocket/rtsocket.c
index 6a0738b..b5824b3 100644
--- a/tools/regression/sockets/rtsocket/rtsocket.c
+++ b/tools/regression/sockets/rtsocket/rtsocket.c
@@ -41,7 +41,7 @@
#include <unistd.h>
int
-main(int argc, char *argv[])
+main(void)
{
int sock, socks[2];
diff --git a/tools/regression/sockets/sblock/Makefile b/tools/regression/sockets/sblock/Makefile
index af8d0e4..aa2f890 100644
--- a/tools/regression/sockets/sblock/Makefile
+++ b/tools/regression/sockets/sblock/Makefile
@@ -4,6 +4,6 @@
PROG= sblock
MAN=
-WARNS?= 2
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/sblock/sblock.c b/tools/regression/sockets/sblock/sblock.c
index a9f9518..415c4d4 100644
--- a/tools/regression/sockets/sblock/sblock.c
+++ b/tools/regression/sockets/sblock/sblock.c
@@ -54,7 +54,7 @@
static int interrupted;
static void
-signal_handler(int signum)
+signal_handler(int signum __unused)
{
interrupted++;
@@ -95,7 +95,7 @@ locking_recver(int fd)
ssize_t len;
char ch;
- if (sleep(1) < 0)
+ if (sleep(1) != 0)
err(-1, "FAIL: locking_recver: sleep");
len = recv(fd, &ch, sizeof(ch), 0);
if (len < 0 && errno != EINTR)
@@ -116,7 +116,7 @@ signaller(pid_t locking_recver_pid, int fd)
ssize_t len;
char ch;
- if (sleep(2) < 0) {
+ if (sleep(2) != 0) {
warn("signaller sleep(2)");
return;
}
@@ -124,7 +124,7 @@ signaller(pid_t locking_recver_pid, int fd)
warn("signaller kill(%d)", locking_recver_pid);
return;
}
- if (sleep(1) < 0) {
+ if (sleep(1) != 0) {
warn("signaller sleep(1)");
return;
}
@@ -141,14 +141,14 @@ signaller(pid_t locking_recver_pid, int fd)
warn("signaller close");
return;
}
- if (sleep(1) < 0) {
+ if (sleep(1) != 0) {
warn("signaller sleep(1)");
return;
}
}
int
-main(int argc, char *argv[])
+main(void)
{
int error, fds[2], recver_fd, sender_fd;
pid_t blocking_recver_pid;
diff --git a/tools/regression/sockets/sendfile/sendfile.c b/tools/regression/sockets/sendfile/sendfile.c
index 73033d7..18ae9ad 100644
--- a/tools/regression/sockets/sendfile/sendfile.c
+++ b/tools/regression/sockets/sendfile/sendfile.c
@@ -452,8 +452,8 @@ run_parent(void)
static void
cleanup(void)
{
- if (*path != '\0')
- unlink(path);
+
+ unlink(path);
}
int
@@ -461,12 +461,12 @@ main(int argc, char *argv[])
{
int pagesize;
- *path = '\0';
+ path[0] = '\0';
pagesize = getpagesize();
if (argc == 1) {
- snprintf(path, PATH_MAX, "/tmp/sendfile.XXXXXXXXXXXX");
+ snprintf(path, sizeof(path), "sendfile.XXXXXXXXXXXX");
file_fd = mkstemp(path);
if (file_fd == -1)
FAIL_ERR("mkstemp");
diff --git a/tools/regression/sockets/shutdown/Makefile b/tools/regression/sockets/shutdown/Makefile
index 07ba65d..63045f5 100644
--- a/tools/regression/sockets/shutdown/Makefile
+++ b/tools/regression/sockets/shutdown/Makefile
@@ -4,6 +4,6 @@
PROG= shutdown
MAN=
-WARNS?= 2
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/shutdown/shutdown.c b/tools/regression/sockets/shutdown/shutdown.c
index c4e884d..3d23c94 100644
--- a/tools/regression/sockets/shutdown/shutdown.c
+++ b/tools/regression/sockets/shutdown/shutdown.c
@@ -45,6 +45,8 @@ main(void)
int listen_sock, connect_sock;
u_short port;
+ listen_sock = -1;
+
/* Shutdown(2) on an invalid file descriptor has to return EBADF. */
if ((shutdown(listen_sock, SHUT_RDWR) != -1) && (errno != EBADF))
errx(-1, "shutdown() for invalid file descriptor does not "
diff --git a/tools/regression/sockets/sigpipe/Makefile b/tools/regression/sockets/sigpipe/Makefile
index 030703e..5116701 100644
--- a/tools/regression/sockets/sigpipe/Makefile
+++ b/tools/regression/sockets/sigpipe/Makefile
@@ -4,6 +4,6 @@
PROG= sigpipe
MAN=
-WARNS?= 2
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/sigpipe/sigpipe.c b/tools/regression/sockets/sigpipe/sigpipe.c
index 641536a..894d9de 100644
--- a/tools/regression/sockets/sigpipe/sigpipe.c
+++ b/tools/regression/sockets/sigpipe/sigpipe.c
@@ -69,7 +69,7 @@ got_signal(void)
}
static void
-signal_handler(int signum)
+signal_handler(int signum __unused)
{
signaled = 1;
diff --git a/tools/regression/sockets/so_setfib/Makefile b/tools/regression/sockets/so_setfib/Makefile
index fc12745..5c421c5 100644
--- a/tools/regression/sockets/so_setfib/Makefile
+++ b/tools/regression/sockets/so_setfib/Makefile
@@ -1,14 +1,16 @@
# $FreeBSD$
+.include <bsd.own.mk>
+
PROG= so_setfib
MAN=
WARNS?= 6
-.ifdef INET6
-CFLAGS+= -DINET6
-.endif
-.ifdef INET
+.if ${MK_INET} != "no"
CFLAGS+= -DINET
.endif
+.if ${MK_INET6} != "no"
+CFLAGS+= -DINET6
+.endif
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/so_setfib/so_setfib.c b/tools/regression/sockets/so_setfib/so_setfib.c
index 3c07852..50cb020 100644
--- a/tools/regression/sockets/so_setfib/so_setfib.c
+++ b/tools/regression/sockets/so_setfib/so_setfib.c
@@ -45,6 +45,7 @@
* 5. Repeat for next domain family and type from (2) on.
*/
+#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
@@ -143,6 +144,7 @@ t(u_int dom, u_int type)
if (s == -1) {
printf("not ok %d %s_%s # socket(): %s\n", testno,
t_dom[dom].name, t_type[type].name, strerror(errno));
+ testno++;
return;
}
@@ -168,6 +170,11 @@ main(int argc __unused, char *argv[] __unused)
u_int i, j;
size_t s;
+ if (geteuid() != 0) {
+ printf("1..0 # SKIP: must be root");
+ return (0);
+ }
+
/* Initalize randomness. */
srandomdev();
@@ -175,6 +182,10 @@ main(int argc __unused, char *argv[] __unused)
s = sizeof(rt_numfibs);
if (sysctlbyname("net.fibs", &rt_numfibs, &s, NULL, 0) == -1)
err(1, "sysctlbyname(net.fibs, ..)");
+
+ printf("1..%lu\n",
+ (nitems(t_dom) - 1) * nitems(t_type) * (2 + rt_numfibs + 2 + 3));
+
/* Adjust from number to index. */
rt_numfibs -= 1;
diff --git a/tools/regression/sockets/so_setfib/so_setfib.t b/tools/regression/sockets/so_setfib/so_setfib.t
deleted file mode 100644
index c80c173..0000000
--- a/tools/regression/sockets/so_setfib/so_setfib.t
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/sh
-#-
-# Copyright (c) 2012 Cisco Systems, Inc.
-# All rights reserved.
-#
-# This software was developed by Bjoern Zeeb under contract to
-# Cisco Systems, Inc..
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# $FreeBSD$
-#
-
-cd `dirname $0`
-
-EXECUTABLE=`basename $0 .t`
-
-FIBS=`sysctl -n net.fibs`
-INET=`sysctl -n kern.features.inet`
-INET6=`sysctl -n kern.features.inet6`
-
-case "${INET}" in
-1) OPTS="${OPTS} -DINET" ;;
-*) INET=0 ;;
-esac
-case "${INET6}" in
-1) OPTS="${OPTS} -DINET6" ;;
-*) INET6=0 ;;
-esac
-
-make ${EXECUTABLE} ${OPTS} 2>&1 > /dev/null
-
-# two out of bounds on each side + 3 random
-FIBS=$((2 + FIBS + 2 + 3))
-# ROUTE and LOCAL are 1 domain together given 2 or 1 types only
-TESTS=$(((1 + ${INET} + ${INET6}) * 3 * ${FIBS}))
-
-echo "1..${TESTS}"
-
-exec ./${EXECUTABLE}
diff --git a/tools/regression/sockets/socketpair/Makefile b/tools/regression/sockets/socketpair/Makefile
index ae71b17..ed66e3c 100644
--- a/tools/regression/sockets/socketpair/Makefile
+++ b/tools/regression/sockets/socketpair/Makefile
@@ -4,6 +4,6 @@
PROG= socketpair
MAN=
-WARNS?= 2
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/socketpair/socketpair.c b/tools/regression/sockets/socketpair/socketpair.c
index 5f46476..779878a 100644
--- a/tools/regression/sockets/socketpair/socketpair.c
+++ b/tools/regression/sockets/socketpair/socketpair.c
@@ -47,7 +47,7 @@
* right places.
*/
int
-main(int argc, char *argv[])
+main(void)
{
int fd1, fd2, fd3;
int sv[2];
diff --git a/tools/regression/sockets/unix_bindconnect/Makefile b/tools/regression/sockets/unix_bindconnect/Makefile
index 2c4edfd..52cc844 100644
--- a/tools/regression/sockets/unix_bindconnect/Makefile
+++ b/tools/regression/sockets/unix_bindconnect/Makefile
@@ -2,6 +2,6 @@
PROG= unix_bindconnect
MAN=
-WARNS?= 2
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/unix_bindconnect/unix_bindconnect.c b/tools/regression/sockets/unix_bindconnect/unix_bindconnect.c
index 7db82a0..079dc4d 100644
--- a/tools/regression/sockets/unix_bindconnect/unix_bindconnect.c
+++ b/tools/regression/sockets/unix_bindconnect/unix_bindconnect.c
@@ -54,8 +54,8 @@
#define UNWIND_MAX 1024
-int unwind_len;
-struct unwind {
+static int unwind_len;
+static struct unwind {
char u_path[PATH_MAX];
} unwind_list[UNWIND_MAX];
@@ -105,7 +105,7 @@ bind_test(const char *directory_path)
sun.sun_len = sizeof(sun);
sun.sun_family = AF_UNIX;
if (snprintf(sun.sun_path, sizeof(sun.sun_path), "%s", socket_path)
- >= sizeof(sun.sun_path)) {
+ >= (int)sizeof(sun.sun_path)) {
warn("bind_test: snprintf(sun.sun_path)");
close(sock1);
return (-1);
@@ -216,7 +216,7 @@ connect_test(const char *directory_path)
sun.sun_len = sizeof(sun);
sun.sun_family = AF_UNIX;
if (snprintf(sun.sun_path, sizeof(sun.sun_path), "%s", socket_path)
- >= sizeof(sun.sun_path)) {
+ >= (int)sizeof(sun.sun_path)) {
warn("connect_test: snprintf(sun.sun_path)");
close(sock1);
return (-1);
@@ -298,7 +298,7 @@ connect_test(const char *directory_path)
return (0);
}
int
-main(int argc, char *argv[])
+main(void)
{
char directory_path[PATH_MAX];
int error;
diff --git a/tools/regression/sockets/unix_close_race/Makefile b/tools/regression/sockets/unix_close_race/Makefile
index 8b9f792..370adc4 100644
--- a/tools/regression/sockets/unix_close_race/Makefile
+++ b/tools/regression/sockets/unix_close_race/Makefile
@@ -2,6 +2,6 @@
PROG= unix_close_race
MAN=
-WARNS?= 3
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/unix_close_race/unix_close_race.c b/tools/regression/sockets/unix_close_race/unix_close_race.c
index 97783e3..89c1b20 100644
--- a/tools/regression/sockets/unix_close_race/unix_close_race.c
+++ b/tools/regression/sockets/unix_close_race/unix_close_race.c
@@ -54,12 +54,13 @@
#include <unistd.h>
#include <err.h>
-#define UNIXSTR_PATH "/tmp/mytest.socket"
+static char socket_path[] = "tmp.XXXXXXXX";
+
#define USLEEP 100
#define LOOPS 100000
int
-main(int argc, char **argv)
+main(void)
{
struct sockaddr_un servaddr;
int listenfd, connfd, pid;
@@ -74,16 +75,20 @@ main(int argc, char **argv)
if (ncpus < 2)
warnx("SMP not present, test may be unable to trigger race");
+ if (mkstemp(socket_path) == -1)
+ err(1, "mkstemp failed");
+ unlink(socket_path);
+
/*
* Create a UNIX domain socket that the child will repeatedly
* accept() from, and that the parent will repeatedly connect() to.
*/
if ((listenfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0)
err(1, "parent: socket error");
- (void)unlink(UNIXSTR_PATH);
+ (void)unlink(socket_path);
bzero(&servaddr, sizeof(servaddr));
servaddr.sun_family = AF_LOCAL;
- strcpy(servaddr.sun_path, UNIXSTR_PATH);
+ strcpy(servaddr.sun_path, socket_path);
if (bind(listenfd, (struct sockaddr *) &servaddr,
sizeof(servaddr)) < 0)
err(1, "parent: bind error");
@@ -102,7 +107,7 @@ main(int argc, char **argv)
sleep(1);
bzero(&servaddr, sizeof(servaddr));
servaddr.sun_family = AF_LOCAL;
- strcpy(servaddr.sun_path, UNIXSTR_PATH);
+ strcpy(servaddr.sun_path, socket_path);
for (counter = 0; counter < LOOPS; counter++) {
if ((connfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) {
(void)kill(pid, SIGTERM);
diff --git a/tools/regression/sockets/unix_passfd/Makefile b/tools/regression/sockets/unix_passfd/Makefile
index 77c6b03..600b7b1 100644
--- a/tools/regression/sockets/unix_passfd/Makefile
+++ b/tools/regression/sockets/unix_passfd/Makefile
@@ -2,6 +2,6 @@
PROG= unix_passfd
MAN=
-WARNS?= 2
+WARNS?= 3
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/unix_passfd/unix_passfd.c b/tools/regression/sockets/unix_passfd/unix_passfd.c
index 327a58f..07ef589 100644
--- a/tools/regression/sockets/unix_passfd/unix_passfd.c
+++ b/tools/regression/sockets/unix_passfd/unix_passfd.c
@@ -29,11 +29,14 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
+#include <sys/sysctl.h>
+#include <sys/un.h>
#include <err.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -106,11 +109,10 @@ samefile(const char *test, struct stat *sb1, struct stat *sb2)
}
static void
-sendfd(const char *test, int sockfd, int sendfd)
+sendfd_payload(const char *test, int sockfd, int sendfd,
+ void *payload, size_t paylen)
{
struct iovec iovec;
- char ch;
-
char message[CMSG_SPACE(sizeof(int))];
struct cmsghdr *cmsghdr;
struct msghdr msghdr;
@@ -118,13 +120,12 @@ sendfd(const char *test, int sockfd, int sendfd)
bzero(&msghdr, sizeof(msghdr));
bzero(&message, sizeof(message));
- ch = 0;
msghdr.msg_control = message;
msghdr.msg_controllen = sizeof(message);
- iovec.iov_base = &ch;
- iovec.iov_len = sizeof(ch);
+ iovec.iov_base = payload;
+ iovec.iov_len = paylen;
msghdr.msg_iov = &iovec;
msghdr.msg_iovlen = 1;
@@ -138,33 +139,35 @@ sendfd(const char *test, int sockfd, int sendfd)
len = sendmsg(sockfd, &msghdr, 0);
if (len < 0)
err(-1, "%s: sendmsg", test);
- if (len != sizeof(ch))
+ if ((size_t)len != paylen)
errx(-1, "%s: sendmsg: %zd bytes sent", test, len);
}
static void
-recvfd(const char *test, int sockfd, int *recvfd)
+sendfd(const char *test, int sockfd, int sendfd)
+{
+ char ch;
+
+ return (sendfd_payload(test, sockfd, sendfd, &ch, sizeof(ch)));
+}
+
+static void
+recvfd_payload(const char *test, int sockfd, int *recvfd,
+ void *buf, size_t buflen)
{
struct cmsghdr *cmsghdr;
- char message[CMSG_SPACE(sizeof(int))];
+ char message[CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) + sizeof(int)];
struct msghdr msghdr;
struct iovec iovec;
ssize_t len;
- char ch;
bzero(&msghdr, sizeof(msghdr));
- ch = 0;
msghdr.msg_control = message;
msghdr.msg_controllen = sizeof(message);
- iovec.iov_base = &ch;
- iovec.iov_len = sizeof(ch);
-
- msghdr.msg_iov = &iovec;
- msghdr.msg_iovlen = 1;
-
- iovec.iov_len = sizeof(ch);
+ iovec.iov_base = buf;
+ iovec.iov_len = buflen;
msghdr.msg_iov = &iovec;
msghdr.msg_iovlen = 1;
@@ -172,23 +175,37 @@ recvfd(const char *test, int sockfd, int *recvfd)
len = recvmsg(sockfd, &msghdr, 0);
if (len < 0)
err(-1, "%s: recvmsg", test);
- if (len != sizeof(ch))
+ if ((size_t)len != buflen)
errx(-1, "%s: recvmsg: %zd bytes received", test, len);
+
cmsghdr = CMSG_FIRSTHDR(&msghdr);
if (cmsghdr == NULL)
errx(-1, "%s: recvmsg: did not receive control message", test);
- if (cmsghdr->cmsg_len != CMSG_LEN(sizeof(int)) ||
- cmsghdr->cmsg_level != SOL_SOCKET ||
- cmsghdr->cmsg_type != SCM_RIGHTS)
+ *recvfd = -1;
+ for (; cmsghdr != NULL; cmsghdr = CMSG_NXTHDR(&msghdr, cmsghdr)) {
+ if (cmsghdr->cmsg_level == SOL_SOCKET &&
+ cmsghdr->cmsg_type == SCM_RIGHTS &&
+ cmsghdr->cmsg_len == CMSG_LEN(sizeof(int))) {
+ *recvfd = *(int *)CMSG_DATA(cmsghdr);
+ if (*recvfd == -1)
+ errx(-1, "%s: recvmsg: received fd -1", test);
+ }
+ }
+ if (*recvfd == -1)
errx(-1, "%s: recvmsg: did not receive single-fd message",
test);
- *recvfd = *(int *)CMSG_DATA(cmsghdr);
- if (*recvfd == -1)
- errx(-1, "%s: recvmsg: received fd -1", test);
+}
+
+static void
+recvfd(const char *test, int sockfd, int *recvfd)
+{
+ char ch;
+
+ return (recvfd_payload(test, sockfd, recvfd, &ch, sizeof(ch)));
}
int
-main(int argc, char *argv[])
+main(void)
{
struct stat putfd_1_stat, putfd_2_stat, getfd_1_stat, getfd_2_stat;
int fd[2], putfd_1, putfd_2, getfd_1, getfd_2;
@@ -330,6 +347,43 @@ main(int argc, char *argv[])
closesocketpair(fd);
printf("%s passed\n", test);
+
+ /*
+ * Test for PR 181741. Receiver sets LOCAL_CREDS, and kernel
+ * prepends a control message to the data. Sender sends large
+ * payload. Payload + SCM_RIGHTS + LOCAL_CREDS hit socket buffer
+ * limit, and receiver receives truncated data.
+ */
+ test = "test8-rights+creds+payload";
+ printf("beginning %s\n", test);
+
+ {
+ const int on = 1;
+ u_long sendspace;
+ size_t len;
+ void *buf;
+
+ len = sizeof(sendspace);
+ if (sysctlbyname("net.local.stream.sendspace", &sendspace,
+ &len, NULL, 0) < 0)
+ err(-1, "%s: sysctlbyname(net.local.stream.sendspace)",
+ test);
+
+ if ((buf = malloc(sendspace)) == NULL)
+ err(-1, "%s: malloc", test);
+
+ domainsocketpair(test, fd);
+ if (setsockopt(fd[1], 0, LOCAL_CREDS, &on, sizeof(on)) < 0)
+ err(-1, "%s: setsockopt(LOCAL_CREDS)", test);
+ tempfile(test, &putfd_1);
+ sendfd_payload(test, fd[0], putfd_1, buf, sendspace);
+ recvfd_payload(test, fd[1], &getfd_1, buf, sendspace);
+ close(putfd_1);
+ close(getfd_1);
+ closesocketpair(fd);
+ }
+
+ printf("%s passed\n", test);
return (0);
}
diff --git a/tools/regression/sockets/unix_sendtorace/Makefile b/tools/regression/sockets/unix_sendtorace/Makefile
index 0b18376..75e7b9f 100644
--- a/tools/regression/sockets/unix_sendtorace/Makefile
+++ b/tools/regression/sockets/unix_sendtorace/Makefile
@@ -2,6 +2,6 @@
PROG= unix_sendtorace
MAN=
-WARNS?= 3
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/unix_sendtorace/unix_sendtorace.c b/tools/regression/sockets/unix_sendtorace/unix_sendtorace.c
index 2445b81..9fd748d 100644
--- a/tools/regression/sockets/unix_sendtorace/unix_sendtorace.c
+++ b/tools/regression/sockets/unix_sendtorace/unix_sendtorace.c
@@ -45,9 +45,10 @@
#include <string.h>
#include <unistd.h>
-#define PATH "/tmp/123"
#define ITERATIONS 1000000
+static char socket_path[] = "tmp.XXXXXX";
+
static void
stream_server(int listenfd)
{
@@ -75,7 +76,7 @@ stream_client(void)
bzero(&sun, sizeof(sun));
sun.sun_len = sizeof(sun);
sun.sun_family = AF_UNIX;
- strcpy(sun.sun_path, PATH);
+ strcpy(sun.sun_path, socket_path);
for (i = 0; i < ITERATIONS; i++) {
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
@@ -104,7 +105,7 @@ stream_test(void)
bzero(&sun, sizeof(sun));
sun.sun_len = sizeof(sun);
sun.sun_family = AF_UNIX;
- strcpy(sun.sun_path, PATH);
+ strcpy(sun.sun_path, socket_path);
if (bind(listenfd, (struct sockaddr *)&sun, sizeof(sun)) < 0)
err(-1, "stream_test: bind");
@@ -124,7 +125,7 @@ stream_test(void)
} else
stream_server(listenfd);
- (void)unlink(PATH);
+ (void)unlink(socket_path);
}
static void
@@ -151,7 +152,7 @@ datagram_client(void)
bzero(&sun, sizeof(sun));
sun.sun_len = sizeof(sun);
sun.sun_family = AF_UNIX;
- strcpy(sun.sun_path, PATH);
+ strcpy(sun.sun_path, socket_path);
for (i = 0; i < ITERATIONS; i++) {
fd = socket(PF_UNIX, SOCK_DGRAM, 0);
if (fd < 0) {
@@ -180,7 +181,7 @@ datagram_test(void)
bzero(&sun, sizeof(sun));
sun.sun_len = sizeof(sun);
sun.sun_family = AF_UNIX;
- strcpy(sun.sun_path, PATH);
+ strcpy(sun.sun_path, socket_path);
if (bind(serverfd, (struct sockaddr *)&sun, sizeof(sun)) < 0)
err(-1, "datagram_test: bind");
@@ -197,14 +198,16 @@ datagram_test(void)
} else
datagram_server(serverfd);
- (void)unlink(PATH);
+ (void)unlink(socket_path);
}
int
-main(int argc, char *argv[])
+main(void)
{
-
- (void)unlink(PATH);
+
+ if (mkstemp(socket_path) == -1)
+ err(1, "mkstemp failed");
+ (void)unlink(socket_path);
datagram_test();
if (0)
stream_test();
diff --git a/tools/regression/sockets/unix_socket/Makefile b/tools/regression/sockets/unix_socket/Makefile
index 40f6b92..bb60456 100644
--- a/tools/regression/sockets/unix_socket/Makefile
+++ b/tools/regression/sockets/unix_socket/Makefile
@@ -2,6 +2,6 @@
PROG= unix_socket
MAN=
-WARNS?= 3
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/unix_socket/unix_socket.c b/tools/regression/sockets/unix_socket/unix_socket.c
index 24b6baf..085366f 100644
--- a/tools/regression/sockets/unix_socket/unix_socket.c
+++ b/tools/regression/sockets/unix_socket/unix_socket.c
@@ -40,7 +40,7 @@
#include <unistd.h>
int
-main(int argc, char *argv[])
+main(void)
{
int sock, socks[2];
diff --git a/tools/regression/sockets/unix_sorflush/Makefile b/tools/regression/sockets/unix_sorflush/Makefile
index 237eb3d..db0aa6a 100644
--- a/tools/regression/sockets/unix_sorflush/Makefile
+++ b/tools/regression/sockets/unix_sorflush/Makefile
@@ -2,6 +2,6 @@
PROG= unix_sorflush
MAN=
-WARNS?= 3
+WARNS?= 6
.include <bsd.prog.mk>
diff --git a/tools/regression/sockets/unix_sorflush/unix_sorflush.c b/tools/regression/sockets/unix_sorflush/unix_sorflush.c
index 126de2f..e0deb00 100644
--- a/tools/regression/sockets/unix_sorflush/unix_sorflush.c
+++ b/tools/regression/sockets/unix_sorflush/unix_sorflush.c
@@ -68,7 +68,7 @@ shutdown_and_exit(int s)
}
int
-main(int argc, char *argv[])
+main(void)
{
pid_t pida, pidb;
int sv[2];
diff --git a/tools/regression/sockets/zerosend/zerosend.c b/tools/regression/sockets/zerosend/zerosend.c
index a42ec51..1f3217a 100644
--- a/tools/regression/sockets/zerosend/zerosend.c
+++ b/tools/regression/sockets/zerosend/zerosend.c
@@ -209,12 +209,12 @@ setup_pipe(const char *test, int *fdp)
static void
setup_fifo(const char *test, int *fdp)
{
- char path[PATH_MAX];
+ char path[] = "0send_fifo.XXXXXXX";
int fd1, fd2;
- strcpy(path, "/tmp/0send_fifo.XXXXXXX");
- if (mktemp(path) == NULL)
+ if (mkstemp(path) == -1)
err(-1, "%s: setup_fifo: mktemp", test);
+ unlink(path);
if (mkfifo(path, 0600) < 0)
err(-1, "%s: setup_fifo: mkfifo(%s)", test, path);
OpenPOWER on IntegriCloud