• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

proftpd / proftpd / 30135626854

25 Jul 2026 12:15AM UTC coverage: 93.034% (+0.6%) from 92.428%
30135626854

push

github

51363 of 55209 relevant lines covered (93.03%)

219.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.21
/tests/api/netacl.c
1
/*
2
 * ProFTPD - FTP server testsuite
3
 * Copyright (c) 2008-2026 The ProFTPD Project team
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, see <https://www.gnu.org/licenses/>.
17
 *
18
 * As a special exemption, The ProFTPD Project team and other respective
19
 * copyright holders give permission to link this program with OpenSSL, and
20
 * distribute the resulting executable, without including the source code for
21
 * OpenSSL in the source distribution.
22
 */
23

24
/* NetACL API tests */
25

26
#include "tests.h"
27

28
static pool *p = NULL;
29

30
/* Fixtures */
31

32
static void set_up(void) {
33
  if (p == NULL) {
6✔
34
    p = permanent_pool = make_sub_pool(NULL);
6✔
35
  }
6✔
36

37
  init_netaddr();
38

6✔
39
  if (getenv("TEST_VERBOSE") != NULL) {
40
    pr_trace_set_levels("dns", 1, 20);
6✔
41
    pr_trace_set_levels("netacl", 1, 20);
6✔
42
  }
6✔
43
}
44

6✔
45
static void tear_down(void) {
46
  if (getenv("TEST_VERBOSE") != NULL) {
6✔
47
    pr_trace_set_levels("dns", 0, 0);
6✔
48
    pr_trace_set_levels("netacl", 0, 0);
6✔
49
  }
6✔
50

51
  if (p) {
52
    destroy_pool(p);
6✔
53
    p = permanent_pool = NULL;
6✔
54
  }
6✔
55
}
56

6✔
57
/* Tests */
58

59
START_TEST (netacl_create_test) {
60
  pr_netacl_t *res;
1✔
61
  pr_netacl_type_t acl_type;
1✔
62
  char *acl_str;
1✔
63

1✔
64
  res = pr_netacl_create(NULL, NULL);
65
  ck_assert_msg(res == NULL, "Failed to handle NULL arguments");
1✔
66
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
67

1✔
68
  res = pr_netacl_create(NULL, "");
69
  ck_assert_msg(res == NULL, "Failed to handle NULL pool");
1✔
70
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
71

1✔
72
  res = pr_netacl_create(p, NULL);
73
  ck_assert_msg(res == NULL, "Failed to handle NULL ACL string");
1✔
74
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
75

1✔
76
  res = pr_netacl_create(p, "");
77
  ck_assert_msg(res == NULL, "Failed to handle empty ACL string");
1✔
78
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
79

1✔
80
  acl_str = "ALL";
81
  res = pr_netacl_create(p, acl_str);
1✔
82
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s'", acl_str);
1✔
83

1✔
84
  acl_type = pr_netacl_get_type(res);
85
  ck_assert_msg(acl_type == PR_NETACL_TYPE_ALL,
1✔
86
    "Failed to have ALL type for ACL string '%s'", acl_str);
1✔
87

88
  acl_str = "none";
89
  res = pr_netacl_create(p, acl_str);
1✔
90
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s'", acl_str);
1✔
91

1✔
92
  acl_type = pr_netacl_get_type(res);
93
  ck_assert_msg(acl_type == PR_NETACL_TYPE_NONE,
1✔
94
    "Failed to have NONE type for ACL string '%s'", acl_str);
1✔
95

96
  acl_str = pstrdup(p, "localhost/24");
97
  res = pr_netacl_create(p, acl_str);
1✔
98
  ck_assert_msg(res == NULL, "Failed to handle bad ACL string '%s': %s",
1✔
99
    acl_str, strerror(errno));
1✔
100
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
101

1✔
102
  acl_str = pstrdup(p, "127.0.0.1/24");
103
  res = pr_netacl_create(p, acl_str);
1✔
104
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
105
    strerror(errno));
1✔
106

107
  acl_type = pr_netacl_get_type(res);
108
  ck_assert_msg(acl_type == PR_NETACL_TYPE_IPMASK,
1✔
109
    "Failed to have IPMASK type for ACL string '%s'", acl_str);
1✔
110

111
  acl_str = pstrdup(p, "127.0.0.1/36");
112
  res = pr_netacl_create(p, acl_str);
1✔
113
  ck_assert_msg(res == NULL, "Failed to handle bad ACL string '%s': %s", acl_str,
1✔
114
    strerror(errno));
1✔
115

116
  acl_str = pstrdup(p, "0.0.0.0/0");
117
  res = pr_netacl_create(p, acl_str);
1✔
118
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
119
    strerror(errno));
1✔
120

121
#ifdef PR_USE_IPV6
122
  acl_str = pstrdup(p, "::1/36");
123
  res = pr_netacl_create(p, acl_str);
1✔
124
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
125
    strerror(errno));
1✔
126

127
  acl_type = pr_netacl_get_type(res);
128
  ck_assert_msg(acl_type == PR_NETACL_TYPE_IPMASK,
1✔
129
    "Failed to have IPMASK type for ACL string '%s'", acl_str);
1✔
130

131
  acl_str = pstrdup(p, "::ffff:127.0.0.1/111");
132
  res = pr_netacl_create(p, acl_str);
1✔
133
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
134
    strerror(errno));
1✔
135

136
  acl_type = pr_netacl_get_type(res);
137
  ck_assert_msg(acl_type == PR_NETACL_TYPE_IPMASK,
1✔
138
    "Failed to have IPMASK type for ACL string '%s'", acl_str);
1✔
139

140
  acl_str = pstrdup(p, "::1/136");
141
  res = pr_netacl_create(p, acl_str);
1✔
142
  ck_assert_msg(res == NULL, "Failed to handle bad ACL string '%s': %s", acl_str,
1✔
143
    strerror(errno));
1✔
144

145
  acl_str = pstrdup(p, "::ffff:127.0.0.1/136");
146
  res = pr_netacl_create(p, acl_str);
1✔
147
  ck_assert_msg(res == NULL, "Failed to handle bad ACL string '%s': %s", acl_str,
1✔
148
    strerror(errno));
1✔
149

150
  acl_str = pstrdup(p, "::1");
151
  res = pr_netacl_create(p, acl_str);
1✔
152
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
153
    strerror(errno));
1✔
154

155
  acl_type = pr_netacl_get_type(res);
156
  ck_assert_msg(acl_type == PR_NETACL_TYPE_IPMATCH,
1✔
157
    "Failed to have IPMATCH type for ACL string '%s'", acl_str);
1✔
158

159
  acl_str = pstrdup(p, "!::1");
160
  res = pr_netacl_create(p, acl_str);
1✔
161
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
162
    strerror(errno));
1✔
163

164
  acl_type = pr_netacl_get_type(res);
165
  ck_assert_msg(acl_type == PR_NETACL_TYPE_IPMATCH,
1✔
166
    "Failed to have IPMATCH type for ACL string '%s'", acl_str);
1✔
167
#endif
168

169
  acl_str = pstrdup(p, "127.0.0.1/0");
170
  res = pr_netacl_create(p, acl_str);
1✔
171
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
172
    strerror(errno));
1✔
173

174
  acl_type = pr_netacl_get_type(res);
175
  ck_assert_msg(acl_type == PR_NETACL_TYPE_IPMASK,
1✔
176
    "Failed to have IPMASK type for ACL string '%s'", acl_str);
1✔
177

178
  acl_str = pstrdup(p, "127.0.0.1/-1");
179
  res = pr_netacl_create(p, acl_str);
1✔
180
  ck_assert_msg(res == NULL, "Failed to handle bad ACL string '%s': %s", acl_str,
1✔
181
    strerror(errno));
1✔
182

183
  acl_str = pstrdup(p, "127.0.0.1.2/24");
184
  res = pr_netacl_create(p, acl_str);
1✔
185
  ck_assert_msg(res == NULL, "Failed to handle bad ACL string '%s': %s", acl_str,
1✔
186
    strerror(errno));
1✔
187

188
  acl_str = pstrdup(p, "127.0.0.1/25f");
189
  res = pr_netacl_create(p, acl_str);
1✔
190
  ck_assert_msg(res == NULL, "Failed to handle bad ACL string '%s': %s", acl_str,
1✔
191
    strerror(errno));
1✔
192

193
  acl_str = pstrdup(p, "127.0.0.");
194
  res = pr_netacl_create(p, acl_str);
1✔
195
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
196
    strerror(errno));
1✔
197

198
  acl_type = pr_netacl_get_type(res);
199
  ck_assert_msg(acl_type == PR_NETACL_TYPE_IPGLOB,
1✔
200
    "Failed to have IPGLOB type for ACL string '%s'", acl_str);
1✔
201

202
  acl_str = pstrdup(p, "127.0.0.1");
203
  res = pr_netacl_create(p, acl_str);
1✔
204
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
205
    strerror(errno));
1✔
206

207
  acl_type = pr_netacl_get_type(res);
208
  ck_assert_msg(acl_type == PR_NETACL_TYPE_IPMATCH,
1✔
209
    "Failed to have IPMATCH type for ACL string '%s'", acl_str);
1✔
210

211
  acl_str = pstrdup(p, "!127.0.0.1");
212
  res = pr_netacl_create(p, acl_str);
1✔
213
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
214
    strerror(errno));
1✔
215

216
  acl_type = pr_netacl_get_type(res);
217
  ck_assert_msg(acl_type == PR_NETACL_TYPE_IPMATCH,
1✔
218
    "Failed to have IPMATCH type for ACL string '%s'", acl_str);
1✔
219

220
  acl_str = pstrdup(p, "127.0.0.1.1");
221
  res = pr_netacl_create(p, acl_str);
1✔
222
  ck_assert_msg(res == NULL, "Failed to handle bad ACL string '%s': %s", acl_str,
1✔
223
    strerror(errno));
1✔
224

225
  acl_str = pstrdup(p, ".0.0.1");
226
  res = pr_netacl_create(p, acl_str);
1✔
227
  ck_assert_msg(res == NULL, "Failed to handle bad ACL string '%s': %s", acl_str,
1✔
228
    strerror(errno));
1✔
229

230
  acl_str = pstrdup(p, "*.0.0.1");
231
  res = pr_netacl_create(p, acl_str);
1✔
232
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
233
    strerror(errno));
1✔
234

235
  acl_type = pr_netacl_get_type(res);
236
  ck_assert_msg(acl_type == PR_NETACL_TYPE_IPGLOB,
1✔
237
    "Failed to have IPGLOB type for ACL string '%s'", acl_str);
1✔
238

239
  acl_str = pstrdup(p, ".edu");
240
  res = pr_netacl_create(p, acl_str);
1✔
241
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
242
    strerror(errno));
1✔
243

244
  acl_type = pr_netacl_get_type(res);
245
  ck_assert_msg(acl_type == PR_NETACL_TYPE_DNSGLOB,
1✔
246
    "Failed to have DNSGLOB type for ACL string '%s'", acl_str);
1✔
247

248
  acl_str = pstrdup(p, "localhost");
249
  res = pr_netacl_create(p, acl_str);
1✔
250
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
251
    strerror(errno));
1✔
252

253
  acl_type = pr_netacl_get_type(res);
254
  ck_assert_msg(acl_type == PR_NETACL_TYPE_DNSMATCH,
1✔
255
    "Failed to have DNSMATCH type for ACL string '%s'", acl_str);
1✔
256

257
  acl_str = pstrdup(p, "foobar");
258
  res = pr_netacl_create(p, acl_str);
1✔
259
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
260
    strerror(errno));
1✔
261

262
  acl_type = pr_netacl_get_type(res);
263
  ck_assert_msg(acl_type == PR_NETACL_TYPE_DNSMATCH,
1✔
264
    "Failed to have DNSMATCH type for ACL string '%s'", acl_str);
1✔
265

266
  acl_str = pstrdup(p, "!foobar");
267
  res = pr_netacl_create(p, acl_str);
1✔
268
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
269
    strerror(errno));
1✔
270

271
  acl_type = pr_netacl_get_type(res);
272
  ck_assert_msg(acl_type == PR_NETACL_TYPE_DNSMATCH,
1✔
273
    "Failed to have DNSMATCH type for ACL string '%s'", acl_str);
1✔
274

275
  acl_str = pstrdup(p, "!fo?bar");
276
  res = pr_netacl_create(p, acl_str);
1✔
277
  ck_assert_msg(res != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
278
    strerror(errno));
1✔
279

280
  acl_type = pr_netacl_get_type(res);
281
  ck_assert_msg(acl_type == PR_NETACL_TYPE_DNSGLOB,
1✔
282
    "Failed to have DNSGLOB type for ACL string '%s'", acl_str);
1✔
283
}
284
END_TEST
1✔
285

286
START_TEST (netacl_get_str_test) {
287
  pr_netacl_t *acl;
1✔
288
  char *acl_str, *ok;
1✔
289
  const char *res;
1✔
290

1✔
291
  res = pr_netacl_get_str(NULL, NULL);
292
  ck_assert_msg(res == NULL, "Failed to handle NULL arguments");
1✔
293
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
294

1✔
295
  res = pr_netacl_get_str(p, NULL);
296
  ck_assert_msg(res == NULL, "Failed to handle NULL ACL");
1✔
297
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
298

1✔
299
  acl_str = "all";
300
  acl = pr_netacl_create(p, acl_str);
1✔
301
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
302

1✔
303
  res = pr_netacl_get_str(NULL, acl);
304
  ck_assert_msg(res == NULL, "Failed to handle NULL pool");
1✔
305
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
306

1✔
307
  ok = "all <all>";
308
  res = pr_netacl_get_str(p, acl);
1✔
309
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
310
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
311

1✔
312
  acl_str = "AlL";
313
  acl = pr_netacl_create(p, acl_str);
1✔
314
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
315

1✔
316
  res = pr_netacl_get_str(p, acl);
317
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
318
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
319

1✔
320
  acl_str = "None";
321
  acl = pr_netacl_create(p, acl_str);
1✔
322
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
323

1✔
324
  ok = "none <none>";
325
  res = pr_netacl_get_str(p, acl);
1✔
326
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
327
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
328

1✔
329
  acl_str = pstrdup(p, "127.0.0.1");
330
  acl = pr_netacl_create(p, acl_str);
1✔
331
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
332

1✔
333
  ok = "127.0.0.1 <IP address match>";
334
  res = pr_netacl_get_str(p, acl);
1✔
335
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
336
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
337

1✔
338
  acl_str = pstrdup(p, "!127.0.0.1");
339
  acl = pr_netacl_create(p, acl_str);
1✔
340
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
341

1✔
342
  ok = "!127.0.0.1 <IP address match, inverted>";
343
  res = pr_netacl_get_str(p, acl);
1✔
344
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
345
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
346

1✔
347
  acl_str = pstrdup(p, "127.0.0.");
348
  acl = pr_netacl_create(p, acl_str);
1✔
349
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
350

1✔
351
  ok = "127.0.0.* <IP address glob>";
352
  res = pr_netacl_get_str(p, acl);
1✔
353
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
354
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
355

1✔
356
  acl_str = pstrdup(p, "localhost");
357
  acl = pr_netacl_create(p, acl_str);
1✔
358
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
359

1✔
360
  ok = "localhost <DNS hostname match>";
361
  res = pr_netacl_get_str(p, acl);
1✔
362
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
363
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
364

1✔
365
  acl_str = pstrdup(p, ".castaglia.org");
366
  acl = pr_netacl_create(p, acl_str);
1✔
367
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
368

1✔
369
  ok = "*.castaglia.org <DNS hostname glob>";
370
  res = pr_netacl_get_str(p, acl);
1✔
371
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
372
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
373

1✔
374
  acl_str = pstrdup(p, "127.0.0.1/24");
375
  acl = pr_netacl_create(p, acl_str);
1✔
376
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
377

1✔
378
  ok = "127.0.0.1/24 <IP address mask, 24-bit mask>";
379
  res = pr_netacl_get_str(p, acl);
1✔
380
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
381
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
382

1✔
383
  acl_str = pstrdup(p, "127.0.0.1/0");
384
  acl = pr_netacl_create(p, acl_str);
1✔
385
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
386

1✔
387
  ok = "127.0.0.1/0 <IP address mask, 0-bit mask>";
388
  res = pr_netacl_get_str(p, acl);
1✔
389
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
390
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
391

1✔
392
  acl_str = pstrdup(p, "0.0.0.0/0");
393
  acl = pr_netacl_create(p, acl_str);
1✔
394
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
395

1✔
396
  ok = "0.0.0.0/0 <IP address mask, 0-bit mask>";
397
  res = pr_netacl_get_str(p, acl);
1✔
398
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
399
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
400

1✔
401
  acl_str = pstrdup(p, "!127.0.0.1/24");
402
  acl = pr_netacl_create(p, acl_str);
1✔
403
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
404

1✔
405
  ok = "!127.0.0.1/24 <IP address mask, 24-bit mask, inverted>";
406
  res = pr_netacl_get_str(p, acl);
1✔
407
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
408
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
409

1✔
410
#ifdef PR_USE_IPV6
411
  acl_str = pstrdup(p, "::1/24");
412
  acl = pr_netacl_create(p, acl_str);
1✔
413
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
414

1✔
415
  ok = "::1/24 <IP address mask, 24-bit mask>";
416
  res = pr_netacl_get_str(p, acl);
1✔
417
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
418
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
419

1✔
420
  acl_str = pstrdup(p, "::1/127");
421
  acl = pr_netacl_create(p, acl_str);
1✔
422
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
423

1✔
424
  ok = "::1/127 <IP address mask, 127-bit mask>";
425
  res = pr_netacl_get_str(p, acl);
1✔
426
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
427
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
428

1✔
429
  acl_str = pstrdup(p, "::ffff:127.0.0.1/127");
430
  acl = pr_netacl_create(p, acl_str);
1✔
431
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
432

1✔
433
  ok = "::ffff:127.0.0.1/127 <IP address mask, 127-bit mask>";
434
  res = pr_netacl_get_str(p, acl);
1✔
435
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
436
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
437
#endif
1✔
438
}
439
END_TEST
1✔
440

441
START_TEST (netacl_get_str2_test) {
442
  pr_netacl_t *acl;
1✔
443
  char *acl_str, *ok;
1✔
444
  const char *res;
1✔
445
  int flags = PR_NETACL_FL_STR_NO_DESC;
1✔
446

1✔
447
  res = pr_netacl_get_str2(NULL, NULL, 0);
448
  ck_assert_msg(res == NULL, "Failed to handle NULL arguments");
1✔
449
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
450

1✔
451
  res = pr_netacl_get_str2(p, NULL, 0);
452
  ck_assert_msg(res == NULL, "Failed to handle NULL ACL");
1✔
453
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
454

1✔
455
  acl_str = "all";
456
  acl = pr_netacl_create(p, acl_str);
1✔
457
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
458

1✔
459
  res = pr_netacl_get_str2(NULL, acl, flags);
460
  ck_assert_msg(res == NULL, "Failed to handle NULL pool");
1✔
461
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
462

1✔
463
  ok = "all";
464
  res = pr_netacl_get_str2(p, acl, flags);
1✔
465
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
466
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
467

1✔
468
  acl_str = "AlL";
469
  acl = pr_netacl_create(p, acl_str);
1✔
470
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
471

1✔
472
  res = pr_netacl_get_str2(p, acl, flags);
473
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
474
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
475

1✔
476
  acl_str = "None";
477
  acl = pr_netacl_create(p, acl_str);
1✔
478
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
479

1✔
480
  ok = "none";
481
  res = pr_netacl_get_str2(p, acl, flags);
1✔
482
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
483
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
484

1✔
485
  acl_str = pstrdup(p, "127.0.0.1");
486
  acl = pr_netacl_create(p, acl_str);
1✔
487
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
488

1✔
489
  ok = "127.0.0.1";
490
  res = pr_netacl_get_str2(p, acl, flags);
1✔
491
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
492
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
493

1✔
494
  acl_str = pstrdup(p, "!127.0.0.1");
495
  acl = pr_netacl_create(p, acl_str);
1✔
496
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
497

1✔
498
  ok = "!127.0.0.1";
499
  res = pr_netacl_get_str2(p, acl, flags);
1✔
500
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
501
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
502

1✔
503
  acl_str = pstrdup(p, "127.0.0.");
504
  acl = pr_netacl_create(p, acl_str);
1✔
505
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
506

1✔
507
  ok = "127.0.0.*";
508
  res = pr_netacl_get_str2(p, acl, flags);
1✔
509
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
510
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
511

1✔
512
  acl_str = pstrdup(p, "localhost");
513
  acl = pr_netacl_create(p, acl_str);
1✔
514
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
515

1✔
516
  ok = "localhost";
517
  res = pr_netacl_get_str2(p, acl, flags);
1✔
518
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
519
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
520

1✔
521
  acl_str = pstrdup(p, ".castaglia.org");
522
  acl = pr_netacl_create(p, acl_str);
1✔
523
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
524

1✔
525
  ok = "*.castaglia.org";
526
  res = pr_netacl_get_str2(p, acl, flags);
1✔
527
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
528
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
529

1✔
530
  acl_str = pstrdup(p, "127.0.0.1/24");
531
  acl = pr_netacl_create(p, acl_str);
1✔
532
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
533

1✔
534
  ok = "127.0.0.1/24";
535
  res = pr_netacl_get_str2(p, acl, flags);
1✔
536
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
537
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
538

1✔
539
  acl_str = pstrdup(p, "127.0.0.1/0");
540
  acl = pr_netacl_create(p, acl_str);
1✔
541
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
542

1✔
543
  ok = "127.0.0.1/0";
544
  res = pr_netacl_get_str2(p, acl, flags);
1✔
545
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
546
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
547

1✔
548
  acl_str = pstrdup(p, "0.0.0.0/0");
549
  acl = pr_netacl_create(p, acl_str);
1✔
550
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
551

1✔
552
  ok = "0.0.0.0/0";
553
  res = pr_netacl_get_str2(p, acl, flags);
1✔
554
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
555
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
556

1✔
557
  acl_str = pstrdup(p, "!127.0.0.1/24");
558
  acl = pr_netacl_create(p, acl_str);
1✔
559
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
560

1✔
561
  ok = "!127.0.0.1/24";
562
  res = pr_netacl_get_str2(p, acl, flags);
1✔
563
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
564
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
565

1✔
566
#ifdef PR_USE_IPV6
567
  acl_str = pstrdup(p, "::1/24");
568
  acl = pr_netacl_create(p, acl_str);
1✔
569
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
570

1✔
571
  ok = "::1/24";
572
  res = pr_netacl_get_str2(p, acl, flags);
1✔
573
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
574
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
575

1✔
576
  acl_str = pstrdup(p, "::1/127");
577
  acl = pr_netacl_create(p, acl_str);
1✔
578
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
579

1✔
580
  ok = "::1/127";
581
  res = pr_netacl_get_str2(p, acl, flags);
1✔
582
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
583
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
584

1✔
585
  acl_str = pstrdup(p, "::ffff:127.0.0.1/127");
586
  acl = pr_netacl_create(p, acl_str);
1✔
587
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
588

1✔
589
  ok = "::ffff:127.0.0.1/127";
590
  res = pr_netacl_get_str2(p, acl, flags);
1✔
591
  ck_assert_msg(res != NULL, "Failed to get ACL string: %s", strerror(errno));
1✔
592
  ck_assert_msg(strcmp(res, ok) == 0, "Expected '%s', got '%s'", ok, res);
1✔
593
#endif
1✔
594
}
595
END_TEST
1✔
596

597
START_TEST (netacl_dup_test) {
598
  pr_netacl_t *acl, *res;
1✔
599

1✔
600
  res = pr_netacl_dup(NULL, NULL);
601
  ck_assert_msg(res == NULL, "Failed to handle NULL arguments");
1✔
602
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
603

1✔
604
  res = pr_netacl_dup(p, NULL);
605
  ck_assert_msg(res == NULL, "Failed to handle NULL ACL argument");
1✔
606
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
607

1✔
608
  acl = pr_netacl_create(p, "ALL");
609
  ck_assert_msg(acl != NULL, "Failed to create ALL ACL");
1✔
610

1✔
611
  res = pr_netacl_dup(NULL, acl);
612
  ck_assert_msg(res == NULL, "Failed to handle NULL pool");
1✔
613
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
614

1✔
615
  res = pr_netacl_dup(p, acl);
616
  ck_assert_msg(res != NULL, "Failed to dup ACL: %s", strerror(errno));
1✔
617
  ck_assert_msg(strcmp(pr_netacl_get_str(p, res), pr_netacl_get_str(p, acl)) == 0,
1✔
618
    "Expected '%s', got '%s'", pr_netacl_get_str(p, acl),
1✔
619
    pr_netacl_get_str(p, res));
620
}
621
END_TEST
1✔
622

623
START_TEST (netacl_match_test) {
624
  pr_netacl_t *acl;
1✔
625
  const pr_netaddr_t *addr;
1✔
626
  char *acl_str;
1✔
627
  int have_localdomain = FALSE, res, reverse_dns;
1✔
628

1✔
629
  res = pr_netacl_match(NULL, NULL);
630
  ck_assert_msg(res == -2, "Failed to handle NULL arguments");
1✔
631
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
632

1✔
633
  acl_str = "all";
634
  acl = pr_netacl_create(p, acl_str);
1✔
635
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
636
    strerror(errno));
1✔
637

638
  res = pr_netacl_match(acl, NULL);
639
  ck_assert_msg(res == -2, "Failed to handle NULL addr");
1✔
640
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
641

1✔
642
  addr = pr_netaddr_get_addr(p, "localhost", NULL);
643
  ck_assert_msg(addr != NULL, "Failed to get addr for '%s': %s", "localhost",
1✔
644
    strerror(errno));
1✔
645

646
  if (getenv("CI") == NULL) {
647
    /* It's possible that the DNS name for 'localhost' that is used will
1✔
648
     * actually be 'localhost.localdomain', depending on the contents of
649
     * the host's /etc/hosts file.
650
     */
651
    if (strcmp(pr_netaddr_get_dnsstr(addr), "localhost.localdomain") == 0) {
652
      have_localdomain = TRUE;
×
653
    }
×
654
  }
655

656
  res = pr_netacl_match(NULL, addr);
657
  ck_assert_msg(res == -2, "Failed to handle NULL ACL");
1✔
658
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
659

1✔
660
  res = pr_netacl_match(acl, addr);
661
  ck_assert_msg(res == 1, "Failed to positively match ACL to addr: %s",
1✔
662
    strerror(errno));
1✔
663

664
  acl_str = "none";
665
  acl = pr_netacl_create(p, acl_str);
1✔
666
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
667
    strerror(errno));
1✔
668

669
  res = pr_netacl_match(acl, addr);
670
  ck_assert_msg(res == -1, "Failed to negatively match ACL to addr: %s",
1✔
671
    strerror(errno));
1✔
672

673
  acl_str = pstrdup(p, "127.0.0.1");
674
  acl = pr_netacl_create(p, acl_str);
1✔
675
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
676
    strerror(errno));
1✔
677

678
  res = pr_netacl_match(acl, addr);
679
  ck_assert_msg(res == 1, "Failed to positively match ACL to addr: %s",
1✔
680
    strerror(errno));
1✔
681

682
  acl_str = pstrdup(p, "!127.0.0.1");
683
  acl = pr_netacl_create(p, acl_str);
1✔
684
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
685
    strerror(errno));
1✔
686

687
  res = pr_netacl_match(acl, addr);
688
  ck_assert_msg(res == -1, "Failed to negatively match ACL to addr: %s",
1✔
689
    strerror(errno));
1✔
690

691
  acl_str = pstrdup(p, "192.168.0.1");
692
  acl = pr_netacl_create(p, acl_str);
1✔
693
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
694
    strerror(errno));
1✔
695

696
  res = pr_netacl_match(acl, addr);
697
  ck_assert_msg(res == 0, "Failed to match ACL to addr: %s", strerror(errno));
1✔
698

1✔
699
  acl_str = pstrdup(p, "!192.168.0.1");
700
  acl = pr_netacl_create(p, acl_str);
1✔
701
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
702
    strerror(errno));
1✔
703

704
  res = pr_netacl_match(acl, addr);
705
  ck_assert_msg(res == 1, "Failed to positively match ACL to addr: %s",
1✔
706
    strerror(errno));
1✔
707

708
  acl_str = pstrdup(p, "127.0.0.0/24");
709
  acl = pr_netacl_create(p, acl_str);
1✔
710
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
711
    strerror(errno));
1✔
712

713
  res = pr_netacl_match(acl, addr);
714
  ck_assert_msg(res == 1, "Failed to positively match ACL to addr: %s",
1✔
715
    strerror(errno));
1✔
716

717
  acl_str = pstrdup(p, "!127.0.0.0/24");
718
  acl = pr_netacl_create(p, acl_str);
1✔
719
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
720
    strerror(errno));
1✔
721

722
  res = pr_netacl_match(acl, addr);
723
  ck_assert_msg(res == -1, "Failed to negatively match ACL to addr: %s",
1✔
724
    strerror(errno));
1✔
725

726
  acl_str = pstrdup(p, "!1.2.3.4/24");
727
  acl = pr_netacl_create(p, acl_str);
1✔
728
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
729
    strerror(errno));
1✔
730

731
  res = pr_netacl_match(acl, addr);
732
  ck_assert_msg(res == 1, "Failed to positively match ACL to addr: %s",
1✔
733
    strerror(errno));
1✔
734

735
  acl_str = pstrdup(p, "127.0.0.");
736
  acl = pr_netacl_create(p, acl_str);
1✔
737
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
738
    strerror(errno));
1✔
739

740
  res = pr_netacl_match(acl, addr);
741
  ck_assert_msg(res == 1, "Failed to positively match ACL to addr: %s",
1✔
742
    strerror(errno));
1✔
743

744
  acl_str = pstrdup(p, "!127.0.0.");
745
  acl = pr_netacl_create(p, acl_str);
1✔
746
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
747
    strerror(errno));
1✔
748

749
  res = pr_netacl_match(acl, addr);
750
  ck_assert_msg(res == -1, "Failed to negatively match ACL to addr: %s",
1✔
751
    strerror(errno));
1✔
752

753
  acl_str = pstrdup(p, "!1.2.3.");
754
  acl = pr_netacl_create(p, acl_str);
1✔
755
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
756
    strerror(errno));
1✔
757

758
  res = pr_netacl_match(acl, addr);
759
  ck_assert_msg(res == 1, "Failed to positively match ACL to addr: %s",
1✔
760
    strerror(errno));
1✔
761

762
  if (have_localdomain == TRUE) {
763
    acl_str = pstrdup(p, "localhost.localdomain");
1✔
764

×
765
  } else {
766
    acl_str = pstrdup(p, "localhost");
767
  }
1✔
768

769
  acl = pr_netacl_create(p, acl_str);
770
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
771
    strerror(errno));
1✔
772

773
  res = pr_netacl_match(acl, addr);
774
  if (getenv("CI") == NULL) {
1✔
775
    ck_assert_msg(res == 1, "Failed to positively match ACL to addr: %s",
1✔
776
      strerror(errno));
×
777
  }
778

779
  if (have_localdomain == TRUE) {
780
    acl_str = pstrdup(p, "!localhost.localdomain");
1✔
781

×
782
  } else {
783
    acl_str = pstrdup(p, "!localhost");
784
  }
1✔
785

786
  acl = pr_netacl_create(p, acl_str);
787
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
788
    strerror(errno));
1✔
789

790
  res = pr_netacl_match(acl, addr);
791
  if (getenv("CI") == NULL) {
1✔
792
    ck_assert_msg(res == -1, "Failed to negatively match ACL to addr: %s",
1✔
793
      strerror(errno));
×
794
  }
795

796
  acl_str = "!www.google.com";
797
  acl = pr_netacl_create(p, acl_str);
1✔
798
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
799
    strerror(errno));
1✔
800

801
  res = pr_netacl_match(acl, addr);
802
  ck_assert_msg(res == 1, "Failed to positively match ACL to addr: %s",
1✔
803
    strerror(errno));
1✔
804

805
  if (have_localdomain == TRUE) {
806
    acl_str = pstrdup(p, "loc*st.loc*in");
1✔
807

×
808
  } else {
809
    acl_str = pstrdup(p, "loc*st");
810
  }
1✔
811

812
  acl = pr_netacl_create(p, acl_str);
813
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
814
    strerror(errno));
1✔
815

816
  res = pr_netacl_match(acl, addr);
817
  if (getenv("CI") == NULL) {
1✔
818
    ck_assert_msg(res == 1, "Failed to positively match ACL to addr: %s",
1✔
819
      strerror(errno));
×
820
  }
821

822
  if (have_localdomain == TRUE) {
823
    acl_str = pstrdup(p, "!loc*st.loc*in");
1✔
824

×
825
  } else {
826
    acl_str = pstrdup(p, "!loc*st");
827
  }
1✔
828

829
  acl = pr_netacl_create(p, acl_str);
830
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
831
    strerror(errno));
1✔
832

833
  res = pr_netacl_match(acl, addr);
834
  if (getenv("CI") == NULL) {
1✔
835
    ck_assert_msg(res == -1, "Failed to negatively match ACL to addr: %s",
1✔
836
      strerror(errno));
×
837
  }
838

839
  acl_str = "!www.g*g.com";
840
  acl = pr_netacl_create(p, acl_str);
1✔
841
  ck_assert_msg(acl != NULL, "Failed to handle ACL string '%s': %s", acl_str,
1✔
842
    strerror(errno));
1✔
843

844
  res = pr_netacl_match(acl, addr);
845
  ck_assert_msg(res == 1, "Failed to positively match ACL to addr: %s",
1✔
846
    strerror(errno));
1✔
847

848
  reverse_dns = ServerUseReverseDNS;
849
  ServerUseReverseDNS = FALSE;
1✔
850

1✔
851
  res = pr_netacl_match(acl, addr);
852
  ck_assert_msg(res == 0, "Matched DNS glob ACL to addr unexpectedly");
1✔
853

1✔
854
  ServerUseReverseDNS = reverse_dns;
855
}
1✔
856
END_TEST
1✔
857

858
START_TEST (netacl_get_negated_test) {
859
  pr_netacl_t *acl;
1✔
860
  int res;
1✔
861

1✔
862
  res = pr_netacl_get_negated(NULL);
863
  ck_assert_msg(res == -1, "Failed to handle NULL argument");
1✔
864
  ck_assert_msg(errno == EINVAL, "Failed to set errno to EINVAL");
1✔
865

1✔
866
  acl = pr_netacl_create(p, "127.0.0.1");
867
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
868

1✔
869
  res = pr_netacl_get_negated(acl);
870
  ck_assert_msg(res == 0, "Expected %d, got %d", 0, res);
1✔
871

1✔
872
  acl = pr_netacl_create(p, "!127.0.0.1");
873
  ck_assert_msg(acl != NULL, "Failed to create ACL: %s", strerror(errno));
1✔
874

1✔
875
  res = pr_netacl_get_negated(acl);
876
  ck_assert_msg(res == 1, "Expected %d, got %d", 1, res);
1✔
877
}
1✔
878
END_TEST
1✔
879

880
Suite *tests_get_netacl_suite(void) {
881
  Suite *suite;
890✔
882
  TCase *testcase;
890✔
883

890✔
884
  suite = suite_create("netacl");
885

890✔
886
  testcase = tcase_create("base");
887
  tcase_add_checked_fixture(testcase, set_up, tear_down);
890✔
888

890✔
889
  tcase_add_test(testcase, netacl_create_test);
890
  tcase_add_test(testcase, netacl_get_str_test);
890✔
891
  tcase_add_test(testcase, netacl_get_str2_test);
890✔
892
  tcase_add_test(testcase, netacl_dup_test);
890✔
893
  tcase_add_test(testcase, netacl_match_test);
890✔
894
  tcase_add_test(testcase, netacl_get_negated_test);
890✔
895

890✔
896
  /* Some of the network-related tests may take a little longer. */
897
  tcase_set_timeout(testcase, 30);
898

890✔
899
  suite_add_tcase(suite, testcase);
900
  return suite;
890✔
901
}
890✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc