Search in sources :

Example 1 with LockdownVpnTracker

use of com.android.server.net.LockdownVpnTracker in project platform_frameworks_base by android.

the class ConnectivityService method setLockdownTracker.

/**
     * Internally set new {@link LockdownVpnTracker}, shutting down any existing
     * {@link LockdownVpnTracker}. Can be {@code null} to disable lockdown.
     */
private void setLockdownTracker(LockdownVpnTracker tracker) {
    // Shutdown any existing tracker
    final LockdownVpnTracker existing = mLockdownTracker;
    mLockdownTracker = null;
    if (existing != null) {
        existing.shutdown();
    }
    try {
        if (tracker != null) {
            mNetd.setFirewallEnabled(true);
            mNetd.setFirewallInterfaceRule("lo", true);
            mLockdownTracker = tracker;
            mLockdownTracker.init();
        } else {
            mNetd.setFirewallEnabled(false);
        }
    } catch (RemoteException e) {
    // ignored; NMS lives inside system_server
    }
}
Also used : LockdownVpnTracker(com.android.server.net.LockdownVpnTracker) RemoteException(android.os.RemoteException)

Example 2 with LockdownVpnTracker

use of com.android.server.net.LockdownVpnTracker in project android_frameworks_base by DirtyUnicorns.

the class ConnectivityService method setLockdownTracker.

/**
     * Internally set new {@link LockdownVpnTracker}, shutting down any existing
     * {@link LockdownVpnTracker}. Can be {@code null} to disable lockdown.
     */
private void setLockdownTracker(LockdownVpnTracker tracker) {
    // Shutdown any existing tracker
    final LockdownVpnTracker existing = mLockdownTracker;
    mLockdownTracker = null;
    if (existing != null) {
        existing.shutdown();
    }
    try {
        if (tracker != null) {
            mNetd.setFirewallEnabled(true);
            mNetd.setFirewallInterfaceRule("lo", true);
            mLockdownTracker = tracker;
            mLockdownTracker.init();
        } else {
            mNetd.setFirewallEnabled(false);
        }
    } catch (RemoteException e) {
    // ignored; NMS lives inside system_server
    }
}
Also used : LockdownVpnTracker(com.android.server.net.LockdownVpnTracker) RemoteException(android.os.RemoteException)

Example 3 with LockdownVpnTracker

use of com.android.server.net.LockdownVpnTracker in project android_frameworks_base by ResurrectionRemix.

the class ConnectivityService method setLockdownTracker.

/**
     * Internally set new {@link LockdownVpnTracker}, shutting down any existing
     * {@link LockdownVpnTracker}. Can be {@code null} to disable lockdown.
     */
private void setLockdownTracker(LockdownVpnTracker tracker) {
    // Shutdown any existing tracker
    final LockdownVpnTracker existing = mLockdownTracker;
    mLockdownTracker = null;
    if (existing != null) {
        existing.shutdown();
    }
    try {
        if (tracker != null) {
            mNetd.setFirewallEnabled(true);
            mNetd.setFirewallInterfaceRule("lo", true);
            mLockdownTracker = tracker;
            mLockdownTracker.init();
        } else {
            mNetd.setFirewallEnabled(false);
        }
    } catch (RemoteException e) {
    // ignored; NMS lives inside system_server
    }
}
Also used : LockdownVpnTracker(com.android.server.net.LockdownVpnTracker) RemoteException(android.os.RemoteException)

Example 4 with LockdownVpnTracker

use of com.android.server.net.LockdownVpnTracker in project android_frameworks_base by crdroidandroid.

the class ConnectivityService method updateLockdownVpn.

@Override
public boolean updateLockdownVpn() {
    if (Binder.getCallingUid() != Process.SYSTEM_UID) {
        Slog.w(TAG, "Lockdown VPN only available to AID_SYSTEM");
        return false;
    }
    // Tear down existing lockdown if profile was removed
    mLockdownEnabled = LockdownVpnTracker.isEnabled();
    if (mLockdownEnabled) {
        final String profileName = new String(mKeyStore.get(Credentials.LOCKDOWN_VPN));
        final VpnProfile profile = VpnProfile.decode(profileName, mKeyStore.get(Credentials.VPN + profileName));
        if (profile == null) {
            Slog.e(TAG, "Lockdown VPN configured invalid profile " + profileName);
            setLockdownTracker(null);
            return true;
        }
        int user = UserHandle.getUserId(Binder.getCallingUid());
        synchronized (mVpns) {
            Vpn vpn = mVpns.get(user);
            if (vpn == null) {
                Slog.w(TAG, "VPN for user " + user + " not ready yet. Skipping lockdown");
                return false;
            }
            setLockdownTracker(new LockdownVpnTracker(mContext, mNetd, this, vpn, profile));
        }
    } else {
        setLockdownTracker(null);
    }
    return true;
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) Vpn(com.android.server.connectivity.Vpn) LockdownVpnTracker(com.android.server.net.LockdownVpnTracker) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString)

Example 5 with LockdownVpnTracker

use of com.android.server.net.LockdownVpnTracker in project platform_frameworks_base by android.

the class ConnectivityService method updateLockdownVpn.

@Override
public boolean updateLockdownVpn() {
    if (Binder.getCallingUid() != Process.SYSTEM_UID) {
        Slog.w(TAG, "Lockdown VPN only available to AID_SYSTEM");
        return false;
    }
    // Tear down existing lockdown if profile was removed
    mLockdownEnabled = LockdownVpnTracker.isEnabled();
    if (mLockdownEnabled) {
        byte[] profileTag = mKeyStore.get(Credentials.LOCKDOWN_VPN);
        if (profileTag == null) {
            Slog.e(TAG, "Lockdown VPN configured but cannot be read from keystore");
            return false;
        }
        String profileName = new String(profileTag);
        final VpnProfile profile = VpnProfile.decode(profileName, mKeyStore.get(Credentials.VPN + profileName));
        if (profile == null) {
            Slog.e(TAG, "Lockdown VPN configured invalid profile " + profileName);
            setLockdownTracker(null);
            return true;
        }
        int user = UserHandle.getUserId(Binder.getCallingUid());
        synchronized (mVpns) {
            Vpn vpn = mVpns.get(user);
            if (vpn == null) {
                Slog.w(TAG, "VPN for user " + user + " not ready yet. Skipping lockdown");
                return false;
            }
            setLockdownTracker(new LockdownVpnTracker(mContext, mNetd, this, vpn, profile));
        }
    } else {
        setLockdownTracker(null);
    }
    return true;
}
Also used : VpnProfile(com.android.internal.net.VpnProfile) Vpn(com.android.server.connectivity.Vpn) LockdownVpnTracker(com.android.server.net.LockdownVpnTracker) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString)

Aggregations

LockdownVpnTracker (com.android.server.net.LockdownVpnTracker)12 RemoteException (android.os.RemoteException)6 VpnProfile (com.android.internal.net.VpnProfile)6 NetworkPolicyManager.uidRulesToString (android.net.NetworkPolicyManager.uidRulesToString)5 Vpn (com.android.server.connectivity.Vpn)5