3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23 #include <sys/param.h>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <sys/socket.h>
27 #include <sys/un.h>
28 #include <stdio.h>
29 #include <unistd.h>
30 #include <string.h>
31 #include <errno.h>
32 #include <stdint.h>
33 #include <stdlib.h>
34 #include <pthread.h>
35
36 extern const char *__progname;
37
38 static void *
39 server(void *varg)
40 {
41 int ret;
42 int sock = (int)varg;
97 fprintf(stderr, "listener - listen fail %s\n", strerror(errno));
98 exit(1);
99 }
100
101 for (;;) {
102 asock = accept(lsock, NULL, 0);
103 if (asock == -1) {
104 fprintf(stderr, "listener - accept fail %s\n",
105 strerror(errno));
106 exit(1);
107 }
108
109 /* start worker */
110 ret = pthread_create(NULL, NULL, server, (void *)asock);
111 if (ret == -1) {
112 fprintf(stderr, "%s - thread create fail %s\n",
113 __progname, strerror(errno));
114 exit(1);
115 }
116 }
117
118 exit(0);
119 }
120
121 /*
122 * This should be a place only root is allowed to write.
123 * The test will create and destroy this directory.
124 */
125 char testdir[100] = "/var/run/os-tests-sockfs";
126 struct sockaddr_un addr;
127 int test_uid = UID_NOBODY;
128
129 int
130 main(int argc, char **argv)
131 {
132 int ret;
133 int sock;
134 unsigned int i;
135
136 if (argc > 1) {
137 ret = strlcpy(testdir, argv[1], sizeof (testdir));
138 if (ret >= sizeof (testdir)) {
|
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23 /*
24 * Copyright 2019 Joyent, Inc.
25 */
26
27 #include <sys/param.h>
28 #include <sys/types.h>
29 #include <sys/stat.h>
30 #include <sys/socket.h>
31 #include <sys/un.h>
32 #include <stdio.h>
33 #include <unistd.h>
34 #include <string.h>
35 #include <errno.h>
36 #include <stdint.h>
37 #include <stdlib.h>
38 #include <pthread.h>
39
40 extern const char *__progname;
41
42 static void *
43 server(void *varg)
44 {
45 int ret;
46 int sock = (int)varg;
101 fprintf(stderr, "listener - listen fail %s\n", strerror(errno));
102 exit(1);
103 }
104
105 for (;;) {
106 asock = accept(lsock, NULL, 0);
107 if (asock == -1) {
108 fprintf(stderr, "listener - accept fail %s\n",
109 strerror(errno));
110 exit(1);
111 }
112
113 /* start worker */
114 ret = pthread_create(NULL, NULL, server, (void *)asock);
115 if (ret == -1) {
116 fprintf(stderr, "%s - thread create fail %s\n",
117 __progname, strerror(errno));
118 exit(1);
119 }
120 }
121 }
122
123 /*
124 * This should be a place only root is allowed to write.
125 * The test will create and destroy this directory.
126 */
127 char testdir[100] = "/var/run/os-tests-sockfs";
128 struct sockaddr_un addr;
129 int test_uid = UID_NOBODY;
130
131 int
132 main(int argc, char **argv)
133 {
134 int ret;
135 int sock;
136 unsigned int i;
137
138 if (argc > 1) {
139 ret = strlcpy(testdir, argv[1], sizeof (testdir));
140 if (ret >= sizeof (testdir)) {
|