跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

0029-macos-utc-timezone.patch

50 行 · 1.5 KB历史下载
1--- a/pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go
2+++ b/pkg/guestagent/fakecloudinit/fakecloudinit_darwin.go
3@@ -186,6 +186,10 @@
4 }
5
6 func setTimezone(ctx context.Context, timezone string) error {
7+ // systemsetup lists GMT as its UTC zone on macOS.
8+ if timezone == "Etc/UTC" || timezone == "UTC" {
9+ timezone = "GMT"
10+ }
11 cmd := exec.CommandContext(ctx, "systemsetup", "-settimezone", timezone)
12 logrus.Infof("Executing command: %v", cmd.Args)
13 if output, err := cmd.CombinedOutput(); err != nil {
14--- /dev/null
15+++ b/pkg/guestagent/fakecloudinit/timezone_darwin_test.go
16@@ -0,0 +1,34 @@
17+// SPDX-FileCopyrightText: Copyright The Lima Authors
18+// SPDX-License-Identifier: Apache-2.0
19+
20+package fakecloudinit
21+
22+import (
23+ "os"
24+ "path/filepath"
25+ "strings"
26+ "testing"
27+)
28+
29+func TestSystemSetupUTCZone(t *testing.T) {
30+ dir := t.TempDir()
31+ log := filepath.Join(dir, "args")
32+ cmd := filepath.Join(dir, "systemsetup")
33+ if err := os.WriteFile(cmd, []byte("#!/bin/sh\nprintf '%s\\n' \"$@\" > \"$CAGE_TEST_ARGS\"\n"), 0o700); err != nil {
34+ t.Fatal(err)
35+ }
36+ t.Setenv("PATH", dir)
37+ t.Setenv("CAGE_TEST_ARGS", log)
38+ for input, want := range map[string]string{"Etc/UTC": "GMT", "UTC": "GMT", "GMT": "GMT", "Asia/Shanghai": "Asia/Shanghai", "Unlisted/Zone": "Unlisted/Zone"} {
39+ if err := setTimezone(t.Context(), input); err != nil {
40+ t.Fatal(err)
41+ }
42+ data, err := os.ReadFile(log)
43+ if err != nil {
44+ t.Fatal(err)
45+ }
46+ if got := strings.TrimSpace(string(data)); got != "-settimezone\n"+want {
47+ t.Errorf("%s: got %q", input, got)
48+ }
49+ }
50+}