home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / mod.std.unix.v5 / text0043.txt < prev    next >
Encoding:
Text File  |  1987-06-30  |  2.1 KB  |  65 lines

  1. >From: Kay Dekker <seismo!mcvax!warwick!kay>
  2. To: ut-sally!std-unix
  3. Organization: Computer Science, Warwick University, UK
  4. Date: Sat,  8 Feb 86 10:20:38 GMT
  5.  
  6. >Date: Wed, 5 Feb 86 08:12:33 pst
  7. >>From: seismo!sun!rtech!daveb (Dave Brower)
  8. >Organization: Relational Technology Inc, Alameda CA
  9. >
  10. >The answer is only to do limited operations when in setuid.  The best
  11. >way to do this would be to allow processes to painlessly shift back and
  12. >forth between their real-uid and effective-uid.  This is allowed, but
  13. >not documented on BSD, but appears not to be allowed at all on SV.
  14. >This way, you can have your one section that need to run setuid be setuid
  15. >whenver needed, while running as the real user the reset of the time.
  16.  
  17. This is *exactly* what I found myself needing to do last night...  When
  18. you say "BSD", does this include 4.1?  If so, how do I do it?  and why
  19. isn't it documented?
  20.  
  21.                         Kay.
  22. -- 
  23. Virtue is its own punishment.
  24.             ... mcvax!ukc!warwick!kay
  25.  
  26. [ It was introduced in 4.2BSD.  Here's the man page.
  27. Note that only super-user can actually switch back and forth
  28. between ruid and euid.  -mod ]
  29.  
  30.  
  31. SETREUID(2)         UNIX Programmer's Manual          SETREUID(2)
  32.  
  33. NAME
  34.      setreuid - set real and effective user ID's
  35.  
  36. SYNOPSIS
  37.      setreuid(ruid, euid)
  38.      int ruid, euid;
  39.  
  40. DESCRIPTION
  41.      The real and effective user ID's of the current process are
  42.      set according to the arguments.  If _r_u_i_d or _e_u_i_d is -1, the
  43.      current uid is filled in by the system.  Only the super-user
  44.      may modify the real uid of a process.  Users other than the
  45.      super-user may change the effective uid of a process only to
  46.      the real uid.
  47.  
  48. RETURN VALUE
  49.      Upon successful completion, a value of 0 is returned.  Oth-
  50.      erwise, a value of -1 is returned and _e_r_r_n_o is set to indi-
  51.      cate the error.
  52.  
  53. ERRORS
  54.      [EPERM]        The current process is not the super-user and
  55.                     a change other than changing the effective
  56.                     user-id to the real user-id was specified.
  57.  
  58. SEE ALSO
  59.      getuid(2), setregid(2), setuid(3)
  60.  
  61. Printed 2/11/86         12 February 1983                        1
  62.  
  63. Volume-Number: Volume 5, Number 44
  64.  
  65.