Bug 1019264

Summary: add-user utility reports "No java.io.Console available to interact with user." when used silently with su and piped to a file
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Tom Fonteyne <tfonteyn>
Component: Scripts and CommandsAssignee: Darran Lofthouse <darran.lofthouse>
Status: CLOSED CURRENTRELEASE QA Contact: Petr Kremensky <pkremens>
Severity: unspecified Docs Contact: Russell Dickenson <rdickens>
Priority: medium    
Version: 6.1.1CC: brian.stansberry, darran.lofthouse, fnasser, pgier
Target Milestone: ER7   
Target Release: EAP 6.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-15 16:16:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tom Fonteyne 2013-10-15 11:40:08 UTC
Description of problem:

https://issues.jboss.org/browse/WFLY-2305

Running add-user.sh in silent mode and redirecting the output to a file results in an exception:

Exception in thread "main" java.lang.IllegalStateException: JBAS015232: No java.io.Console available to interact with user.


How reproducible: always

Steps to Reproduce:

[tom@orac bin]$ ./add-user.sh --silent=true foo bar > /tmp/capture.log 2>&1
[tom@orac bin]$ cat /tmp/capture.log
Exception in thread "main" java.lang.IllegalStateException: JBAS015232: No java.io.Console available to interact with user.
at org.jboss.as.domain.management.security.adduser.AddUser.<init>(AddUser.java:101)
at org.jboss.as.domain.management.security.adduser.AddUser.main(AddUser.java:222)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.modules.Module.run(Module.java:292)
at org.jboss.modules.Main.main(Main.java:455)

Comment 1 JBoss JIRA Server 2013-10-15 13:40:15 UTC
Darran Lofthouse <darran.lofthouse> updated the status of jira WFLY-2305 to Coding In Progress

Comment 2 JBoss JIRA Server 2013-10-15 14:16:04 UTC
Darran Lofthouse <darran.lofthouse> made a comment on jira WFLY-2305

The actual problem here is that --silent=true is not a valid argument, the valid argument is --silent 

{noformat}
[darranl@localhost bin]$ ./add-user.sh --help
Usage: ./add-user.sh [args...]
where args include:
    -a                                  If set add an application user instead 
                                        of a management user

    -dc <value>                         Define the location of the domain 
                                        config directory.

    -sc <value>                         Define the location the server config 
                                        directory.

    -up, --user-properties <value>      The file name of the user properties 
                                        file which can be an absolute path.

    -g, --group <value>                 Comma-separated list of groups for the 
                                        user.

    -gp, --group-properties <value>     The file name of the group properties 
                                        file which can be an absolute path. (If 
                                        group properties is specified then user 
                                        properties MUST also be specified).

    -p, --password <value>              Password of the user. Should not be 
                                        same as the username

    -u, --user <value>                  Name of the user

    -r, --realm <value>                 Name of the realm used to secure the 
                                        management interfaces (default is 
                                        "ManagementRealm")

    -s, --silent                        Activate the silent mode (no output to 
                                        the console)

    -e, --enable                        Activate the silent mode (no output to 
                                        the console)

    -d, --disable                       Activate the silent mode (no output to 
                                        the console)

    -cw, --confirm-warning              Automatically confirm warning in 
                                        interactive mode

    -h, --help                          Display this message and exit
{noformat}

I will add unofficial support for an argument --silent=true.

Comment 3 Darran Lofthouse 2013-10-15 14:24:56 UTC
Proposing we make a change here as it is a tiny fix to address a usability issue.

The real issue is that the end user is entering the wrong command and is not setting silent mode as they expect, however a couple of users have been caught by this so adding support for the approach users are using to set silent mode.

Comment 5 Petr Kremensky 2013-11-06 11:06:41 UTC
Add-user script now supports --silent=true argument. We should update help message for the script and documentation as well, I'll create a BZs for this.

Verified on EAP 6.2.0.ER7.

Comment 6 Darran Lofthouse 2013-11-06 11:13:11 UTC
Please DO NOT document --silent=true as a valid option. 

The only reason for adding support for this option is users are not reading the current help text showing the valid options and are then getting caught out when they use an invalid form of this option - for that reason we are unofficially accepting it.

Comment 7 Petr Kremensky 2013-11-06 11:34:36 UTC
Thanks for clarification, I won't create any BZ regarding this than.