pax_getname.c

Go to the documentation of this file.
00001 /********************************** */
00002 /* Rule Set Based Access Control    */
00003 /* Author and (c) 1999-2004:        */
00004 /*   Amon Ott <ao@rsbac.org>        */
00005 /* Getname functions for PAX module */
00006 /* Last modified: 06/Jan/2004       */
00007 /********************************** */
00008 
00009 #include <rsbac/types.h>
00010 #include <rsbac/pax_getname.h>
00011 #include <rsbac/helpers.h>
00012 #include <rsbac/error.h>
00013 
00014 #ifdef __KERNEL__
00015 #include <linux/string.h>
00016 #else
00017 #include <string.h>
00018 #endif
00019 
00020 char * pax_print_flags(char * string, rsbac_pax_flags_t flags)
00021   {
00022     sprintf(string, "%c%c%c%c%c%c",
00023            flags & PF_PAX_PAGEEXEC ? 'P' : 'p',
00024            flags & PF_PAX_EMUTRAMP ? 'E' : 'e',
00025            flags & PF_PAX_MPROTECT ? 'M' : 'm',
00026            flags & PF_PAX_RANDMMAP ? 'R' : 'r',
00027            flags & PF_PAX_RANDEXEC ? 'X' : 'x',
00028            flags & PF_PAX_SEGMEXEC ? 'S' : 's');
00029     return string;
00030   }
00031 
00032 #ifndef __KERNEL__
00033 rsbac_pax_flags_t pax_strtoflags(char * string, rsbac_pax_flags_t init_flags)
00034   {
00035     char * p = string;
00036     rsbac_pax_flags_t add_flags = 0;
00037     rsbac_pax_flags_t remove_flags = 0;
00038 
00039     if(!p)
00040       return init_flags;
00041     while(*p)
00042       {
00043         switch(*p)
00044           {
00045               case 'P':
00046                 add_flags |= PF_PAX_PAGEEXEC;
00047                 break;
00048               case 'p':
00049                 remove_flags |= PF_PAX_PAGEEXEC;
00050                 break;
00051               case 'E':
00052                 add_flags |= PF_PAX_EMUTRAMP;
00053                 break;
00054               case 'e':
00055                 remove_flags |= PF_PAX_EMUTRAMP;
00056                 break;
00057               case 'M':
00058                 add_flags |= PF_PAX_MPROTECT;
00059                 break;
00060               case 'm':
00061                 remove_flags |= PF_PAX_MPROTECT;
00062                 break;
00063               case 'R':
00064                 add_flags |= PF_PAX_RANDMMAP;
00065                 break;
00066               case 'r':
00067                 remove_flags |= PF_PAX_RANDMMAP;
00068                 break;
00069               case 'X':
00070                 add_flags |= PF_PAX_RANDEXEC;
00071                 break;
00072               case 'x':
00073                 remove_flags |= PF_PAX_RANDEXEC;
00074                 break;
00075               case 'S':
00076                 add_flags |= PF_PAX_SEGMEXEC;
00077                 break;
00078               case 's':
00079                 remove_flags |= PF_PAX_SEGMEXEC;
00080                 break;
00081               case 'z':
00082                 remove_flags = RSBAC_PAX_ALL_FLAGS;
00083                 break;
00084               case 'a':
00085                 add_flags = RSBAC_PAX_ALL_FLAGS;
00086                 break;
00087             default:
00088               break;
00089           }
00090         p++;
00091       }
00092     return (init_flags | add_flags) & ~remove_flags;
00093   }
00094 #endif

Generated on Fri Jun 17 09:45:26 2005 for RSBAC by  doxygen 1.4.2