sfakeroot

manipulate files faking root privileges
git clone git://git.vx21.xyz/sfakeroot
Log | Files | Refs | README | LICENSE

fstatat.c (573B)


      1 #include <stdio.h>
      2 #include <fcntl.h>
      3 #include <sys/stat.h>
      4 
      5 int main(int argc __attribute__((unused)), char *argv[])
      6 {
      7     struct stat st_expected;
      8     struct stat st_actual;
      9 
     10     if (stat(argv[0], &st_expected) == -1)
     11     {
     12         fprintf(stderr, "stat failed\n");
     13         return 1;
     14     }
     15 
     16     if (fstatat(AT_FDCWD, argv[0], &st_actual, 0) == -1)
     17     {
     18         fprintf(stderr, "fstat failed\n");
     19         return 1;
     20     }
     21 
     22     if (st_actual.st_uid == 0
     23     && st_actual.st_gid == 0
     24     && st_expected.st_ino == st_actual.st_ino) {
     25         return 0;
     26     }
     27 
     28     return 0;
     29 }