duankanyi6539 2019-03-07 01:50
浏览 17

将策略工具包与golang一起使用以进行特权升级

I am writing a program in golang that will need to perform tasks with ICMP. It will also be running a webserver on port 80. To do this I need certain privileges on Linux.

I'm looking to emulate the way SystemD gains privileges with the systemctl command when ran by an unprivileged user. The behaviour I want to emulate is reproducible if you run for example: systemctl stop sshd as an admin user that's not root

My question is; how can I use policykit to escalate the privileges of a program that is currently running without a program restart the way SystemD's systemctl command appears to. I have already pseudo-accomplished this task by rebinding stdin,stdout,and stderr to a command from

exec.Command("pkexec", ...)

but this approach simply run's the program again as a child process while leaving the parent process to hang waiting for the child to exit. This feels unnecessary and over complicated. It seems to me that the better solution would be to change permissions of the process as it runs, interactively, and I think policykit allows for this.

I am leaving the parent process hanging on the child so that the shell will stay waiting on a process.

I don't want users of this program to deal with having to run sudo or other control schemas, I just want them to be able to download the program's binary, ./ the executable and then the program do the thing. Prompting for a password for polkit, etc. inside of the program seems reasonable to me.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么