LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 764|回复: 1

kde 可以直接限制打开文件 或 执行程序?

[复制链接]
发表于 2009-9-22 23:29:34 | 显示全部楼层 |阅读模式
寻找机机,目标: remote desktop free acc,
发现一 openSUSE 主机(不确定),
桌面上只能打开 konqueror、firefox 两个程序,
不爽,没有 shell 多难受,左突右撞,
konqueror 无法访问 /,连家目录下少数文件访问都受限制,如访问 ~/.bash_history 弓单出 "You are not authorized to open this file.",
找到 http://api.kde.org/3.5-api/kdeli ... un_8cpp_source.html
  1. [url=http://api.kde.org/3.5-api/kdelibs-apidocs/kio/html/classKRun.html#a7cac381825d4143b03bc19fd563a0674]00198[/url] bool [url=http://api.kde.org/3.5-api/kdelibs-apidocs/kio/html/classKRun.html#a59f662f719e5941f79b56c65c2beeac3]KRun::displayOpenWithDialog[/url]( const KURL::List& lst, bool tempFiles, const [url=http://doc.trolltech.com/3.3/qstring.html]QString[/url]& suggestedFileName )
  2. 00199 {
  3. 00200     if (kapp && !kapp->authorizeKAction("openwith"))
  4. 00201     {
  5. 00202        // TODO: Better message, i18n freeze :-(
  6. 00203        KMessageBox::sorry(0L, i18n([color=Red]"You are not authorized to open this file."[/color]));
  7. 00204        return false;
  8. 00205     }
  9. 00206
  10. 00207     [url=http://api.kde.org/3.5-api/kdelibs-apidocs/kio/html/classKOpenWithDlg.html]KOpenWithDlg[/url] l( lst, i18n("Open with:"), QString::null, 0L );
  11. 00208     if ( l.[url=http://doc.trolltech.com/3.3/qdialog.html#exec]exec[/url]() )
  12. 00209     {
  13. 00210       [url=http://api.kde.org/3.5-api/kdelibs-apidocs/kio/html/classKService.html#a1f779f61688fa83379c3f365cd578118]KService::Ptr[/url] service = l.[url=http://api.kde.org/3.5-api/kdelibs-apidocs/kio/html/classKOpenWithDlg.html#a8e8db71c2aec0336a8489832ed76a8ed]service[/url]();
  14. 00211       if ( !!service )
  15. 00212         return [url=http://api.kde.org/3.5-api/kdelibs-apidocs/kio/html/classKRun.html#ad86a1cb147017c650f441f2a8abbb81f]KRun::run[/url]( *service, lst, 0 /*window*/, tempFiles, suggestedFileName );
  16. 00213
  17. 00214       kdDebug(7010) << "No service set, running " << l.[url=http://api.kde.org/3.5-api/kdelibs-apidocs/kio/html/classKOpenWithDlg.html#a8fbe33fe87c2b6133bb3340e860d5261]text[/url]() << endl;
  18. 00215       return [url=http://api.kde.org/3.5-api/kdelibs-apidocs/kio/html/classKRun.html#ad86a1cb147017c650f441f2a8abbb81f]KRun::run[/url]( l.[url=http://api.kde.org/3.5-api/kdelibs-apidocs/kio/html/classKOpenWithDlg.html#a8fbe33fe87c2b6133bb3340e860d5261]text[/url](), lst, suggestedFileName ); // TODO handle tempFiles 00216     }
  19. 00217     return false;
  20. 00218 }
复制代码
firefox 通过 file:///,却能像正常 普通用户 一样访问所有资源,
确认机机上无 selinux。

有点意思,kde-3.x 中 kio 代码部分印证 标题 猜测,暂未找到设置方法。
暂未发现 当前新版 kde-4.x 中 kio 对应物,貌似去掉了。
 楼主| 发表于 2009-9-23 12:41:37 | 显示全部楼层
确认 kde3 kde4 中使用 policykit 可以完成授权验证:
kde3 如上可由 kio 调用,
kde4 则可由 polkit-qt 调用,
gnome 则可由 gconf 调用。

firefox 则完全不受 policykit 控制。
上面机机应该是严格配置过 policykit,但还是有漏洞。

也就是说,通过 policykit 可以配置一个对 普通用户 有严格限制的 GUI 环境(kde3 kde4 gnome)。

不知道 policykit 能否做到根据特定时间段授权。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表