cmd/tailscale: show an error when we hit the multiple users Android bug (#65)

Updates tailscale/tailscale#2180

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
pull/66/head
Andrew Dunham 2 years ago committed by GitHub
parent 901c43c3b9
commit 576b46f8f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -81,6 +81,11 @@ var googleDNSServers = []netip.Addr{
// VPN status was revoked. // VPN status was revoked.
var errVPNNotPrepared = errors.New("VPN service not prepared or was revoked") var errVPNNotPrepared = errors.New("VPN service not prepared or was revoked")
// errMultipleUsers is used when we get a "INTERACT_ACROSS_USERS" error, which
// happens due to a bug in Android. See:
// https://github.com/tailscale/tailscale/issues/2180
var errMultipleUsers = errors.New("VPN cannot be created on this device due to an Android bug with multiple users")
func newBackend(dataDir string, jvm *jni.JVM, appCtx jni.Object, store *stateStore, func newBackend(dataDir string, jvm *jni.JVM, appCtx jni.Object, store *stateStore,
settings settingsFunc) (*backend, error) { settings settingsFunc) (*backend, error) {
@ -266,6 +271,9 @@ func (b *backend) updateTUN(service jni.Object, rcfg *router.Config, dcfg *dns.O
establish := jni.GetMethodID(env, bcls, "establish", "()Landroid/os/ParcelFileDescriptor;") establish := jni.GetMethodID(env, bcls, "establish", "()Landroid/os/ParcelFileDescriptor;")
parcelFD, err := jni.CallObjectMethod(env, builder, establish) parcelFD, err := jni.CallObjectMethod(env, builder, establish)
if err != nil { if err != nil {
if strings.Contains(err.Error(), "INTERACT_ACROSS_USERS") {
return errMultipleUsers
}
return fmt.Errorf("VpnService.Builder.establish: %v", err) return fmt.Errorf("VpnService.Builder.establish: %v", err)
} }
if parcelFD == 0 { if parcelFD == 0 {

@ -368,6 +368,9 @@ func (a *App) runBackend() error {
if service != 0 { if service != 0 {
if cfg.rcfg != nil && state.State >= ipn.Starting { if cfg.rcfg != nil && state.State >= ipn.Starting {
if err := b.updateTUN(service, cfg.rcfg, cfg.dcfg); err != nil { if err := b.updateTUN(service, cfg.rcfg, cfg.dcfg); err != nil {
if errors.Is(err, errMultipleUsers) {
a.pushNotify(service, "Multiple Users", multipleUsersText)
}
log.Printf("VPN update failed: %v", err) log.Printf("VPN update failed: %v", err)
notifyVPNClosed() notifyVPNClosed()
} }
@ -1405,3 +1408,6 @@ func randHex(n int) string {
rand.Read(b) rand.Read(b)
return hex.EncodeToString(b) return hex.EncodeToString(b)
} }
const multipleUsersText = "Tailscale can't start due to an Android bug when multiple users are present on this device. " +
"Please see https://tailscale.com/s/multi-user-bug for more information."

Loading…
Cancel
Save