Fixes for dtfile. Still not completely functional, but I will work on
that.
>From 94ccfbe81d142582e120d3e3cb0c50ff1cb795bc Mon Sep 17 00:00:00 2001
From: Pascal Stumpf <pascal.stu...@cubes.de>
Date: Fri, 10 Aug 2012 15:09:04 +0200
Subject: [PATCH] Fixes for dtfile on OpenBSD, plus missing prototypes. Use
statfs() on BSD to find out if a file system is NFS.
---
cde/programs/dtfile/Desktop.c | 1 +
cde/programs/dtfile/FileManip.c | 5 +++--
cde/programs/dtfile/Filter.c | 1 +
cde/programs/dtfile/Find.c | 6 +++---
cde/programs/dtfile/Main.c | 2 +-
cde/programs/dtfile/MkDir.c | 6 +++---
cde/programs/dtfile/SharedProcs.c | 2 ++
cde/programs/dtfile/SharedProcs.h | 3 +++
cde/programs/dtfile/Trash.c | 19 +++++++++++++++++++
cde/programs/dtfile/dtcopy/sharedFuncs.c | 19 ++++++++++++++++++-
10 files changed, 54 insertions(+), 10 deletions(-)
diff --git a/cde/programs/dtfile/Desktop.c b/cde/programs/dtfile/Desktop.c
index 2619769..a090af2 100644
--- a/cde/programs/dtfile/Desktop.c
+++ b/cde/programs/dtfile/Desktop.c
@@ -105,6 +105,7 @@
#include <Xm/PushBG.h>
#include <Xm/RowColumn.h>
#include <Xm/CascadeBG.h>
+#include <Xm/LabelG.h>
#include <Xm/SeparatoG.h>
#include <Xm/VirtKeys.h>
diff --git a/cde/programs/dtfile/FileManip.c b/cde/programs/dtfile/FileManip.c
index dd785d7..91f631c 100644
--- a/cde/programs/dtfile/FileManip.c
+++ b/cde/programs/dtfile/FileManip.c
@@ -64,7 +64,7 @@
# define ROOTINO UFSROOTINO
# endif /* sco */
#else
-# if defined(linux)
+# if defined(linux) || defined(CSRG_BASED)
# define ROOTINO 2
# endif
# include <sys/param.h>
@@ -994,7 +994,8 @@ FileManip(
if (lstat (to, &s2) >= 0) /* <to> exists */
{
if ((stat (to, &s3) >= 0) &&
-#if defined(__hp_osf) || (__ultrix) || defined(__osf__) || defined(linux)
+#if defined(__hp_osf) || (__ultrix) || defined(__osf__) || defined(linux) || \
+ defined(CSRG_BASED)
(((s3.st_mode & S_IFMT) == S_IFDIR) /* if is a directory */
|| ((s3.st_mode & S_IFMT) == S_IFSOCK)) ) /* or a net special */
#else
diff --git a/cde/programs/dtfile/Filter.c b/cde/programs/dtfile/Filter.c
index 7ff8145..5ee2137 100644
--- a/cde/programs/dtfile/Filter.c
+++ b/cde/programs/dtfile/Filter.c
@@ -106,6 +106,7 @@
#include "Filter.h"
#include "Help.h"
+char **DtDtsDataTypeNames(void);
static char * FILE_FILTER = "FileFilter";
diff --git a/cde/programs/dtfile/Find.c b/cde/programs/dtfile/Find.c
index 61a6b34..094d285 100644
--- a/cde/programs/dtfile/Find.c
+++ b/cde/programs/dtfile/Find.c
@@ -1811,7 +1811,7 @@ ExecuteFind(
if (access_priv == -1 && geteuid() != root_user)
{
#else
-# if defined(__hp_osf) || defined(__ultrix) || defined(__osf__) ||
defined(linux)
+# if defined(__hp_osf) || defined(__ultrix) || defined(__osf__) ||
defined(linux) || defined(CSRG_BASED)
setreuid(geteuid(),-1);
if (access ((char *) path, R_OK) == -1)
{
@@ -1908,10 +1908,10 @@ ExecuteFind(
#ifdef __osf__
oldSig = signal(SIGCHLD, sigchld_handler);
#else
- oldSig = signal(SIGCLD, SIG_DFL);
+ oldSig = signal(SIGCHLD, SIG_DFL);
#endif /* __osf__ */
find_rec->popenId = findpopen(command, "r",&(find_rec->childpid));
- signal (SIGCLD, oldSig);
+ signal (SIGCHLD, oldSig);
if (find_rec->popenId == NULL)
{
diff --git a/cde/programs/dtfile/Main.c b/cde/programs/dtfile/Main.c
index cba5527..caf0fc3 100644
--- a/cde/programs/dtfile/Main.c
+++ b/cde/programs/dtfile/Main.c
@@ -1020,7 +1020,7 @@ main(
/* error handling follows, none for now */
;
#else
- (void) signal (SIGCLD, SIG_IGN);
+ (void) signal (SIGCHLD, SIG_IGN);
#endif /* __osf__ */
XtSetLanguageProc( NULL, NULL, NULL );
diff --git a/cde/programs/dtfile/MkDir.c b/cde/programs/dtfile/MkDir.c
index 972050e..434c756 100644
--- a/cde/programs/dtfile/MkDir.c
+++ b/cde/programs/dtfile/MkDir.c
@@ -107,13 +107,13 @@ RunFileCommand(
/* prepare to catch the command termination */
- oldSig = signal (SIGCLD, SIG_DFL);
+ oldSig = signal (SIGCHLD, SIG_DFL);
/* fork a process to run command */
if ((child = fork ()) < 0) /* fork failed */
{
- (void) signal (SIGCLD, oldSig);
+ (void) signal (SIGCHLD, oldSig);
return (-1);
}
@@ -126,7 +126,7 @@ RunFileCommand(
wait_return = wait (&exit_value);
} while (wait_return != child);
- (void) signal (SIGCLD, oldSig); /* child stopped or terminated */
+ (void) signal (SIGCHLD, oldSig); /* child stopped or terminated */
return (exit_value); /* if exit_value == 0 then success */
}
diff --git a/cde/programs/dtfile/SharedProcs.c
b/cde/programs/dtfile/SharedProcs.c
index 5da0294..333efe0 100644
--- a/cde/programs/dtfile/SharedProcs.c
+++ b/cde/programs/dtfile/SharedProcs.c
@@ -130,6 +130,8 @@ extern XmWidgetExtData _XmGetWidgetExtData(
#include "Main.h"
#include "SharedProcs.h"
+extern char *pathcollapse();
+
/* Defines */
#define RW_ALL S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH
diff --git a/cde/programs/dtfile/SharedProcs.h
b/cde/programs/dtfile/SharedProcs.h
index ec2eae8..fe5f624 100644
--- a/cde/programs/dtfile/SharedProcs.h
+++ b/cde/programs/dtfile/SharedProcs.h
@@ -50,6 +50,9 @@
/******** Public Function Declarations ********/
+extern String _DtStripSpaces(
+ String string) ;
+
extern char * _DtPName(
register char *name) ;
extern char * _DtFollowLink(
diff --git a/cde/programs/dtfile/Trash.c b/cde/programs/dtfile/Trash.c
index a3b85e2..2f7fa3d 100644
--- a/cde/programs/dtfile/Trash.c
+++ b/cde/programs/dtfile/Trash.c
@@ -101,7 +101,12 @@
#include <dirent.h>
#include <unistd.h>
#include <string.h>
+#if defined(CSRG_BASED)
+#include <sys/param.h>
+#include <sys/mount.h>
+#else
#include <ustat.h>
+#endif
#include <Xm/RowColumn.h>
#include <Xm/CascadeB.h>
@@ -4106,17 +4111,29 @@ CheckDeletePermission(
char *parentdir,
char *destinationPath)
{
+#if defined(CSRG_BASED)
+ struct statfs statbuf;
+#else
struct stat statbuf;
+#endif
char fname[1024];
+#if defined(CSRG_BASED)
+ if (statfs(parentdir,&statbuf) < 0) /* does not exist */
+#else
if (lstat(parentdir,&statbuf) < 0) /* does not exist */
+#endif
return -1;
/* check if we are root */
if (getuid() == 0)
{
/* if NFS, need to check if server trusts root */
+#if defined(CSRG_BASED)
+ if (!strcmp(statbuf.f_fstypename, "nfs")) /* Root user and nfs */
+#else
if (FileSysType(statbuf.st_dev) < 0) /* Root user and nfs */
+#endif
{
char *tmpfile;
tmpfile = tempnam(parentdir,"quang");
@@ -4195,6 +4212,7 @@ CheckDeletePermissionRecur(
return 0;
}
+#if !defined(CSRG_BASED)
static int
FileSysType(
int dev)
@@ -4204,6 +4222,7 @@ FileSysType(
return -2;
return u1.f_tinode;
}
+#endif
static int
RestoreObject(
diff --git a/cde/programs/dtfile/dtcopy/sharedFuncs.c
b/cde/programs/dtfile/dtcopy/sharedFuncs.c
index 334c98c..fa25453 100644
--- a/cde/programs/dtfile/dtcopy/sharedFuncs.c
+++ b/cde/programs/dtfile/dtcopy/sharedFuncs.c
@@ -69,7 +69,7 @@
# define ROOTINO UFSROOTINO
#endif
-#if defined(linux)
+#if defined(linux) || defined(CSRG_BASED)
# include <sys/param.h>
# define ROOTINO 2
#endif
@@ -80,9 +80,12 @@
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
+#include <sys/mount.h>
#include <pwd.h>
#include <fcntl.h>
+#if !defined(CSRG_BASED)
#include <ustat.h>
+#endif
#include <dirent.h>
@@ -373,6 +376,7 @@ ImageInitialize( Display *display )
return ;
} /* end ImageInitialize */
+#if !defined(CSRG_BASED)
static int
CopyFileSysType(
int dev)
@@ -382,6 +386,7 @@ CopyFileSysType(
return -2;
return u1.f_tinode;
}
+#endif
static int
CopyCheckDeletePermissionRecur(
@@ -446,17 +451,29 @@ CopyCheckDeletePermission(
char *parentdir,
char *destinationPath)
{
+#if defined(CSRG_BASED)
+ struct statfs statbuf;
+#else
struct stat statbuf;
+#endif
char fname[1024];
+#if defined(CSRG_BASED)
+ if (statfs(parentdir,&statbuf) < 0) /* does not exist */
+#else
if (lstat(parentdir,&statbuf) < 0) /* does not exist */
+#endif
return -1;
/* check if we are root */
if (getuid() == 0)
{
/* if NFS, need to check if server trusts root */
+#if defined(CSRG_BASED)
+ if (!strcmp(statbuf.f_fstypename, "nfs")) /* Root user and nfs */
+#else
if (CopyFileSysType(statbuf.st_dev) < 0) /* Root user and nfs */
+#endif
{
char *tmpfile;
tmpfile = tempnam(parentdir,"quang");
--
1.7.6
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
cdesktopenv-devel mailing list
cdesktopenv-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel