/********************************************/
/* This module will (hopefully) check to see*/
/* if loadable modules are enabled in the   */
/* kernel...for a really secure system, this*/
/* should be disabled and they should be    */
/* static in the kernel. 		    */
/*                                          */ 
/* This will (obviously) not work under     */
/* Solaris or AIX...			    */
/* Note I will check in lsatmain.c to see   */
/* if we are on a linux distro before we    */
/* run this. I think this will save some    */
/* cpu cycles instead of coming here to do  */
/* this check...		   	    */
/* 					    */
/* See lsatmain.c for more details.         */
/********************************************/
 
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

int checkmodules(filename, distribution, verbose, html)
const char *const filename;
int verbose;
int distribution;
int html;
{
    const char * header   =NULL;
    const char * tempfile =NULL;
    const char * shellcode=NULL;
  
    if (verbose >= 0)
    {
        printf(" Running checkmodules module...\n");
    }


    if ((system("cat /proc/modules 1>/dev/null 2>/dev/null >/dev/null")) == 0 )
    {
        /* we think that modules are enabled.*/
        /* lets kindof make sure...          */

        /* I am not 100% on this one. Anyone?*/
        /* Bueller? Bueller? Anyone?         */

        if ((system("grep module /proc/ksyms 1>/dev/null 2>/dev/null >/dev/null")) == 0)
        {
            /* we really think, sortof, that modules are enabled...*/

            header = "Modules appear to be enabled in the kernel.\nFor the paranoid, consider recompiling as static.\n";
            if ((dostuff(0, filename, 0, header, html)) < 0)
            {
   	        /* something went wrong */
                perror(" Creation of list failed.");
       	        return(-1);
            } 
        } 
    }

    if (verbose > 0)
    {
        printf(" Finished in checkmodules module.\n");
    }

    return(0);
}

