Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Bug in xbps-create when a relative symlink point to an absolute symlink

オープン
#435 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
c
領域
cli, tooling

調査の方向性

Start by running the supplied reproduction script and inspect xbps-create's symlink handling around readlink and realpath. Compare the generated files.plist with the package contents, then verify that the corrected metadata lets xbps-remove remove both symlinks without truncating the target path.

索引モデルが issue の本文から書いたものです。

説明

bug

Simple script to reproduce

#! /bin/sh

set -e

PKGVER=bug-1_1
ARCH=x86_64
DESC="Package to show a bug in xbps-create"

DESTDIR=/tmp/bug-1

mkdir -p $DESTDIR/etc/A
ln -s /etc/os-release $DESTDIR/etc/abs
ln -s ../abs $DESTDIR/etc/A/rel

xbps-create --arch "$ARCH" --desc "$DESC" --pkgver "$PKGVER" $DESTDIR

After running this script you'll end up with a badly formed package. Contents are ok:

$ tar tvf bug-1_1.x86_64.xbps
-rw-r--r-- root/root       503 1969-12-31 21:00 ./props.plist
-rw-r--r-- root/root       744 1969-12-31 21:00 ./files.plist
lrwxrwxrwx 0/0               0 2021-11-28 20:06 ./etc/abs -> /etc/os-release
lrwxrwxrwx 0/0               0 2021-11-28 20:06 ./etc/A/rel -> ../abs

But files.plist is wrong:

$ tar xOf bug-1_1.x86_64.xbps ./files.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>dirs</key>
	<array>
		<dict>
			<key>file</key>
			<string>/etc</string>
		</dict>
		<dict>
			<key>file</key>
			<string>/etc/A</string>
		</dict>
	</array>
	<key>links</key>
	<array>
		<dict>
			<key>file</key>
			<string>/etc/A/rel</string>
			<key>mtime</key>
			<integer>1638140801</integer>
			<key>target</key>
			<string>lease</string>
		</dict>
		<dict>
			<key>file</key>
			<string>/etc/abs</string>
			<key>mtime</key>
			<integer>1638140801</integer>
			<key>target</key>
			<string>/etc/os-release</string>
		</dict>
	</array>
</dict>
</plist>

What is going on I think is:

  • the file in destdir /etc/A/rel is a symlink and readlink gives ../abs which is understood to be relative since it starts with .
  • the filename is then canonicalized (using realpath) to /etc/os-release
  • since the symlink was thought to be relative, this is expected to be inside destdir
  • hence we drop the destdir prefix /tmp/bug-1, that's 10 characters so /etc/os-release minus 10 characters gives lease

This actually bit us in the wip sagemath package. The net result is that those symlinks that are badly reported in files.plistare not removed by xbps-remove.

I've since made a workaround in the sagemath package so this won't affect us, but it'd be nice to fix this logic (whiich is kind of hard to understand), at the very least check that the prefix for the link is indeed the destdir before droping it naively and complain if not.

All of this is affected by whether the canonicalized path is actually an existing file; that's why I chose /etc/os-release which should always exist (if this file is not there, the bug doesn't trigger).

主要言語
C
スター
1.2k
フォーク
152
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

void-linux/xbps のほかの issue

void-linux/xbps の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。