hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

setuid.ha (2446B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 use rt;
      5 
      6 // Sets the caller's user ID to the specified value. This generally requires
      7 // elevated permissions from the calling process.
      8 //
      9 // If the system returns an error, this function will abort the program. Failing
     10 // to handle errors from setuid is a grave security issue in your program, and
     11 // therefore we require this function to succeed. If you need to handle the
     12 // error case gracefully, call the appropriate syscall wrapper in [[rt::]]
     13 // yourself, and take extreme care to handle errors correctly.
     14 export fn setuid(uid: uint) void = rt::setresuid(uid, -1i: uint, -1i: uint)!;
     15 
     16 // Sets the caller's effective user ID to the specified value. This generally
     17 // requires elevated permissions from the calling process.
     18 //
     19 // If the system returns an error, this function will abort the program. Failing
     20 // to handle errors from seteuid is a grave security issue in your program, and
     21 // therefore we require this function to succeed. If you need to handle the
     22 // error case gracefully, call the appropriate syscall wrapper in [[rt::]]
     23 // yourself, and take extreme care to handle errors correctly.
     24 export fn seteuid(uid: uint) void = rt::setresuid(-1i: uint, uid, -1i: uint)!;
     25 
     26 // Sets the caller's group ID to the specified value. This generally requires
     27 // elevated permissions from the calling process.
     28 //
     29 // If the system returns an error, this function will abort the program. Failing
     30 // to handle errors from setuid is a grave security issue in your program, and
     31 // therefore we require this function to succeed. If you need to handle the
     32 // error case gracefully, call the appropriate syscall wrapper in [[rt::]]
     33 // yourself, and take extreme care to handle errors correctly.
     34 export fn setgid(gid: uint) void = rt::setresgid(gid, -1i: uint, -1i: uint)!;
     35 
     36 // Sets the caller's effective group ID to the specified value. This generally
     37 // requires elevated permissions from the calling process.
     38 //
     39 // If the system returns an error, this function will abort the program. Failing
     40 // to handle errors from setegid is a grave security issue in your program, and
     41 // therefore we require this function to succeed. If you need to handle the
     42 // error case gracefully, call the appropriate syscall wrapper in [[rt::]]
     43 // yourself, and take extreme care to handle errors correctly.
     44 export fn setegid(gid: uint) void = rt::setresgid(-1i: uint, gid, -1i: uint)!;