From 958d387b8c2cd0d9b6002f97ba435fc36006a20a Mon Sep 17 00:00:00 2001 From: Mygod Date: Wed, 17 Aug 2016 12:29:17 +0800 Subject: [PATCH] Fix su detection --- .../com/github/shadowsocks/ShadowsocksNatService.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala index 438d5f6b..bb59d1d8 100644 --- a/src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala +++ b/src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala @@ -305,9 +305,11 @@ class ShadowsocksNatService extends BaseService { override def startRunner(profile: Profile) = if (su == null) { su = new Shell.Builder().useSU().setWantSTDERR(true).setWatchdogTimeout(10).open((_, exitCode, _) => if (exitCode == 0) super.startRunner(profile) else { - Log.wtf(TAG, "libsuperuser#55 has been fixed. Please remove the redundant code.") - su.close() - su = null + if (su != null) { + Log.wtf(TAG, "libsuperuser#55 has been fixed. Please remove the redundant code.") + su.close() + su = null + } super.stopRunner(true, getString(R.string.nat_no_root)) }) su.waitForIdle()