From 85a3892d4ecad4aae98f062e824f54e477bf8912 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sat, 1 Jul 2017 15:32:47 +0200 Subject: Remove permission fixing options --- .../org/pacien/tincapp/activities/StartActivity.kt | 7 --- .../org/pacien/tincapp/commands/PermissionFixer.kt | 20 --------- .../tincapp/service/VpnInterfaceConfigurator.kt | 52 ---------------------- app/src/main/res/values-ja/strings.xml | 3 -- app/src/main/res/values-nb-rNO/strings.xml | 3 -- app/src/main/res/values/strings.xml | 3 -- 6 files changed, 88 deletions(-) delete mode 100644 app/src/main/java/org/pacien/tincapp/commands/PermissionFixer.kt delete mode 100644 app/src/main/java/org/pacien/tincapp/service/VpnInterfaceConfigurator.kt diff --git a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt index 6d39a9d..71d5403 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt @@ -13,7 +13,6 @@ import android.widget.FrameLayout import kotlinx.android.synthetic.main.base.* import org.pacien.tincapp.R -import org.pacien.tincapp.commands.PermissionFixer import org.pacien.tincapp.context.AppPaths import org.pacien.tincapp.service.TincVpnService @@ -63,7 +62,6 @@ class StartActivity : BaseActivity() { AlertDialog.Builder(this) .setTitle(R.string.title_tinc_config_dir) .setMessage(confDir) - .setNeutralButton(R.string.action_fix_perms) { _, _ -> fixPerms() } .setNegativeButton(R.string.action_copy) { _, _ -> copyIntoClipboard(resources.getString(R.string.title_tinc_config_dir), confDir) } .setPositiveButton(R.string.action_close) { _, _ -> /* nop */ } .show() @@ -74,9 +72,4 @@ class StartActivity : BaseActivity() { .putExtra(TincVpnService.INTENT_EXTRA_NET_NAME, netName)) } - private fun fixPerms() { - val ok = PermissionFixer.makePrivateDirsPublic(applicationContext) - notify(if (ok) R.string.message_perms_fixed else R.string.message_perms_fix_failure) - } - } diff --git a/app/src/main/java/org/pacien/tincapp/commands/PermissionFixer.kt b/app/src/main/java/org/pacien/tincapp/commands/PermissionFixer.kt deleted file mode 100644 index 493927c..0000000 --- a/app/src/main/java/org/pacien/tincapp/commands/PermissionFixer.kt +++ /dev/null @@ -1,20 +0,0 @@ -package org.pacien.tincapp.commands - -import android.annotation.SuppressLint -import android.content.Context -import org.pacien.tincapp.context.AppPaths -import java.io.File - -/** - * @author pacien - */ -object PermissionFixer { - - @SuppressLint("SetWorldReadable", "SetWorldWritable") - private fun setAllRWXPermissions(f: File): Boolean = - f.setReadable(true, false) && f.setWritable(true, false) && f.setExecutable(true, false) - - fun makePrivateDirsPublic(ctx: Context): Boolean = listOf(AppPaths.confDir(ctx), AppPaths.logDir(ctx), AppPaths.pidDir(ctx)) - .map { setAllRWXPermissions(it) }.all { it } - -} diff --git a/app/src/main/java/org/pacien/tincapp/service/VpnInterfaceConfigurator.kt b/app/src/main/java/org/pacien/tincapp/service/VpnInterfaceConfigurator.kt deleted file mode 100644 index 8104940..0000000 --- a/app/src/main/java/org/pacien/tincapp/service/VpnInterfaceConfigurator.kt +++ /dev/null @@ -1,52 +0,0 @@ -package org.pacien.tincapp.service - -import android.net.VpnService -import org.apache.commons.configuration2.Configuration -import org.apache.commons.configuration2.builder.fluent.Configurations -import org.apache.commons.configuration2.ex.ConfigurationException -import java.io.File - -/** - * @author pacien - */ -object VpnInterfaceConfigurator { - - val KEY_ADDRESSES = "Address" - val KEY_ROUTES = "Route" - val KEY_DNS_SERVERS = "DNSServer" - val KEY_SEARCH_DOMAINS = "SearchDomain" - val KEY_ALLOWED_APPLICATIONS = "AllowApplication" - val KEY_DISALLOWED_APPLICATIONS = "DisallowApplication" - val KEY_ALLOWED_FAMILIES = "AllowFamily" - val KEY_ALLOW_BYPASS = "AllowBypass" - val KEY_BLOCKING = "Blocking" - val KEY_MTU = "MTU" - - private fun Configuration.getStringList(key: String): List = - getList(String::class.java, key, emptyList()) - - private fun Configuration.getCidrList(key: String): List = - getStringList(key).map { CidrAddress(it) } - - private fun Configuration.getIntList(key: String): List = - getList(Int::class.java, key, emptyList()) - - fun applyConfiguration(net: VpnService.Builder, cfg: Configuration): VpnService.Builder = net - .addAddresses(cfg.getCidrList(KEY_ADDRESSES)) - .addRoutes(cfg.getCidrList(KEY_ROUTES)) - .addDnsServers(cfg.getStringList(KEY_DNS_SERVERS)) - .addSearchDomains(cfg.getStringList(KEY_SEARCH_DOMAINS)) - .addAllowedApplications(cfg.getStringList(KEY_ALLOWED_APPLICATIONS)) - .addDisallowedApplications(cfg.getStringList(KEY_DISALLOWED_APPLICATIONS)) - .allowFamilies(cfg.getIntList(KEY_ALLOWED_FAMILIES)) - .allowBypass(cfg.getBoolean(KEY_ALLOW_BYPASS, false)) - .setBlocking(cfg.getBoolean(KEY_BLOCKING, false)) - .overrideMtu(cfg.getInteger(KEY_MTU, null)) - - fun applyConfiguration(net: VpnService.Builder, cfg: File): VpnService.Builder = try { - applyConfiguration(net, Configurations().properties(cfg)) - } catch (e: ConfigurationException) { - throw IllegalArgumentException(e.message) - } - -} diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index e40ad5e..c27f2d1 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -22,11 +22,8 @@ 閉じる コピー プロジェクト Web サイト - conf を編集可能に設定 接続 - 新しい権限を正常に適用しました。 - 新しい権限の設定中にエラーが発生しました。 テキストをクリップボードにコピーしました。 VPN 権限を付与しました。 VPN 権限が拒否されました。 diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index 146c0ac..95f1267 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -22,11 +22,8 @@ Lukk Kopier Prosjektets nettside - Sett oppsett som skrivbart Koble til - Nye tilganger lagt til. - Feil ved tillegg av nye tilganger. Tekst kopiert til utklippstavle. VPN-tilganger gitt. VPN-tilganger nektet. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 943f9b2..4e5faea 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -22,11 +22,8 @@ Close Copy Project website - Set conf editable Connect - New permissions successfully applied. - Error encountered when setting new permissions. Text copied to clipboard. VPN permissions granted. VPN permissions denied. -- cgit v1.2.3