curl 无法写入用户拥有的 /tmp 目录

Thi*_*ala 5 ubuntu permissions tmp curl

我尝试按照https://docs.docker.com/engine/security/rootless/中的说明运行脚本:

$ curl -fsSL https://get.docker.com/rootless | sh
Run Code Online (Sandbox Code Playgroud)

但脚本在以下行中崩溃了:

curl -L -o docker.tgz "$STATIC_RELEASE_URL"
Run Code Online (Sandbox Code Playgroud)

随着消息:

Warning: Failed to create the file docker.tgz: Permission denied
curl: (23) Failure writing output to destination
Run Code Online (Sandbox Code Playgroud)

我将问题范围缩小到curl尝试写入tmp由 创建的文件夹mktemp -d,但我不明白为什么它失败。

一些背景:

$ whoami
thiago

$ uname -a
Linux thiago-acer 5.8.0-55-generic #62~20.04.1-Ubuntu SMP Wed Jun 2 08:55:04 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ mktemp -d
/tmp/tmp.U1nPTN5dlS

$ cd /tmp/tmp.U1nPTN5dlS

$ ls -la
total 8
drwx------  2 thiago thiago 4096 Jun 17 18:20 .
drwxrwxrwt 25 root   root   4096 Jun 17 18:20 ..
Run Code Online (Sandbox Code Playgroud)

运行上面的命令后,我尝试了:

# this fails with the same message as above
curl https://download.docker.com/linux/static/stable/x86_64/docker-20.10.7.tgz -O

# this works just fine
curl https://download.docker.com/linux/static/stable/x86_64/docker-20.10.7.tgz -o - > docker-20.10.7.tgz

# this also works
wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.7.tgz
Run Code Online (Sandbox Code Playgroud)

curl -O如果我在其他文件夹(例如我的主文件夹)上尝试该命令,该命令也可以工作。

任何帮助表示赞赏。

Sli*_*lim 0

我不知道这会帮助多少人,但分享以防万一它可以帮助别人。对我来说,我有Failure writing output to destination错误,但不是Permission denied错误。

这是因为我的/tmp目录已满

$ df -h /tmp
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           7.8G  7.8G     0 100% /tmp
Run Code Online (Sandbox Code Playgroud)

清理我的/tmp目录解决了我的问题。