setuid:不支持操作 [英] setuid: operation not supported

查看:63
本文介绍了setuid:不支持操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

package main

import (
        "log"
        "syscall"
)

func main() {
        setuidErr := syscall.Setuid(0)
        if setuidErr != nil {
                log.Fatal(setuidErr)
        }
}

当我运行上面的代码时,出现以下错误:

When I run above code, I get the following error:

不支持操作
退出状态 1

operation not supported
exit status 1

go 版本:1.15.5

有人可以帮我吗?

推荐答案

这里引用官方文档

在 Linux 上 Setuid 和 Setgid 只影响当前线程,而不影响当前线程过程.这与大多数呼叫者的期望不符,所以我们必须在这里返回一个错误而不是让调用者认为调用成功.

On Linux Setuid and Setgid only affects the current thread, not the process. This does not match what most callers expect so we must return an error here rather than letting the caller think that the call succeeded.

一个可能的解决方案是在这个 commit

A possible solution is in this commit

这篇关于setuid:不支持操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆