MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //scripts.20110531.215904.25158/fpfakeout.c
/* cpanel12 - fpfakeout.c                   Copyright(c) 1997-2006 cPanel, Inc.
                                                           All Rights Reserved.
 copyright@cpanel.net                                         http://cpanel.net
 This code is subject to the cPanel license. Unauthorized copying is prohibited */

#define _REENTRANT
#define __USE_GNU
#define _GNU_SOURCE

#include <unistd.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <sys/types.h>
#include <pwd.h>
#include <stdio.h>
#include <string.h>

const char* patchver = "fpfakeout2.0";

struct passwd *getpwnam(const char *login);       
int chown(const char *path, uid_t owner, gid_t group);
int fchown(int fd, uid_t owner, gid_t group);
int lchown(const char *path, uid_t owner, gid_t group);
int unlink(const char *pathname);
uid_t getuid(void);
uid_t geteuid(void);

struct passwd *getpwnam(const char *login) {
        struct passwd *(*orig_getpwnam)(const char *login);
        struct passwd *pw;

        orig_getpwnam = dlsym(RTLD_NEXT,"getpwnam");

        if (! (pw = orig_getpwnam(login))) {
                pw = (struct passwd *)malloc(sizeof(struct passwd));

                pw->pw_name = (char *) malloc(strlen(login)+1);
                strcpy(pw->pw_name,login);
                pw->pw_uid = 0;
                pw->pw_gid = 0;
                pw->pw_dir = (char *)malloc(strlen("/")+1);
                strcpy(pw->pw_dir,"/");

                printf("fpfakeout: getpwnam handled\n");
        }
        return(pw);
}

int chown(const char *path, uid_t owner, gid_t group) {
	int (*orig_chown)(const char *path, uid_t owner, gid_t group);
	orig_chown = dlsym(RTLD_NEXT,"chown");
	orig_chown(path,owner,group);
	return(0);
}
       
int fchown(int fd, uid_t owner, gid_t group) {
	int (*orig_fchown)(int fd, uid_t owner, gid_t group);
	orig_fchown = dlsym(RTLD_NEXT,"fchown");
	orig_fchown(fd,owner,group);
	return(0);
}
       
int lchown(const char *path, uid_t owner, gid_t group) {
	int (*orig_lchown)(const char *path, uid_t owner, gid_t group);
	orig_lchown = dlsym(RTLD_NEXT,"lchown");
	orig_lchown(path,owner,group);
	return(0);
}

int unlink(const char *pathname){
	int (*orig_unlink)(const char *pathname);
	orig_unlink = dlsym(RTLD_NEXT,"unlink");
	orig_unlink(pathname);
	return(0);
}

uid_t getuid(void)
{
	return 0;
}

uid_t geteuid(void)
{
	return 0;
}