Skip to content

Commit e900fa6

Browse files
committed
fixup! FIX Restrict socket permissions and manage ACLs if needed
1 parent 7bd354d commit e900fa6

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

.github/workflows/runner-e2e.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ jobs:
5555
run: |
5656
cd dist
5757
tar -zxvf apache-apisix-java-plugin-runner-*bin.tar.gz
58-
chmod 777 /tmp/runner.sock
5958
java -jar -DAPISIX_LISTEN_ADDRESS=unix:/tmp/runner.sock -DAPISIX_CONF_EXPIRE_TIME=3600 ./apisix-runner-bin/apisix-java-plugin-runner.jar &
6059
6160
- name: startup apisix

runner-core/src/main/java/org/apache/apisix/plugin/runner/server/ApplicationRunner.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@
2626
import java.nio.file.attribute.AclEntryPermission;
2727
import java.nio.file.attribute.AclEntryType;
2828
import java.nio.file.attribute.AclFileAttributeView;
29-
import java.nio.file.attribute.PosixFilePermission;
3029
import java.util.HashMap;
3130
import java.util.List;
3231
import java.util.Map;
3332
import java.util.stream.Collectors;
3433
import java.util.Optional;
35-
import java.util.Set;
3634

3735
import org.slf4j.Logger;
3836
import org.slf4j.LoggerFactory;
@@ -75,6 +73,8 @@ public class ApplicationRunner implements CommandLineRunner {
7573

7674
private final Logger logger = LoggerFactory.getLogger(ApplicationRunner.class);
7775
private static final List<String> SOCKET_ALLOWED_USERS = Splitter.on(',')
76+
.omitEmptyStrings()
77+
.trimResults()
7878
.splitToList(System.getProperty("socket.allowed.users", ""));
7979

8080
@Value("${socket.file}")
@@ -136,16 +136,11 @@ public void start(String path) throws Exception {
136136
}
137137
}
138138

139-
private static void manageSocketPermissions(String pathString) throws IOException {
140-
Set<PosixFilePermission> permissions = Set.of(
141-
PosixFilePermission.OWNER_READ,
142-
PosixFilePermission.OWNER_WRITE,
143-
PosixFilePermission.OWNER_EXECUTE);
144-
Path path = Paths.get(pathString);
145-
Files.setPosixFilePermissions(path, permissions);
139+
private static void manageSocketPermissions(String socketFile) throws IOException {
140+
Runtime.getRuntime().exec("chmod 700 " + socketFile);
146141

147142
if (!SOCKET_ALLOWED_USERS.isEmpty()) {
148-
Optional.ofNullable(Files.getFileAttributeView(path, AclFileAttributeView.class))
143+
Optional.ofNullable(Files.getFileAttributeView(Paths.get(socketFile), AclFileAttributeView.class))
149144
.orElseThrow(() -> new UnsupportedOperationException("ACLs are not supported on this filesystem."))
150145
.setAcl(SOCKET_ALLOWED_USERS.stream()
151146
.map(ApplicationRunner::computeAclEntry)

0 commit comments

Comments
 (0)