| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2014 Google, Inc. |
|---|
| 3 | | - * |
|---|
| 4 | | - * Licensed under the terms of the GNU GPL License version 2 |
|---|
| 5 | 4 | * |
|---|
| 6 | 5 | * Selftests for execveat(2). |
|---|
| 7 | 6 | */ |
|---|
| 8 | 7 | |
|---|
| 8 | +#ifndef _GNU_SOURCE |
|---|
| 9 | 9 | #define _GNU_SOURCE /* to get O_PATH, AT_EMPTY_PATH */ |
|---|
| 10 | +#endif |
|---|
| 10 | 11 | #include <sys/sendfile.h> |
|---|
| 11 | 12 | #include <sys/stat.h> |
|---|
| 12 | 13 | #include <sys/syscall.h> |
|---|
| .. | .. |
|---|
| 312 | 313 | fail += check_execveat_fail(AT_FDCWD, fullname_symlink, |
|---|
| 313 | 314 | AT_SYMLINK_NOFOLLOW, ELOOP); |
|---|
| 314 | 315 | |
|---|
| 316 | + /* Non-regular file failure */ |
|---|
| 317 | + fail += check_execveat_fail(dot_dfd, "pipe", 0, EACCES); |
|---|
| 318 | + unlink("pipe"); |
|---|
| 319 | + |
|---|
| 315 | 320 | /* Shell script wrapping executable file: */ |
|---|
| 316 | 321 | /* dfd + path */ |
|---|
| 317 | 322 | fail += check_execveat(subdir_dfd, "../script", 0); |
|---|
| .. | .. |
|---|
| 385 | 390 | fd = open("subdir.ephemeral/script", O_RDWR|O_CREAT|O_TRUNC, 0755); |
|---|
| 386 | 391 | write(fd, script, strlen(script)); |
|---|
| 387 | 392 | close(fd); |
|---|
| 393 | + |
|---|
| 394 | + mkfifo("pipe", 0755); |
|---|
| 388 | 395 | } |
|---|
| 389 | 396 | |
|---|
| 390 | 397 | int main(int argc, char **argv) |
|---|