sfakeroot

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

lstat.c (543B)


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