|
From: Jiri J. <jja...@re...> - 2014-09-23 09:45:49
|
Signed-off-by: Jiri Jaburek <jja...@re...>
---
audit-test/utils/bin/do_fchmodat.c | 12 ++++++++----
audit-test/utils/bin/do_fchownat.c | 12 ++++++++----
audit-test/utils/bin/do_linkat.c | 24 ++++++++++++++++++------
audit-test/utils/bin/do_mkdirat.c | 12 +++++++++---
audit-test/utils/bin/do_mknodat.c | 13 ++++++++++---
audit-test/utils/bin/do_openat.c | 13 +++++++++----
audit-test/utils/bin/do_readlinkat.c | 12 +++++++++---
audit-test/utils/bin/do_renameat.c | 12 +++++++++---
audit-test/utils/bin/do_symlinkat.c | 13 ++++++++++---
audit-test/utils/bin/do_unlinkat.c | 12 +++++++++---
audit-test/utils/bin/do_utimensat.c | 12 ++++++++----
11 files changed, 107 insertions(+), 40 deletions(-)
diff --git a/audit-test/utils/bin/do_fchmodat.c b/audit-test/utils/bin/do_fchmodat.c
index ce49746..006cf50 100644
--- a/audit-test/utils/bin/do_fchmodat.c
+++ b/audit-test/utils/bin/do_fchmodat.c
@@ -26,10 +26,14 @@ int main(int argc, char **argv)
return TEST_ERROR;
}
- dir_fd = open(argv[1], O_DIRECTORY);
- if (dir_fd == -1) {
- perror("do_fchmodat: open dir fd");
- return TEST_ERROR;
+ if (!strcmp(argv[1], "AT_FDCWD")) {
+ dir_fd = AT_FDCWD;
+ } else {
+ dir_fd = open(argv[1], O_DIRECTORY);
+ if (dir_fd == -1) {
+ perror("do_fchmodat: open dir_fd");
+ return TEST_ERROR;
+ }
}
errno = 0;
diff --git a/audit-test/utils/bin/do_fchownat.c b/audit-test/utils/bin/do_fchownat.c
index 2d2baf5..5eb16ae 100644
--- a/audit-test/utils/bin/do_fchownat.c
+++ b/audit-test/utils/bin/do_fchownat.c
@@ -28,10 +28,14 @@ int main(int argc, char **argv)
return TEST_ERROR;
}
- dir_fd = open(argv[1], O_DIRECTORY);
- if (dir_fd == -1) {
- perror("do_fchownat: open dir fd");
- return TEST_ERROR;
+ if (!strcmp(argv[1], "AT_FDCWD")) {
+ dir_fd = AT_FDCWD;
+ } else {
+ dir_fd = open(argv[1], O_DIRECTORY);
+ if (dir_fd == -1) {
+ perror("do_fchownat: open dir_fd");
+ return TEST_ERROR;
+ }
}
pw = getpwnam(argv[3]);
diff --git a/audit-test/utils/bin/do_linkat.c b/audit-test/utils/bin/do_linkat.c
index 0f528f4..41535b8 100644
--- a/audit-test/utils/bin/do_linkat.c
+++ b/audit-test/utils/bin/do_linkat.c
@@ -26,15 +26,27 @@ int main(int argc, char **argv)
}
/* directory */
- dir_fd = open(argv[1], O_DIRECTORY);
- if (dir_fd < 0)
- return TEST_ERROR;
+ if (!strcmp(argv[1], "AT_FDCWD")) {
+ dir_fd = AT_FDCWD;
+ } else {
+ dir_fd = open(argv[1], O_DIRECTORY);
+ if (dir_fd == -1) {
+ perror("do_linkat: open dir_fd");
+ return TEST_ERROR;
+ }
+ }
/* new_directory */
if (argc > 4) {
- newdir_fd = open(argv[4], O_DIRECTORY);
- if (newdir_fd < 0)
- return TEST_ERROR;
+ if (!strcmp(argv[4], "AT_FDCWD")) {
+ newdir_fd = AT_FDCWD;
+ } else {
+ newdir_fd = open(argv[4], O_DIRECTORY);
+ if (newdir_fd == -1) {
+ perror("do_linkat: open newdir_fd");
+ return TEST_ERROR;
+ }
+ }
} else {
newdir_fd = dir_fd;
}
diff --git a/audit-test/utils/bin/do_mkdirat.c b/audit-test/utils/bin/do_mkdirat.c
index 5a6e54f..a3fe48f 100644
--- a/audit-test/utils/bin/do_mkdirat.c
+++ b/audit-test/utils/bin/do_mkdirat.c
@@ -35,9 +35,15 @@ int main(int argc, char **argv)
}
#endif
- dir_fd = open(argv[1], O_DIRECTORY);
- if (dir_fd < 0)
- return TEST_ERROR;
+ if (!strcmp(argv[1], "AT_FDCWD")) {
+ dir_fd = AT_FDCWD;
+ } else {
+ dir_fd = open(argv[1], O_DIRECTORY);
+ if (dir_fd == -1) {
+ perror("do_mkdirat: open dir_fd");
+ return TEST_ERROR;
+ }
+ }
errno = 0;
exitval = mkdirat(dir_fd, argv[2], S_IRWXU);
diff --git a/audit-test/utils/bin/do_mknodat.c b/audit-test/utils/bin/do_mknodat.c
index 7e9ea2c..d6f5f47 100644
--- a/audit-test/utils/bin/do_mknodat.c
+++ b/audit-test/utils/bin/do_mknodat.c
@@ -28,9 +28,16 @@ int main(int argc, char **argv)
return TEST_ERROR;
}
- dir_fd = open(argv[1], O_DIRECTORY);
- if (dir_fd < 0)
- return TEST_ERROR;
+ if (!strcmp(argv[1], "AT_FDCWD")) {
+ dir_fd = AT_FDCWD;
+ } else {
+ dir_fd = open(argv[1], O_DIRECTORY);
+ if (dir_fd == -1) {
+ perror("do_mknodat: open dir_fd");
+ return TEST_ERROR;
+ }
+ }
+
#ifdef LSM_SELINUX
if (argc == 4 && setfscreatecon(argv[3]) < 0) {
perror("do_mknodat: setfscreatecon");
diff --git a/audit-test/utils/bin/do_openat.c b/audit-test/utils/bin/do_openat.c
index 6205406..9c30c5e 100644
--- a/audit-test/utils/bin/do_openat.c
+++ b/audit-test/utils/bin/do_openat.c
@@ -48,11 +48,16 @@ int main(int argc, char **argv)
return TEST_ERROR;
}
- dirfd = open(argv[1], O_DIRECTORY);
- if (dirfd == -1) {
- perror("do_openat: open dirfd");
- return TEST_ERROR;
+ if (!strcmp(argv[1], "AT_FDCWD")) {
+ dirfd = AT_FDCWD;
+ } else {
+ dirfd = open(argv[1], O_DIRECTORY);
+ if (dirfd == -1) {
+ perror("do_openat: open dirfd");
+ return TEST_ERROR;
+ }
}
+
#ifdef LSM_SELINUX
if (argc == 5 && setfscreatecon(argv[4]) < 0) {
perror("do_openat: setfscreatecon");
diff --git a/audit-test/utils/bin/do_readlinkat.c b/audit-test/utils/bin/do_readlinkat.c
index 121e651..bb4fa7d 100644
--- a/audit-test/utils/bin/do_readlinkat.c
+++ b/audit-test/utils/bin/do_readlinkat.c
@@ -26,9 +26,15 @@ int main(int argc, char **argv)
return TEST_ERROR;
}
- dir_fd = open(argv[1], O_DIRECTORY);
- if (dir_fd < 0)
- return TEST_ERROR;
+ if (!strcmp(argv[1], "AT_FDCWD")) {
+ dir_fd = AT_FDCWD;
+ } else {
+ dir_fd = open(argv[1], O_DIRECTORY);
+ if (dir_fd == -1) {
+ perror("do_readlinkat: open dir_fd");
+ return TEST_ERROR;
+ }
+ }
errno = 0;
exitval = readlinkat(dir_fd, argv[2], buf, PATH_MAX);
diff --git a/audit-test/utils/bin/do_renameat.c b/audit-test/utils/bin/do_renameat.c
index cbdec09..96f0545 100644
--- a/audit-test/utils/bin/do_renameat.c
+++ b/audit-test/utils/bin/do_renameat.c
@@ -26,9 +26,15 @@ int main(int argc, char **argv)
return TEST_ERROR;
}
- dir_fd = open(argv[1], O_DIRECTORY);
- if (dir_fd < 0)
- return TEST_ERROR;
+ if (!strcmp(argv[1], "AT_FDCWD")) {
+ dir_fd = AT_FDCWD;
+ } else {
+ dir_fd = open(argv[1], O_DIRECTORY);
+ if (dir_fd == -1) {
+ perror("do_renameat: open dir_fd");
+ return TEST_ERROR;
+ }
+ }
errno = 0;
exitval = renameat(dir_fd, argv[2], dir_fd, argv[3]);
diff --git a/audit-test/utils/bin/do_symlinkat.c b/audit-test/utils/bin/do_symlinkat.c
index 1829dcf..3edcb39 100644
--- a/audit-test/utils/bin/do_symlinkat.c
+++ b/audit-test/utils/bin/do_symlinkat.c
@@ -29,9 +29,16 @@ int main(int argc, char **argv)
return TEST_ERROR;
}
- dir_fd = open(argv[1], O_DIRECTORY);
- if (dir_fd < 0)
- return TEST_ERROR;
+ if (!strcmp(argv[1], "AT_FDCWD")) {
+ dir_fd = AT_FDCWD;
+ } else {
+ dir_fd = open(argv[1], O_DIRECTORY);
+ if (dir_fd == -1) {
+ perror("do_symlinkat: open dir_fd");
+ return TEST_ERROR;
+ }
+ }
+
#ifdef LSM_SELINUX
if (argc == 5 && setfscreatecon(argv[4]) < 0) {
perror("do_symlinkat: setfscreatecon");
diff --git a/audit-test/utils/bin/do_unlinkat.c b/audit-test/utils/bin/do_unlinkat.c
index 8694bd8..f72f4e0 100644
--- a/audit-test/utils/bin/do_unlinkat.c
+++ b/audit-test/utils/bin/do_unlinkat.c
@@ -25,9 +25,15 @@ int main(int argc, char **argv)
return TEST_ERROR;
}
- dir_fd = open(argv[1], O_DIRECTORY);
- if (dir_fd < 0)
- return TEST_ERROR;
+ if (!strcmp(argv[1], "AT_FDCWD")) {
+ dir_fd = AT_FDCWD;
+ } else {
+ dir_fd = open(argv[1], O_DIRECTORY);
+ if (dir_fd == -1) {
+ perror("do_unlinkat: open dir_fd");
+ return TEST_ERROR;
+ }
+ }
errno = 0;
exitval = unlinkat(dir_fd, argv[2], 0);
diff --git a/audit-test/utils/bin/do_utimensat.c b/audit-test/utils/bin/do_utimensat.c
index bf1fe0b..46f3adb 100644
--- a/audit-test/utils/bin/do_utimensat.c
+++ b/audit-test/utils/bin/do_utimensat.c
@@ -28,10 +28,14 @@ int main(int argc, char **argv)
return TEST_ERROR;
}
- dirfd = open(argv[1], O_DIRECTORY);
- if (dirfd == -1) {
- perror("do_utimensat: open dirfd");
- return TEST_ERROR;
+ if (!strcmp(argv[1], "AT_FDCWD")) {
+ dirfd = AT_FDCWD;
+ } else {
+ dirfd = open(argv[1], O_DIRECTORY);
+ if (dirfd == -1) {
+ perror("do_utimensat: open dirfd");
+ return TEST_ERROR;
+ }
}
times[0].tv_sec = 0;
--
1.8.3.1
|