Bug 1373987 - [GSS](6.4.z) jsvc not working with EAP 6 when binding to port 80 using a non-root user
Summary: [GSS](6.4.z) jsvc not working with EAP 6 when binding to port 80 using a non-...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: jbossas
Version: 6.4.9
Hardware: x86_64
OS: Linux
high
high
Target Milestone: ---
: ---
Assignee: Petr Jurak
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-07 15:39 UTC by Lei Yu
Modified: 2019-12-16 06:39 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
RHEL 6, Fedora 23
Last Closed: 2017-06-21 06:51:56 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
run_jsvc.sh (1.12 KB, application/x-shellscript)
2016-09-07 15:39 UTC, Lei Yu
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker JBCS-151 0 Blocker Closed JSVC not working with EAP 6 when binding to port 80 using a non-root user 2017-07-01 01:48:19 UTC

Description Lei Yu 2016-09-07 15:39:22 UTC
Created attachment 1198771 [details]
run_jsvc.sh

Description of problem:

Customer would like to use jsvc with JBoss EAP 6 for binding to port 80 and 443 as non-root user. Testing was done using jboss-eap-6.4.0-installer.jar to install jboss 6.4.0, with openjdk and sun jdk and also jboss 6.4.7 with sun jdk only. All the tests failed with the following exception, JBoss was not able to start at port 80 with jsvc:
============================ error message =============================
13:48:32,944 ERROR [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-3) JBWEB003043: Error initializing endpoint: java.net.BindException: Permission denied /127.0.0.1:80
========================================================================

Version-Release number of selected component (if applicable):

jsvc 1.0.15 DR1 

How reproducible:

Always

Steps to Reproduce:

1) change JBoss http port to 80 using CLI
2) create run_jsvc.sh for starting JBoss using jsvc (see attached)
3) execute run_jsvc.sh as root, expecting to see JBoss running binding to port with user jboss

Actual results:

Error initializing endpoint: java.net.BindException: Permission denied /127.0.0.1:80

Expected results:

JBoss running as user jboss without errors

Additional info:

Tom has the following comments

Created By: Tom Fonteyne  (07/09/2016 13:08)
[private]

http://git.app.eng.bos.redhat.com/git/apache/commons-daemon.git/

only has one branch, and no tags.

checkout remotes/origin/1.0.15.redhat

then:

commons-daemon/src/native/unix/native/jsvc-unix.c

line 832:

    /* Load the service */
    if (java_load(args) != true) {
        log_debug("java_load failed");
        return 3;
    }
    else
        log_debug("java_load done");

    /* Downgrade user */
#ifdef OS_LINUX
    if (args->user && set_caps(0) != 0) {
        log_debug("set_caps (0) failed");
        return 4;
    }
#else
    if (set_user_group(args->user, uid, gid) != 0)
        return 4;
#endif

    /* Start the service */
    umask(envmask);
    if (java_start() != true) {
        log_debug("java_start failed");
        return 5;
    }
    else
        log_debug("java_start done");
...

So Java gets loaded, capabilities get withdrawn, java starts.

Double check "/proc/<pid>/status   and its easy to see that the capabilities have not been inherited.

Test 1: remove the set_cap(0)
=> port 80 works (obviously)
=> /proc/<pid>/status   shows that the process still has the caps set (again, obviously) => not good as not secure.

Solution:

    /* Load the service */
    if (java_load(args) != true) {
        log_debug("java_load failed");
        return 3;
    }
    else
        log_debug("java_load done");

    /* Start the service */
    umask(envmask);
    if (java_start() != true) {
        log_debug("java_start failed");
        return 5;
    }
    else
        log_debug("java_start done");

    /* Downgrade user */
#ifdef OS_LINUX
    if (args->user && set_caps(0) != 0) {
        log_debug("set_caps (0) failed");
        return 4;
    }
#else
    if (set_user_group(args->user, uid, gid) != 0)
        return 4;
#endif

Now port 80 works, but more importantly /prov/<pid>/status   shows that the caps have been correctly/securely removed.


Note: there is no need to use the shell command "setcap" to modify jsvc or java itself !

Also note: rather obviously this still means you need to start jsvc as "root" with a "-user" setting to get EAP running as a non-root user.

Comment 1 JBoss JIRA Server 2016-10-07 12:23:14 UTC
Coty Sutherland <csutherl> updated the status of jira JBCS-151 to Closed


Note You need to log in before you can comment on or make changes to this bug.