working login

This commit is contained in:
Andras Schmelczer 2026-09-13 22:03:44 +01:00
commit 21859bcfb3
4 changed files with 260 additions and 1 deletions

110
BUILDING.md Normal file
View file

@ -0,0 +1,110 @@
# Linux build
The project targets **Unity 2018.1.6f1**. Keep this version for now: the
simulation uses the bundled UNet networking API and the legacy .NET runtime.
No engine migration has been made.
## Toolchain
The following tools were installed and launched on this Debian 13 x86_64 host:
- Unity Editor: `/opt/unity/2018.1.6f1/Editor/Unity`, including Linux player support.
- Blender 2.79b: `/opt/blender-2.79b-linux-glibc219-x86_64/blender`, also available
as `blender` on PATH. The project's Blender models use the 2.79 file format.
- GTK 2, libsoup 2.4, GLU, and GConf 2 compatibility libraries. GConf was installed
from Debian's `libgconf-2-4_3.2.6-8_amd64.deb` and
`gconf2-common_3.2.6-8_all.deb`; Debian 13 no longer ships those packages.
- Xvfb and xauth for running the old editor without a desktop display.
Downloads: [Unity 2018.1.6f1](https://unity.com/releases/editor/whats-new/2018.1.6f1),
[Blender 2.79b](https://download.blender.org/release/Blender2.79/),
[Debian GConf packages](https://deb.debian.org/debian/pool/main/g/gconf/).
## Build command
Once Unity is activated and the damaged source assets below are restored:
```sh
./build-linux.sh
```
For an editor installed elsewhere:
```sh
UNITY_EDITOR=/path/to/2018.1.6f1/Editor/Unity ./build-linux.sh
```
The intended output is `Builds/linux/Simulation.x86_64`, with its accompanying
data directory. The editor log is `Builds/linux/build.log`. The build uses
`Assets/Scenes/Main.unity`; the original settings incorrectly named the absent
`SampleScene.unity` despite already containing Main's GUID.
The existing standalone startup code selects the client menu. This build command
preserves that behavior.
## Current blockers and verification
**No Linux executable has been built.** The editor starts, but the attempted
batch build exits with status 1 at license activation:
```text
Failed to activate/update license. Missing or bad username and password.
```
Unity Personal is free for eligible users, but still requires activation.
For a desktop session, sign in to Unity Hub, then use Settings > Licenses >
Add license > Get a free personal license if it is not activated automatically.
See [Unity's Hub license instructions](https://docs.unity.com/en-us/hub/manage-license).
For SSH access, Unity CLI 1.0.0-beta.9 is installed at
`/root/.local/bin/unity`, along with GNOME Keyring and `libsecret-tools`.
Its login command prints a URL that can be opened in a browser on another
device. Run `./unity-ssh.sh` as the same Linux user that will run the build.
It starts a private D-Bus session and a dedicated Unity keyring under
`~/.local/share/unity-ssh/keyrings`, leaving the desktop login keyring intact.
Choose a password on first use and use the same password when reopening the
helper. This password protects saved credentials locally; enter your Unity
account password only on Unity's sign-in page. The helper verifies that the
keyring can store and retrieve a test credential before opening a shell.
In that shell, run:
```sh
unity auth login
unity license activate --personal --accept-eula
unity license status
```
The activation command accepts the Unity Personal license terms. Type `exit`
when finished to close the shell and its keyring session.
The command options and browser-assisted login startup have been checked here.
Keyring tests with temporary credentials cover creation, reopening, incorrect
password rejection, inherited desktop sessions, and concurrent-session
rejection. The CLI's own credential-store check resolves the Secret Service
backend inside the helper. Run `./unity-ssh.sh --check` to check the keyring
without starting a Unity sign-in.
Sign-in, activation, and compatibility with the old editor still need to be
verified. See [Unity CLI instructions](https://docs.unity.com/en-us/unity-cli/use-unity-cli)
and [release notes](https://docs.unity.com/en-us/unity-cli/release-notes).
There is also existing file corruption, independent of activation. An audit
found **33 asset files whose contents are Unity metadata instead of their
expected source/model/image/material data**. Five of these are C# source files:
- `UnityProject/Assets/Scripts/CarLL.cs`
- `UnityProject/Assets/Scripts/misc/trafficLightColor.cs`
- `UnityProject/Assets/Standard Assets/CrossPlatformInput/Scripts/VirtualInput.cs`
- `UnityProject/Assets/!ext/PostProcessing/Editor/PostProcessingInspector.cs`
- `UnityProject/Assets/!ext/PostProcessing/Editor/Monitors/WaveformMonitor.cs`
A separate compilation attempt with Unity's bundled Mono compiler and genuine
2018.1 assemblies fails with `CS8025: Parsing error` in `VirtualInput.cs`.
The full asset list is in the local `Builds/linux/source-audit.txt`; compiler
output is in `Builds/linux/script-check/compile.log`.
Some metadata is damaged too: there are duplicated GUIDs, source code stored in
`.cs.meta` files, and empty directories with `.meta` names. The file at
`UnityProject/Scripts/CarLL.cs` is not a usable backup: it contains a
`TrafficController` class. A clean original checkout/archive is needed to
restore these files reliably. Existing assets and the old Library cache were
left intact.

View file

@ -6,6 +6,6 @@ EditorBuildSettings:
serializedVersion: 2
m_Scenes:
- enabled: 1
path: Assets/Scenes/SampleScene.unity
path: Assets/Scenes/Main.unity
guid: 99c9720ab356a0642a771bea13969a05
m_configObjects: {}

42
build-linux.sh Executable file
View file

@ -0,0 +1,42 @@
#!/usr/bin/env bash
set -euo pipefail
repo_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
unity_editor="${UNITY_EDITOR:-/opt/unity/2018.1.6f1/Editor/Unity}"
output_dir="$repo_dir/Builds/linux"
log_file="$output_dir/build.log"
if [[ ! -x "$unity_editor" ]]; then
echo "Set UNITY_EDITOR to the Unity 2018.1.6f1 Editor/Unity executable." >&2
exit 1
fi
mkdir -p "$output_dir"
echo "Building Linux x86_64 player; log: $log_file"
# Unity 2018 on Linux still needs an X server in batch mode.
runner=()
if [[ -z "${DISPLAY:-}" ]]; then
if ! command -v xvfb-run >/dev/null; then
echo "Install xvfb and xauth for builds without a display." >&2
exit 1
fi
runner=(xvfb-run -a)
fi
if "${runner[@]}" "$unity_editor" \
-batchmode -nographics -quit \
-projectPath "$repo_dir/UnityProject" \
-buildTarget Linux64 \
-buildLinux64Player "$output_dir/Simulation.x86_64" \
-logFile "$log_file"; then
if [[ ! -x "$output_dir/Simulation.x86_64" ]]; then
echo "Unity exited without producing a Linux player. See $log_file." >&2
exit 1
fi
echo "Built $output_dir/Simulation.x86_64"
else
result=$?
[[ ! -f "$log_file" ]] || tail -n 60 "$log_file" >&2
exit "$result"
fi

107
unity-ssh.sh Executable file
View file

@ -0,0 +1,107 @@
#!/usr/bin/env bash
set -euo pipefail
unity_cli="${UNITY_CLI:-$HOME/.local/bin/unity}"
if [[ ! -x "$unity_cli" ]]; then
echo "Set UNITY_CLI to the installed Unity CLI executable." >&2
exit 1
fi
# Always use a private bus, including when SSH inherited a desktop bus.
if [[ "${1:-}" != --keyring-session ]]; then
exec dbus-run-session -- bash "$0" --keyring-session "$@"
fi
shift
unset GNOME_KEYRING_CONTROL
# Give Unity its own credential collection. Do not read or modify the user's
# desktop login.keyring, which may be locked, damaged, or in use elsewhere.
keyring_data_dir="${UNITY_SSH_KEYRING_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/unity-ssh}"
umask 077
mkdir -p "$keyring_data_dir"
exec 9>"$keyring_data_dir/session.lock"
if ! flock -n 9; then
echo "A Unity SSH keyring session is already open. Exit it before starting another." >&2
exit 1
fi
read -r -s -p "Unity keyring password (choose one on first use): " unity_keyring_password
echo
if [[ -z "$unity_keyring_password" ]]; then
echo "A nonempty password is required for the encrypted keyring." >&2
exit 1
fi
runtime_dir="$(mktemp -d "${TMPDIR:-/tmp}/unity-keyring.XXXXXX")"
daemon_pid=""
cleanup() {
if [[ -n "$daemon_pid" ]]; then
kill "$daemon_pid" 2>/dev/null || true
wait "$daemon_pid" 2>/dev/null || true
fi
rm -rf -- "$runtime_dir"
}
trap cleanup EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
# Keep the daemon on this bus, wait for it to register, and stop it on exit.
# Only the daemon sees the alternate data directory; Unity keeps its normal
# configuration and license-file locations.
XDG_DATA_HOME="$keyring_data_dir" gnome-keyring-daemon \
--foreground --unlock --components=secrets --control-directory="$runtime_dir" \
< <(printf '%s' "$unity_keyring_password") >"$runtime_dir/daemon.log" 2>&1 &
daemon_pid=$!
unset unity_keyring_password
owner='(false,)'
for (( attempt=0; attempt<100; attempt++ )); do
owner="$(gdbus call --session --dest org.freedesktop.DBus \
--object-path /org/freedesktop/DBus \
--method org.freedesktop.DBus.NameHasOwner org.freedesktop.secrets)"
[[ "$owner" != '(true,)' ]] || break
kill -0 "$daemon_pid" 2>/dev/null || break
sleep 0.1
done
if [[ "$owner" != '(true,)' ]]; then
echo "The Unity keyring service did not start." >&2
cat "$runtime_dir/daemon.log" >&2
exit 1
fi
locked="$(gdbus call --session --dest org.freedesktop.secrets \
--object-path /org/freedesktop/secrets/collection/login \
--method org.freedesktop.DBus.Properties.Get org.freedesktop.Secret.Collection Locked 2>/dev/null)" || locked='missing'
if [[ "$locked" != '(<false>,)' ]]; then
echo "Could not unlock the Unity keyring at $keyring_data_dir/keyrings." >&2
echo "Use the password chosen for this helper. No credential files were removed." >&2
exit 1
fi
# Check persistence before asking the user to complete a browser sign-in.
probe="unity-ssh-$$-$RANDOM"
printf '%s' "$probe" | timeout 10 secret-tool store --label='Unity SSH keyring check' unity-ssh-check "$probe"
saved="$(timeout 10 secret-tool lookup unity-ssh-check "$probe")"
timeout 10 secret-tool clear unity-ssh-check "$probe"
if [[ "$saved" != "$probe" ]]; then
echo "The Unity keyring could not save and retrieve a test credential." >&2
exit 1
fi
echo "Unity keyring storage check passed."
export PATH="$(dirname -- "$unity_cli"):$PATH"
export UNITY_NO_CLI_INVOKED_TELEMETRY=1
if [[ "${1:-}" == --check ]]; then
exit 0
fi
if (( $# )); then
"$unity_cli" "$@"
exit $?
fi
echo "Unity login shell ready. Run: unity auth login"
echo "Open the printed sign-in URL in your own computer's browser."
echo "After signing in and reviewing the Personal terms, run:"
echo " unity license activate --personal --accept-eula"
echo " unity license status"
echo "Type exit to close this shell and its keyring session."
bash --noprofile --norc -i