On Saturday 27 December 2008 11:46:03 Mitar wrote: > Hi! > > I discovered that open syscall with only O_APPEND fails with > "permission denied" if an user does not have rights to write to a file > (what is normal) even if it is root (what is a surprise). For example, > if I have a file owned by www:www and with 644 permissions root cannot > do open("testfile", O_APPEND) call. If I change ownership of I change > permission to for example 666, call succeedes. > > This works on Linux (Debian). So this is a feature? Or a bug? > > (I discovered that because htpasswd failed to add new > username/password pair (ran as root) to a file owner by www.) > > Checked on FreeBSD 7.0-STABLE.
Can't reproduce: $ ls -al test.txt -rw-r--r-- 1 www www 33 Dec 27 15:12 test.txt $ sudo ./open test.txt opened as fd 3 $ cat test.txt this file cannot be appended to $ cat -n open.c 1 #include <sys/types.h> 2 #include <sys/uio.h> 3 #include <unistd.h> 4 #include <stdio.h> 5 #include <fcntl.h> 6 #include <err.h> 7 #include <sysexits.h> 8 9 int main(void) 10 { 11 const char fname[] = "test.txt"; 12 const char txt[] = "cannot be appended to\n"; 13 int fd; 14 15 fd = open(fname, O_WRONLY|O_APPEND); 16 if( fd < 0 ) 17 err(EX_NOINPUT, "Failed to open %s", fname); 18 19 printf("%s opened as fd %i\n", fname, fd); 20 if( write(fd, txt, sizeof(txt)) < 0 ) 21 err(EX_DATAERR, "write()"); 22 close(fd); 23 return EX_OK; 24 } -- Mel Problem with today's modular software: they start with the modules and never get to the software part. _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"