13 #include <sys/systeminfo.h>
16 int chown (const char *path
, uid_t owner
, gid_t group
) {return 0;}
17 int lchown (const char *path
, uid_t owner
, gid_t group
) {return 0;}
18 int fchown (int fildes
, uid_t owner
, gid_t group
) {return 0;}
20 uid_t
getuid (void) {return 0;}
21 int stat(const char *path
, struct stat
*buf
);
23 uid_t
geteuid (void) {return 0;}
24 gid_t
getgid (void) {return 0;}
25 gid_t
getegid (void) {return 0;}
28 int setuid (uid_t p
) {return 0;}
29 int setgid (gid_t p
) {return 0;}
31 /* This is to fool cpio and pkgmk */
32 int fstat(int fildes
, struct stat
*buf
)
35 static int (*p_fstat
) (int fildes
, struct stat
*buf
) = NULL
;
37 p_fstat
= (int (*)(int fildes
, struct stat
*buf
))
38 dlsym (RTLD_NEXT
, "fstat");
39 ret
= (*p_fstat
)(fildes
, buf
);
42 buf
->st_uid
= 0; /* root */
43 buf
->st_gid
= 2; /* bin */
49 /* this is to fool mkdir, don't allow to remove owner execute right from directories */
50 int chmod(const char *path
, mode_t mode
)
53 static int (*p_chmod
) (const char *path
, mode_t mode
) = NULL
;
55 p_chmod
= (int (*)(const char *path
, mode_t mode
))
56 dlsym (RTLD_NEXT
, "chmod");
58 if ((mode
& S_IXUSR
) == 0)
61 if (stat(path
, &statbuf
) == 0)
63 if ((statbuf
.st_mode
& S_IFDIR
) != 0)
64 mode
= (mode
| S_IXUSR
);
68 ret
= (*p_chmod
)(path
, mode
);
74 /* This is to fool tar */
75 int fstatat64(int fildes
, const char *path
, struct stat64
*buf
, int flag
)
78 static int (*p_fstatat
) (int fildes
, const char *path
, struct stat64
*buf
, int flag
) = NULL
;
79 if (p_fstatat
== NULL
)
80 p_fstatat
= (int (*)(int fildes
, const char *path
, struct stat64
*buf
, int flag
))
81 dlsym (RTLD_NEXT
, "fstatat64");
82 ret
= (*p_fstatat
)(fildes
, path
, buf
, flag
);
85 buf
->st_uid
= 0; /* root */
86 buf
->st_gid
= 2; /* bin */
93 uid_t
getuid (void) {return 0;}
94 uid_t
geteuid (void) {return 0;}
96 /* This is to fool tar */
98 int __lxstat(int n
, const char *path
, struct stat
*buf
)
101 static int (*p_lstat
) (int n
, const char *path
, struct stat
*buf
) = NULL
;
103 p_lstat
= (int (*)(int n
, const char *path
, struct stat
*buf
))
104 dlsym (RTLD_NEXT
, "__lxstat");
105 ret
= (*p_lstat
)(n
, path
, buf
);
108 buf
->st_uid
= 0; /* root */
109 buf
->st_gid
= 0; /* root */
114 int __lxstat64(int n
, const char *path
, struct stat64
*buf
)
117 static int (*p_lstat
) (int n
, const char *path
, struct stat64
*buf
) = NULL
;
119 p_lstat
= (int (*)(int n
, const char *path
, struct stat64
*buf
))
120 dlsym (RTLD_NEXT
, "__lxstat64");
121 ret
= (*p_lstat
)(n
, path
, buf
);