/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <windows.h>
#include <malloc.h>
#include <string.h>
#include "jni.h"
#include "jni_util.h"
#include "sun_management_FileSystemImpl.h"
/*
* Access mask to represent any file access
*/
/*
* Returns JNI_TRUE if the specified file is on a file system that supports
* persistent ACLs (On NTFS file systems returns true, on FAT32 file systems
* returns false).
*/
char* root;
char* p;
/*
* Get root directory. Assume that files are absolute paths. For UNCs
* the slash after the share name is required.
*/
if (*root == '\\') {
/*
* \\server\share\file ==> \\server\share\
*/
p = root;
while ((*p == '\\') && (slashskip > 0)) {
char* p2;
p++;
return JNI_FALSE;
}
p = p2;
slashskip--;
}
if (slashskip != 0) {
return JNI_FALSE;
}
p++;
*p = '\0';
} else {
if (p == NULL) {
return JNI_FALSE;
}
p++;
*p = '\0';
}
/*
* Get the volume information - this gives us the file system file and
* also tells us if the file system supports persistent ACLs.
*/
NULL, // address of name of the volume, can be NULL
0, // length of volume name
NULL, // address of volume serial number, can be NULL
&dwFlags,
if (res == 0) {
return JNI_FALSE;
}
}
/*
* Returns the security descriptor for a file.
*/
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
return NULL;
}
} else {
return NULL;
}
}
return sd;
}
/*
* Returns pointer to the SID identifying the owner of the specified
* file.
*/
return NULL;
}
return owner;
}
/*
* Returns pointer discretionary access-control list (ACL) from the security
* descriptor of the specified file.
*/
return NULL;
}
if (!present) {
return NULL;
}
return acl;
}
/*
* Returns JNI_TRUE if the specified owner is the only SID will access
* to the file.
*/
DWORD i;
/*
* If there's no DACL then there's no access to the file
*/
return JNI_TRUE;
}
/*
* Get the ACE count
*/
return JNI_FALSE;
}
/*
* Iterate over the ACEs. For each "allow" type check that the SID
* matches the owner, and check that the access is read only.
*/
for (i = 0; i < acl_size_info.AceCount; i++) {
void* ace;
return -1;
}
continue;
}
/*
* If the ACE allows any access then the file is not secure.
*/
return JNI_FALSE;
}
}
}
return JNI_TRUE;
}
/*
* Class: sun_management_FileSystemImpl
* Method: init0
* Signature: ()V
*/
{
/* nothing to do */
}
/*
* Class: sun_management_FileSystemImpl
* Method: isSecuritySupported0
*/
{
const char* path;
if (isCopy) {
}
return res;
} else {
/* exception thrown - doesn't matter what we return */
return JNI_TRUE;
}
}
/*
* Class: sun_management_FileSystemImpl
* Method: isAccessUserOnly0
*/
{
const char* path;
/*
* From the security descriptor get the file owner and
* DACL. Then check if anybody but the owner has access
* to the file.
*/
} else {
/*
* If acl is NULL it means that an exception was thrown
* or there is "all acess" to the file.
*/
}
}
}
if (isCopy) {
}
}
return res;
}