freebsd-ports/lang/cli/files/patch-pal::unix::file::file.c
Maxim Sobolev 1b712c05fc - Clean-up build system a bit;
- fix remaining two places where CFLAGS weren't respected;
- use cpio(1) to copy hierarchies instead of tar(1), so that it is possible
  to build the port as ordinary user, but still have installed files be
  owned by root;
- use slightly different solution for the problem with 777 permissions on
  directories created during the build. Instead of harcoding resulting
  prmission apply umask(2) to all mode arguments of [f]chmod() calls.
  Since Rotor has no notion of file-level security anyway this should be
  an optimal way to fix the problem.

Submitted by:	Patrick Backlund <pbacklun@cc.hut.fi> (cpio fix)
		sobomax (the rest)
2002-04-16 17:54:35 +00:00

42 lines
1 KiB
C

$FreeBSD$
--- pal/unix/file/file.c.orig Fri Mar 22 03:48:20 2002
+++ pal/unix/file/file.c Wed Apr 10 11:52:45 2002
@@ -37,6 +37,9 @@
#include <sys/stat.h>
#include <errno.h>
+#define chmod( path, mode ) chmod( ( path ), ( mode ) & ~GetUmask() )
+#define fchmod( fd, mode ) fchmod( ( fd ), ( mode ) & ~GetUmask() )
+#define lchmod( path, mode ) lchmod( ( path ), ( mode ) & ~GetUmask() )
SET_DEFAULT_DEBUG_CHANNEL(FILE);
@@ -44,6 +47,8 @@
static int FILECloseStdHandle( HOBJSTRUCT *handle_data);
static int FILEDuplicateHandle( HANDLE handle, HOBJSTRUCT *handle_data);
+static mode_t GetUmask( void );
+
static file *FILENewFileData( void );
static BOOL FILEAddNewLockedRgn(SHMFILELOCKS* fileLocks,
@@ -2342,6 +2347,17 @@
HMGRUnlockHandle(handle,&file_data->handle_data);
}
+static mode_t GetUmask( void )
+{
+ mode_t mask;
+
+ /* XXX: Probably need to block signals to avoid race here */
+ mask = umask( 0 );
+ umask( mask );
+ /* XXX: Unblock here */
+
+ return mask;
+}
/*++
Function: