2005-12-21 05:53:43 -06:00
|
|
|
#include <fcntl.h>
|
2004-09-08 09:02:45 -05:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2005-12-21 05:53:43 -06:00
|
|
|
#include <unistd.h>
|
2004-09-08 09:02:45 -05:00
|
|
|
#include <dlfcn.h>
|
|
|
|
|
|
|
|
#ifdef _cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-02-24 09:17:51 -06:00
|
|
|
#ifdef SOLARIS
|
|
|
|
|
2005-06-17 08:12:57 -05:00
|
|
|
#include <sys/systeminfo.h>
|
|
|
|
#include <strings.h>
|
|
|
|
|
2004-09-08 09:02:45 -05:00
|
|
|
int chown (const char *path, uid_t owner, gid_t group) {return 0;}
|
|
|
|
int lchown (const char *path, uid_t owner, gid_t group) {return 0;}
|
|
|
|
int fchown (int fildes, uid_t owner, gid_t group) {return 0;}
|
|
|
|
|
|
|
|
uid_t getuid (void) {return 0;}
|
2005-12-21 05:53:43 -06:00
|
|
|
int stat(const char *path, struct stat *buf);
|
2004-09-08 09:02:45 -05:00
|
|
|
#ifdef __notdef__
|
|
|
|
uid_t geteuid (void) {return 0;}
|
|
|
|
gid_t getgid (void) {return 0;}
|
|
|
|
gid_t getegid (void) {return 0;}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int setuid (uid_t p) {return 0;}
|
|
|
|
int setgid (gid_t p) {return 0;}
|
|
|
|
|
2005-02-24 09:17:51 -06:00
|
|
|
/* This is to fool cpio and pkgmk */
|
2004-09-08 09:02:45 -05:00
|
|
|
int fstat(int fildes, struct stat *buf)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
static int (*p_fstat) (int fildes, struct stat *buf) = NULL;
|
|
|
|
if (p_fstat == NULL)
|
|
|
|
p_fstat = (int (*)(int fildes, struct stat *buf))
|
|
|
|
dlsym (RTLD_NEXT, "fstat");
|
|
|
|
ret = (*p_fstat)(fildes, buf);
|
|
|
|
if (buf != NULL)
|
2004-11-18 01:20:43 -06:00
|
|
|
{
|
|
|
|
buf->st_uid = 0; /* root */
|
2004-12-07 03:57:32 -06:00
|
|
|
buf->st_gid = 2; /* bin */
|
2004-11-18 01:20:43 -06:00
|
|
|
}
|
2004-09-08 09:02:45 -05:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-12-21 05:53:43 -06:00
|
|
|
/* this is to fool mkdir, don't allow to remove owner execute right from directories */
|
|
|
|
int chmod(const char *path, mode_t mode)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
static int (*p_chmod) (const char *path, mode_t mode) = NULL;
|
|
|
|
if (p_chmod == NULL)
|
|
|
|
p_chmod = (int (*)(const char *path, mode_t mode))
|
|
|
|
dlsym (RTLD_NEXT, "chmod");
|
|
|
|
|
|
|
|
if ((mode & S_IXUSR) == 0)
|
|
|
|
{
|
|
|
|
struct stat statbuf;
|
|
|
|
if (stat(path, &statbuf) == 0)
|
|
|
|
{
|
|
|
|
if ((statbuf.st_mode & S_IFDIR) != 0)
|
|
|
|
mode = (mode | S_IXUSR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = (*p_chmod)(path, mode);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-02-24 09:17:51 -06:00
|
|
|
/* This is to fool tar */
|
|
|
|
int fstatat64(int fildes, const char *path, struct stat64 *buf, int flag)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
static int (*p_fstatat) (int fildes, const char *path, struct stat64 *buf, int flag) = NULL;
|
|
|
|
if (p_fstatat == NULL)
|
|
|
|
p_fstatat = (int (*)(int fildes, const char *path, struct stat64 *buf, int flag))
|
|
|
|
dlsym (RTLD_NEXT, "fstatat64");
|
|
|
|
ret = (*p_fstatat)(fildes, path, buf, flag);
|
|
|
|
if (buf != NULL)
|
|
|
|
{
|
|
|
|
buf->st_uid = 0; /* root */
|
|
|
|
buf->st_gid = 2; /* bin */
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined LINUX
|
|
|
|
|
2005-08-18 06:50:51 -05:00
|
|
|
uid_t getuid (void) {return 0;}
|
|
|
|
uid_t geteuid (void) {return 0;}
|
|
|
|
|
2005-02-24 09:17:51 -06:00
|
|
|
/* This is to fool tar */
|
|
|
|
int __lxstat64(int n, const char *path, struct stat64 *buf)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
static int (*p_lstat) (int n, const char *path, struct stat64 *buf) = NULL;
|
|
|
|
if (p_lstat == NULL)
|
|
|
|
p_lstat = (int (*)(int n, const char *path, struct stat64 *buf))
|
|
|
|
dlsym (RTLD_NEXT, "__lxstat64");
|
|
|
|
ret = (*p_lstat)(n, path, buf);
|
|
|
|
if (buf != NULL)
|
|
|
|
{
|
|
|
|
buf->st_uid = 0; /* root */
|
|
|
|
buf->st_gid = 0; /* root */
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2004-09-08 09:02:45 -05:00
|
|
|
#ifdef _cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|