mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
io: Fix destructive nature of tst-fchmod-errors
We must not change the permissions of /dev/null if running as root. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
parent
424d97be50
commit
3844cdc330
@ -18,8 +18,10 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <support/check.h>
|
||||
#include <support/xunistd.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int
|
||||
do_test (void)
|
||||
@ -27,9 +29,14 @@ do_test (void)
|
||||
{
|
||||
/* Permissions on /dev/null (the opened descriptor) cannot be changed. */
|
||||
int fd = xopen ("/dev/null", O_RDWR, 0);
|
||||
if (getuid () == 0)
|
||||
puts ("info: /dev/null fchmod test skipped because of root privileges");
|
||||
else
|
||||
{
|
||||
errno = 0;
|
||||
TEST_COMPARE (fchmod (fd, 0), -1);
|
||||
TEST_COMPARE (errno, EPERM);
|
||||
}
|
||||
xclose (fd);
|
||||
|
||||
/* Now testing an invalid file descriptor. */
|
||||
|
Loading…
Reference in New Issue
Block a user