shadow-utils write locks with NUL-terminated contents while uutils/shadow does not.

未关闭
#399 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
64/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
rust
领域
backend

调研方向

The report points to shadow-utils' lib/commonio.c and describes lock parsing in uutils/shadow, but names no uutils file or test. Start by tracing lock creation and stale-lock parsing in uu_shadow_core, then look for lock tests. Done when a lock written with a NUL-terminated PID is handled without deleting a lock that is still held.

由索引模型根据 Issue 内容生成。

描述

See https://github.com/shadow-maint/shadow/blob/763e75e12be2b389f527502aa66dbca8ae7c8610/lib/commonio.c#L111

stprintf_a(buf, "%lu", (unsigned long) pid);
len = (ssize_t) strlen (buf) + 1;
if (write_full(fd, buf, len) == -1) {

and with shadow-utils + strace I got:

write(5<.../etc/subuid.633201>, "633201\0", 7) = 7
write(6<.../etc/subgid.633201>, "633201\0", 7) = 7

while uutils/shadow doesn't.

This itself does not pose a compatibility issue since users are not expected to have both running on the same system live. However, there maybe edge cases (e.g. switching between the two). Additionally, I ran into this because I was trying to reuse uutils's uu_shadow_core in another small util of mine to handle locking.

This may cause the following:

  1. shadow-utils holds a lock containing 633201\0.
  2. uutils’ trim().parse::<i32>() rejects the NUL.
  3. uutils interprets the parse failure as a stale lock and deletes it.
  4. uutils can then acquire the lock while shadow-utils is still working, breaking mutual exclusion.

A PR is possible if you decided this to be fixed.

主要语言
Rust
星标
20
派生
10
平均合并
22 小时 17 分钟
30 天内合并 PR
37

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

uutils/shadow 的其他 Issue

查看 uutils/shadow 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。