Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Simplify CLI config safeguards and startup coverage

Neeraj Gupta6b8d825ebab8
diff --git a/cli/cmd/root.go b/cli/cmd/root.go
index 832451f71c..19154a0c8f 100644
--- a/cli/cmd/root.go
+++ b/cli/cmd/root.go
@@ -24,15 +24,13 @@ func GenerateDocs() error {
return doc.GenMarkdownTree(rootCmd, "./docs/generated")
}
-func Execute(controller *pkg.ClICtrl, ver string, beforeNetwork func() error) {
+func Execute(controller *pkg.ClICtrl, ver string, networkConfigErr error) {
ctrl = controller
version = ver
rootCmd.PersistentPreRunE = func(command *cobra.Command, args []string) error {
network := command == exportCmd || command == addAccCmd || command.Parent() == _adminCmd
- if network {
- if err := beforeNetwork(); err != nil {
- return err
- }
+ if network && networkConfigErr != nil {
+ return networkConfigErr
}
if network || command.Parent() == accountCmd {
ctrl.KeyHolder = secrets.NewKeyHolder(secrets.GetOrCreateClISecret())
diff --git a/cli/docs/selfhost.md b/cli/docs/selfhost.md
index 7f13402622..3cbf2a3e6e 100644
--- a/cli/docs/selfhost.md
+++ b/cli/docs/selfhost.md
@@ -4,9 +4,7 @@ If you are self-hosting the server, you can still configure CLI to export data &
To do this, first configure the CLI to point to your server. Define a `config.yaml` and put it in `~/.ente/` or the directory specified by `ENTE_CLI_CONFIG_DIR`.
-`ENTE_CLI_CONFIG_DIR` selects both configuration and the saved account database. The legacy `ENTE_CLI_CONFIG_PATH` is used only when `ENTE_CLI_CONFIG_DIR` is unset. For example, use `ENTE_CLI_CONFIG_DIR=/path/to/existing-cli-directory ente export` when that directory already contains the accounts you intend to use.
-
-If you previously kept configuration in the working directory, migrate its settings into the existing configuration directory, then remove or rename the old file. Network commands stop while a separate working-directory config exists; local account commands remain available. Selecting a different directory, including `.`, also selects a different account database. Invalid trusted configuration must be corrected before running commands.
+`ENTE_CLI_CONFIG_DIR` selects configuration and saved accounts; `ENTE_CLI_CONFIG_PATH` is the legacy fallback. See [configuration migration](../../docs/docs/self-hosting/administration/cli.md#step-1-configure-endpoint) before switching from a working-directory config.
```yaml
endpoint:
diff --git a/cli/main.go b/cli/main.go
index 92b208a6fd..96c65c2306 100644
--- a/cli/main.go
+++ b/cli/main.go
@@ -12,6 +12,7 @@ import (
"log"
"os"
"path/filepath"
+ "slices"
"strings"
)
@@ -79,9 +80,7 @@ func main() {
if os.Args[1] == "version" && viper.GetString("endpoint.api") != constants.EnteApiUrl {
log.Printf("Custom endpoint: %s\n", viper.GetString("endpoint.api"))
}
- cmd.Execute(&ctrl, AppVersion, func() error {
- return checkWorkingDirectoryConfig(cliConfigDir)
- })
+ cmd.Execute(&ctrl, AppVersion, checkWorkingDirectoryConfig(cliConfigDir))
}
func initConfig(cliConfigDir string) error {
@@ -97,13 +96,8 @@ func initConfig(cliConfigDir string) error {
}
}
value := viper.Get("endpoint.api")
- hasEndpoint := value != nil
- for _, key := range viper.AllKeys() {
- if key == "endpoint" || key == "endpoint.api" {
- hasEndpoint = true
- }
- }
- if hasEndpoint {
+ keys := viper.AllKeys()
+ if value != nil || slices.Contains(keys, "endpoint") || slices.Contains(keys, "endpoint.api") {
endpoint, ok := value.(string)
if !ok || strings.TrimSpace(endpoint) == "" {
return fmt.Errorf("invalid endpoint.api in trusted configuration %q; expected a non-empty string", path)
@@ -165,7 +159,7 @@ func checkWorkingDirectoryConfig(cliConfigDir string) error {
return fmt.Errorf("cannot inspect working-directory configuration")
}
if path != "" {
- return fmt.Errorf("refusing network command: working-directory configuration %q is ignored. Migrate your settings into %q, then remove or rename the working-directory file. ENTE_CLI_CONFIG_DIR selects both configuration and account storage", path, cliConfigDir)
+ return fmt.Errorf("refusing network command: working-directory configuration %q is ignored. If it contains your intended Ente CLI settings, migrate them into %q and remove or rename the old file; otherwise run from another directory. ENTE_CLI_CONFIG_DIR selects both configuration and account storage", path, cliConfigDir)
}
return nil
}
diff --git a/cli/main_test.go b/cli/main_test.go
index 50e9cd2211..0562ba42fe 100644
--- a/cli/main_test.go
+++ b/cli/main_test.go
@@ -49,21 +49,13 @@ func TestCLIConfigDiscovery(t *testing.T) {
root := t.TempDir()
home := filepath.Join(root, "home")
cwd := filepath.Join(root, "cwd")
- if err := os.MkdirAll(home, 0700); err != nil {
- t.Fatal(err)
- }
writeConfig := func(path, endpoint string) {
t.Helper()
- if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
- t.Fatal(err)
- }
body := "endpoint:\n api: " + endpoint + "\n"
if filepath.Ext(path) == ".json" {
body = `{"endpoint":{"api":"` + endpoint + `"}}`
}
- if err := os.WriteFile(path, []byte(body), 0600); err != nil {
- t.Fatal(err)
- }
+ writeTestConfig(t, path, body)
}
writeConfig(filepath.Join(cwd, tt.cwdConfig), "https://untrusted.invalid")
if tt.trustedConfig != "" {
diff --git a/cli/startup_test.go b/cli/startup_test.go
index d2bf4f4d0a..7f7a043a04 100644
--- a/cli/startup_test.go
+++ b/cli/startup_test.go
@@ -3,8 +3,10 @@ package main
import (
"bytes"
"context"
+ "encoding/base64"
"encoding/json"
"errors"
+ "flag"
"net/http"
"net/http/httptest"
"os"
@@ -15,224 +17,190 @@ import (
"testing"
"time"
+ "github.com/ente/cli/internal/api"
+ "github.com/ente/cli/pkg"
+ "github.com/ente/cli/pkg/model"
"github.com/ente/cli/utils/constants"
"github.com/spf13/viper"
"github.com/zalando/go-keyring"
+ bolt "go.etcd.io/bbolt"
)
func TestCLIStartup(t *testing.T) {
- if args := os.Getenv("ENTE_CLI_TEST_ARGS"); args != "" {
- keyring.MockInit()
- if os.Getenv("ENTE_CLI_TEST_NO_KEYRING") != "" {
- keyring.MockInitWithError(errors.New("unexpected keyring access"))
- }
- var command []string
- if err := json.Unmarshal([]byte(args), &command); err != nil {
- t.Fatal(err)
+ if os.Getenv("ENTE_CLI_TEST_STARTUP") != "" {
+ keyring.MockInitWithError(errors.New("unexpected keyring access"))
+ if os.Getenv("ENTE_CLI_TEST_KEYRING") != "" {
+ keyring.MockInit()
+ if err := keyring.Set("ente", "ente-cli-user", base64.StdEncoding.EncodeToString(make([]byte, 32))); err != nil {
+ t.Fatal(err)
+ }
}
- os.Args = append([]string{"ente"}, command...)
+ os.Args = append([]string{"ente"}, flag.Args()...)
main()
- return
+ os.Exit(0)
}
var requests atomic.Int32
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
requests.Add(1)
- w.WriteHeader(http.StatusUnauthorized)
+ if r.URL.Path != "/admin/users/" || r.Header.Get("X-Auth-Token") != base64.URLEncoding.EncodeToString([]byte("synthetic-token")) {
+ t.Errorf("unexpected authenticated request: %s", r.URL.Path)
+ }
+ w.Header().Set("Content-Type", "application/json")
+ _, _ = w.Write([]byte(`{"users":[]}`))
}))
defer server.Close()
- tests := []struct {
- name string
- args []string
- wantError string
- wantOutput string
- keyring bool
- config string
- noConfig bool
- }{
- {name: "export", args: []string{"export"}, wantError: "refusing network command"},
- {name: "default endpoint", args: []string{"export"}, wantError: "refusing network command", noConfig: true},
- {name: "login", args: []string{"account", "add"}, wantError: "refusing network command"},
- {name: "list users", args: []string{"admin", "list-users"}, wantError: "refusing network command"},
- {name: "get user", args: []string{"admin", "get-user-id", "--user", "[email protected]"}, wantError: "refusing network command"},
- {name: "disable 2fa", args: []string{"admin", "disable-2fa", "--user", "[email protected]"}, wantError: "refusing network command"},
- {name: "disable passkey", args: []string{"admin", "disable-passkey", "--user", "[email protected]"}, wantError: "refusing network command"},
- {name: "delete user", args: []string{"admin", "delete-user", "--user", "[email protected]"}, wantError: "refusing network command"},
- {name: "subscription", args: []string{"admin", "update-subscription", "--user", "[email protected]"}, wantError: "refusing network command"},
- {name: "send mail", args: []string{"admin", "send-mail", "[email protected]", "[email protected]", "Test"}, wantError: "refusing network command"},
- {name: "version", args: []string{"version"}, wantOutput: "Version"},
- {name: "export help", args: []string{"export", "--help"}, wantOutput: "Usage:"},
- {name: "login help", args: []string{"account", "add", "--help"}, wantOutput: "Usage:"},
- {name: "admin help", args: []string{"admin", "list-users", "--help"}, wantOutput: "Usage:"},
- {name: "completion", args: []string{"completion", "bash"}, wantOutput: "bash completion"},
- {name: "list accounts", args: []string{"account", "list"}, wantOutput: "Configured accounts: 0", keyring: true},
- {name: "get token", args: []string{"account", "get-token", "--email", "[email protected]"}, wantOutput: "account not found", keyring: true},
- {name: "update account", args: []string{"account", "update", "--email", "[email protected]", "--dir", "."}, wantOutput: "account not found", keyring: true},
- {name: "decrypt", args: []string{"auth", "decrypt", "missing", "output"}, wantError: "error reading file"},
- {name: "invalid trusted YAML", args: []string{"export"}, wantError: "cannot load trusted configuration", config: "endpoint: [secret-sentinel"},
- {name: "invalid trusted endpoint", args: []string{"export"}, wantError: "invalid endpoint.api", config: "endpoint:\n api: []\n"},
- {name: "null trusted endpoint", args: []string{"export"}, wantError: "invalid endpoint.api", config: "endpoint:\n api: null\n"},
- {name: "null trusted endpoint section", args: []string{"export"}, wantError: "invalid endpoint.api", config: "endpoint: null\n"},
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- root := t.TempDir()
- home := filepath.Join(root, "home")
- cwd := filepath.Join(root, "cwd")
- body := tt.config
- if body == "" {
- body = "endpoint:\n api: " + server.URL + "\n"
- }
- if !tt.noConfig {
- writeTestConfig(t, filepath.Join(home, ".ente", "config.yaml"), body)
- }
- writeTestConfig(t, filepath.Join(cwd, "config.yaml"), "not valid YAML: [secret-sentinel")
- args, err := json.Marshal(tt.args)
- if err != nil {
- t.Fatal(err)
- }
- executable, err := os.Executable()
- if err != nil {
- t.Fatal(err)
- }
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
- defer cancel()
- command := exec.CommandContext(ctx, executable, "-test.run=^TestCLIStartup$")
- command.Dir = cwd
- command.Env = append(os.Environ(),
- "HOME="+home, "USERPROFILE="+home,
- "ENTE_CLI_CONFIG_DIR=", "ENTE_CLI_CONFIG_PATH=",
- "ENTE_CLI_SECRETS_PATH=",
- "ENTE_CLI_TMP_PATH="+root,
- "ENTE_CLI_TEST_ARGS="+string(args), "ENTE_CLI_TEST_NO_KEYRING=",
- )
- if !tt.keyring {
- command.Env = append(command.Env, "ENTE_CLI_TEST_NO_KEYRING=1")
- }
- var stdout, stderr bytes.Buffer
- command.Stdout, command.Stderr = &stdout, &stderr
- err = command.Run()
- if tt.wantError != "" {
- if err == nil || !strings.Contains(stderr.String(), tt.wantError) || stdout.Len() != 0 {
- t.Fatalf("error=%v stdout=%q stderr=%q", err, stdout.String(), stderr.String())
- }
- } else if err != nil || !strings.Contains(stdout.String(), tt.wantOutput) {
- t.Fatalf("error=%v stdout=%q stderr=%q", err, stdout.String(), stderr.String())
- }
- if strings.Contains(stderr.String(), "secret-sentinel") || strings.Contains(stderr.String(), "unexpected keyring access") {
- t.Fatalf("unsafe startup: %s", stderr.String())
- }
- })
+ cwd, trusted := t.TempDir(), t.TempDir()
+ for key, value := range map[string]string{
+ "ENTE_CLI_TEST_STARTUP": "1", "ENTE_CLI_TEST_KEYRING": "",
+ "ENTE_CLI_CONFIG_DIR": trusted, "ENTE_CLI_CONFIG_PATH": "",
+ "ENTE_CLI_SECRETS_PATH": "", "ENTE_CLI_TMP_PATH": t.TempDir(),
+ } {
+ t.Setenv(key, value)
+ }
+ writeTestConfig(t, filepath.Join(trusted, "config.yaml"), "endpoint:\n api: "+server.URL+"\n")
+ writeTestConfig(t, filepath.Join(cwd, "config.yaml"), "not valid YAML: [secret-sentinel")
+ seedTestAccount(t, filepath.Join(trusted, "ente-cli.db"))
+ executable, err := os.Executable()
+ if err != nil {
+ t.Fatal(err)
+ }
+ run := func(wantError string, args ...string) string {
+ t.Helper()
+ ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second)
+ defer cancel()
+ command := exec.CommandContext(ctx, executable, append([]string{"-test.run=^TestCLIStartup$", "--"}, args...)...)
+ command.Dir = cwd
+ var stdout, stderr bytes.Buffer
+ command.Stdout, command.Stderr = &stdout, &stderr
+ err := command.Run()
+ if (err != nil) != (wantError != "") || !strings.Contains(stderr.String(), wantError) || (wantError != "" && stdout.Len() != 0) {
+ t.Fatalf("%v: error=%v stdout=%q stderr=%q", args, err, stdout.String(), stderr.String())
+ }
+ if strings.Contains(stderr.String(), "secret-sentinel") || strings.Contains(stderr.String(), "unexpected keyring access") {
+ t.Fatalf("unsafe startup: %s", stderr.String())
+ }
+ return stdout.String()
+ }
+ for _, args := range [][]string{{"export"}, {"account", "add"}, {"admin", "list-users"}} {
+ run("refusing network command", args...)
+ }
+ for _, args := range [][]string{{"version"}, {"export", "--help"}, {"completion", "bash"}} {
+ run("", args...)
+ }
+ t.Setenv("ENTE_CLI_TEST_KEYRING", "1")
+ if output := run("", "account", "list"); !strings.Contains(output, "Configured accounts: 1") {
+ t.Fatalf("local account command failed: %q", output)
+ }
+ if requests.Load() != 0 {
+ t.Fatal("working-directory config allowed a network request")
}
- if got := requests.Load(); got != 0 {
- t.Fatalf("received %d unexpected network requests", got)
+ if err := os.Remove(filepath.Join(cwd, "config.yaml")); err != nil {
+ t.Fatal(err)
+ }
+ if output := run("", "admin", "list-users", "--admin-user", "[email protected]"); output != "" || requests.Load() != 1 {
+ t.Fatalf("expected one authenticated request and an empty user list, got output=%q requests=%d", output, requests.Load())
}
+ t.Setenv("ENTE_CLI_TEST_KEYRING", "")
+ writeTestConfig(t, filepath.Join(trusted, "config.yaml"), "endpoint: [secret-sentinel")
+ run("cannot load trusted configuration", "export")
}
-func TestInvalidTrustedConfig(t *testing.T) {
- for name, body := range map[string]string{
- "malformed YAML": "endpoint: [secret-sentinel",
- "endpoint list": "endpoint:\n api: []\n",
- "empty endpoint": "endpoint:\n api: ''\n",
- "null endpoint": "endpoint:\n api: null\n",
- "null endpoint section": "endpoint: null\n",
- "endpoint object": "endpoint:\n api: {}\n",
- "TOML": "[endpoint]\napi = 'secret-sentinel'\n",
- } {
- t.Run(name, func(t *testing.T) {
- viper.Reset()
- dir := t.TempDir()
- writeTestConfig(t, filepath.Join(dir, "config.yaml"), body)
- err := initConfig(dir)
- if err == nil || strings.Contains(err.Error(), "secret-sentinel") {
- t.Fatalf("expected sanitized configuration error, got %v", err)
- }
- })
+func seedTestAccount(t *testing.T, path string) {
+ t.Helper()
+ key := make([]byte, 32)
+ account := model.Account{Email: "[email protected]", UserID: 1, App: api.AppPhotos,
+ Token: *model.MakeEncString([]byte("synthetic-token"), key), MasterKey: *model.MakeEncString(key, key), SecretKey: *model.MakeEncString(key, key)}
+ data, err := json.Marshal(account)
+ if err != nil {
+ t.Fatal(err)
+ }
+ db, err := pkg.GetDB(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer db.Close()
+ if err := db.Update(func(tx *bolt.Tx) error {
+ bucket, err := tx.CreateBucketIfNotExists([]byte(pkg.AccBucket))
+ if err != nil {
+ return err
+ }
+ return bucket.Put([]byte(account.AccountKey()), data)
+ }); err != nil {
+ t.Fatal(err)
}
- t.Cleanup(viper.Reset)
}
-func TestTrustedConfigSymlink(t *testing.T) {
- for name, exists := range map[string]bool{"missing target": false, "existing target": true} {
- t.Run(name, func(t *testing.T) {
- viper.Reset()
- dir := t.TempDir()
- target := filepath.Join(t.TempDir(), "settings.yaml")
- if exists {
- writeTestConfig(t, target, "endpoint:\n api: https://trusted.invalid\n")
- }
- if err := os.Symlink(target, filepath.Join(dir, "config.yaml")); err != nil {
- t.Skipf("file symlinks unavailable: %v", err)
- }
- err := initConfig(dir)
- if !exists {
- if err == nil || !strings.Contains(err.Error(), "cannot inspect trusted configuration") {
- t.Fatalf("expected configuration error, got %v", err)
- }
- } else if err != nil || viper.GetString("endpoint.api") != "https://trusted.invalid" {
- t.Fatalf("linked configuration not loaded: %v", err)
- }
- })
- }
+func TestTrustedConfig(t *testing.T) {
t.Cleanup(viper.Reset)
+ dir := t.TempDir()
+ for _, body := range []string{
+ "endpoint: [secret-sentinel", "endpoint:\n api: []\n", "endpoint:\n api: ''\n",
+ "endpoint:\n api: null\n", "endpoint: null\n", "endpoint:\n api: {}\n", "[endpoint]\napi = 'secret-sentinel'\n",
+ } {
+ viper.Reset()
+ writeTestConfig(t, filepath.Join(dir, "config.yaml"), body)
+ if err := initConfig(dir); err == nil || strings.Contains(err.Error(), "secret-sentinel") {
+ t.Fatalf("expected sanitized configuration error, got %v", err)
+ }
+ }
+ viper.Reset()
+ writeTestConfig(t, filepath.Join(dir, "config.yaml"), "log:\n http: true\n")
+ if err := initConfig(dir); err != nil || viper.GetString("endpoint.api") != constants.EnteApiUrl || !viper.GetBool("log.http") {
+ t.Fatalf("configuration without an endpoint lost its default: %v", err)
+ }
}
-func TestTrustedConfigWithoutEndpoint(t *testing.T) {
+func TestConfigSymlinks(t *testing.T) {
viper.Reset()
t.Cleanup(viper.Reset)
- dir := t.TempDir()
- writeTestConfig(t, filepath.Join(dir, "config.yaml"), "log:\n http: true\n")
- if err := initConfig(dir); err != nil {
+ dir, target := t.TempDir(), filepath.Join(t.TempDir(), "settings.yaml")
+ if err := os.Symlink(target, filepath.Join(dir, "config.yaml")); err != nil {
+ t.Skipf("symlinks unavailable: %v", err)
+ }
+ if err := initConfig(dir); err == nil {
+ t.Fatal("dangling trusted config was ignored")
+ }
+ writeTestConfig(t, target, "endpoint:\n api: https://trusted.invalid\n")
+ if err := initConfig(dir); err != nil || viper.GetString("endpoint.api") != "https://trusted.invalid" {
+ t.Fatalf("linked configuration not loaded: %v", err)
+ }
+ alias := filepath.Join(t.TempDir(), "alias")
+ if err := os.Symlink(dir, alias); err != nil {
t.Fatal(err)
}
- if viper.GetString("endpoint.api") != constants.EnteApiUrl || !viper.GetBool("log.http") {
- t.Fatal("configuration without an endpoint did not retain the default API")
+ t.Chdir(dir)
+ if err := checkWorkingDirectoryConfig(alias); err != nil {
+ t.Fatal(err)
}
}
func TestWorkingDirectoryConfig(t *testing.T) {
+ cwd, trusted := t.TempDir(), t.TempDir()
+ t.Chdir(cwd)
for _, name := range []string{"config.yaml", "config.json", "config.toml", "config"} {
- t.Run(name, func(t *testing.T) {
- cwd, trusted := t.TempDir(), t.TempDir()
- t.Chdir(cwd)
- writeTestConfig(t, filepath.Join(cwd, name), "not valid YAML: [secret-sentinel")
- err := checkWorkingDirectoryConfig(trusted)
- if err == nil || !strings.Contains(err.Error(), "refusing network command") || strings.Contains(err.Error(), "secret-sentinel") {
- t.Fatalf("expected migration error, got %v", err)
- }
- })
- }
- t.Run("same directory", func(t *testing.T) {
- cwd := t.TempDir()
- t.Chdir(cwd)
- writeTestConfig(t, filepath.Join(cwd, "config.yaml"), "endpoint:\n api: https://trusted.invalid\n")
- alias := filepath.Join(t.TempDir(), "alias")
- if err := os.Symlink(cwd, alias); err != nil {
- t.Skipf("directory symlinks unavailable: %v", err)
+ writeTestConfig(t, name, "not valid YAML: [secret-sentinel")
+ if err := checkWorkingDirectoryConfig(trusted); err == nil || strings.Contains(err.Error(), "secret-sentinel") {
+ t.Fatalf("expected migration error, got %v", err)
}
- for _, dir := range []string{".", "./", cwd, alias} {
+ for _, dir := range []string{".", "./", cwd} {
if err := checkWorkingDirectoryConfig(dir); err != nil {
t.Fatalf("trusted directory %q: %v", dir, err)
}
}
- })
- t.Run("no configuration file", func(t *testing.T) {
- cwd := t.TempDir()
- t.Chdir(cwd)
- if err := os.Mkdir("config.yaml", 0700); err != nil {
- t.Fatal(err)
- }
- if err := checkWorkingDirectoryConfig(t.TempDir()); err != nil {
+ if err := os.Remove(name); err != nil {
t.Fatal(err)
}
- })
-}
-
-func TestConfigDirectoryRoot(t *testing.T) {
- dir := filepath.VolumeName(t.TempDir()) + string(filepath.Separator)
+ }
+ if err := os.Mkdir("config.yaml", 0700); err != nil {
+ t.Fatal(err)
+ }
+ if err := checkWorkingDirectoryConfig(trusted); err != nil {
+ t.Fatal(err)
+ }
+ dir := filepath.VolumeName(cwd) + string(filepath.Separator)
t.Setenv("ENTE_CLI_CONFIG_DIR", dir)
- got, err := GetCLIConfigDir()
- if err != nil || got != dir {
+ if got, err := GetCLIConfigDir(); err != nil || got != dir {
t.Fatalf("config directory = %q, %v; want %q", got, err, dir)
}
}
diff --git a/docs/docs/self-hosting/administration/cli.md b/docs/docs/self-hosting/administration/cli.md
index 7edd04e3ad..600bda559b 100644
--- a/docs/docs/self-hosting/administration/cli.md
+++ b/docs/docs/self-hosting/administration/cli.md
@@ -19,9 +19,7 @@ To do this, first configure the CLI to use your server's endpoint.
Define `config.yaml` and place it in `~/.ente/` or the directory specified by `ENTE_CLI_CONFIG_DIR`.
-`ENTE_CLI_CONFIG_DIR` selects both configuration and the saved account database. The legacy `ENTE_CLI_CONFIG_PATH` is used only when `ENTE_CLI_CONFIG_DIR` is unset. For example, `ENTE_CLI_CONFIG_DIR=/path/to/existing-cli-directory ente export` uses the accounts already stored in that directory.
-
-If you previously kept configuration in the working directory, migrate its settings into the existing configuration directory, then remove or rename the old file. Network commands stop while a separate working-directory config exists; local account commands remain available. Setting `ENTE_CLI_CONFIG_DIR=.` also changes the account database location. Invalid trusted configuration must be corrected before running commands.
+`ENTE_CLI_CONFIG_DIR` selects both configuration and saved accounts; `ENTE_CLI_CONFIG_PATH` is the legacy fallback. Use the existing account directory, e.g. `ENTE_CLI_CONFIG_DIR=/path/to/existing-cli-directory ente export`. Network commands stop if a separate working-directory config exists. If it contains your intended Ente settings, migrate them into that existing directory and remove or rename the old file; otherwise run from another directory. Local account commands remain available. Invalid trusted configuration must be corrected first.
```yaml
# Set the API endpoint to your domain where Museum is being served.