diff options
author | Pacien TRAN-GIRARD | 2017-07-01 15:32:47 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2017-07-01 15:32:47 +0200 |
commit | 85a3892d4ecad4aae98f062e824f54e477bf8912 (patch) | |
tree | 6e6901f3ed5f1fe0cebf26551608f219132bd47f /app | |
parent | 3619cf121b5b496ede1a0588f77b44f9bdb8386b (diff) | |
download | tincapp-85a3892d4ecad4aae98f062e824f54e477bf8912.tar.gz |
Remove permission fixing options
Diffstat (limited to 'app')
6 files changed, 0 insertions, 88 deletions
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 | |||
13 | import kotlinx.android.synthetic.main.base.* | 13 | import kotlinx.android.synthetic.main.base.* |
14 | 14 | ||
15 | import org.pacien.tincapp.R | 15 | import org.pacien.tincapp.R |
16 | import org.pacien.tincapp.commands.PermissionFixer | ||
17 | import org.pacien.tincapp.context.AppPaths | 16 | import org.pacien.tincapp.context.AppPaths |
18 | import org.pacien.tincapp.service.TincVpnService | 17 | import org.pacien.tincapp.service.TincVpnService |
19 | 18 | ||
@@ -63,7 +62,6 @@ class StartActivity : BaseActivity() { | |||
63 | AlertDialog.Builder(this) | 62 | AlertDialog.Builder(this) |
64 | .setTitle(R.string.title_tinc_config_dir) | 63 | .setTitle(R.string.title_tinc_config_dir) |
65 | .setMessage(confDir) | 64 | .setMessage(confDir) |
66 | .setNeutralButton(R.string.action_fix_perms) { _, _ -> fixPerms() } | ||
67 | .setNegativeButton(R.string.action_copy) { _, _ -> copyIntoClipboard(resources.getString(R.string.title_tinc_config_dir), confDir) } | 65 | .setNegativeButton(R.string.action_copy) { _, _ -> copyIntoClipboard(resources.getString(R.string.title_tinc_config_dir), confDir) } |
68 | .setPositiveButton(R.string.action_close) { _, _ -> /* nop */ } | 66 | .setPositiveButton(R.string.action_close) { _, _ -> /* nop */ } |
69 | .show() | 67 | .show() |
@@ -74,9 +72,4 @@ class StartActivity : BaseActivity() { | |||
74 | .putExtra(TincVpnService.INTENT_EXTRA_NET_NAME, netName)) | 72 | .putExtra(TincVpnService.INTENT_EXTRA_NET_NAME, netName)) |
75 | } | 73 | } |
76 | 74 | ||
77 | private fun fixPerms() { | ||
78 | val ok = PermissionFixer.makePrivateDirsPublic(applicationContext) | ||
79 | notify(if (ok) R.string.message_perms_fixed else R.string.message_perms_fix_failure) | ||
80 | } | ||
81 | |||
82 | } | 75 | } |
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 @@ | |||
1 | package org.pacien.tincapp.commands | ||
2 | |||
3 | import android.annotation.SuppressLint | ||
4 | import android.content.Context | ||
5 | import org.pacien.tincapp.context.AppPaths | ||
6 | import java.io.File | ||
7 | |||
8 | /** | ||
9 | * @author pacien | ||
10 | */ | ||
11 | object PermissionFixer { | ||
12 | |||
13 | @SuppressLint("SetWorldReadable", "SetWorldWritable") | ||
14 | private fun setAllRWXPermissions(f: File): Boolean = | ||
15 | f.setReadable(true, false) && f.setWritable(true, false) && f.setExecutable(true, false) | ||
16 | |||
17 | fun makePrivateDirsPublic(ctx: Context): Boolean = listOf(AppPaths.confDir(ctx), AppPaths.logDir(ctx), AppPaths.pidDir(ctx)) | ||
18 | .map { setAllRWXPermissions(it) }.all { it } | ||
19 | |||
20 | } | ||
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 @@ | |||
1 | package org.pacien.tincapp.service | ||
2 | |||
3 | import android.net.VpnService | ||
4 | import org.apache.commons.configuration2.Configuration | ||
5 | import org.apache.commons.configuration2.builder.fluent.Configurations | ||
6 | import org.apache.commons.configuration2.ex.ConfigurationException | ||
7 | import java.io.File | ||
8 | |||
9 | /** | ||
10 | * @author pacien | ||
11 | */ | ||
12 | object VpnInterfaceConfigurator { | ||
13 | |||
14 | val KEY_ADDRESSES = "Address" | ||
15 | val KEY_ROUTES = "Route" | ||
16 | val KEY_DNS_SERVERS = "DNSServer" | ||
17 | val KEY_SEARCH_DOMAINS = "SearchDomain" | ||
18 | val KEY_ALLOWED_APPLICATIONS = "AllowApplication" | ||
19 | val KEY_DISALLOWED_APPLICATIONS = "DisallowApplication" | ||
20 | val KEY_ALLOWED_FAMILIES = "AllowFamily" | ||
21 | val KEY_ALLOW_BYPASS = "AllowBypass" | ||
22 | val KEY_BLOCKING = "Blocking" | ||
23 | val KEY_MTU = "MTU" | ||
24 | |||
25 | private fun Configuration.getStringList(key: String): List<String> = | ||
26 | getList(String::class.java, key, emptyList()) | ||
27 | |||
28 | private fun Configuration.getCidrList(key: String): List<CidrAddress> = | ||
29 | getStringList(key).map { CidrAddress(it) } | ||
30 | |||
31 | private fun Configuration.getIntList(key: String): List<Int> = | ||
32 | getList(Int::class.java, key, emptyList()) | ||
33 | |||
34 | fun applyConfiguration(net: VpnService.Builder, cfg: Configuration): VpnService.Builder = net | ||
35 | .addAddresses(cfg.getCidrList(KEY_ADDRESSES)) | ||
36 | .addRoutes(cfg.getCidrList(KEY_ROUTES)) | ||
37 | .addDnsServers(cfg.getStringList(KEY_DNS_SERVERS)) | ||
38 | .addSearchDomains(cfg.getStringList(KEY_SEARCH_DOMAINS)) | ||
39 | .addAllowedApplications(cfg.getStringList(KEY_ALLOWED_APPLICATIONS)) | ||
40 | .addDisallowedApplications(cfg.getStringList(KEY_DISALLOWED_APPLICATIONS)) | ||
41 | .allowFamilies(cfg.getIntList(KEY_ALLOWED_FAMILIES)) | ||
42 | .allowBypass(cfg.getBoolean(KEY_ALLOW_BYPASS, false)) | ||
43 | .setBlocking(cfg.getBoolean(KEY_BLOCKING, false)) | ||
44 | .overrideMtu(cfg.getInteger(KEY_MTU, null)) | ||
45 | |||
46 | fun applyConfiguration(net: VpnService.Builder, cfg: File): VpnService.Builder = try { | ||
47 | applyConfiguration(net, Configurations().properties(cfg)) | ||
48 | } catch (e: ConfigurationException) { | ||
49 | throw IllegalArgumentException(e.message) | ||
50 | } | ||
51 | |||
52 | } | ||
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 @@ | |||
22 | <string name="action_close">閉じる</string> | 22 | <string name="action_close">閉じる</string> |
23 | <string name="action_copy">コピー</string> | 23 | <string name="action_copy">コピー</string> |
24 | <string name="action_open_project_website">プロジェクト Web サイト</string> | 24 | <string name="action_open_project_website">プロジェクト Web サイト</string> |
25 | <string name="action_fix_perms">conf を編集可能に設定</string> | ||
26 | <string name="action_connect">接続</string> | 25 | <string name="action_connect">接続</string> |
27 | 26 | ||
28 | <string name="message_perms_fixed">新しい権限を正常に適用しました。</string> | ||
29 | <string name="message_perms_fix_failure">新しい権限の設定中にエラーが発生しました。</string> | ||
30 | <string name="message_text_copied">テキストをクリップボードにコピーしました。</string> | 27 | <string name="message_text_copied">テキストをクリップボードにコピーしました。</string> |
31 | <string name="message_vpn_permissions_granted">VPN 権限を付与しました。</string> | 28 | <string name="message_vpn_permissions_granted">VPN 権限を付与しました。</string> |
32 | <string name="message_vpn_permissions_denied">VPN 権限が拒否されました。</string> | 29 | <string name="message_vpn_permissions_denied">VPN 権限が拒否されました。</string> |
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 @@ | |||
22 | <string name="action_close">Lukk</string> | 22 | <string name="action_close">Lukk</string> |
23 | <string name="action_copy">Kopier</string> | 23 | <string name="action_copy">Kopier</string> |
24 | <string name="action_open_project_website">Prosjektets nettside</string> | 24 | <string name="action_open_project_website">Prosjektets nettside</string> |
25 | <string name="action_fix_perms">Sett oppsett som skrivbart</string> | ||
26 | <string name="action_connect">Koble til</string> | 25 | <string name="action_connect">Koble til</string> |
27 | 26 | ||
28 | <string name="message_perms_fixed">Nye tilganger lagt til.</string> | ||
29 | <string name="message_perms_fix_failure">Feil ved tillegg av nye tilganger.</string> | ||
30 | <string name="message_text_copied">Tekst kopiert til utklippstavle.</string> | 27 | <string name="message_text_copied">Tekst kopiert til utklippstavle.</string> |
31 | <string name="message_vpn_permissions_granted">VPN-tilganger gitt.</string> | 28 | <string name="message_vpn_permissions_granted">VPN-tilganger gitt.</string> |
32 | <string name="message_vpn_permissions_denied">VPN-tilganger nektet.</string> | 29 | <string name="message_vpn_permissions_denied">VPN-tilganger nektet.</string> |
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 @@ | |||
22 | <string name="action_close">Close</string> | 22 | <string name="action_close">Close</string> |
23 | <string name="action_copy">Copy</string> | 23 | <string name="action_copy">Copy</string> |
24 | <string name="action_open_project_website">Project website</string> | 24 | <string name="action_open_project_website">Project website</string> |
25 | <string name="action_fix_perms">Set conf editable</string> | ||
26 | <string name="action_connect">Connect</string> | 25 | <string name="action_connect">Connect</string> |
27 | 26 | ||
28 | <string name="message_perms_fixed">New permissions successfully applied.</string> | ||
29 | <string name="message_perms_fix_failure">Error encountered when setting new permissions.</string> | ||
30 | <string name="message_text_copied">Text copied to clipboard.</string> | 27 | <string name="message_text_copied">Text copied to clipboard.</string> |
31 | <string name="message_vpn_permissions_granted">VPN permissions granted.</string> | 28 | <string name="message_vpn_permissions_granted">VPN permissions granted.</string> |
32 | <string name="message_vpn_permissions_denied">VPN permissions denied.</string> | 29 | <string name="message_vpn_permissions_denied">VPN permissions denied.</string> |