static boolean parseAvailableResult ( List < String > stdout , boolean checkForRoot ) { if ( stdout == null ) { return false ; } // this is only one of many ways this can be done boolean echoSeen = false ; for ( String line : stdout ) { if ( line . contains ( "uid=" ) ) { // id command is working, let's see if we are actually root return ! checkForRoot || line . contains ( "uid=0" ) ; } else if ( line . contains ( "-BOC-" ) ) { // if we end up here, at least the su command starts some kind of shell, let's hope it has root privileges - // no way to know without additional native binaries echoSeen = true ; } } return echoSeen ; }
See if the shell is alive and if so check the UID