diff --git a/build-helper.bat b/build-helper.bat new file mode 100644 index 00000000..d8e8c54d --- /dev/null +++ b/build-helper.bat @@ -0,0 +1,10 @@ +@echo off + +echo Building authenticator-helper for Windows... +cd helper +poetry install +rmdir /s /q ..\build\windows\helper +poetry run pyinstaller authenticator-helper.spec --distpath ..\build\windows +cd .. + +echo All done, output in build/windows/ diff --git a/build-ykman.sh b/build-helper.sh similarity index 53% rename from build-ykman.sh rename to build-helper.sh index 31b44f1d..abba3558 100755 --- a/build-ykman.sh +++ b/build-helper.sh @@ -15,22 +15,22 @@ case "$(uname)" in OS="windows";; esac -echo "Building ykman-rpc for $OS..." +echo "Building authenticator-helper for $OS..." OUTPUT="build/$OS" -cd ykman-rpc +cd helper poetry install -rm -rf ../$OUTPUT/ykman-rpc -poetry run pyinstaller ykman-rpc.spec --distpath ../$OUTPUT +rm -rf ../$OUTPUT/helper +poetry run pyinstaller authenticator-helper.spec --distpath ../$OUTPUT cd .. # Fixup permissions (should probably be more strict) -find $OUTPUT/ykman-rpc -type f -exec chmod a-x {} + -chmod a+x $OUTPUT/ykman-rpc/ykman-rpc +find $OUTPUT/helper -type f -exec chmod a-x {} + +chmod a+x $OUTPUT/helper/authenticator-helper # Adhoc sign executable (MacOS) if [ "$OS" = "macos" ]; then - codesign -f --timestamp --entitlements macos/ykman.entitlements --sign - $OUTPUT/ykman-rpc/ykman-rpc + codesign -f --timestamp --entitlements macos/helper.entitlements --sign - $OUTPUT/helper/authenticator-helper fi echo "All done, output in $OUTPUT/" diff --git a/build-ykman.bat b/build-ykman.bat deleted file mode 100644 index 164c4b9b..00000000 --- a/build-ykman.bat +++ /dev/null @@ -1,10 +0,0 @@ -@echo off - -echo Building ykman-rpc for Windows... -cd ykman-rpc -poetry install -rmdir /s /q ..\build\windows\ykman-rpc -poetry run pyinstaller ykman-rpc.spec --distpath ..\build\windows -cd .. - -echo All done, output in build/windows/ diff --git a/ykman-rpc/.gitignore b/helper/.gitignore similarity index 100% rename from ykman-rpc/.gitignore rename to helper/.gitignore diff --git a/ykman-rpc/ykman-rpc.exe.manifest b/helper/authenticator-helper.exe.manifest similarity index 100% rename from ykman-rpc/ykman-rpc.exe.manifest rename to helper/authenticator-helper.exe.manifest diff --git a/ykman-rpc/ykman-rpc.py b/helper/authenticator-helper.py similarity index 90% rename from ykman-rpc/ykman-rpc.py rename to helper/authenticator-helper.py index 6bf6c7d9..da94ee3e 100644 --- a/ykman-rpc/ykman-rpc.py +++ b/helper/authenticator-helper.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from rpc import run_rpc_pipes, run_rpc_socket +from helper import run_rpc_pipes, run_rpc_socket import socket import sys diff --git a/ykman-rpc/ykman-rpc.spec b/helper/authenticator-helper.spec similarity index 86% rename from ykman-rpc/ykman-rpc.spec rename to helper/authenticator-helper.spec index 27f696b5..4c260d56 100755 --- a/ykman-rpc/ykman-rpc.spec +++ b/helper/authenticator-helper.spec @@ -5,7 +5,7 @@ block_cipher = None a = Analysis( - ["ykman-rpc.py"], + ["authenticator-helper.py"], pathex=[], binaries=[], datas=[], @@ -26,14 +26,14 @@ exe = EXE( a.scripts, [], exclude_binaries=True, - name="ykman-rpc", + name="authenticator-helper", icon="NONE", debug=False, bootloader_ignore_signals=False, strip=False, upx=True, console=True, - manifest="ykman-rpc.exe.manifest", + manifest="authenticator-helper.exe.manifest", version="version_info.txt", disable_windowed_traceback=False, target_arch=None, @@ -48,5 +48,5 @@ coll = COLLECT( strip=False, upx=True, upx_exclude=[], - name="ykman-rpc", + name="helper", ) diff --git a/ykman-rpc/rpc/__init__.py b/helper/helper/__init__.py similarity index 100% rename from ykman-rpc/rpc/__init__.py rename to helper/helper/__init__.py diff --git a/ykman-rpc/rpc/base.py b/helper/helper/base.py similarity index 100% rename from ykman-rpc/rpc/base.py rename to helper/helper/base.py diff --git a/ykman-rpc/rpc/device.py b/helper/helper/device.py similarity index 100% rename from ykman-rpc/rpc/device.py rename to helper/helper/device.py diff --git a/ykman-rpc/rpc/fido.py b/helper/helper/fido.py similarity index 100% rename from ykman-rpc/rpc/fido.py rename to helper/helper/fido.py diff --git a/ykman-rpc/rpc/management.py b/helper/helper/management.py similarity index 100% rename from ykman-rpc/rpc/management.py rename to helper/helper/management.py diff --git a/ykman-rpc/rpc/oath.py b/helper/helper/oath.py similarity index 100% rename from ykman-rpc/rpc/oath.py rename to helper/helper/oath.py diff --git a/ykman-rpc/rpc/qr.py b/helper/helper/qr.py similarity index 100% rename from ykman-rpc/rpc/qr.py rename to helper/helper/qr.py diff --git a/ykman-rpc/rpc/yubiotp.py b/helper/helper/yubiotp.py similarity index 100% rename from ykman-rpc/rpc/yubiotp.py rename to helper/helper/yubiotp.py diff --git a/ykman-rpc/poetry.lock b/helper/poetry.lock similarity index 100% rename from ykman-rpc/poetry.lock rename to helper/poetry.lock diff --git a/ykman-rpc/pyproject.toml b/helper/pyproject.toml similarity index 88% rename from ykman-rpc/pyproject.toml rename to helper/pyproject.toml index 838550af..2ea23dfa 100644 --- a/ykman-rpc/pyproject.toml +++ b/helper/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] -name = "ykman-rpc" +name = "authenticator-helper" version = "0.1.0" -description = "Yubico Authenticator helper app" +description = "Yubico Authenticator Helper" authors = ["Dain Nilsson "] [tool.poetry.dependencies] diff --git a/ykman-rpc/shell.py b/helper/shell.py similarity index 95% rename from ykman-rpc/shell.py rename to helper/shell.py index d83b75fe..e37f3242 100755 --- a/ykman-rpc/shell.py +++ b/helper/shell.py @@ -228,22 +228,22 @@ def log_stderr(stderr): @click.command() @click.argument("executable", nargs=-1) def shell(executable): - """A basic shell for interacting with the ykman rpc.""" - rpc = subprocess.Popen( # nosec - executable or [sys.executable, "ykman-rpc.py"], + """A basic shell for interacting with the Yubico Authenticator Helper.""" + helper = subprocess.Popen( # nosec + executable or [sys.executable, "authenticator-helper.py"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf8", ) - Thread(daemon=True, target=log_stderr, args=(rpc.stderr,)).start() + Thread(daemon=True, target=log_stderr, args=(helper.stderr,)).start() click.echo("Shell starting...") - shell = RpcShell(rpc.stdin, cast(IO[str], rpc.stdout)) + shell = RpcShell(helper.stdin, cast(IO[str], helper.stdout)) shell.cmdloop() click.echo("Stopping...") - rpc.communicate() + helper.communicate() if __name__ == "__main__": diff --git a/ykman-rpc/version_info.txt b/helper/version_info.txt similarity index 100% rename from ykman-rpc/version_info.txt rename to helper/version_info.txt diff --git a/lib/desktop/init.dart b/lib/desktop/init.dart index 3286e5ed..79d5829c 100755 --- a/lib/desktop/init.dart +++ b/lib/desktop/init.dart @@ -59,10 +59,10 @@ Future initialize(List argv) async { } })); - // Either use the _YKMAN_EXE environment variable, or look relative to executable. - var exe = Platform.environment['_YKMAN_PATH']; + // Either use the _HELPER_PATH environment variable, or look relative to executable. + var exe = Platform.environment['_HELPER_PATH']; if (exe?.isEmpty ?? true) { - var relativePath = 'ykman-rpc/ykman-rpc'; + var relativePath = 'helper/authenticator-helper'; if (Platform.isMacOS) { relativePath = '../Resources/' + relativePath; } else if (Platform.isWindows) { @@ -73,10 +73,10 @@ Future initialize(List argv) async { .toFilePath(); } - _log.info('Starting subprocess: $exe'); + _log.info('Starting Helper subprocess: $exe'); final rpc = RpcSession(exe!); await rpc.initialize(); - _log.info('ykman-rpc process started', exe); + _log.info('Helper process started', exe); rpc.setLogLevel(Logger.root.level); return ProviderScope( diff --git a/lib/desktop/rpc.dart b/lib/desktop/rpc.dart index 2d93ed2b..88dbee99 100644 --- a/lib/desktop/rpc.dart +++ b/lib/desktop/rpc.dart @@ -10,7 +10,7 @@ import 'package:yubico_authenticator/app/logging.dart'; import '../app/models.dart'; import 'models.dart'; -final _log = Logger('rpc'); +final _log = Logger('helper'); class Signaler { final _send = StreamController(); @@ -92,7 +92,7 @@ class RpcSession { static void _logEntry(String entry) { try { final record = jsonDecode(entry); - Logger('rpc.${record['name']}').log( + Logger('helper.${record['name']}').log( _py2level[record['level']] ?? Level.INFO, record['message'], record['exc_text'], @@ -105,7 +105,7 @@ class RpcSession { Future initialize() async { final process = await Process.start(executable, []); - _log.debug('RPC process started'); + _log.debug('Helper process started'); process.stderr .transform(const Utf8Decoder()) .transform(const LineSplitter()) @@ -133,7 +133,7 @@ class RpcSession { // Bind to random port final server = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0); final port = server.port; - _log.debug('Listening for RPC connection on $port'); + _log.debug('Listening for Helper connection on $port'); // Launch the elevated process final process = @@ -150,15 +150,15 @@ class RpcSession { .transform(const Utf8Decoder()) .transform(const LineSplitter()) .join('\n'); - _log.warning('Failed to elevate RPC process', error); + _log.warning('Failed to elevate the Helper process', error); return false; } - _log.debug('Elevated RPC process started'); + _log.debug('Elevated Helper process started'); // Accept only a single connection final client = await server.first; await server.close(); - _log.debug('Client connected: $client'); + _log.debug('Helper connected: $client'); // Stop the old subprocess. try { @@ -174,12 +174,12 @@ class RpcSession { // The nonce needs to be received first. if (!authenticated) { if (nonce == line) { - _log.debug('Client authenticated with correct nonce'); + _log.debug('Helper authenticated with correct nonce'); authenticated = true; completer.complete(); return ''; } else { - _log.warning('Client used WRONG NONCE: $line'); + _log.warning('Helper used WRONG NONCE: $line'); client.close(); completer.completeError(Exception('Invalid nonce')); throw Exception('Invalid nonce'); diff --git a/macos/ykman-sandbox.entitlements b/macos/helper-sandbox.entitlements similarity index 100% rename from macos/ykman-sandbox.entitlements rename to macos/helper-sandbox.entitlements diff --git a/macos/ykman.entitlements b/macos/helper.entitlements similarity index 100% rename from macos/ykman.entitlements rename to macos/helper.entitlements