2a8730b21c
* file.c (move_dir_dir): Give an error when an attempt is made to move an empty directory into itself. 1999-06-14 Wayne Roberts <wroberts1@cx983858-b.orng1.occa.home.com> * vfs/smbfs.c: New file. Implements the Samba-based file system. * vfs/vfs.h: Declare vfs_smbfs_ops, vfs_file_is_smb. * vfs/vfs.c (vfs_file_is_smb): implemented. (vfs_init) register smbfs. * vfs/samba: Incorporate SAMBA source code required for smbfs 1999-05-27 Miguel de Icaza <miguel@nuclecu.unam.mx> * Make.common.in (confdir): Define confdir as sysconfdir. This should fix the problem we had with FSSTND distributions.
68 строки
1.1 KiB
C
68 строки
1.1 KiB
C
/* test whether ftruncte() can truncate a file as non-root */
|
|
|
|
#if defined(HAVE_UNISTD_H)
|
|
#include <unistd.h>
|
|
#endif
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <stdio.h>
|
|
#include <fcntl.h>
|
|
#include <errno.h>
|
|
#include <sys/wait.h>
|
|
|
|
#define DATA "conftest.truncroot"
|
|
|
|
static int sys_waitpid(pid_t pid,int *status,int options)
|
|
{
|
|
#ifdef HAVE_WAITPID
|
|
return waitpid(pid,status,options);
|
|
#else /* USE_WAITPID */
|
|
return wait4(pid, status, options, NULL);
|
|
#endif /* USE_WAITPID */
|
|
}
|
|
|
|
main()
|
|
{
|
|
int fd;
|
|
char buf[1024];
|
|
pid_t pid;
|
|
|
|
if (getuid() != 0) {
|
|
fprintf(stderr,"ERROR: This test must be run as root - assuming \
|
|
ftruncate doesn't need root.\n");
|
|
exit(1);
|
|
}
|
|
|
|
fd = open(DATA,O_RDWR|O_CREAT|O_TRUNC,0666);
|
|
if(!fd)
|
|
exit(1);
|
|
|
|
if(write(fd, buf, 1024) != 1024)
|
|
exit(1);
|
|
|
|
if((pid = fork()) < 0)
|
|
exit(1);
|
|
|
|
if(pid) {
|
|
/* Parent. */
|
|
int status = 1;
|
|
if(sys_waitpid(pid, &status, 0) != pid) {
|
|
unlink(DATA);
|
|
exit(1);
|
|
}
|
|
unlink(DATA);
|
|
exit(WEXITSTATUS(status));
|
|
}
|
|
|
|
/* Child. */
|
|
if(setuid(500) < 0)
|
|
exit(1);
|
|
|
|
if(ftruncate(fd, 0) < 0) {
|
|
if(errno == EPERM || errno == EACCES)
|
|
exit(0);
|
|
}
|
|
exit(1);
|
|
}
|