0
0
mirror of https://github.com/schwabe/ics-openvpn.git synced 2024-09-20 12:02:28 +02:00

Add fix for CM9 /dev/tun ownership (closes issue #35)

This commit is contained in:
Arne Schwabe 2012-05-30 17:17:36 +02:00
parent 97de0aad36
commit dddbf44d0c
4 changed files with 47 additions and 9 deletions

View File

@ -125,7 +125,7 @@
<string name="custom_options_title">Custom Options</string>
<string name="edit_vpn">Edit VPN Settings</string>
<string name="remove_vpn_query">Remove the VPN Profile %s?</string>
<string name="tun_error_helpful">" On some custom ICS images the permission on /dev/tun might be wrong, or the tun module might be missing completly"</string>
<string name="tun_error_helpful">" On some custom ICS images the permission on /dev/tun might be wrong, or the tun module might be missing completly. For CM9 images try the fix ownership option under general settings"</string>
<string name="tun_open_error">Opening tun interface failed badly.</string>
<string name="error">"Error: "</string>
<string name="clear">Clear</string>
@ -194,10 +194,13 @@
<string name="converted_profile">imported profile</string>
<string name="converted_profile_i">imported profile %d</string>
<string name="broken_images">Broken Images</string>
<string name="broken_images_faq">&lt;p>Offical HTC images are known to have a strange routing problem causing traffic not to flow through the tunnel (See also &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=18\">Issue 18&lt;/a> in the bug tracker.)&lt;/p>&lt;p>The offical SONY images from Xperia arc S and Xperia Ray have been reported to be missing the VPNService completly from the image. Other Sony images may be affected as well. (See also &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=29\">Issue 29&lt;/a> in the bug tracker.)&lt;/p>&lt;p>On custom build images the tun module might be missing or the rights of /dev/tun might be wrong. On the experimental CM9 Defy image a &lt;i>chown system /dev/tun&lt;/i> is needed to make the VPNService API work.&lt;/p></string>
<string name="broken_images_faq">&lt;p>Offical HTC images are known to have a strange routing problem causing traffic not to flow through the tunnel (See also &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=18\">Issue 18&lt;/a> in the bug tracker.)&lt;/p>&lt;p>The offical SONY images from Xperia arc S and Xperia Ray have been reported to be missing the VPNService completly from the image. Other Sony images may be affected as well. (See also &lt;a href=\"http://code.google.com/p/ics-openvpn/issues/detail?id=29\">Issue 29&lt;/a> in the bug tracker.)&lt;/p>&lt;p>On custom build images the tun module might be missing or the rights of /dev/tun might be wrong. Some CM9 images need the fix ownership option under general settings.&lt;/p></string>
<string name="error_empty_username">The username must not be empty.</string>
<string name="pkcs12_file_encryption_key">PKCS12 File Encryption Key</string>
<string name="private_key_password">Private Key Password</string>
<string name="password">Password</string>
<string name="generalsettings">General Settings</string>
<string name="owner_fix_summary">Tries to set the owner of /dev/tun to system. Some CM9 images need this to make the VPNService API work. Requires root.</string>
<string name="owner_fix">Fix owner of /dev/tun</string>
</resources>

View File

@ -5,14 +5,9 @@
android:fragment="de.blinkt.openvpn.VPNProfileList"
android:summary="@string/vpn_list_summary"
android:title="@string/vpn_list_title" />
<!--
<header
<header
android:fragment="de.blinkt.openvpn.GeneralSettings"
android:title="@string/generalsettings" />
-->
<header
android:fragment="de.blinkt.openvpn.FaqFragment"
android:summary="@string/faq_summary"

View File

@ -0,0 +1,17 @@
package de.blinkt.openvpn;
import android.os.Bundle;
import android.preference.PreferenceFragment;
public class GeneralSettings extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.general_settings);
}
}

View File

@ -30,9 +30,11 @@ import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.VpnService;
import android.os.Bundle;
import android.os.Parcelable;
import android.preference.PreferenceManager;
import android.text.InputType;
import android.text.method.PasswordTransformationMethod;
import android.view.View;
@ -76,7 +78,9 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
private ProfileManager mPM;
private VpnProfile mSelectedProfile;
private boolean mCmfixed=false;
static boolean minivpnwritten=false;
@Override
@ -326,6 +330,25 @@ public class LaunchVPN extends ListActivity implements OnItemClickListener {
}
Intent intent = VpnService.prepare(this);
// Check if we want to fix /dev/tun
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean usecm9fix = prefs.getBoolean("useCM9Fix", false);
if(usecm9fix && !mCmfixed ) {
ProcessBuilder pb = new ProcessBuilder(new String[] {"su","-c","chown system /dev/tun"});
try {
Process p = pb.start();
int ret = p.waitFor();
if(ret ==0)
mCmfixed=true;
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
if (intent != null) {
// Start the query