Skip to content

Commit fb2c7f8

Browse files
Add should_default_ccid helper
1 parent 8306d9c commit fb2c7f8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/nitrokey/should_use_ccid.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import ctypes
2+
import sys
3+
4+
5+
def should_default_ccid() -> bool:
6+
try:
7+
import smartcard
8+
except ImportError:
9+
return False
10+
11+
if sys.platform != "win32" and sys.platform != "cygwin":
12+
# Linux or MacOS don't need admin to access with CTAPHID
13+
return False
14+
15+
try:
16+
if ctypes.windll.shell32.IsUserAnAdmin():
17+
return False
18+
else:
19+
return True
20+
except Exception:
21+
return False

0 commit comments

Comments
 (0)