From eaec696ad6070e930a4c85285b18b6033d0ecbeb Mon Sep 17 00:00:00 2001 From: Pascal Stumpf 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 2619769f..a090af20 100644 --- a/cde/programs/dtfile/Desktop.c +++ b/cde/programs/dtfile/Desktop.c @@ -105,6 +105,7 @@ #include #include #include +#include #include #include diff --git a/cde/programs/dtfile/FileManip.c b/cde/programs/dtfile/FileManip.c index dd785d79..91f631c4 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 @@ -994,7 +994,8 @@ FileManip( if (lstat (to, &s2) >= 0) /* 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 7ff81458..5ee2137e 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 61a6b341..094d2854 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 cba55272..caf0fc37 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 972050e8..434c756a 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 5da02945..333efe08 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 ec2eae8d..fe5f6243 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 a3b85e2b..2f7fa3d3 100644 --- a/cde/programs/dtfile/Trash.c +++ b/cde/programs/dtfile/Trash.c @@ -101,7 +101,12 @@ #include #include #include +#if defined(CSRG_BASED) +#include +#include +#else #include +#endif #include #include @@ -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 334c98cc..fa25453f 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 # define ROOTINO 2 #endif @@ -80,9 +80,12 @@ #include #include #include +#include #include #include +#if !defined(CSRG_BASED) #include +#endif #include @@ -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"); -- 2.25.1