KernelSU icon indicating copy to clipboard operation
KernelSU copied to clipboard

REMOVE变量与system/product同时使用时挂载到错误的路径

Open Greyh4t opened this issue 1 year ago • 2 comments

Please check before submitting an issue

  • [X] I have searched the issues and haven't found anything relevant
  • [X] I will upload bugreport file in KernelSU Manager - Settings - Report log
  • [X] I know how to reproduce the issue which may not be specific to my device

Describe the bug

模块里面设置 REMOVE 变量,并且 REMOVE 变量包含 /product/ 开头的路径,同时创建 system/product/test_file 文件,打包后刷进去,test_file 会被错误地挂载到 /product/product/test_file,出现了两层 product 目录,去模块目录下看到文件的路径是 system/product/product/test_file 按照文档的的说明,如果要在 /product 替换文件,需要将文件放到 system/product 目录下,所以两层 product 应该是 bug 吧

To Reproduce

这个是复现问题的模块

kernelsudebug.zip

Expected behavior

No response

Screenshots

No response

Logs

KernelSU_bugreport_2024-01-07_01_58.tar[1].gz

Device info

  • Device: xiaomi14
  • OS Version: HyperOS 1.0.28.0.UNCCNXM
  • KernelSU Version: 0.72(11413)
  • Kernel Version: 6.1.25-android14-11-g923d9e76856e

Additional context

No response

Greyh4t avatar Jan 06 '24 17:01 Greyh4t

看了一下,问题应该是出在 https://github.com/tiann/KernelSU/blob/1fad91a4e2d473faa4a2c4f9957b5918e03ac05e/userspace/ksud/src/installer.sh#L316 $1product,这个命令就等效于 mv -f $MODPATH/system/product $MODPATH/product && ln -sf ../$1 $MODPATH/system/product

如果 $MODPATH/product 已经是一个文件夹,$MODPATH/system/product 就会被移动到 $MODPATH/product 里面去,出现两层 product 嵌套的情况,恰巧 REMOVE 变量在这之前处理,会创建 $MODPATH/product 文件夹,这样看的话应该 REPLACE 也有类似的问题

改成下面这样应该能修复这个bug mv -f $MODPATH/system/$1 $MODPATH/ && ln -sf ../$1 $MODPATH/system/$1

Greyh4t avatar Jan 06 '24 18:01 Greyh4t

看了一下,问题应该是出在

https://github.com/tiann/KernelSU/blob/1fad91a4e2d473faa4a2c4f9957b5918e03ac05e/userspace/ksud/src/installer.sh#L316

$1product,这个命令就等效于 mv -f $MODPATH/system/product $MODPATH/product && ln -sf ../$1 $MODPATH/system/product 如果 $MODPATH/product 已经是一个文件夹,$MODPATH/system/product 就会被移动到 $MODPATH/product 里面去,出现两层 product 嵌套的情况,恰巧 REMOVE 变量在这之前处理,会创建 $MODPATH/product 文件夹,这样看的话应该 REPLACE 也有类似的问题

改成下面这样应该能修复这个bug mv -f $MODPATH/system/$1 $MODPATH/ && ln -sf ../$1 $MODPATH/system/$1

改成 mv -f $MODPATH/system/$1 $MODPATH/ && ln -sf ../$1 $MODPATH/system/$1 有bug,会导致目录已经存在的时候mv报错无法合并,改成 cp -rf $MODPATH/system/$1 $MODPATH/ && rm -rf $MODPATH/system/$1 && ln -sf ../$1 $MODPATH/system/$1 应该就没问题了

Greyh4t avatar Jan 08 '24 05:01 Greyh4t