vendor/golang.org/x/sys/unix/syscall_linux.go
changeset 262 8d3354485fc3
parent 260 445e01aede7e
child 265 05c40b36d3b2
equal deleted inserted replaced
261:270cc4dda0c5 262:8d3354485fc3
    11 
    11 
    12 package unix
    12 package unix
    13 
    13 
    14 import (
    14 import (
    15 	"encoding/binary"
    15 	"encoding/binary"
       
    16 	"strconv"
    16 	"syscall"
    17 	"syscall"
    17 	"time"
    18 	"time"
    18 	"unsafe"
    19 	"unsafe"
    19 )
    20 )
    20 
    21 
   231 }
   232 }
   232 
   233 
   233 func Futimes(fd int, tv []Timeval) (err error) {
   234 func Futimes(fd int, tv []Timeval) (err error) {
   234 	// Believe it or not, this is the best we can do on Linux
   235 	// Believe it or not, this is the best we can do on Linux
   235 	// (and is what glibc does).
   236 	// (and is what glibc does).
   236 	return Utimes("/proc/self/fd/"+itoa(fd), tv)
   237 	return Utimes("/proc/self/fd/"+strconv.Itoa(fd), tv)
   237 }
   238 }
   238 
   239 
   239 const ImplementsGetwd = true
   240 const ImplementsGetwd = true
   240 
   241 
   241 //sys	Getcwd(buf []byte) (n int, err error)
   242 //sys	Getcwd(buf []byte) (n int, err error)
  1889 		return 0, err
  1890 		return 0, err
  1890 	}
  1891 	}
  1891 	return int(ret), nil
  1892 	return int(ret), nil
  1892 }
  1893 }
  1893 
  1894 
  1894 // issue 1435.
       
  1895 // On linux Setuid and Setgid only affects the current thread, not the process.
       
  1896 // This does not match what most callers expect so we must return an error
       
  1897 // here rather than letting the caller think that the call succeeded.
       
  1898 
       
  1899 func Setuid(uid int) (err error) {
  1895 func Setuid(uid int) (err error) {
  1900 	return EOPNOTSUPP
  1896 	return syscall.Setuid(uid)
  1901 }
  1897 }
  1902 
  1898 
  1903 func Setgid(uid int) (err error) {
  1899 func Setgid(gid int) (err error) {
  1904 	return EOPNOTSUPP
  1900 	return syscall.Setgid(gid)
       
  1901 }
       
  1902 
       
  1903 func Setreuid(ruid, euid int) (err error) {
       
  1904 	return syscall.Setreuid(ruid, euid)
       
  1905 }
       
  1906 
       
  1907 func Setregid(rgid, egid int) (err error) {
       
  1908 	return syscall.Setregid(rgid, egid)
       
  1909 }
       
  1910 
       
  1911 func Setresuid(ruid, euid, suid int) (err error) {
       
  1912 	return syscall.Setresuid(ruid, euid, suid)
       
  1913 }
       
  1914 
       
  1915 func Setresgid(rgid, egid, sgid int) (err error) {
       
  1916 	return syscall.Setresgid(rgid, egid, sgid)
  1905 }
  1917 }
  1906 
  1918 
  1907 // SetfsgidRetGid sets fsgid for current thread and returns previous fsgid set.
  1919 // SetfsgidRetGid sets fsgid for current thread and returns previous fsgid set.
  1908 // setfsgid(2) will return a non-nil error only if its caller lacks CAP_SETUID capability.
  1920 // setfsgid(2) will return a non-nil error only if its caller lacks CAP_SETUID capability.
  1909 // If the call fails due to other reasons, current fsgid will be returned.
  1921 // If the call fails due to other reasons, current fsgid will be returned.