run part of code as root

Deadly 提交于 2019-11-28 10:52:48

问题


I have a package which runs uses Gtk and written in vala.A dialog box or a gui opens after selecting a file.I want this dialog box or gui to run as root so as to open and read the files which don't open with normal users.I have this code

static void open_file(string filename) {
    selected_file = filename;
    stdout.printf(selected_file);
    new ProgressWindow(selected_file, {});

}

I want to run ProgressWindow to run as root.Is it possible?


回答1:


No. To run as root, it must be in a separate process and you must run that process using pkexec via PolicyKit. Here's a tutorial on PolicyKit in Vala.



来源:https://stackoverflow.com/questions/42779843/run-part-of-code-as-root

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!