Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions cli/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
Expand All @@ -22,6 +23,15 @@ import (
// insecureStorage is bound to the global --insecure-storage flag.
var insecureStorage bool

// useFileStorage reports whether the token lives in the credentials file rather
// than the OS keyring. That is the case when --insecure-storage is set, and
// always on Android (Termux), which has no keyring and where probing for one
// kills the process: the seccomp filter rejects the faccessat2 syscall that
// exec.LookPath makes, so the keyring backend crashes with SIGSYS.
func useFileStorage() bool {
return insecureStorage || runtime.GOOS == "android" || os.Getenv("TERMUX_VERSION") != ""
}

// credentialsFilePath returns the path to the plaintext token file used when
// --insecure-storage is set: $XDG_CONFIG_HOME/mobilecli/credentials, falling
// back to ~/.config/mobilecli/credentials. We deliberately use ~/.config on
Expand All @@ -42,7 +52,7 @@ func credentialsFilePath() (string, error) {
// storeToken saves the token in the keyring, or in the credentials file when
// --insecure-storage is set.
func storeToken(token string) error {
if insecureStorage {
if useFileStorage() {
return storeTokenInFile(token)
}
if err := keyring.Set(keyringService, keyringUser, token); err != nil {
Expand Down Expand Up @@ -74,7 +84,7 @@ func loadToken() (string, error) {
return token, nil
}

if insecureStorage {
if useFileStorage() {
return loadTokenFromFile()
}

Expand Down Expand Up @@ -155,7 +165,7 @@ func loadTokenFromFile() (string, error) {
// deleteToken removes the stored token. It returns keyring.ErrNotFound when no
// token was stored, so logout can report "not logged in".
func deleteToken() error {
if insecureStorage {
if useFileStorage() {
path, err := credentialsFilePath()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion publish/npm-linux-amd64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"url": "git+https://github.com/mobile-next/mobilecli.git"
},
"license": "FSL-1.1-ALv2",
"os": ["linux"],
"os": ["linux", "android"],
"cpu": ["x64"]
}
2 changes: 1 addition & 1 deletion publish/npm-linux-arm64/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"url": "git+https://github.com/mobile-next/mobilecli.git"
},
"license": "FSL-1.1-ALv2",
"os": ["linux"],
"os": ["linux", "android"],
"cpu": ["arm64"]
}
1 change: 1 addition & 0 deletions publish/npm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ switch (process.platform) {
break;

case "linux":
case "android":
Comment thread
coderabbitai[bot] marked this conversation as resolved.
switch (process.arch) {
case "arm64":
packageName = "@mobilenext/mobilecli-linux-arm64";
Expand Down