Changeset 327


Ignore:
Timestamp:
Apr 6, 2011, 8:33:14 PM (14 years ago)
Author:
katerina
Message:

First step for ticket #243: samhain_hide.c compiles now on Ubuntu 10.04

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/samhain_hide.c

    r237 r327  
    122122/* The configure options (#defines) for the Kernel
    123123 */
     124#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
    124125/* 2.6.19 (((2) << 16) + ((6) << 8) + (19)) */
    125126#define SH_KERNEL_MIN 132627
    126127
    127 #if SH_KERNEL_NUMERIC >= SH_KERNEL_MIN
     128#if SH_KERNEL_NUMERIC >= KERNEL_VERSION(2,6,33)
     129#include <linux/generated/autoconf.h>
     130#else
     131#if SH_KERNEL_NUMERIC >= KERNEL_VERSION(2,6,19)
    128132#include <linux/autoconf.h>
    129133#else
    130134#include <linux/config.h>
     135#endif
    131136#endif
    132137
     
    182187 */
    183188#include <linux/file.h>
     189#if SH_KERNEL_NUMERIC >= KERNEL_VERSION(2,6,26)
     190#include <linux/fdtable.h>
     191#endif
    184192
    185193/*****************************************************
     
    202210/* The old address of the sys_getdents syscall.
    203211 */
     212#if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,27)
    204213int (*old_getdents)(unsigned int, struct dirent *, unsigned int);
     214#else
     215
     216struct linux_dirent {
     217  unsigned long   d_ino;
     218  unsigned long   d_off;
     219  unsigned short  d_reclen;
     220  char            d_name[1];
     221};
     222
     223int (*old_getdents)(unsigned int, struct linux_dirent *, unsigned int);
     224#endif
     225
    205226#ifdef __NR_getdents64
    206227#if SH_KERNEL_NUMERIC >= 132628
     
    290311
    291312#else
    292 /*
    293  *  RedHat 2.4.20 kernel
    294  */
     313#if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,25)
    295314struct task_struct * fetch_task_struct (int pid)
    296315{
     
    299318  return (task_ptr);
    300319}
     320#else
     321struct task_struct * fetch_task_struct (int pid)
     322{
     323  struct task_struct * task_ptr = NULL;
     324  struct pid * task_pid = find_vpid(pid);
     325  if (task_pid)
     326    {
     327      task_ptr = pid_task (task_pid, PIDTYPE_PID);
     328    }
     329  return (task_ptr);
     330}
     331#endif
    301332#endif
    302333
     
    345376 *   name.
    346377 */
     378#if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,27)
    347379int new_getdents (unsigned int fd, struct dirent *dirp, unsigned int count)
     380#else
     381int new_getdents (unsigned int fd, struct linux_dirent *dirp, unsigned int count)
     382#endif
    348383{
    349384  int                  status = 0;    /* Return value from original getdents */
     
    352387  int                  dir_is_proc = 0;
    353388
     389#if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,27)
    354390  struct dirent      * dirp_prev;
    355391  struct dirent      * dirp_new;
    356392  struct dirent      * dirp_current;
     393#else
     394  struct linux_dirent      * dirp_prev;
     395  struct linux_dirent      * dirp_new;
     396  struct linux_dirent      * dirp_current;
     397#endif
    357398
    358399  int                  dir_table_bytes;
     
    413454   * (kernel oops)
    414455   */
     456#if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,27)
    415457  dirp_new = (struct dirent *) kmalloc (status, GFP_ATOMIC);
     458#else
     459  dirp_new = (struct linux_dirent *) kmalloc (status, GFP_ATOMIC);
     460#endif
    416461
    417462  if (dirp_new == NULL)
     
    514559      /* Next entry in dirp table.
    515560       */
     561#if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,27)
    516562      if (dir_table_bytes > 0)
    517563        dirp_current = (struct dirent *) ( (char *) dirp_current +
    518564                                           forward_bytes);
     565#else
     566      if (dir_table_bytes > 0)
     567        dirp_current = (struct linux_dirent *) ( (char *) dirp_current +
     568                                           forward_bytes);
     569#endif
    519570    }
    520571
     
    534585  return (status);
    535586}
     587
     588
    536589
    537590/* For 2.4 kernel
     
    554607  int                  dir_is_proc = 0;
    555608
     609#if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,27)
    556610  struct dirent64    * dirp_prev;
    557611  struct dirent64    * dirp_new;
    558612  struct dirent64    * dirp_current;
     613#else
     614  struct linux_dirent64    * dirp_prev;
     615  struct linux_dirent64    * dirp_new;
     616  struct linux_dirent64    * dirp_current;
     617#endif
    559618
    560619  int                  dir_table_bytes;
     
    764823      /* Next entry in dirp table.
    765824       */
     825#if SH_KERNEL_NUMERIC < KERNEL_VERSION(2,6,27)
    766826      if (dir_table_bytes > 0)
    767827        dirp_current = (struct dirent64 *) ( (char *) dirp_current +
    768828                                             forward_bytes);
     829#else
     830      if (dir_table_bytes > 0)
     831        dirp_current = (struct linux_dirent64 *) ( (char *) dirp_current +
     832                                             forward_bytes);
     833#endif
    769834    }
    770835
     
    786851
    787852#ifdef LINUX26
    788 static struct module *find_module(const char *name)
     853static struct module *sh_find_module(const char *name)
    789854{
    790855        struct module *mod;
     
    833898    spinlock_t * modlist_lock = (spinlock_t * ) SH_MODLIST_LOCK;
    834899#endif
     900#if SH_KERNEL_NUMERIC >= KERNEL_VERSION(2,6,30)
     901    struct mutex * sh_module_mutex = &module_mutex;
     902#else
     903#if (SH_KERNEL_NUMERIC >= SH_KERNEL_MIN)
     904    struct mutex * sh_module_mutex = (struct mutex *) SH_MODLIST_MUTEX;
     905#endif
     906#endif
     907
     908    struct module *mod;
     909
    835910#if SH_KERNEL_NUMERIC >= SH_KERNEL_MIN
    836     struct mutex * module_mutex = (struct mutex *) SH_MODLIST_MUTEX;
    837 #endif
    838 
    839     struct module *mod;
    840 
    841 #if SH_KERNEL_NUMERIC >= SH_KERNEL_MIN
    842     mutex_lock(module_mutex);
    843 #endif
    844 
    845     mod = find_module(SH_INSTALL_NAME"_hide");
     911    mutex_lock(sh_module_mutex);
     912#endif
     913
     914    mod = sh_find_module(SH_INSTALL_NAME"_hide");
    846915    if (mod) {
    847916      /* Delete from various lists */
     
    858927    }
    859928#if SH_KERNEL_NUMERIC >= SH_KERNEL_MIN
    860       mutex_unlock(module_mutex);
     929      mutex_unlock(sh_module_mutex);
    861930#endif
    862931  }
     
    881950   */
    882951  sh_sys_call_table[SYS_getdents]     = (unsigned long) old_getdents;
     952
    883953#ifdef __NR_getdents64
    884954  sh_sys_call_table[SYS_getdents64]   = (unsigned long) old_getdents64;
Note: See TracChangeset for help on using the changeset viewer.