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

Đang mở
#399 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
64/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Rust
Star
20
Fork
10
Merge trung bình
22 giờ 17 phút
Pull request đã merge (30 ngày)
37

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của uutils/shadow

Tất cả issue của uutils/shadow

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.