douyanguo7964 2014-12-08 20:28
浏览 729

检查应用程序是否在golang中以管理员身份运行

In a Google Go application what is the easiest way to check if the current process is running as an administrator?

  • 写回答

1条回答 默认 最新

  • dongwen7371 2014-12-08 23:24
    关注

    The short answer is to use user.Current. HOWEVER...

    You will need to find a way to, given the user.User struct, figure out whether the user is root. You'll have to figure that one out on your own. More importantly, you should not use this for security purposes. Figuring out whether the current user is root without being lied to by the person running the program is very tricky. For example, a naive implementation of this on Linux with a setuid binary would be vulnerable to the user using LD_PRELOAD to trick the binary into thinking it was running as root. Make sure that you either, a) understand the exact semantics of this and are convinced there is no way to circumvent it by the user (and if you choose this route, you should probably just see if others have figured it out), or, b) do not make any security-critical decisions based on this information.

    评论

报告相同问题?

悬赏问题

  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 spring后端vue前端
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题