You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/06/29 14:32:33 UTC
svn commit: r789308 - in
/commons/sandbox/runtime/trunk/src/main/native/os/unix: file.c main.c
Author: mturk
Date: Mon Jun 29 12:32:32 2009
New Revision: 789308
URL: http://svn.apache.org/viewvc?rev=789308&view=rev
Log:
Set permissions according to the process umask
Modified:
commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c?rev=789308&r1=789307&r2=789308&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c Mon Jun 29 12:32:32 2009
@@ -36,6 +36,8 @@
#else
typedef struct stat struct_stat;
#endif
+extern mode_t acr_default_umask;
+extern mode_t acr_default_perms;
ACR_DECLARE(int) ACR_FileTypeGet(JNIEnv *_E, const char *fname)
{
@@ -370,8 +372,8 @@
UNREFERENCED_O;
/* Don't do anything if we can't handle the requested attributes */
- if ((mask & ACR_FILE_ATTR_HIDDEN))
- return JNI_FALSE;
+ if (mask == ACR_FILE_ATTR_HIDDEN)
+ return JNI_TRUE;
WITH_CSTR(pathname) {
int protection = ACR_FileProtectionGet(_E, J2S(pathname));
@@ -383,18 +385,22 @@
protection &= ~ACR_FPROT_WWRITE;
}
else {
- /* ### umask this! */
- protection |= ACR_FPROT_UWRITE;
- protection |= ACR_FPROT_GWRITE;
- protection |= ACR_FPROT_WWRITE;
+ if (acr_default_perms & S_IWUSR)
+ protection |= ACR_FPROT_UWRITE;
+ if (acr_default_perms & S_IWGRP)
+ protection |= ACR_FPROT_GWRITE;
+ if (acr_default_perms & S_IWOTH)
+ protection |= ACR_FPROT_WWRITE;
}
}
if (mask & ACR_FILE_ATTR_EXECUTABLE) {
if (attr & ACR_FILE_ATTR_EXECUTABLE) {
- /* ### umask this! */
- protection |= ACR_FPROT_UEXECUTE;
- protection |= ACR_FPROT_GEXECUTE;
- protection |= ACR_FPROT_WEXECUTE;
+ if (acr_default_perms & S_IXUSR)
+ protection |= ACR_FPROT_UEXECUTE;
+ if (acr_default_perms & S_IXGRP)
+ protection |= ACR_FPROT_GEXECUTE;
+ if (acr_default_perms & S_IXOTH)
+ protection |= ACR_FPROT_WEXECUTE;
}
else {
protection &= ~ACR_FPROT_UEXECUTE;
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c?rev=789308&r1=789307&r2=789308&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c Mon Jun 29 12:32:32 2009
@@ -34,6 +34,8 @@
extern int ACR_InitClazzCache(JNIEnv *);
extern int ACR_DestroyClazzCache(JNIEnv *);
+mode_t acr_default_umask;
+mode_t acr_default_perms;
typedef struct acr_thread_local_t {
JNIEnv *env;
@@ -74,6 +76,9 @@
return JNI_ERR;
if (ACR_InitClazzCache(env) != ACR_SUCCESS)
return JNI_ERR;
+ acr_default_umask = umask(0777);
+ (void)umask(acr_default_umask);
+ acr_default_perms = ~acr_default_umask & 0777;
return JNI_VERSION_1_4;
}
@@ -111,3 +116,4 @@
return tlsd->env;
}
+