Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add polkit support #121

Merged
merged 1 commit into from
Sep 11, 2024
Merged

Conversation

wangrong1069
Copy link
Contributor

As title.

Log: enhance security
Task: https://pms.uniontech.com/task-view-355353.html

@deepin-ci-robot
Copy link

deepin pr auto review

关键摘要:

  • LFTManager::checkAuthorization函数中,使用PolkitQt1::Authority::instance()->checkAuthorizationSync进行权限检查,但没有处理权限检查失败的情况。建议添加错误处理逻辑,例如发送错误消息或返回错误码。
  • LFTManager::checkAuthorization函数中,当权限检查结果不为PolkitQt1::Authority::Yes时,直接发送错误消息并返回false,这可能不是最佳处理方式。建议根据具体业务逻辑决定是否需要更复杂的错误处理策略。
  • LFTManager::checkAuthorization函数中,使用了calledFromDBus()函数来判断是否从DBus调用而来。这个函数的实现和返回值没有在提交中给出,需要确保这个函数的实现是正确的,并且返回值能够正确区分DBus调用和非DBus调用。
  • LFTManager::checkAuthorization函数中,直接使用了sendErrorReply函数来发送错误消息,但没有提供这个函数的实现细节。需要确保sendErrorReply函数能够正确发送错误消息,并且能够处理不同类型的错误。

是否建议立即修改:

Copy link
Contributor

@re2zero re2zero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look's good

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: re2zero, wangrong1069

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wangrong1069
Copy link
Contributor Author

/forcemerge

@deepin-bot deepin-bot bot merged commit 4f316fb into linuxdeepin:master Sep 11, 2024
14 checks passed
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>
<action id="com.deepin.anything">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

action id最好在后面加一个具体行为,比如com.deepin.anything.access-file-index

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

非安全性问题, 后期会整改

@@ -1639,3 +1680,23 @@ int LFTManager::_doSearch(void *vbuf, quint32 maxCount, const QString &path, con

return total;
}

bool LFTManager::checkAuthorization(void)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个action的提示信息是"访问文件索引需要认证",看起来不能满足所有接口的提示,建议定义多个action,这个方法加一个actionId参数

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

非安全性问题, 后期会整改

PolkitQt1::Authority::Result result;

result = PolkitQt1::Authority::instance()->checkAuthorizationSync(actionId,
PolkitQt1::SystemBusNameSubject(appBusName),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

参考systemd代码:https://github.com/systemd/systemd/blob/main/src/shared/bus-polkit.c#L84
作为服务,subject应该用caller生成

Copy link
Contributor Author

@wangrong1069 wangrong1069 Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的确是使用 sender 来进行身份验证.
这里的 QDBusMessage::service() 来自于 q_dbus_message_get_sender().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants