diff -Naurb --exclude-from /home/muli/w/excludes 2.6.8-rc2bk8/security/august.c 2.6.8-rc2bk8aug/security/august.c --- 2.6.8-rc2bk8/security/august.c 1970-01-01 00:00:00.000000000 +0000 +++ 2.6.8-rc2bk8aug/security/august.c 2004-07-31 21:23:10.000000000 +0000 @@ -0,0 +1,142 @@ +/* + * August Rules + * + * Copyright (C) 2004 Muli Ben-Yehuda + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2 of the + * License. + */ + +#include +#include +#include +#include +#include +#include + +static int frob_me_plenty; + +static inline int frob_this_dentry(struct dentry* d) +{ + return (d && + d->d_inode && + d->d_inode->i_security == &frob_me_plenty); +} + +static inline int frob_this_file(struct file* f) +{ + return (f && frob_this_dentry(f->f_dentry)); +} + +/* for handling r/w */ +static int august_file_permission (struct file *file, int mask) +{ + if (!(mask & MAY_WRITE)) + return 0; + + if (frob_this_file(file)) { + printk(KERN_INFO "%s denying: %p\n", __func__, file); + return 1; + } + + return 0; +} + +/* renames */ +static int august_inode_rename(struct inode *old_dir, struct dentry *old_dentry, + struct inode *new_dir, struct dentry *new_dentry) +{ + if (frob_this_dentry(old_dentry)) { + printk(KERN_INFO "%s denying dentry: %p\n", __func__, old_dentry); + return 1; + } + + return 0; +} + +/* write via mmap */ +static int august_file_mmap(struct file * file, unsigned long prot, + unsigned long flags) +{ + if (frob_this_file(file)) { + printk(KERN_INFO "%s denying: %p\n", __func__, file); + return 1; + } + + return 0; +} + +static void august_inode_free_security(struct inode *inode) +{ + if (inode) + inode->i_security = NULL; +} + +static int august_inode_permission(struct inode *inode, int mask, struct nameidata *nd) +{ + const unsigned char* n; + + if (!(mask & MAY_WRITE)) + return 0; + + /* temporary workaround - we are getting bad nd's here */ + /* (lower than PAGE_SIZE) - found out why */ + if (((unsigned long)nd < 0x10000) || + ((unsigned long)nd->last.name < 0x10000)) + return 0; + + n = nd->last.name; + + /* if this is the magic file, attach the token to it */ + if (!strcmp("stage3.tmp", n)) { + printk(KERN_INFO "putting the hex on '%s'\n", n); + if (IS_ERR(inode)) + printk("no inode?!\n"); + else + inode->i_security = &frob_me_plenty; + } + + return 0; +} + +static struct security_operations august_security_ops = { + .inode_free_security = august_inode_free_security, + .inode_permission = august_inode_permission, + .file_permission = august_file_permission, + .inode_rename = august_inode_rename, + .file_mmap = august_file_mmap +}; + +static int __init august_init(void) +{ + int ret; + + /* register ourselves with the security framework */ + ret = register_security(&august_security_ops); + if (ret) { + printk (KERN_INFO "failure registering august with " + "the kernel (%d)\n", ret); + return ret; + } + + printk (KERN_INFO "august initialized\n"); + return 0; +} + +static void __exit august_exit(void) +{ + if (unregister_security(&august_security_ops)) { + printk (KERN_INFO "failure unregistering august " + "module with the kernel\n"); + } + printk(KERN_INFO "august module removed\n"); +} + +security_initcall(august_init); +module_exit(august_exit); + +MODULE_DESCRIPTION("august module, written for august penguin 2003"); +MODULE_LICENSE("GPL"); + diff -Naurb --exclude-from /home/muli/w/excludes 2.6.8-rc2bk8/security/Kconfig 2.6.8-rc2bk8aug/security/Kconfig --- 2.6.8-rc2bk8/security/Kconfig 2004-06-16 05:19:42.000000000 +0000 +++ 2.6.8-rc2bk8aug/security/Kconfig 2004-07-31 19:45:01.000000000 +0000 @@ -44,6 +44,12 @@ If you are unsure how to answer this question, answer N. +config SECURITY_AUGUST + tristate "August Security" + depends on SECURITY!=n + help + All Hail August Penguin 3! + source security/selinux/Kconfig endmenu diff -Naurb --exclude-from /home/muli/w/excludes 2.6.8-rc2bk8/security/Makefile 2.6.8-rc2bk8aug/security/Makefile --- 2.6.8-rc2bk8/security/Makefile 2004-06-16 05:19:43.000000000 +0000 +++ 2.6.8-rc2bk8aug/security/Makefile 2004-07-31 19:45:15.000000000 +0000 @@ -15,3 +15,4 @@ obj-$(CONFIG_SECURITY_SELINUX) += selinux/built-in.o obj-$(CONFIG_SECURITY_CAPABILITIES) += commoncap.o capability.o obj-$(CONFIG_SECURITY_ROOTPLUG) += commoncap.o root_plug.o +obj-$(CONFIG_SECURITY_AUGUST) += august.o