home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / unixSyscall / setreuid.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-11-17  |  1.6 KB  |  62 lines

  1. /* 
  2.  * setreuid.c --
  3.  *
  4.  *    Source code for the setreuid library procedure.
  5.  *
  6.  * Copyright 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: /sprite/src/lib/c/unixSyscall/RCS/setreuid.c,v 1.1 88/11/17 13:30:52 ouster Exp $ SPRITE (Berkeley)";
  18. #endif not lint
  19.  
  20. #include <sprite.h>
  21. #include <proc.h>
  22. #include "compatInt.h"
  23.  
  24. /*
  25.  *----------------------------------------------------------------------
  26.  *
  27.  * setreuid --
  28.  *
  29.  *    Procedure to map from Unix setreuid system call to Sprite Proc_SetIDs.
  30.  *
  31.  * Results:
  32.  *    UNIX_ERROR is returned upon error, with the actual error code
  33.  *    stored in errno.  Upon success, UNIX_SUCCESS is returned.
  34.  *
  35.  * Side effects:
  36.  *    The real and effective user ID's of the process are modified as
  37.  *    specified, if the user is privileged to do so.
  38.  *
  39.  *----------------------------------------------------------------------
  40.  */
  41.  
  42. int
  43. setreuid(ruid, euid)
  44.     int    ruid, euid;
  45. {
  46.     ReturnStatus status;    /* result returned by Proc_SetIDs */
  47.  
  48.     if (ruid == -1) {
  49.     ruid = PROC_NO_ID;
  50.     }
  51.     if (euid == -1) {
  52.     euid = PROC_NO_ID;
  53.     }
  54.     status = Proc_SetIDs(ruid, euid);
  55.     if (status != SUCCESS) {
  56.     errno = Compat_MapCode(status);
  57.     return(UNIX_ERROR);
  58.     } else {
  59.     return(UNIX_SUCCESS);
  60.     }
  61. }
  62.