From 1d378d13a52c8850dc4a75294138354a3930e6bd Mon Sep 17 00:00:00 2001 From: mvs Date: Mon, 29 Nov 2021 21:21:26 +0000 Subject: [PATCH] Create socket within current directory instead of /tmp. Also remove it with "make clean". --- regress/sys/kern/unconacc/Makefile | 4 +++- regress/sys/kern/unconacc/unconacc.c | 8 +++++--- regress/sys/kern/undgram_conclose/Makefile | 4 +++- regress/sys/kern/undgram_conclose/undgram_conclose.c | 7 +++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/regress/sys/kern/unconacc/Makefile b/regress/sys/kern/unconacc/Makefile index 3ece45dbcbd..d945c71a169 100644 --- a/regress/sys/kern/unconacc/Makefile +++ b/regress/sys/kern/unconacc/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.1 2021/11/29 13:05:04 mvs Exp $ +# $OpenBSD: Makefile,v 1.2 2021/11/29 21:21:26 mvs Exp $ # Copyright (c) 2021 Makkoveev Vitaliy # @@ -19,4 +19,6 @@ WARNINGS = yes PROG = unconacc LDADD+= -lpthread +CLEANFILES += unconacc.socket + .include diff --git a/regress/sys/kern/unconacc/unconacc.c b/regress/sys/kern/unconacc/unconacc.c index bfe5934c342..6b875fd0986 100644 --- a/regress/sys/kern/unconacc/unconacc.c +++ b/regress/sys/kern/unconacc/unconacc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: unconacc.c,v 1.1 2021/11/29 13:05:04 mvs Exp $ */ +/* $OpenBSD: unconacc.c,v 1.2 2021/11/29 21:21:26 mvs Exp $ */ /* * Copyright (c) 2021 Vitaliy Makkoveev @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -134,6 +135,8 @@ main(int argc, char *argv[]) int i; + umask(0077); + if (argc == 2 && !strcmp(argv[1], "--infinite")) tv = NULL; @@ -149,8 +152,7 @@ main(int argc, char *argv[]) memset(&sun, 0, sizeof(sun)); sun.sun_len = sizeof(sun); sun.sun_family = AF_UNIX; - snprintf(sun.sun_path, sizeof(sun.sun_path) - 1, - "/tmp/socket%d", getpid()); + snprintf(sun.sun_path, sizeof(sun.sun_path) - 1, "unconacc.socket"); if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) err(1, "socket"); diff --git a/regress/sys/kern/undgram_conclose/Makefile b/regress/sys/kern/undgram_conclose/Makefile index e306448671b..5d0bcb6e18a 100644 --- a/regress/sys/kern/undgram_conclose/Makefile +++ b/regress/sys/kern/undgram_conclose/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.1 2021/11/19 17:14:38 mvs Exp $ +# $OpenBSD: Makefile,v 1.2 2021/11/29 21:21:26 mvs Exp $ # Copyright (c) 2021 Makkoveev Vitaliy # @@ -19,4 +19,6 @@ WARNINGS = yes PROG = undgram_conclose LDADD+= -lpthread +CLEANFILES += undgram_conclose.socket + .include diff --git a/regress/sys/kern/undgram_conclose/undgram_conclose.c b/regress/sys/kern/undgram_conclose/undgram_conclose.c index cf0ceaf0166..85258a51375 100644 --- a/regress/sys/kern/undgram_conclose/undgram_conclose.c +++ b/regress/sys/kern/undgram_conclose/undgram_conclose.c @@ -1,4 +1,4 @@ -/* $OpenBSD: undgram_conclose.c,v 1.1 2021/11/19 17:14:38 mvs Exp $ */ +/* $OpenBSD: undgram_conclose.c,v 1.2 2021/11/29 21:21:26 mvs Exp $ */ /* * Copyright (c) 2021 Vitaliy Makkoveev @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -112,6 +113,8 @@ main(int argc, char *argv[]) pthread_t thr; int error, i; + umask(0077); + if (argc == 2 && !strcmp(argv[1], "--infinite")) tv = NULL; @@ -128,7 +131,7 @@ main(int argc, char *argv[]) sun.sun_len = sizeof(sun); sun.sun_family = AF_UNIX; snprintf(sun.sun_path, sizeof(sun.sun_path) - 1, - "/tmp/socket%d", getpid()); + "undgram_conclose.socket"); if ((error = pthread_create(&thr, NULL, thr_close, &sun))) therrc(1, error, "pthread_create"); -- 2.20.1