summaryrefslogtreecommitdiff
path: root/io/tst-fchownat.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2006-01-30 09:30:09 +0000
committerJakub Jelinek <jakub@redhat.com>2006-01-30 09:30:09 +0000
commit3e543bc56346540cbf73fd48d0172fc6a588efd5 (patch)
treeb2c3502b6596d238ac861cc82cafdc6f8b84e143 /io/tst-fchownat.c
parent06f313e361a523605ba6d4c9cdc67a7353cd367c (diff)
Updated to fedora-glibc-20060130T0922
Diffstat (limited to 'io/tst-fchownat.c')
-rw-r--r--io/tst-fchownat.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/io/tst-fchownat.c b/io/tst-fchownat.c
index 0cbf78b2b0..fd32ac9e6b 100644
--- a/io/tst-fchownat.c
+++ b/io/tst-fchownat.c
@@ -112,6 +112,20 @@ do_test (void)
return 1;
}
+ /* Before closing the file, try using this file descriptor to open
+ another file. This must fail. */
+ if (fchownat (fd, "some-file", 1, 1, 0) != -1)
+ {
+ puts ("fchownat using descriptor for normal file worked");
+ return 1;
+ }
+ if (errno != ENOTDIR)
+ {
+ puts ("\
+error for fchownat using descriptor for normal file not ENOTDIR ");
+ return 1;
+ }
+
close (fd);
if (fchownat (dir_fd, "some-file", st1.st_uid + 1, st1.st_gid + 1, 0) != 0)
@@ -139,7 +153,38 @@ do_test (void)
return 1;
}
+ /* Create a file descriptor which is closed again right away. */
+ int dir_fd2 = dup (dir_fd);
+ if (dir_fd2 == -1)
+ {
+ puts ("dup failed");
+ return 1;
+ }
+ close (dir_fd2);
+
+ if (fchownat (dir_fd2, "some-file", 1, 1, 0) != -1)
+ {
+ puts ("fchownat using closed descriptor worked");
+ return 1;
+ }
+ if (errno != EBADF)
+ {
+ puts ("error for fchownat using closed descriptor not EBADF ");
+ return 1;
+ }
+
close (dir_fd);
+ if (fchownat (-1, "some-file", 1, 1, 0) != -1)
+ {
+ puts ("fchownat using invalid descriptor worked");
+ return 1;
+ }
+ if (errno != EBADF)
+ {
+ puts ("error for fchownat using invalid descriptor not EBADF ");
+ return 1;
+ }
+
return 0;
}