零号智能

  • Python
  • 部署
  • go
  • VPS
  • 运维
  • 生活琐事
  • html
零号智能
Fantasia's blog npc0.com.
  1. 首页
  2. go
  3. 正文

go 在Linux下Exec执行shell

2021年1月7日 4079点热度 0人点赞 0条评论
//+build linux
e.job.Cmd.SysProcAttr = &syscall.SysProcAttr{}
uid, uErr := strconv.Atoi(userInfo.Uid)
gid, gErr := strconv.Atoi(userInfo.Gid)
fmt.Println(userInfo.Uid, userInfo.Gid)
if uErr == nil && gErr == nil {
   // 仅Linux下有效。
   e.job.Cmd.SysProcAttr.Credential = &syscall.Credential{
      Uid: uint32(uid),
      Gid: uint32(gid),
   }
}
本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: 暂无
最后更新:2021年5月22日

vpc

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2021 npc0.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

粤ICP备19157245号-1

粤公网安备 44030702002746号