aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYury Molchan <yury.molchan@gmail.com>2023-12-06 04:29:39 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2024-05-13 16:14:47 +0200
commitc1f95130c554580afc1d6090d30b3946b578714e (patch)
treed2a4db51b5b97e0f69996231c35ae0661d20170f
parent5c0c18f5665fe8d3c3fae0176e231deb6c2480a7 (diff)
downloadjgit-c1f95130c554580afc1d6090d30b3946b578714e.tar.gz
jgit-c1f95130c554580afc1d6090d30b3946b578714e.zip
Check an execution bit by reading it from the file system
Files.isExecutable() checks possibility to execute a file from the JVM, not POSIX attributes. So it fails when Java Security Manager does not allow to execute a file, but file has X-bit. Change-Id: I85b96fb6cedbaff1b3c063728c25b6ce4d04e9b9
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
index ee907f2ee6..e73095f5a8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, Robin Rosenberg and others
+ * Copyright (C) 2010, 2024, Robin Rosenberg and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
@@ -203,7 +203,16 @@ public class FS_POSIX extends FS {
/** {@inheritDoc} */
@Override
public boolean canExecute(File f) {
- return FileUtils.canExecute(f);
+ if (!isFile(f)) {
+ return false;
+ }
+ try {
+ Path path = FileUtils.toPath(f);
+ Set<PosixFilePermission> pset = Files.getPosixFilePermissions(path);
+ return pset.contains(PosixFilePermission.OWNER_EXECUTE);
+ } catch (IOException ex) {
+ return false;
+ }
}
/** {@inheritDoc} */