ccx-utils

Miscellaneous utilities written in C
git clone https://ccx.te2000.cz/git/ccx-utils
Log | Files | Refs

nosuid.c (488B)


      1 /* ISC license. */
      2 
      3 #include <sys/prctl.h>
      4 #include <linux/securebits.h>
      5 
      6 #include <skalibs/exec.h>
      7 #include <skalibs/djbunix.h>
      8 #include <skalibs/strerr.h>
      9 
     10 #define USAGE "nosuid prog..."
     11 #define dieusage() strerr_dieusage(100, USAGE)
     12 
     13 int main (int argc, char const *const *argv)
     14 {
     15   if (argc < 2) dieusage() ;
     16 
     17   if (prctl(PR_SET_SECUREBITS, SECBIT_NOROOT | SECBIT_NOROOT_LOCKED) < 0) {
     18     strerr_dief1sys(111, "Failed to set securebits via prctl()");
     19   }
     20 
     21   else xexec(&argv[1]) ;
     22 }