Exemplo n.º 1
0
Arquivo: tester.c Projeto: jre/upart
void
testfiles(FILE *idx)
{
	char *bad, *name, *fullname, *imgfile, *outfile, *errfile, *exitfile;
	char *newoutfile, *newerrfile;
	int exitval, failed, failures, testcount;
	size_t i;

	printf("running tests...\n");

	bad = NULL;
	testcount = 0;
	failures = 0;
	while ((name = nextname(TESTINDEX_PATH, idx)) != NULL) {
		for (i = 0; i < NITEMS(flags); i++) {
			fullname = strjoin(name, flags[i], (void *)NULL);
			imgfile = strjoin(name, ".img", (void *)NULL);
			outfile = strjoin(fullname, ".out", (void *)NULL);
			errfile = strjoin(fullname, ".err", (void *)NULL);
			exitfile = strjoin(fullname, ".exit", (void *)NULL);
			newoutfile = strjoin("test-", fullname, ".out", (void *)NULL);
			newerrfile = strjoin("test-", fullname, ".err", (void *)NULL);

			rmfile(newoutfile);
			rmfile(newerrfile);
			exitval = runtest(flags[i], imgfile,
			    newoutfile, newerrfile);
			failed = 0;

			if (!checkexitval(fullname, exitval, exitfile))
				failed = 1;
			if (!checkfiles(fullname, outfile, newoutfile, 0))
				failed = 1;
			if (!checkfiles(fullname, errfile, newerrfile, 1))
				failed = 1;

			testcount++;
			if (failed) {
				failures++;
				bad = appendname(bad, fullname);
			}

			free(fullname);
			free(imgfile);
			free(outfile);
			free(errfile);
			free(exitfile);
			free(newoutfile);
			free(newerrfile);
		}
	}

	printf("%d tests failed out of %d total.\n", failures, testcount);
	if (failures != 0) {
		printf("The following tests failed:\n  %s\n", bad);
		exit(EXIT_FAILURE);
	}
}
int
main (int argc, char **argv)
{
  struct commandline cmd;

  (void) memset ((char *) &cmd, 0, sizeof (struct commandline));
  clear_args ();
  if (!parseargs (argc, argv, &cmd) || !cmd.infile)
    usage ();

  if (cmd.cflag || cmd.hflag || cmd.tflag)
    checkfiles (cmd.infile, cmd.outfile);
  else
    checkfiles (cmd.infile, NULL);

  if (cmd.cflag) {
    c_output (cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile);
  }
  else if (cmd.hflag) {
    h_output (cmd.infile, "-DRPC_HDR", DONT_EXTEND, cmd.outfile);
  }
  else if (cmd.tflag) {
    t_output (cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile);
  }
  else {
    /* the rescans are required, since cpp may effect input */
    c_output (cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c");
    reinitialize ();
    h_output (cmd.infile, "-DRPC_HDR", EXTEND, ".h");
    reinitialize ();
    t_output (cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.c");
  }
#ifdef __MSDOS__
  if (dos_cppfile != NULL) {
    (void) fclose (fin);
    (void) unlink (dos_cppfile);
  }
#endif
  exit (nonfatalerrors);
  /* NOTREACHED */
}
Exemplo n.º 3
0
int main(void) 
{
	initialise();
	checkhbc();
	
	printf("Push button [A] to start switching to SD NAND\n");
	printf("Push button [B] to start switching back to real NAND\n");
	printf("Push button [Home] to exit now\n");
	while(1){
		WPAD_ScanPads();
            u32 wpaddown = WPAD_ButtonsDown(0);
		if (wpaddown & WPAD_BUTTON_A){
			switchnow = true;
			break;
		}
		if (wpaddown & WPAD_BUTTON_HOME){
			printf("exiting now...OK\n");
			sleep(5);
			exitme();
		}
		if (wpaddown & WPAD_BUTTON_B){
			switchback = true;
			break;
		}
	}

	initfat();
	checkfiles();
	
	if(switchback == true)
	{
	   printf("\n");

       if((switchmii == false) &&  (switchsneek == true))
       {
		  printf("It seems sneek is not running, check switchtosneek and switchtomii files\n\n");
	      sleep(5);
          exitme();
	   }

	   if(armbootmii == false)
       {
          printf("No sneek v2 file in bootmii directory: armbootmii.bin\n\n");
	      sleep(5);
          exitme();
       }

       printf("You have ");
       if( armbootsneek == true && armbootmii == true ) printf("sneek and bootmii setups");
       if( armbootsneek == false && armbootmii == true ) printf("bootmii setups");

       if( armbootsneek == false && armbootmii == true ) printf(" turn bootmii on");
       if( armbootsneek == true && armbootmii == true ) printf(" switch to bootmii");
       printf("\n");

	   miscinit();
	   
	   renamefilesback();
	   removeswitchmii();
	   createswitchsneek();

	   miscdeinit();
		
	   sleep(5);

	   WPAD_Shutdown();
	   STM_RebootSystem();				
	}
	
	if(switchnow == true)
	{	
	    printf("\n");
	
        if((switchmii == true) &&  (switchsneek == false))
        {
		   printf("It seems bootmii is not running, check switchtosneek and switchtomii files\n\n");
	       sleep(5);
           exitme();
	    }
	   
	    if(armbootsneek == false)
        {
           printf("No sneek v2 file in bootmii directory: armbootsneek.bin\n\n");
	       sleep(5);
           exitme();
        }

        printf("You have ");
        if( armbootsneek == true && armbootmii == true ) printf("sneek and bootmii setups");
        if( armbootsneek == true && armbootmii == false ) printf("sneek setups");

        if( armbootsneek == true && armbootmii == false ) printf(" turn sneek on");
        if( armbootsneek == true && armbootmii == true ) printf(" switch to sneek");
        printf("\n");

        renamefiles();
	    removeswitchsneek();
	    createswitchmii();

        sleep(5);

	    WPAD_Shutdown();
	    STM_RebootSystem();				
	}
		
	return 0;
}
Exemplo n.º 4
0
int
main(int argc, const char **argv)
{
	struct commandline cmd;

	memset(&cmd, 0, sizeof (struct commandline));
	clear_args();
	if (!parseargs(argc, argv, &cmd))
		usage();
	/*
	 * Only the client and server side stubs are likely to be customized,
	 *  so in that case only, check if the outfile exists, and if so,
	 *  print an error message and exit.
	 */
	if (cmd.Ssflag || cmd.Scflag || cmd.makefileflag)
		checkfiles(cmd.infile, cmd.outfile);
	else
		checkfiles(cmd.infile, NULL);

	if (cmd.cflag) {
		c_output(cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile);
	} else if (cmd.hflag) {
		h_output(cmd.infile, "-DRPC_HDR", DONT_EXTEND, cmd.outfile,
		    cmd.hflag);
	} else if (cmd.lflag) {
		l_output(cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile);
	} else if (cmd.sflag || cmd.mflag || (cmd.nflag)) {
		s_output(argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND,
			cmd.outfile, cmd.mflag, cmd.nflag);
	} else if (cmd.tflag) {
		t_output(cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile);
	} else if  (cmd.Ssflag) {
		svc_output(cmd.infile, "-DRPC_SERVER", DONT_EXTEND,
			cmd.outfile);
	} else if (cmd.Scflag) {
		clnt_output(cmd.infile, "-DRPC_CLIENT", DONT_EXTEND,
			    cmd.outfile);
	} else if (cmd.makefileflag) {
		mkfile_output(&cmd);
	} else {
		/* the rescans are required, since cpp may effect input */
		c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c");
		reinitialize();
		h_output(cmd.infile, "-DRPC_HDR", EXTEND, ".h", cmd.hflag);
		reinitialize();
		l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c");
		reinitialize();
		if (inetdflag || !tirpcflag)
			s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND,
			"_svc.c", cmd.mflag, cmd.nflag);
		else
			s_output(allnc, allnv, cmd.infile, "-DRPC_SVC",
				EXTEND, "_svc.c", cmd.mflag, cmd.nflag);
		if (tblflag) {
			reinitialize();
			t_output(cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.i");
		}

		if (allfiles) {
			reinitialize();
			svc_output(cmd.infile, "-DRPC_SERVER", EXTEND,
				"_server.c");
			reinitialize();
			clnt_output(cmd.infile, "-DRPC_CLIENT", EXTEND,
				"_client.c");

		}
		if (allfiles || (cmd.makefileflag == 1)){
			reinitialize();
			mkfile_output(&cmd);
		}
	}

	exit(nonfatalerrors);
	/* NOTREACHED */
}
//**************************************************************
// Main <smile> All sub-programs/functions should be called 	
// from here. Note: they should also be listed in lciheader.h  
//**************************************************************
int main(int argc, char *argv[])
{
    int retval=0;     // a return value indicator		
    int verbose=0;    // for verbosity			
    // note: switches: 
    //lci -a = advanced help
    //lci -d = perform a diff of the md5output and old md5output
    //lci -v = verbose, verbose = 1
    //lci    = slightly verbose, verbose = 0, 
    // the module name is printed as it performes each module
    //lci -s = silent, verbose = -1, nothing printed at all.
    //lci -r = run checkrpm module.
    //lci -m = force a distribution mode, e.g. lci -m redhat
    //lci -h = give help output
    //lci -o outfile = put output in outfile instead of lci.out	
    //lci -w = print output in html format
    //lci -x module = exclude module from checks
    
    int diff=0; // do we run the md5 diff? 
    int rpmmodule=0; // do we run the rpm module? 
    int inetexists=0; // if inetd.conf exists, this is 1 	
    int distribution=1; // what distro are we on?		
    // -1=user specified a distro, its in man_distro 
    // 1=redhat 
    // 2=debian 
    // 3=solaris 
    // 4=gentoo
    // 5=macosx 
    // 6=slackware
    // default = redhat   
    int html=0; // html output? 
    // html = 0: normal output
    //html = 1: user wants html output
     
    char release[50]; // array for release level		
    char kernel[50];  // what kernel user is running	
    static char *man_distro; // if the user specifies a distribution 
    const char * header   =NULL;   // to print out the header 
    static char *out_file = "lci.out";  // output filename var  
    char xlist[100]; // modules to exclude 
    int xarray[33] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 
    int  somethinginxlist = 0;
    // note if no filename given, default = lci.out	
    FILE *tempptr;    // a temp file pointer		

     uid_t uidme;
     uidme = getuid();

    // we used to set the umask of the user here... 
    // note that does not work all of the time.     
    // instead use open with options below. Also,   
    // warn user at bottom about setting umask to   
    // sensible value before modifying files.       

    // we will again try to set umask here...       
    mode_t old_umask;

    old_umask=(umask(0177));


    // Now do options processing 
    int i;
    for (i=1; i < argc; i++)
    {
	if(argv[i][0] == '-')
	{
	    switch (argv[i][1]) 
	    {
		case 'a': 
			  usage(); 
			  break;
	        case 'h':
			  usage();
			  break;
		case 'd': 
			  diff = 1; 
			  break;
		case 'm': 
			  strcpy(man_distro, argv[i]+3);
			  break;
		case 'o': 
			  strcpy(out_file, argv[i]+3);
			  break;
		case 'r': 
			  rpmmodule = 1; 
			  break;
		case 's': 
			  verbose = -1; 
			  break;
	        case 'v': 
			  verbose = 1; 
			  break;
		case 'w': 
			  html = 1; 
			  out_file="lci.html"; 
			  break;
		case 'x': strcpy(xlist,argv[i]+3);
			  somethinginxlist = 1;
			  break;
	        default : 
			  usage(); 
		break;
	    }
	}
    }

    if (!out_file) // if no filename after -o 
    {
        usage();  // note usage() will exit lci 
    }

    // if an exclude list was given, parse the file and 
    // fill the array of excludes..			
    if (somethinginxlist == 1)
    {
	if (findexclude(xlist, xarray) != 0)
	{
	     // something went wrong 
	     perror("Error reading exclude list...\n");
	     return(-1);
	}
    }

    // check if output exists, if it does, make a 	
    // backup and rm the orig. named one.		
    tempptr = fopen(out_file, "r");
    if (tempptr != 0)
    {
        // output file exists 
        // make a backup copy 
	char *newname = NULL;
	if ((newname = (char *) calloc(2, sizeof(out_file))) == NULL)
	{
	    perror("Can not allocate temp memory in lcimain.\n");
	    perror("Strange. Bailing...\n");
	    exit(-1);
	}
        fclose(tempptr);
	// add .old onto the old outfile name 
        sprintf(newname, "%s.old", out_file);

        // gnu, but should be ok... 
        // whoops, we are now failure checking this...   
        retval = 0;
        retval = rename(out_file, newname);
        if (retval < 0)
        {
            // damn, rename bombed 
            perror("GNU rename bombed in lcimain.\n");
            perror("Very odd, you should have seen errors, report them :) \n");
            exit(-1);
        }
	
	// free up calloc'd mem 
	free(newname);
    }
    
    // now that we have a backup, remove the outfile 
    // don't care about failure here...              
    remove(out_file);

    // not seem to work 100% of the time on my system
    // for making files w/chmod 0600...              
    // reverting to open with options...             
    retval = 0;
    if ((retval = open(out_file, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) 
    {
	perror("Could not make file w/perms 0600...\n");
	perror("Possible link attack while creating/opening file!\n");
	perror("Bailing in lcimain...\n");
        exit(-1);
    }

    // we print this out no matter what verbose is 
    printf("Starting LCI...\n");

    // remove old tempfiles (if lci got killed) 
    // if this fails, we should stop _now_! 
    if (rm() < 0)
    {
	perror("Could not remove tempfiles during startup.\n");
	perror("You may need root permissions to do this.\n");
	return(-1);
    }
    
    // read that in, check kernel version and "release"	
    if (verbose >= 0)
    {
        printf("Getting system information...\n");
    }

    retval = versions(release, kernel, verbose);
    if (retval < 0)
    {
        // something went wrong... 			
        perror("Problem in versions function.\n");
        return(0);
    }

    // note about Mandrake: until I can find vast differences 
    // between RedHat/Mandrake in terms of configs, we assume 
    // that it is redhat and don't check /etc/mandrake_rel... 
    // simple check to see if we are on RedHat or Debian 
    // first, did the user specify a distro? 
    if (distribution != -1)
    {
        if ((system("cat /etc/redhat-release 1>/dev/null 2>/dev/null >/dev/null")) == 0)
        {
            // we are on redhat 
            distribution = 1;
        }
        if ((system("cat /etc/debian_version 1>/dev/null 2>/dev/null >/dev/null")) == 0)
        {
            // we are on debian 
            distribution = 2;
        }
	if ((system("uname |grep SunOS 1>/dev/null 2>/dev/null >/dev/null")) == 0)
	{
	    // we are on Solaris/SunOS 
	    distribution = 3;
	}
        if ((system("uname -a |grep gentoo 1>/dev/null 2>/dev/null >/dev/null")) == 0)
        {
	    // we are on gentoo 
	    distribution = 4;
	} 
        if ((system("uname |grep Darwin 1>/dev/null 2>/dev/null >/dev/null")) == 0)
	{
	    // we are on Mac OSX 
	    distribution = 5;
	}
        if ((system("cat /etc/slackware-version 1>/dev/null 2>/dev/null >/dev/null")) == 0)  // JTO 
        {
            // we are on slack 
            distribution = 6;
        }
    }
    if (distribution == -1)
    {
	// user specified a distribution 
        if ((strcmp(man_distro, "redhat")) == 0)
	{
	    // redhat 
	    distribution = 1;
	}
        if ((strcmp(man_distro, "centos")) == 0)
	{
	    // CentOS, RHEL-alike 
	    distribution = 1;
	}
        if ((strcmp(man_distro, "caos")) == 0)
	{
	    // CaOS, RHL-alike 
	    distribution = 1;
	}
        if ((strcmp(man_distro, "fedora")) == 0)
	{
	    // Post-RHL 
	    distribution = 1;
	}
	if ((strcmp(man_distro, "debian")) == 0)
	{
	    // debian 
	    distribution = 2;
	}
	if ((strcmp(man_distro, "solaris")) == 0)
	{
	    // solaris 
	    distribution = 3;
	}
	if ((strcmp(man_distro, "mandrake")) == 0)
 	{
	    // mandrake, same as redhat, sortof 
	    distribution = 1;
	}
	if ((strcmp(man_distro, "gentoo")) == 0)
	{
	    // gentoo 
	    distribution = 4;
	}
 	if ((strcmp(man_distro, "macosx")) == 0)
	{
	    // Mac OSX 
	    distribution = 5;
	}
        if ((strcmp(man_distro, "slackware")) == 0) // JTO 
        {
            // slackware- JTO 
            distribution = 6;
        }
	// default is redhat 
        else
	{
	   distribution = 1;
        }
    } // end if (distribution == -1) 

    // ********* checks are below *****************//
    // ok, we should have enough info, run the checks 

    if (verbose >= 0)
    {
	printf("Running modules...\n");
    }

    // we need to make a header if html = 1, as this 
    // could confuse the issue by putting it in the  
    // first module... call dostuff here...          
   
    if (html == 1)
    {
	html = 2; // this tells dostuff to write out header html 
	header = "\n";  // can't be NULL 
        if ((dostuff(0, out_file, 0, header, html)) < 0)
        {
            // something went wrong 
            perror(" Creation of list failed.");
            return (-1);
        }
        html = 1;   // change html int back to one 
    }
 

    // run checkpkgs 
    // did user put it in exclude list? 
    if (xarray[0] == 0 )
    {
        retval = 0;
        retval = checkpkgs(distribution, out_file, verbose, html);
        if (retval < 0)
        {
            // something went wrong...                      
            perror("Problem in checkpkgs module.\n");
            perror("You should have seen errors...\n");
            // module bombed, clean up 
            rm();
            return(0);
        }
    }

    // run checkrpm if rpmmodule = 1 and distribution =1 
    // did user put it in exclude list? 
    if (xarray[1] == 0)
    {
        retval = 0;
        if ((rpmmodule == 1) && (distribution == 1))
        {
            retval = checkrpm(out_file, verbose, html);
            if (retval < 0)
	    {
	        // something went wrong...                      
                perror("Problem in checkrpm module.\n");
                perror("You should have seen errors...\n");
                // module bombed, clean up 
                rm();
                return(0);
	    }
        }
    }

    // run checkinetd 
    // did user put it in exclude list? 
    if (xarray[2] == 0)
    {

    	// if hosts file exists run checkhostsfiles 
    	inetexists = checkinetd(out_file,distribution, verbose, html);
    	// if inetexists == 1, it does!				
    	// if inetexists == 0, it does not...			
    	// if inetexists == -1, we had some problems.		
    	    if (inetexists == 1)
    	    {
                checkhostsfiles(out_file, verbose, html);
    	    }
    	if (inetexists == 0)
    	{
        	// do nothing... 
        	;
        }
    	if (inetexists == -1)
    	{
            // there was a problem. User should have seen	
            // messages from checkinetd program.		
            // do nothing here and continue...		
            // module bombed, clean up 
            rm();
        }
    }

    // check inittab		
    // did user put it in exclude list? 
    if (xarray[3] == 0)
    {
    	retval = 0;
    	retval = checkinittab(out_file, distribution, verbose, html);
    	if (retval < 0)
    	{
            // something went wrong...   
	    perror("Problem in checkinittab module.\n");
	    perror("You should have seen errors...\n");
	    // module bombed, clean up 
	    rm();
	    return(0);
        }
    }

    // check logging		
    // did user put it in exclude list? 
    if (xarray[4] == 0)
    {
        retval = 0;
        retval = checklogging(out_file, distribution, verbose, html);
    	if (retval < 0)
    	{
            // something went wrong...   
            perror("Problem in checklogging module.\n");
            perror("You should have seen errors...\n");
            // module bombed, clean up 
            rm();
            return(0);
        }
    }
        

    // check for setuid/setgid files 
    // did user put it in exclude list? 
    if (xarray[5] == 0)
    {
        retval = 0;
        retval = checkset(out_file, verbose, html);
        if (retval < 0)
        {
            // something went wrong...                      
            perror("Problem in checkset module.\n");
            perror("You should have seen errors...\n");
            // module bombed, clean up 
            rm();
            return(0);
        }
    }


    // check for world writable files/directories 
    // did user put it in exclude list? 
    if (xarray[6] == 0)
    {
        retval = 0;
        retval = checkwrite(out_file, distribution, verbose, html);
        if (retval < 0)
        {
            // something went wrong...                      
            perror("Problem in checkwrite module.\n");
            perror("You should have seen errors...\n");
            // module bombed, clean up 
            rm();
            return(0);
        }
    }

    // check for .exrc and .forward files 
    // did user put it in exclude list? 
    if (xarray[7] == 0)
    {
    	retval = 0;
    	retval = checkdotfiles(out_file, verbose, html);
    	if (retval < 0)
        {	
            // something went wrong...                      
            perror("Problem in checkdotfiles module.\n");
            perror("You should have seen errors...\n");
            // module bombed, clean up 
            rm();
            return(0);
        }
    }


    // check /etc/passwd for uid 0 other than 
    // root and users not needed on the sys.  
    // did user put it in exclude list? 
    if (xarray[8] == 0)
    {
    	retval = 0;
    	retval = checkpasswd(out_file, distribution, verbose, html);
    	if (retval < 0)
    	{
            // something went wrong...                      
            perror("Problem in checkpasswd module.\n");
            perror("You should have seen errors...\n");
	   
	    // module bombed, clean up 
            rm();
            return(0);
        }
    }

    // check to see if sticky bits are set 
    // on /tmp & /var/tmp. I will add more 
    // to this later on...			
    // did user put it in exclude list? 
    if (xarray[9] == 0)
    {
        retval = 0;
        retval = checkfiles(out_file, verbose, html);
        if (retval < 0)
        {
            // something went wrong...			
            perror("Problem in checkfiles module.\n");
            perror("You should have seen errors...\n");
	    // module bombed, clean up 
            rm();
            return(0);
        }
    }

    // did user put it in exclude list? 
    if (xarray[10] == 0)
    {
        retval = 0;
        retval = checkumask(out_file, verbose, html);
        if (retval < 0)
        {
            // something went wrong...                      
            perror("Problem in chumask module.\n");
            perror("You should have seen errors...\n");
	    // module bombed, clean up 
            rm();
            return(0);
        }
    }

    // did user put it in exclude list? 
    if (xarray[11] == 0)
    {
        retval = 0;
        retval = checkftpusers(out_file, verbose, html);
        if (retval < 0)
        {
            // something went wrong...                      
            perror("Problem in checkftpusers module.\n");
            perror("You should have seen errors...\n");
	    // module bombed, clean up 
            rm();
            return(0);
        }
    }

    // did user put it in exclude list? 
    if (xarray[12] == 0)
    {
        retval = 0;
        retval = checkrc(release, kernel, distribution, out_file, verbose, html);
        if (retval < 0)
        {
            // something went wrong...			
            perror("Problem in checkrc module.\n");
            perror("You should have seen errors...\n");
	    // module bombed, clean up 
            rm();
            return(0);
        }
    }

    // did user put it in exclude list? 
    if (xarray[13] == 0)
    {
        retval = 0;
        retval = checkkbd(release, out_file, verbose, html);
        if (retval < 0)
        {
            // something went wrong...                      
            perror("Problem in checkkbd module.\n");
            perror("You should have seen errors...\n");
	    // module bombed, clean up 
            rm();
            return(0);
        }
    }

    // did user put it in exclude list? 
    if (xarray[14] == 0)
    {
        if (distribution != 6) // need to fix for slack, JTO 
        {
        retval = 0;
        retval = checklimits(out_file, verbose, html);
        if (retval < 0)
        {
            // something went wrong...                      
            perror("Problem in checklimits module.\n");
            perror("You should have seen errors...\n");
            // module bombed, clean up 
            rm();
            return(0);
        }
        } // end if its not slack if statement 
    }

    // did user put it in exclude list? 
    if (xarray[15] == 0)
    {
        retval = 0;
    	retval = checkssh(out_file, distribution, verbose, html);
    	if (retval < 0)
        {
	    // something went wrong..	
	    perror("Problem in checkssh module.\n");
	    perror("You should have seen errors...\n");
	    rm();
	    return(0);
        }
    }

    // did user put it in exclude list? 
    if (xarray[16] == 0)
    {
        retval = 0;
        retval = checkopenfiles(out_file, distribution, verbose, html);
        if (retval < 0)
        {
            // something went wrong..       
            perror("Problem in checkopenfiles module.\n");
            perror("You should have seen errors...\n");
            rm();
            return(0);
        }
    }

    // did user put it in exclude list? 
    if (xarray[17] == 0)
    {
        retval = 0;
        retval = checkissue(out_file, verbose, html);
        if (retval < 0)
        {
            // something went wrong..       
            perror("Problem in checksissue module.\n");
            perror("You should have seen errors...\n");
            rm();
            return(0);
        }
    }

    // did user put it in exclude list? 
    if (xarray[18] == 0)
    {
        retval = 0;
        retval = checkwww(out_file, distribution, verbose, html);
        if (retval < 0)
        {
            // something went wrong..       
            perror("Problem in checkwww module.\n");
            perror("You should have seen errors...\n");
            rm();
            return(0);
        }
    }

    // did user put it in exclude list? 
    if (xarray[19] == 0)
    {
        retval = 0;
        retval = checkmd5(out_file, distribution, verbose, html, diff);
        if (retval < 0)
        {
            // something went wrong..       
            perror("Problem in checkmd5 module.\n");
            perror("You should have seen errors...\n");
            rm();
            return(0);
        }
    }

    // did user put it in exclude list? 
    if (xarray[20] == 0)
    {
        if  ((distribution != 3) && (distribution !=5))
    	// we are not on Solaris, so we can run this module 
    	{
            retval = 0;
            retval = checkmodules(out_file, verbose, html);
            if (retval < 0)
            {
                // something went wrong..       
                perror("Problem in checkmodules module.\n");
                perror("You should have seen errors...\n");
                rm();
                return(0);
            }
        }
    }

    // did user put it in exclude list? 
    if (xarray[21] == 0)
    {
        retval = 0;
        retval = checksecuretty(out_file, verbose, html);
        if (retval < 0)
        {
            // something went wrong..       
            perror("Problem in checksecuretty module.\n");
            perror("You should have seen errors...\n");
            rm();
            return(0);
        }
    }

    // did user put it in exclude list? 
    if (xarray[22] == 0)
    {
        retval = 0;
        retval = checkrcperms(out_file, distribution, verbose, html);
        if (retval < 0)
        {
	    // something went wrong...	
	    perror("Problem in checkrcperms module.\n");
	    perror("You should have seen errors...\n");
	    rm();
	    return(0);
        }
    }

    // did user put it in exclude list? 
    if (xarray[23] == 0)
    {
        retval = 0;
        retval = checknet(out_file, distribution, verbose, html);
        if (retval < 0)
        {
            // something went wrong...                      
            perror("Problem in checknet module.\n");
            perror("You should have seen errors...\n");
	    // module bombed, clean up 
            rm();
            return(0);
        }
    }

    // did user put it in exclude list? 
    if (xarray[24] == 0)
    {
        retval = 0;
        retval = checknetforward(out_file, distribution, verbose, html);
        if (retval < 0)
        {
            // something went wrong...                      
            perror("Problem in checknetforward module.\n");
            perror("You should have seen errors...\n");
            // module bombed, clean up 
            rm();
            return(0);
        }
    }


    // did user put it in exclude list? 
    if (xarray[25] == 0)
    {
        if ((distribution !=3) && (distribution != 5))
        {
            // we are on linux... 
            retval = 0;
            retval = checknetp(kernel, out_file, distribution, verbose, html);
            if (retval < 0)
            {
                perror("Problem in checknetpromisc module.\n");
                perror("You should have seen errors...\n");
                rm();
                return(0);
            }
        }
    }

    // did user put it in exclude list? 
    if (xarray[26] == 0)
    {
        if (distribution == 1) // redhat (or derived) specific 
        {
            retval = 0;
            retval = checkcfg(out_file, verbose, html);
            if (retval < 0)
            {
                // something went wrong...                      
                perror("Problem in checkcfg module.\n");
                perror("You should have seen errors...\n");
                // module bombed, clean up 
                rm();
                return(0);
            }
        }
    }

    // did user put it in exclude list? 
    if (xarray[27] == 0)
    {
        if ((distribution !=3) && (distribution != 5)) // we are on linux 
        {
            retval = 0;
            retval = checkbpass(distribution, out_file, verbose, html);
            if (retval < 0)
            {
                // something went wrong...                      
                perror("Problem in checkbpass module.\n");
                perror("You should have seen errors...\n");
                // module bombed, clean up 
                rm();
                return(0);
            }
        }
    }

    // did user put it in exclude list? 
    if (xarray[28] == 0)
    {
        if ((distribution != 3) && (distribution != 5)) // we are on linux 
        {
            retval = 0;
            retval = checkipv4(out_file, verbose, html);
            if (retval < 0)
            {
                // something went wrong...                      
                perror("Problem in checkipv4 module.\n");
                perror("You should have seen errors...\n");
                // module bombed, clean up 
                rm();
                return(0);
            }
        }
    }

    // did user put it in exclude list? 
    if (xarray[29] == 0)
    {
        if ((distribution !=3) && (distribution !=5)) // we are on linux 
        {
            retval = 0;
            retval = checkx(out_file, verbose, html);
            if (retval < 0)
            {
                // something went wrong...                      
                perror("Problem in checkx module.\n");
                perror("You should have seen errors...\n");
                // module bombed, clean up 
                rm();
                return(0);
            }
        }
    }

    // did user put it in exclude list? 
    if (xarray[30] == 0)
    {
        if ((distribution !=3) && (distribution !=5)) // we are on linux 
        {
            retval = 0;
            retval = checkftp(out_file, distribution, verbose, html);
            if (retval < 0)
            {
                // something went wrong...                      
                perror("Problem in checkftp module.\n");
                perror("You should have seen errors...\n");
                // module bombed, clean up 
                rm();
                return(0);
            }
        }
    }

    // did user put it in exclude list? 
    if (xarray[31] == 0)
    {
        retval = 0;
        retval = checklistening(out_file, distribution, verbose, html);
        if (retval < 0)
        {
            // something went wrong..       
            perror("Problem in checklistening module.\n");
            perror("You should have seen errors...\n");
            rm();
            return(0);
        }
    }

    // did user put it in exclude list? 
    if (xarray[32] == 0)
    {
        retval = 0;
	retval = checkdisk(out_file, verbose, html);
	if (retval < 0)
	{
	    // something went wrong...      
	    perror("Problem in checkdisk module.\n");
	    perror("You should have seen errors...\n");
	    rm();
	    return(0);
	}
    }	


    // this is to put a footer html at the end of the output 
    // file if the user wanted html output. 		     
    if (html == 1)
    {
        html = 3; // tells dostuff to do an html footer 
        header = "\n"; // can't be NULL 
        if ((dostuff(0, out_file, 0, header, html)) < 0)
        {
            // something went wrong 
            perror(" Creation of list failed.");
            return (-1);
        }
        html = 1; // set html int back... habit 
    }
    else
    {
        // print a general footer 
	header = "\n";
	if ((dostuff(0, out_file, 0, header, 0)) < 0)
	{
	    // something went wrong 
	    perror(" Creation of footer failed.");
	    return(-1);
	}
    }
    

    // tell the user we are finished and where the output is 
    // we print this out no matter what verbose is 
    printf("Finished.\n");
    printf("Check %s for details.\n", out_file);
    // in silent mode we don't say much 
    if (verbose >= 0)
    {
        printf("Don't forget to check your umask or file perms\n");
        printf("when modifying files on the system.\n");
    }

    // set the umask back... 
    umask(old_umask);
    return(0);
}
Exemplo n.º 6
0
static Bool initCitadel(void)
    {
    if (!read_cfg_messages())
        {
#ifdef WINCIT
        char Buffer[128];
        sprintf(Buffer, getmsg(188), getmsg(671));
        MessageBox(NULL, Buffer, NULL, MB_ICONSTOP | MB_OK);
#else
        printf(getmsg(188), getmsg(671));
#endif
        return (FALSE);
        }

    checkfiles();

    initExtDrivers();

    get_os();

	cfg.battr = 0xff;
    setscreen();

    logo(TRUE); // no go for debug version; td32 go crash crash

    init_internal_sound();

	// some mouse initialization technology!!!!
    initMouseHandler();
    hideCounter = 1;

    if (time(NULL) < 700000000L)
        {
#ifdef WINCIT
        MessageBox(NULL, getcfgmsg(119), NULL, MB_ICONSTOP | MB_OK);
#else
        doccr();
        doccr();
        cPrintf(getcfgmsg(119));
        doccr();
#endif
        dump_cfg_messages();
        return (FALSE);
        }


    static char prompt[92];
    static char citadel[92];
    char *envprompt;
    char *citprompt;

    envprompt = getenv(getcfgmsg(120));
    citprompt = getenv(getcfgmsg(121));
    if (citprompt)
        {
        sprintf(prompt, getcfgmsg(122), citprompt);
        }
    else if (envprompt)
        {
        sprintf(prompt, getcfgmsg(123), envprompt);
        }
    else
        {
        strcpy(prompt, getcfgmsg(124));
        }
    putenv(prompt);

    sprintf(citadel, getcfgmsg(125), programName, version);
    putenv(citadel);


#ifndef WINCIT
    OC.whichIO = CONSOLE;
    OC.SetOutFlag(OUTOK);
    OC.Echo = BOTH;
    OC.setio();
#endif

    VerifyHeap(1);

    // If we aren't reconfiguring, load the tables...
    if (!reconfig)
        {
        // Start by reading ETC.TAB
        getcwd(etcpath, 64);

        FILE *fd;
        if ((fd = fopen(etcTab, FO_RB)) != NULL)
            {
            if (filelength(fileno(fd)) != (long) sizeof(config) ||
					fread(&cfg, 1, sizeof(config), fd) != (long) sizeof(config))
                {
                memset(&cfg, 0, sizeof(cfg));
                reconfig = TRUE;
                }

            fclose(fd);
            unlink(etcTab);


            // If ETC.TAB could be loaded, load the rest
            if (!reconfig)
                {
                changedir(cfg.homepath);

                allocateTables();

                if (!LogTab.Load() || !MessageDat.LoadTable() || !RoomTab.Load())
                    {
                    reconfig = TRUE;
                    }

                Cron.ReadTable(WC_TWpn);
                }
            }
        else
            {
            if (!batchmode)
                {
#ifdef WINCIT
                MessageBox(NULL, "No ETC.TAB.", NULL, MB_ICONSTOP | MB_OK);
#else
                doccr();

                discardable *d;

                if ((d = readData(6)) != NULL)
                    {
                    int i;

                    for (i = 0; ((char **) d->next->aux)[i][0] != '#'; i++)
                        {
                        cPrintf(pcts, ((char **) d->next->aux)[i]);
                        doccr();
                        }

                    doccr();

                    discardData(d);
                    }
                else
                    {
                    cOutOfMemory(28);
                    }

                DeinitializeTimer();
                critical(FALSE);
#endif
                exit(1);
                }

            reconfig = TRUE;
            }
        }



    if (reconfig)
        {
        cfg.attr = 7;

#ifndef WINCIT
        pause(200);
        cls(SCROLL_SAVE);

        cCPrintf(getcfgmsg(126));
        doccr();
#endif


        if (!configcit())
            {
#ifdef WINCIT
            MessageBox(NULL, getcfgmsg(127), NULL, MB_ICONSTOP | MB_OK);
#else
            doccr();
            doccr();
            cPrintf(getcfgmsg(127));
            doccr();
#endif
            dump_cfg_messages();
            return (FALSE);
            }


#ifndef WINCIT
        setdefaultTerm(TT_ANSI);
        CurrentUser->SetWidth(80);
#endif

        Cron.ReadCronCit(WC_TWpn);
        }
    else
        {
#ifndef WINCIT
        if (!CreateScrollBackBuffer())
            {
            cPrintf(getcfgmsg(60));
            doccr();
            }
#endif


        if (readconfigcit)  // forced to read in config.cit
            {
            if (!readconfig(NULL, 1))
                {
#ifdef WINCIT
                MessageBox(NULL, getcfgmsg(129), NULL, MB_ICONSTOP | MB_OK);
#else
                doccr();
                doccr();
                cPrintf(getcfgmsg(129));
                doccr();
#endif
                dump_cfg_messages();
                return (FALSE);
                }
            }
        }

    VerifyHeap(1);

    makeBorders();
    readBordersDat();

    if (cmd_nobells)
        {
        cfg.noBells = 2;
        }

    if (cmd_nochat)
        {
        cfg.noChat = TRUE;
        }

    if (cmd_mdata != CERROR)
        {
        cfg.mdata = cmd_mdata;
        }

    if (*cfg.f6pass)
        {
        if (SameString(cfg.f6pass, getmsg(670)))
            {
            ConsoleLock.LockF6();
            }
        else
            {
            ConsoleLock.Lock();
            }
        }


#ifndef WINCIT
    if (cfg.ovrEms)
        {
        if (_OvrInitEms(0, 0, 0))
            {
            cPrintf(getcfgmsg(130));
            doccr();
            pause(200);
            }
        }

    if (cfg.ovrExt)
        {
        if (_OvrInitExt(0, 0))
            {
            cPrintf(getcfgmsg(131));
            doccr();
            pause(200);
            }
        }

    CommPort->Init();
    setscreen();
#endif

    logo(TRUE); // no go for debug version; td32 go crash crash

#ifndef WINCIT
    StatusLine.Update(WC_TWp);
#endif

    if (cfg.msgpath[(strlen(cfg.msgpath) - 1)] == '\\')
        {
        cfg.msgpath[(strlen(cfg.msgpath) - 1)] = '\0';
        }

    // move to home path
    changedir(cfg.homepath);
    char FileName[128];

    ReIndexFileInfo();  // keep fileinfo.dat nice and pretty

    // open message file
    if (!MessageDat.OpenMessageFile(cfg.msgpath))
		{
		illegal(getmsg(78), MessageDat.GetFilename());
		}

    // Then room file
    sprintf(FileName, sbs, cfg.homepath, roomDat);
    openFile(FileName, &RoomFile);

    citOpen(cfg.trapfile, CO_A, &TrapFile);
    initMenus();
    dump_cfg_messages();

    if(!read_tr_messages())
        {
        errorDisp(getmsg(172));
        }
    else
        {
#ifdef WINCIT
    trap(T_SYSOP, "", gettrmsg(37));
#else
    trap(T_SYSOP, gettrmsg(37));
#endif
        dump_tr_messages();
        }

        read_cfg_messages();            // uh-oh!

    if (!GroupData.Load())
        {
        return (FALSE);
        }

    if (!HallData.Load())
        {
        return (FALSE);
        }

    getRoomPos();

    if (cfg.accounting)
        {
        ReadGrpdataCit(WC_TWpn);
        }

    ReadExternalCit(WC_TWpn);
    ReadProtocolCit(WC_TWpn);
    ReadMdmresltCit(WC_TWpn);
    ReadCommandsCit(WC_TWpn);


#ifndef WINCIT
    ReadMCICit(FALSE);

    CurrentRoom->Load(LOBBY);
    thisRoom = LOBBY;
    checkdir();

    if (!slv_door)
        {
        CITWINDOW *w = CitWindowsMsg(NULL, getmsg(19));

        Initport();
        Initport();

        if (w)
            {
            destroyCitWindow(w, FALSE);
            }
        }
    else
        {
        CommPort->Enable();
        }

    OC.whichIO = MODEM;
    OC.setio();
#endif


    // record when we put system up
    time(&uptimestamp);

#ifndef WINCIT
    setdefaultconfig(FALSE);
    Talley->Fill();
#endif
    logo(FALSE);

    VerifyHeap(1);

    dump_cfg_messages();
    compactMemory(1);

    return (TRUE);
    }
Exemplo n.º 7
0
int
main(int argc, char **argv)
{
	struct commandline cmd;

	(void) memset((char *) &cmd, 0, sizeof(struct commandline));
	clear_args();
	if (!parseargs(argc, argv, &cmd))
		usage();

	if (cmd.cflag || cmd.hflag || cmd.lflag || cmd.tflag || cmd.sflag ||
		cmd.mflag || cmd.nflag || cmd.Ssflag || cmd.Scflag) {
		checkfiles(cmd.infile, cmd.outfile);
	} else
		checkfiles(cmd.infile, NULL);

	if (cmd.cflag) {
		c_output(cmd.infile, "-DRPC_XDR", DONT_EXTEND, cmd.outfile);
	} else if (cmd.hflag) {
		h_output(cmd.infile, "-DRPC_HDR", DONT_EXTEND, cmd.outfile);
	} else if (cmd.lflag) {
		l_output(cmd.infile, "-DRPC_CLNT", DONT_EXTEND, cmd.outfile);
	} else if (cmd.sflag || cmd.mflag || (cmd.nflag)) {
		s_output(argc, argv, cmd.infile, "-DRPC_SVC", DONT_EXTEND,
			cmd.outfile, cmd.mflag, cmd.nflag);
	} else if (cmd.tflag) {
		t_output(cmd.infile, "-DRPC_TBL", DONT_EXTEND, cmd.outfile);
	} else if (cmd.Ssflag) {
		svc_output(cmd.infile, "-DRPC_SERVER", DONT_EXTEND, cmd.outfile);
	} else if (cmd.Scflag) {
		clnt_output(cmd.infile, "-DRPC_CLIENT", DONT_EXTEND, cmd.outfile);
	} else {
		/* the rescans are required, since cpp may effect input */
		c_output(cmd.infile, "-DRPC_XDR", EXTEND, "_xdr.c");
		reinitialize();
		h_output(cmd.infile, "-DRPC_HDR", EXTEND, ".h");
		reinitialize();
		l_output(cmd.infile, "-DRPC_CLNT", EXTEND, "_clnt.c");
		reinitialize();
		if (inetdflag || !tirpcflag)
			s_output(allc, allv, cmd.infile, "-DRPC_SVC", EXTEND,
				"_svc.c", cmd.mflag, cmd.nflag);
		else
			s_output(allnc, allnv, cmd.infile, "-DRPC_SVC",
				EXTEND, "_svc.c", cmd.mflag, cmd.nflag);
		if (tblflag) {
			reinitialize();
			t_output(cmd.infile, "-DRPC_TBL", EXTEND, "_tbl.i");
		}
		if (allfiles) {
			reinitialize();
			svc_output(cmd.infile, "-DRPC_SERVER", EXTEND, "_server.c");
		}
		if (allfiles) {
			reinitialize();
			clnt_output(cmd.infile, "-DRPC_CLIENT", EXTEND, "_client.c");
		}
	}
	exit(nonfatalerrors);
	/* NOTREACHED */
}