unix_dgram.c (383d51d592369f92b836f77abf8f118ab4e44ff1) | unix_dgram.c (bfd03046d18776ea70785ca1ef36dfc60822de3b) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2022 Gleb Smirnoff <glebius@FreeBSD.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 11 unchanged lines hidden (view full) --- 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 | 1/*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2022 Gleb Smirnoff <glebius@FreeBSD.org> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 11 unchanged lines hidden (view full) --- 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 |
28#include <sys/time.h> | |
29#include <sys/event.h> 30#include <sys/ioctl.h> 31#include <sys/select.h> 32#include <sys/socket.h> | 28#include <sys/event.h> 29#include <sys/ioctl.h> 30#include <sys/select.h> 31#include <sys/socket.h> |
32#include <sys/stat.h> |
|
33#include <sys/sysctl.h> | 33#include <sys/sysctl.h> |
34#include <sys/time.h> |
|
34#include <sys/un.h> | 35#include <sys/un.h> |
36 |
|
35#include <aio.h> 36#include <errno.h> 37#include <fcntl.h> 38#include <signal.h> 39#include <stdio.h> 40#include <stdlib.h> 41 42#include <atf-c.h> --- 343 unchanged lines hidden (view full) --- 386 387 len = sizeof(sun); 388 ATF_REQUIRE(getpeername(sd, (struct sockaddr *)&sun, &len) == 0); 389 ATF_REQUIRE(strcmp(sun.sun_path, name) == 0); 390 391 ATF_REQUIRE(close(sd) == 0); 392} 393 | 37#include <aio.h> 38#include <errno.h> 39#include <fcntl.h> 40#include <signal.h> 41#include <stdio.h> 42#include <stdlib.h> 43 44#include <atf-c.h> --- 343 unchanged lines hidden (view full) --- 388 389 len = sizeof(sun); 390 ATF_REQUIRE(getpeername(sd, (struct sockaddr *)&sun, &len) == 0); 391 ATF_REQUIRE(strcmp(sun.sun_path, name) == 0); 392 393 ATF_REQUIRE(close(sd) == 0); 394} 395 |
396ATF_TC_WITHOUT_HEAD(fchmod); 397ATF_TC_BODY(fchmod, tc) 398{ 399 struct stat sb; 400 struct sockaddr_un sun; 401 int error, sd; 402 403 memset(&sun, 0, sizeof(sun)); 404 sun.sun_len = sizeof(sun); 405 sun.sun_family = AF_UNIX; 406 strlcpy(sun.sun_path, "sock", sizeof(sun.sun_path)); 407 408 sd = socket(PF_UNIX, SOCK_DGRAM, 0); 409 ATF_REQUIRE(sd != -1); 410 411 error = fchmod(sd, 0600 | S_ISUID); 412 ATF_REQUIRE_ERRNO(EINVAL, error == -1); 413 414 umask(0022); 415 error = fchmod(sd, 0766); 416 ATF_REQUIRE(error == 0); 417 418 error = bind(sd, (struct sockaddr *)&sun, sizeof(sun)); 419 ATF_REQUIRE(error == 0); 420 421 error = stat(sun.sun_path, &sb); 422 ATF_REQUIRE(error == 0); 423 ATF_REQUIRE_MSG((sb.st_mode & 0777) == 0744, 424 "sb.st_mode = %o", sb.st_mode); 425 426 error = fchmod(sd, 0666); 427 ATF_REQUIRE_ERRNO(EINVAL, error == -1); 428 429 ATF_REQUIRE(close(sd) == 0); 430} 431 |
|
394ATF_TP_ADD_TCS(tp) 395{ 396 ATF_TP_ADD_TC(tp, basic); 397 ATF_TP_ADD_TC(tp, one2many); 398 ATF_TP_ADD_TC(tp, event); 399 ATF_TP_ADD_TC(tp, selfgetpeername); | 432ATF_TP_ADD_TCS(tp) 433{ 434 ATF_TP_ADD_TC(tp, basic); 435 ATF_TP_ADD_TC(tp, one2many); 436 ATF_TP_ADD_TC(tp, event); 437 ATF_TP_ADD_TC(tp, selfgetpeername); |
438 ATF_TP_ADD_TC(tp, fchmod); |
|
400 401 return (atf_no_error()); 402} | 439 440 return (atf_no_error()); 441} |