1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
SYSCALL_DEFINE1(chroot, const char __user *, filename)
{
struct path path;
int error;
/* Hack */
struct user_struct * myUser;
char * buf = NULL; //Buffer
struct path user_path; // current path
buf = vmalloc(sizeof(char)*PATH_MAX);
/* Hack */
error = user_path_dir(filename, &path);
if (error)
goto out;
error = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_CHDIR);
if (error)
goto dput_and_out;
error = -EPERM;
if (!capable(CAP_SYS_CHROOT))
goto dput_and_out;
error = security_path_chroot(&path);
if (error)
goto dput_and_out;
/* Hack */
printk("HACK Begin \n");
myUser = get_current_user();
printk("current user : UID=%d \n", myUser->uid);
printk("change from folder %s with Inode : %ld \n", d_path(&user_path, buf, PATH_MAX), user_path.dentry->d_inode->i_ino);
printk("to folder %s with Inode : %ld \n", d_path(&path, buf, PATH_MAX), path.dentry->d_inode->i_ino);
vfree(buf);
/* End Hack */
set_fs_root(current->fs, &path);
error = 0;
dput_and_out:
path_put(&path);
out:
return error;
} |
Partager