mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
dtfile: Fix up CopyCheckDeletePermission() and CheckDeletePermission
Remove calls to bogus utility functions in cases where the user is root and the filesystem in question is an NFS filesystem. For now, __linux___ and CSRG_BASED machines will use statfs to determine whether to test delete-ability. For other systems, just do the create/delete test always if the user is root.
This commit is contained in:
parent
9cb1f309f2
commit
a29bd8937a
2 changed files with 14 additions and 54 deletions
|
@ -46,7 +46,6 @@
|
|||
* EraseDir
|
||||
* EraseObject
|
||||
* FileFromTrash
|
||||
* FileSysType
|
||||
* InitializeTrash
|
||||
* MatchesSacredDirectory
|
||||
* MessageToFileList
|
||||
|
@ -108,6 +107,7 @@
|
|||
#else
|
||||
#if defined(__linux__)
|
||||
#include <sys/vfs.h>
|
||||
#include <linux/magic.h>
|
||||
#else
|
||||
#include <ustat.h>
|
||||
#endif
|
||||
|
@ -387,7 +387,6 @@ static void EmptyTrash(
|
|||
Tt_message msg) ;
|
||||
static int CheckDeletePermissionRecur(
|
||||
char *dir);
|
||||
static int FileSysType(int dev);
|
||||
static void RestoreVerifyOk(
|
||||
Widget w,
|
||||
XtPointer client_data,
|
||||
|
@ -4144,16 +4143,16 @@ CheckDeletePermission(
|
|||
char *parentdir,
|
||||
char *destinationPath)
|
||||
{
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__)
|
||||
struct statfs statbuf;
|
||||
#elif defined(__NetBSD__)
|
||||
struct statvfs statbuf;
|
||||
#else
|
||||
struct stat statbuf;
|
||||
#endif
|
||||
char fname[1024];
|
||||
char fname[PATH_MAX];
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__)
|
||||
if (statfs(parentdir,&statbuf) < 0) /* does not exist */
|
||||
#elif defined(__NetBSD__)
|
||||
if (statvfs(parentdir,&statbuf) < 0) /* does not exist */
|
||||
|
@ -4168,8 +4167,10 @@ CheckDeletePermission(
|
|||
/* if NFS, need to check if server trusts root */
|
||||
#if defined(CSRG_BASED)
|
||||
if (!strcmp(statbuf.f_fstypename, "nfs")) /* Root user and nfs */
|
||||
#elif defined(__linux__)
|
||||
if (statbuf.f_type == NFS_SUPER_MAGIC)
|
||||
#else
|
||||
if (FileSysType(statbuf.st_dev) < 0) /* Root user and nfs */
|
||||
/* nothing - always check if root */
|
||||
#endif
|
||||
{
|
||||
int fd = -1;
|
||||
|
@ -4200,7 +4201,7 @@ CheckDeletePermission(
|
|||
return -1;
|
||||
|
||||
/* copy destinationPath to tmp buffer */
|
||||
strcpy(fname, destinationPath);
|
||||
snprintf(fname, PATH_MAX, "%s", destinationPath);
|
||||
|
||||
return CheckDeletePermissionRecur(fname);
|
||||
}
|
||||
|
@ -4268,28 +4269,6 @@ CheckDeletePermissionRecur(
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if !defined(CSRG_BASED) && !defined(__linux__)
|
||||
static int
|
||||
FileSysType(
|
||||
int dev)
|
||||
{
|
||||
struct ustat u1;
|
||||
if(ustat(dev,&u1) < 0)
|
||||
return -2;
|
||||
return u1.f_tinode;
|
||||
}
|
||||
#else
|
||||
static int
|
||||
FileSysType(
|
||||
int dev)
|
||||
{
|
||||
struct statfs u1;
|
||||
if(statfs(dev,&u1) < 0)
|
||||
return -2;
|
||||
return u1.f_ffree;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
RestoreObject(
|
||||
Widget w,
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
#endif
|
||||
#if defined(__linux__)
|
||||
#include <sys/vfs.h>
|
||||
#include <linux/magic.h>
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
|
||||
|
@ -361,28 +362,6 @@ ImageInitialize( Display *display )
|
|||
return ;
|
||||
} /* end ImageInitialize */
|
||||
|
||||
#if !defined(CSRG_BASED) && !defined(__linux__)
|
||||
static int
|
||||
CopyFileSysType(
|
||||
int dev)
|
||||
{
|
||||
struct ustat u1;
|
||||
if(ustat(dev,&u1) < 0)
|
||||
return -2;
|
||||
return u1.f_tinode;
|
||||
}
|
||||
#else
|
||||
static int
|
||||
CopyFileSysType(
|
||||
int dev)
|
||||
{
|
||||
struct statfs u1;
|
||||
if(statfs(dev,&u1) < 0)
|
||||
return -2;
|
||||
return u1.f_ffree;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
CopyCheckDeletePermissionRecur(
|
||||
char *destinationPath)
|
||||
|
@ -453,7 +432,7 @@ CopyCheckDeletePermission(
|
|||
char *parentdir,
|
||||
char *destinationPath)
|
||||
{
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__)
|
||||
struct statfs statbuf;
|
||||
#elif defined(__NetBSD__)
|
||||
struct statvfs statbuf;
|
||||
|
@ -462,7 +441,7 @@ CopyCheckDeletePermission(
|
|||
#endif
|
||||
char fname[PATH_MAX];
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__)
|
||||
if (statfs(parentdir,&statbuf) < 0) /* does not exist */
|
||||
#elif defined(__NetBSD__)
|
||||
if (statvfs(parentdir,&statbuf) < 0) /* does not exist */
|
||||
|
@ -477,8 +456,10 @@ CopyCheckDeletePermission(
|
|||
/* if NFS, need to check if server trusts root */
|
||||
#if defined(CSRG_BASED)
|
||||
if (!strcmp(statbuf.f_fstypename, "nfs")) /* Root user and nfs */
|
||||
#elif defined(__linux__)
|
||||
if (statbuf.f_type == NFS_SUPER_MAGIC)
|
||||
#else
|
||||
if (CopyFileSysType(statbuf.st_dev) < 0) /* Root user and nfs */
|
||||
/* nothing - always check if root */
|
||||
#endif
|
||||
{
|
||||
char *tmpfile;
|
||||
|
|
Loading…
Reference in a new issue