mihomo-party-org/clash-party · warning

Admin restart detected but no admin privileges found

Error message

Admin restart detected but no admin privileges found

What it means

checkAdminRestartForTun resumes after an expected elevated relaunch and checks an 'admin restart' marker. This warning is logged when the marker says a restart with admin rights happened, but the current process still lacks admin privileges — so TUN cannot be auto-enabled. It signals the elevation handshake failed or the check ran in the non-elevated instance.

Source

Thrown at src/main/core/permissions.ts:399

      if (process.platform === 'win32') {
        const hasAdminPrivileges = await checkAdminPrivileges()
        if (hasAdminPrivileges) {
          await patchControledMihomoConfig({ tun: { enable: true }, dns: { enable: true } })

          const autoRunEnabled = await checkAutoRun()
          if (autoRunEnabled) {
            await enableAutoRun()
          }

          await restartCore()

          managerLogger.info('TUN mode auto-enabled after admin restart')

          const { mainWindow } = await import('../index')
          mainWindow?.webContents.send('controledMihomoConfigUpdated')
          ipcMain.emit('updateTrayMenu')
        } else {
          managerLogger.warn('Admin restart detected but no admin privileges found')
        }
      }
    } catch (error) {
      managerLogger.error('Failed to auto-enable TUN after admin restart', error)
    }
  } else {
    await validateTunPermissionsOnStartup(restartCore)
  }
}

export function checkTunPermissions(): Promise<boolean> {
  return checkMihomoCorePermissions()
}

export function manualGrantCorePermition(): Promise<void> {
  return grantTunPermissions()
}

View on GitHub (pinned to 911e090537)

Solutions

  1. Clear the stale admin-restart marker/flag so normal launches do not enter this branch.
  2. Retry the elevation: trigger checkAdminRestartForTun again and confirm the elevated relaunch actually spawns with admin rights (verify with isAdmin() in the child).
  3. On Linux/macOS ensure the relaunch command genuinely elevates (sudo/pkexec/osascript with administrator privileges).

Example fix

// before
if (markerExists) { /* assumes admin */ }
// after
if (markerExists) {
  if (await isAdmin()) {
    await patchControledMihomoConfig({ tun: { enable: true } })
  } else {
    await clearAdminRestartMarker() // avoid stale marker loops
  }
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(await isAdmin())) {
  await clearAdminRestartMarker() // stale marker -> skip auto-enable branch
  return
}

Type guard

const isAdmin = (): boolean =>
  process.platform === 'win32'
    ? /* net session probe or elevation check */ true
    : typeof process.getuid === 'function' && process.getuid() === 0

Try / catch

try {
  await checkAdminRestartForTun()
} catch (e) {
  logger.error('admin-restart TUN flow failed', e)
  await clearAdminRestartMarker()
}

Prevention

When it happens

Trigger: The admin-restart marker/flag exists (e.g. leftover from a previous run or set before relaunch) but isAdmin() returns false in the current process — e.g. UAC elevation was declined, the elevated child failed to start and the normal instance handled the marker, or the marker file was not cleaned up.

Common situations: User cancels the OS UAC/admin prompt; on Linux the app was relaunched without sudo; stale marker file persisted from a crash so the next normal launch takes the admin-restart branch.

Related errors


AI-assisted analysis of mihomo-party-org/clash-party@911e090537 (2026-08-30). Data as JSON: /api/errors/f98dbc6ed66de933. Report an issue: GitHub.