【问题标题】:Unexpected bash readable test result with GitHub Actions使用 GitHub Actions 的意外 bash 可读测试结果
【发布时间】:2021-02-13 20:04:31
【问题描述】:

MWE

我有一个 GitHub Actions 工作流程,最近在我没有进行更改的情况下停止工作。错误:

==> ERROR: /etc/makepkg.conf not found.
    Aborting...

这是来自运行# sudo -Eu builder makepkg --printsrcinfo

日志的顺序似乎是错误的,但在earlier log 中是正确的(可能是由于ls -l 的输出很大)。

这个错误的来源似乎是libmakepkg/util/config.sh.in

    # Source the config file; fail if it is not found
    if [[ -r $MAKEPKG_CONF ]]; then
        source_safe "$MAKEPKG_CONF"
    else
        error "$(gettext "%s not found.")" "$MAKEPKG_CONF"
        plainerr "$(gettext "Aborting...")"
        exit $E_CONFIG_ERROR
    fi

我在入口点脚本中添加了以下内容:

echo "Writing SRCINFO..."

# Debug
echo "---"
ls -l /
echo "---"
ls -l /etc
echo "---"
sudo -Eu builder cat /etc/makepkg.conf
echo "---"
sudo -Eu builder /bin/bash -c "[[ -r "/etc/makepkg.conf" ]] && echo 1 || echo 0"
echo "---"

sudo -Eu builder makepkg --printsrcinfo > .SRCINFO

builder 用户是在build.sh 中创建的:

useradd builder -m
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

我明白了:

Setting permissions...
Writing SRCINFO...
---
total 52
lrwxrwxrwx   1 root root    7 Feb  1 19:19 bin -> usr/bin
drwxr-xr-x   2 root root 4096 Jan 19 01:32 boot
drwxr-xr-x   5 root root  340 Feb  7 11:58 dev
-rwxr-xr-x   1 root root  836 Feb  7 11:57 entrypoint.sh
drwxr-xr-x   1 root root 4096 Feb  7 11:58 etc
drwxr-xr-x   6 root root 4096 Feb  7 11:58 github
drwxr-xr-x   1 root root 4096 Feb  7 11:57 home
lrwxrwxrwx   1 root root    7 Feb  1 19:19 lib -> usr/lib
lrwxrwxrwx   1 root root    7 Feb  1 19:19 lib64 -> usr/lib
drwxr-xr-x   2 root root 4096 Jan 19 01:32 mnt
drwxr-xr-x   2 root root 4096 Jan 19 01:32 opt
dr-xr-xr-x 159 root root    0 Feb  7 11:58 proc
drwxr-x---   2 root root 4096 Jan 19 01:32 root
drwxr-xr-x   1 root root 4096 Feb  7 11:58 run
lrwxrwxrwx   1 root root    7 Feb  1 19:19 sbin -> usr/bin
drwxr-xr-x   4 root root 4096 Feb  1 19:19 srv
dr-xr-xr-x  12 root root    0 Feb  7 11:58 sys
drwxrwxrwt   2 root root 4096 Jan 19 01:32 tmp
drwxr-xr-x   1 root root 4096 Feb  7 11:57 usr
drwxr-xr-x   1 root root 4096 Feb  1 19:19 var
---
total 640
-rw-r--r-- 1 root root      0 Jan 19 01:32 arch-release
drwxr-xr-x 3 root root   4096 Feb  1 19:19 audit
-rw-r--r-- 1 root root     28 Dec 20 18:44 bash.bash_logout
-rw-r--r-- 1 root root    618 Dec 20 18:44 bash.bashrc
-rw-r--r-- 1 root root    447 Dec  2 16:02 bindresvport.blacklist
drwxr-xr-x 2 root root   4096 Dec 16 14:38 binfmt.d
drwxr-xr-x 4 root root   4096 Feb  1 19:19 ca-certificates
-rw------- 1 root root    722 Jan 19 01:32 crypttab
drwxr-xr-x 2 root root   4096 Feb  1 19:19 default
drwxr-xr-x 2 root root   4096 Jan  7 19:51 depmod.d
-rw-r--r-- 1 root root    685 Jan 31 20:31 e2scrub.conf
-rw-r--r-- 1 root root     97 Jan 13 22:50 environment
-rw-r--r-- 1 root root   1362 Jan 20 21:31 ethertypes
-rw-r--r-- 1 root root    126 Jan 19 01:32 fstab
-rw-r--r-- 1 root root   2584 Feb  6 00:09 gai.conf
-rw-r--r-- 1 root root    626 Feb  7 11:57 group
-rw-r--r-- 1 root root    610 Jan 31 00:20 group-
-rw------- 1 root root    558 Feb  7 11:57 gshadow
-rw------- 1 root root    546 Jan 31 00:20 gshadow-
-rw-r--r-- 1 root root     73 Jan 19 01:32 host.conf
-rw-r--r-- 1 root root     13 Feb  7 11:58 hostname
-rw-r--r-- 1 root root    174 Feb  7 11:58 hosts
-rw-r--r-- 1 root root    714 Dec  8 17:48 inputrc
drwxr-xr-x 2 root root   4096 Feb  1 19:19 iproute2
drwxr-xr-x 2 root root   4096 Feb  1 19:19 iptables
-rw-r--r-- 1 root root     20 Jan 19 01:32 issue
drwxr-xr-x 3 root root   4096 Feb  1 19:19 kernel
drwxr-xr-x 2 root root   4096 Jul  7  2020 keyutils
-rw-r--r-- 1 root root    369 Jan 14 00:32 krb5.conf
-rw-r--r-- 1 root root  18096 Feb  7 11:57 ld.so.cache
-rw-r--r-- 1 root root    117 Jan 19 01:32 ld.so.conf
drwxr-xr-x 1 root root   4096 Feb  7 11:57 ld.so.conf.d
-rw-r----- 1 root root    191 Jan 13 22:33 libaudit.conf
drwxr-xr-x 2 root root   4096 Feb  1 19:19 libnl
-rw-r--r-- 1 root root     17 Jan 31 00:19 locale.conf
-rw-r--r-- 1 root root     18 Jan 31 00:19 locale.gen
-rw-r--r-- 1 root root   9984 Feb  6 00:09 locale.gen.pacnew
-rw-r--r-- 1 root root   5645 Sep  7 13:42 login.defs
-rw-r--r-- 1 root root   5792 Jul  1  2020 makepkg.conf
-rw-r--r-- 1 root root    812 Jan 31 20:31 mke2fs.conf
drwxr-xr-x 2 root root   4096 Jan  7 19:51 modprobe.d
drwxr-xr-x 2 root root   4096 Dec 16 14:38 modules-load.d
-rw-r--r-- 1 root root      0 Jan 19 01:32 motd
lrwxrwxrwx 1 root root     12 Feb  7 11:58 mtab -> /proc/mounts
-rw-r--r-- 1 root root    767 Dec  2 16:02 netconfig
-rw-r--r-- 1 root root   2717 Feb  6 00:09 nscd.conf
-rw-r--r-- 1 root root    328 Jan 19 01:32 nsswitch.conf
drwxr-xr-x 1 root root   4096 Feb  7 11:57 openldap
lrwxrwxrwx 1 root root     19 Feb  1 19:19 os-release -> /usr/lib/os-release
-rw-r--r-- 1 root root   3264 Feb  7 11:57 pacman.conf
-rw-r--r-- 1 root root   2883 Jul  1  2020 pacman.conf.pacnew
drwxr-xr-x 1 root root   4096 Feb  7 11:57 pacman.d
drwxr-xr-x 1 root root   4096 Feb  7 11:57 pam.d
-rw-r--r-- 1 root root    744 Feb  7 11:57 passwd
-rw-r--r-- 1 root root    699 Jan 31 00:20 passwd-
drwxr-xr-x 2 root root   4096 Feb  1 19:19 pkcs11
-rw-r--r-- 1 root root   1020 Jan 19 01:32 profile
drwxr-xr-x 1 root root   4096 Feb  7 11:57 profile.d
-rw-r--r-- 1 root root   3171 Jan  3 17:14 protocols
-rw-r--r-- 1 root root   1814 Jul  7  2020 request-key.conf
drwxr-xr-x 2 root root   4096 Jul  7  2020 request-key.d
-rw-r--r-- 1 root root    649 Feb  7 11:58 resolv.conf
-rw-r--r-- 1 root root   1634 Feb  6 00:09 rpc
-rw-r--r-- 1 root root    139 Jan 19 01:32 securetty
drwxr-xr-x 2 root root   4096 Feb  1 19:19 security
-rw-r--r-- 1 root root 297708 Jan  3 17:14 services
-rw------- 1 root root    375 Feb  7 11:57 shadow
-rw------- 1 root root    346 Jan 31 00:20 shadow-
-rw-r--r-- 1 root root     83 Jan 19 01:32 shells
drwxr-xr-x 2 root root   4096 Feb  1 19:19 skel
drwxr-xr-x 5 root root   4096 Feb  1 19:19 ssl
-rw-r--r-- 1 root root   3975 Jan 26 18:34 sudo.conf
-r--r----- 1 root root   3160 Feb  7 11:57 sudoers
drwxr-x--- 2 root root   4096 Jan 26 18:34 sudoers.d
-rw-r--r-- 1 root root   6169 Jan 26 18:34 sudo_logsrvd.conf
drwxr-xr-x 2 root root   4096 Dec 16 14:38 sysctl.d
drwxr-xr-x 1 root root   4096 Feb  7 11:57 systemd
drwxr-xr-x 2 root root   4096 Dec 16 14:38 tmpfiles.d
drwxr-xr-x 1 root root   4096 Feb  7 11:57 udev
drwxr-xr-x 1 root root   4096 Feb  1 19:19 X11
-rw-r--r-- 1 root root    642 May  7  2020 xattr.conf
drwxr-xr-x 1 root root   4096 Feb  1 19:19 xdg
drwxr-xr-x 2 root root   4096 Feb  1 19:19 xinetd.d
---
#!/hint/bash
#
# /etc/makepkg.conf
#
...
SRCEXT='.src.tar.gz'
---
0
---
==> ERROR: /etc/makepkg.conf not found.
    Aborting...

/etc/makepkg.conf 的内容被拼接了。)

我也无意中做了[[ -r "/etc/makepkg.conf" ]] && echo 1 || echo 0(作为root),我也得到了0

一个文件怎么可能不可读但我可以cat 它?我还尝试在本地容器中运行完全相同的命令,但无法重现此问题,但自启动以来每次运行 GitHub Actions 都会发生这种情况。

这让我觉得 Actions 设置引起了问题,但那里似乎没有什么奇怪的:

/usr/bin/docker build -t 442333:35a065f0b9f356b32f2852ba2f6b7296 -f "/home/runner/work/visual-studio-code-insiders-arch/visual-studio-code-insiders-arch/./.github/actions/pkg/Dockerfile" "/home/runner/work/visual-studio-code-insiders-arch/visual-studio-code-insiders-arch/.github/actions/pkg"
/usr/bin/docker run --name a065f0b9f356b32f2852ba2f6b7296_baf94b --label 442333 --workdir /github/workspace --rm -e pythonLocation -e LD_LIBRARY_PATH -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/visual-studio-code-insiders-arch/visual-studio-code-insiders-arch":"/github/workspace" 442333:35a065f0b9f356b32f2852ba2f6b7296

【问题讨论】:

  • 请将findmntmount 的输出添加到您的运行中。也许stat /etc/makepkg.conf /bin/bash /bin/cat。请执行sudo -Eu builder bash -x makepkg 并检查输出。 >> /etc/sudoers 奇怪的是它的工作原理 - sudoers 应该是只读的。可能是SELINUX,也可能是带有SUID 的bash 库?我正在集思广益。
  • 我添加了一个 MWE,应该会有所帮助。它也应该更容易分叉和弄乱以获取更多信息。我认为这是由于 GitHub Actions 做了一些事情
  • 我还创建了一个GitHub Community post,因为他们应该更好地了解本地和他们的跑步者之间的差异

标签: linux docker github-actions archlinux


【解决方案1】:

感谢分享。我也有同样的问题。

我在Dockerfile中添加了以下内容

RUN sed -i 's/\tif \[\[ -r $MAKEPKG_CONF \]\]; then/\tif \[\[ -f $MAKEPKG_CONF \]\]; then/' /usr/share/makepkg/util/config.sh

它取代了读取权限检查 (-r) 以检查文件是否存在并且是常规文件 (-f)。

现在我的 github 操作越过了这个特定位置,但下一次检查失败:

==> ERROR: You do not have write permission for the directory $BUILDDIR (/tmp/aurutils).
    Aborting...

这不是一个解决方案,也没有回答根本问题是什么,但我希望它无论如何都会有所帮助。

【讨论】:

    【解决方案2】:

    此问题是由于在容器上使用 glibc >= 2.33 和主机上的 Docker 引擎版本过时所致。

    您可以通过在容器中修补 glibc 来修复它:

    patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst
    curl -LO https://repo.archlinuxcn.org/x86_64/$patched_glibc
    bsdtar -C / -xvf $patched_glibc
    

    感谢lxqt-panel 的解决方法。

    【讨论】:

    猜你喜欢
    • 2021-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多