Skip to content

Commit

Permalink
Using JPMS and jna start module.
Browse files Browse the repository at this point in the history
  • Loading branch information
joakime committed Mar 27, 2024
1 parent 8a89c13 commit 12df2aa
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
<jdk.version.minimum>17</jdk.version.minimum>
<jetty-test-helper.version>6.2</jetty-test-helper.version>
<jetty.git.repo>jetty-setuid-jna</jetty.git.repo>
<jetty.version>12.0.6</jetty.version>
<jetty.version>12.0.7</jetty.version>
<jna.version>5.14.0</jna.version>
</properties>

<dependencies>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<artifactId>jna-jpms</artifactId>
<version>${jna.version}</version>
</dependency>
<dependency>
Expand Down
4 changes: 1 addition & 3 deletions src/main/config/modules/setuid.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@ changing to a restricted user (e.g. Jetty).

[depend]
server
jna

[lib]
lib/setuid/jetty-setuid-jna-${jetty-setuid.version}.jar
lib/setuid/jna-${jna.version}.jar

[ini]
jetty-setuid.version?=@project.version@
jna.version?=@jna.version@

[files]
maven://org.eclipse.jetty.toolchain.setuid/jetty-setuid-jna/${jetty-setuid.version}|lib/setuid/jetty-setuid-jna-${jetty-setuid.version}.jar
maven://net.java.dev.jna/jna/${jna.version}|lib/setuid/jna-${jna.version}.jar

[xml]
etc/jetty-setuid.xml
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// ========================================================================
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//

module org.eclipse.jetty.setuid.jna
{
requires com.sun.jna;
requires org.eclipse.jetty.server;
requires org.eclipse.jetty.util;
requires org.slf4j;

// needed to allow internal classes to use com.sun.jna
opens org.eclipse.jetty.setuid.internal;

exports org.eclipse.jetty.setuid;
}
3 changes: 3 additions & 0 deletions src/main/java/org/eclipse/jetty/setuid/SetUIDListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.NetworkConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.setuid.internal.Group;
import org.eclipse.jetty.setuid.internal.LibC;
import org.eclipse.jetty.setuid.internal.Passwd;
import org.eclipse.jetty.util.component.LifeCycle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.setuid;
package org.eclipse.jetty.setuid.internal;

import com.sun.jna.Pointer;
import com.sun.jna.Structure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
// ========================================================================
//

package org.eclipse.jetty.setuid;
package org.eclipse.jetty.setuid.internal;

import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Platform;
import org.eclipse.jetty.setuid.RLimit;

/**
* Class is for changing user and groupId, it can also be use to retrieve user information by using getpwuid(uid) or getpwnam(username) of both linux and unix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.setuid;
package org.eclipse.jetty.setuid.internal;

import com.sun.jna.Structure;

Expand Down
3 changes: 3 additions & 0 deletions src/test/java/org/eclipse/jetty/setuid/TestLibC.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import java.nio.file.attribute.PosixFilePermission;
import java.util.Set;

import org.eclipse.jetty.setuid.internal.Group;
import org.eclipse.jetty.setuid.internal.LibC;
import org.eclipse.jetty.setuid.internal.Passwd;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down

0 comments on commit 12df2aa

Please sign in to comment.