feat: add Linglong uninstaller script support#54
Conversation
Reviewer's GuideThis PR secures Linglong bundle uninstallation by introducing a dedicated Polkit-enabled script and adapting the application code and build configuration to invoke it via pkexec, enhancing error handling and permission control. Sequence diagram for Linglong bundle uninstallation via Polkit scriptsequenceDiagram
actor User
participant App as Application
participant PKExec as pkexec
participant Script as dde-appwiz-linglong-uninstaller.sh
participant LLCLI as ll-cli
User->>App: Request to uninstall Linglong bundle
App->>PKExec: Start dde-appwiz-linglong-uninstaller.sh with appId
PKExec->>Script: Run script with elevated privileges
Script->>LLCLI: Check if ll-cli is available
Script->>LLCLI: Check if bundle is installed
Script->>LLCLI: Uninstall bundle
Script-->>PKExec: Return success or error
PKExec-->>App: Return exit code
App-->>User: Notify result
Class diagram for updated uninstallLinglongBundle logicclassDiagram
class Application {
+uninstallLinglongBundle(entry: DDesktopEntry): bool
}
class DDesktopEntry {
+rawValue(key: QString): QString
}
Application --> DDesktopEntry: uses
class dde-appwiz-linglong-uninstaller.sh {
+main(appId: string)
+error checking
+calls ll-cli
}
Application --> dde-appwiz-linglong-uninstaller.sh: invokes via pkexec
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Add a timeout to QProcess::waitForFinished in uninstallLinglongBundle to prevent potential hangs if the uninstaller script hangs or never exits.
- Use a more precise check for the installed bundle in the shell script (for example exact matching or structured output parsing) instead of a generic grep to avoid false positives.
- Ensure the Polkit policy file is updated to explicitly authorize the new linglong uninstaller script path so that pkexec can properly escalate privileges.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Add a timeout to QProcess::waitForFinished in uninstallLinglongBundle to prevent potential hangs if the uninstaller script hangs or never exits.
- Use a more precise check for the installed bundle in the shell script (for example exact matching or structured output parsing) instead of a generic grep to avoid false positives.
- Ensure the Polkit policy file is updated to explicitly authorize the new linglong uninstaller script path so that pkexec can properly escalate privileges.
## Individual Comments
### Comment 1
<location> `scripts/dde-appwiz-linglong-uninstaller.sh:22` </location>
<code_context>
+fi
+
+# Check if the Linglong bundle is installed
+if ! ll-cli list | grep -q "$LINGLONG_APP_ID"; then
+ echo "Error: Linglong bundle '$LINGLONG_APP_ID' is not installed."
+ exit 1
</code_context>
<issue_to_address>
Using grep for bundle existence may yield false positives if app IDs are substrings of others.
Use grep -w or another method to ensure only exact app ID matches are detected.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
# Check if the Linglong bundle is installed
if ! ll-cli list | grep -q "$LINGLONG_APP_ID"; then
echo "Error: Linglong bundle '$LINGLONG_APP_ID' is not installed."
exit 1
=======
# Check if the Linglong bundle is installed
if ! ll-cli list | grep -w -q "$LINGLONG_APP_ID"; then
echo "Error: Linglong bundle '$LINGLONG_APP_ID' is not installed."
exit 1
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
b3e7ea4 to
23abfd3
Compare
Added a new script dde-appwiz-linglong-uninstaller.sh for handling Linglong bundle uninstallation with proper error checking and validation Modified uninstallLinglongBundle function to use pkexec with the new script instead of direct ll-cli execution Updated Polkit policy to include the new script path for proper privilege escalation Added installation of the new script in CMakeLists.txt This change improves security by using Polkit for privilege escalation and provides better error handling for Linglong uninstallation feat: 添加玲珑卸载脚本支持 新增 dde-appwiz-linglong-uninstaller.sh 脚本用于处理玲珑包卸载,包含完善 的错误检查和验证 修改 uninstallLinglongBundle 函数使用 pkexec 调用新脚本,替代直接执行 ll-cli 更新 Polkit 策略以包含新脚本路径,实现正确的权限提升 在 CMakeLists.txt 中添加新脚本的安装配置 此改进通过使用 Polkit 进行权限提升提高了安全性,并为玲珑卸载提供了更好的 错误处理 Pms: BUG-291703
23abfd3 to
b1a1fee
Compare
deepin pr auto review我来对这段代码进行审查,从多个方面提出改进意见: 1. 语法逻辑
if (!process.waitForStarted()) {
qDebug() << "Failed to start process";
return false;
}2. 代码质量
set -euo pipefail这会在任何命令失败时立即退出,并且未设置的变量会报错。
3. 代码性能
4. 代码安全
if (appId.isEmpty() || appId.contains(QRegularExpression("[^a-zA-Z0-9_-]"))) {
qDebug() << "Invalid app ID:" << appId;
return false;
}
5. 其他建议
install(FILES scripts/dde-appwiz-linglong-uninstaller.sh
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
总体而言,这次的改进是朝着正确的方向,但还有进一步优化的空间,特别是在错误处理、性能优化和安全性方面。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, wjyrich The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Added a new script dde-appwiz-linglong-uninstaller.sh for handling Linglong bundle uninstallation with proper error checking and validation Modified uninstallLinglongBundle function to use pkexec with the new script instead of direct ll-cli execution
Updated Polkit policy to include the new script path for proper privilege escalation
Added installation of the new script in CMakeLists.txt This change improves security by using Polkit for privilege escalation and provides better error handling for Linglong uninstallation
feat: 添加玲珑卸载脚本支持
新增 dde-appwiz-linglong-uninstaller.sh 脚本用于处理玲珑包卸载,包含完善 的错误检查和验证
修改 uninstallLinglongBundle 函数使用 pkexec 调用新脚本,替代直接执行 ll-cli
更新 Polkit 策略以包含新脚本路径,实现正确的权限提升
在 CMakeLists.txt 中添加新脚本的安装配置
此改进通过使用 Polkit 进行权限提升提高了安全性,并为玲珑卸载提供了更好的
错误处理
Pms: BUG-291703
Summary by Sourcery
Introduce a dedicated Linglong bundle uninstaller script invoked through Polkit for secure privilege escalation and improved error handling
New Features:
Enhancements:
Build: