int inkey(void) { register int i = 257; int noflush = 1; sleeptimes = 0; while (i > DEL) { if (!tty) { if ((i = telrcv(&noflush)) < 0) my_exit(0); if (block) i = 257; else if (i != 17) byte++; } else if (!INPUT_LEFT()) { if (noflush) { fflush(stdout); noflush = 0; } do { if (f_alarm) alarmclock(); if (f_death) my_exit(5); if (XPENDING) checkx(1); } while ((i = getchar()) < 0 && errno == EINTR); if (i < 0) my_exit(0); } else i = getchar(); if (lastcr && i == '\n' && !client) i = 255; lastcr = 0; } /* Change a couple values to the C/Unix standard */ if (i == DEL) i = BS; else if (i == '\r') { i = '\n'; lastcr = 1; } else if (i == CTRL_U) i = CTRL_X; return (i); }
/* * Exit the program in an orderly way. */ void my_exit(register int doflush) { register int save = f_death; if (lockflags) { f_death = 2; return; } f_alarm = 0; if (doflush) f_death = -1; else f_death = -2; alarm(120); if (mybtmp) mybtmp->nox = -1; if (save == 1 && doflush) printf("\a\n\n\n\n\nYou have been logged off.\n\n\n\n\n"); if (ouruser) { int f; struct tm *ltm; char junk[80]; if (doflush) checkx(-1); locks(SEM_USER); if (ouruser->btmpindex >= 0 && mybtmp == &bigbtmp->btmp[ouruser->btmpindex]) ouruser->btmpindex = -1; unlocks(SEM_USER); ouruser->timeoff = msg->t = time(0); strcpy(junk, ETC); strcat(junk, "uselog"); if ((f = open(junk, O_WRONLY | O_CREAT | O_APPEND, 0640)) >= 0) { ltm = localtime(&ouruser->time); sprintf(junk, "%02d%02d%02d:%02d%02d:%04ld:%s\n", ltm->tm_year % 100, ltm->tm_mon + 1, ltm->tm_mday, ltm->tm_hour, ltm->tm_min, (ouruser->timeoff - ouruser->time) / 60 + 1, ouruser->name); write(f, junk, strlen(junk)); close(f); } msync((caddr_t)ouruser, sizeof(struct user), MS_ASYNC); ouruser = NULL; } if (bigbtmp) { remove_loggedin(pid); bigbtmp = 0; } if (doflush) { if (ansi) printf("\033[0m"); fflush(stdout); if (doflush > 1) mysleep(doflush); if (tty) myecho(ON); else { int fdr = 1; struct timeval tv = {30, 0}; shutdown(0, 1); select(1, (fd_set *)&fdr, 0, 0, &tv); } } _exit(0); }
void x_config(GtkWidget *button, gpointer data) { GtkWidget* pBoite; GtkWidget *pEntryRes, *pEntryDepth; char* sRes, *sDepth, *mdev, *sDms, *ptr; int ret; GtkWidget *pVBox; GtkWidget *pFrame; GtkWidget *pVBoxFrame; GtkWidget *pLabel; GtkWidget *combo; GtkTreeIter iter; GtkListStore *store; GtkTreeModel *model; extern GtkWidget *assistant; //* Check if all necessary x files are present *// if(checkx() == -1) { fwife_error(_("Corrupted X installation. Missing file, see log for more details")); return; } pBoite = gtk_dialog_new_with_buttons(_("Configuring X11"), NULL, GTK_DIALOG_MODAL, GTK_STOCK_OK,GTK_RESPONSE_OK, GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL, NULL); gtk_window_set_transient_for(GTK_WINDOW(pBoite), GTK_WINDOW(assistant)); gtk_window_set_position(GTK_WINDOW(pBoite), GTK_WIN_POS_CENTER_ON_PARENT); pVBox = gtk_vbox_new(TRUE, 0); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(pBoite)->vbox), pVBox, TRUE, FALSE, 5); /* Creation du premier GtkFrame */ pFrame = gtk_frame_new(_("X11 Configuration")); gtk_box_pack_start(GTK_BOX(pVBox), pFrame, TRUE, FALSE, 0); /* Creation et insertion d une boite pour le premier GtkFrame */ pVBoxFrame = gtk_vbox_new(TRUE, 0); gtk_container_add(GTK_CONTAINER(pFrame), pVBoxFrame); /* Creation et insertion des elements contenus dans le premier GtkFrame */ pLabel = gtk_label_new(_("Resolution :")); gtk_box_pack_start(GTK_BOX(pVBoxFrame), pLabel, TRUE, FALSE, 0); pEntryRes = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(pEntryRes), "1024x768"); gtk_box_pack_start(GTK_BOX(pVBoxFrame), pEntryRes, TRUE, FALSE, 0); pLabel = gtk_label_new(_("Color depth :")); gtk_box_pack_start(GTK_BOX(pVBoxFrame), pLabel, TRUE, FALSE, 0); pEntryDepth = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(pEntryDepth), "24"); gtk_box_pack_start(GTK_BOX(pVBoxFrame), pEntryDepth, TRUE, FALSE, 0); /* Creation du deuxieme GtkFrame */ pFrame = gtk_frame_new(_("Select your default display manager : ")); gtk_box_pack_start(GTK_BOX(pVBox), pFrame, TRUE, FALSE, 0); /* Creation et insertion d une boite pour le deuxieme GtkFrame */ pVBoxFrame = gtk_vbox_new(TRUE, 0); gtk_container_add(GTK_CONTAINER(pFrame), pVBoxFrame); store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); g_object_unref (GTK_TREE_MODEL (store)); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,"text", 0, NULL); renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,"text", 1, NULL); //* Find Desktop managers installed *// checkdms(store); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); gtk_box_pack_start(GTK_BOX(pVBoxFrame), combo, TRUE, FALSE, 0); gtk_widget_show_all(pBoite); //* Run dialog box *// switch (gtk_dialog_run(GTK_DIALOG(pBoite))) { case GTK_RESPONSE_OK: sRes = strdup((char*)gtk_entry_get_text(GTK_ENTRY(pEntryRes))); sDepth = strdup((char*)gtk_entry_get_text(GTK_ENTRY(pEntryDepth))); gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter); model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo)); gtk_tree_model_get (model, &iter, 0, &sDms, -1); if((sRes == NULL) || !strcmp(sRes, "") || (sDepth == NULL) || !strcmp(sDepth, "")) return; pid_t pid = fork(); if(pid == -1) { LOG("Error when forking process (X11 config)"); } else if (pid == 0) { chroot(TARGETDIR); mdev = fwx_get_mousedev(); if(fwx_doprobe()) { exit(-1); } fwx_doconfig(mdev, sRes, sDepth); unlink("/root/xorg.conf.new"); ret = fwx_dotest(); //* create /sysconfig/desktop file *// write_dms(sDms); exit(ret); } else { wait(&ret); //* change keyboard localisation *// ptr = g_strdup_printf("%s/xkeybchange %s %s %s", SCRIPTDIR, xlayout, xvariant, TARGETDIR); fw_system(ptr); FREE(ptr); gtk_widget_destroy(pBoite); if(ret) x_config(button, data); else gtk_label_set_text(GTK_LABEL(data), g_strdup_printf("%s %s bpp", sRes, sDepth)); } break; case GTK_RESPONSE_CANCEL: case GTK_RESPONSE_NONE: default: gtk_widget_destroy(pBoite); break; } FREE(sRes); FREE(sDepth); return; }
//************************************************************** // 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); }
void bbsstart(void) { unsigned char stdinbuf[STDINBUFSIZ]; long uglastmsg; /* last msg seen in prev. rm */ long ugtemp = TWILIGHTZONE; short prev_rm = TWILIGHTZONE; char cit_cmd; char bueller = 0; room = &sroom; setvbuf(stdin, (char *)stdinbuf, _IOFBF, STDINBUFSIZ); setvbuf(stdout, (char *)stdoutbuf, _IOFBF, STDOUTBUFSIZ); init_system(); /* Putty.exe is obstinate */ /* IAC WILL SGA */ putchar(IAC); putchar(WILL); putchar(TELOPT_SGA); /* magic to set telnet into character mode */ /* IAC DO LINEMODE, IAC WILL ECHO */ write(1,"\377\375\042\377\373\001",6); /* let window sizes come through */ /* IAC DO NAWS */ write(1,"\377\375\037",3); reserve_slot(); do_login(); colorize("\n@G"); curr = LOBBY_RM_NBR; inituser(); openroom(); storeug(&uglastmsg, &ugtemp); /* The first thing we do is make the user read the lobby */ cit_cmd = 'N'; readroom(cit_cmd); for(;;) { /* * check if user has been kicked out of this room while they were in it, * or if room was deleted */ if (ouruser->generation[curr] < 0 || !msg->room[curr].flags) { curr = LOBBY_RM_NBR; openroom(); storeug(&uglastmsg, &ugtemp); } if (cit_cmd) colorize("\n@Y%s>@G ", msg->room[curr].name); checkx(0); if (ouruser->f_prog) cit_cmd = get_single_quiet("ABCD\005eEFGHIJKLNOpPqQRsSTUvVwWxX\027\030yYZ /?#%@-\""); else if (ouruser->f_aide) cit_cmd = get_single_quiet("ABC\005eEFGHIJKLNOpPqQRsSTUvVwWxX\027\030yYZ /?#%@-\""); else if (ouruser->usernum == msg->room[curr].roomaide && !ouruser->f_twit) cit_cmd = get_single_quiet("ABC\005eEFGHIJKLNOpPqQRsSTUwWxX\027\030yYZ /?#%-\""); else cit_cmd = get_single_quiet("BCeEFGHIJKLNOpPqQRsSTUwWxX\027\030yYZ /?#%-\""); if (cit_cmd == SP) cit_cmd = 'N'; if (guest && !strchr("BFGHIJKLNOpPRsSTUwWyY/?#-", cit_cmd)) { colorize("\n\n@RThe Guest user cannot do that.@G\n"); continue; } if (curr == LOBBY_RM_NBR && strchr("DGNqsTU\027X\030Z% ", cit_cmd)) { if (bueller++ >= 12) flush_input(bueller / 25); if (bueller >= 100) { colorize("@R\n\n\nGo away until you have something useful to do!\n\n\n@G"); my_exit(10); } } else bueller = 0; if (strchr("AC\005eEHJpPQSvVx\030yYZ#-\"", cit_cmd)) mybtmp->nox = 1; switch (cit_cmd) { case 'A': printf("Sysop commands (%s)\n", msg->room[curr].name); aide_menu(); break; case 'R': case 'B': cit_cmd = 'R'; printf("Read Reverse\n"); readroom(cit_cmd); break; case 'C': printf("Change config\n"); change_setup(NULL); break; case 'D': printf("Debug\n"); debug(); break; case '\005': if (ouruser->usernum == msg->room[curr].roomaide) { printf("Enter Forum Moderator message\n\nAre you sure you want to enter a message as Forum Moderator? (Y/N) -> "); if (!yesno(-1)) break; sysopflags |= SYSOP_FROM_FM; } else if (ouruser->f_admin) { printf("Enter Sysop message\n\nNOTE: You are entering this message as Sysop!\n\n"); sysopflags |= SYSOP_FROM_SYSOP; } /* FALL THRU */ case 'e': case 'E': { char work[20]; if (ouruser->f_newbie && (curr == MAIL_RM_NBR || curr > 4)) help("newuseraccess", NO); else { if (cit_cmd == 'E') printf("Upload message\n\n"); else if (cit_cmd == 'e') printf("Enter message\n\n"); *work = 0; (void)entermessage(curr, work, cit_cmd == 'e' ? 0 : 2); sysopflags &= ~(SYSOP_FROM_SYSOP | SYSOP_FROM_FM); } } break; case 'F': printf("Read Forward\n"); readroom(cit_cmd); break; case 'G': printf("Goto "); updatels(&prev_rm); /* find next room with unread msgs and open it */ nextroom(); openroom(); storeug(&uglastmsg, &ugtemp); break; case 'H': printf("Help!\n"); help("topics", YES); break; case 'q': case 'Q': get_syself_help(cit_cmd); break; case 'I': printf("Forum Info\n"); readdesc(); break; case 'J': { int old_rm; printf("Jump to "); old_rm = curr; if (findroom() == YES) { int save_rm; mybtmp->nox = 0; save_rm = curr; curr = old_rm; updatels(&prev_rm); curr = save_rm; openroom(); storeug(&uglastmsg, &ugtemp); } } break; case 'K': printf("Known forums and zapped list\n"); knrooms(); break; case 'L': dologout(); break; case 'N': if (ouruser->lastseen[curr] < room->num[MSGSPERRM - 1]) { printf("Read New\n"); readroom(cit_cmd); } else { /* No new notes so just do a Goto now */ printf("Goto "); updatels(&prev_rm); /* find next room with unread msgs and open it */ nextroom(); openroom(); storeug(&uglastmsg, &ugtemp); } break; case 'O': printf("Read Old messages reverse\n"); readroom(cit_cmd); break; case 'p': case 'P': profile_user(cit_cmd == 'P'); break; case 's': /* don't update lastseen, you're skipping the room */ printf("Skip %s\n", msg->room[curr].name); skipping[curr >> 3] |= 1 << (curr & 7); /* after skipping a room, find the next unread room (not a goto) */ nextroom(); openroom(); ugtemp = ouruser->lastseen[curr]; break; case 'S': { int old_rm; printf("Skip %s to ", msg->room[curr].name); old_rm = curr; if (findroom() == YES) { mybtmp->nox = 0; skipping[old_rm >> 3] |= 1 << (old_rm & 7); openroom(); ugtemp = ouruser->lastseen[curr]; } } break; case 'T': printdate("Time\n\n%s"); break; case 'U': printf("Ungoto\n"); ungoto(prev_rm, &uglastmsg, &ugtemp); break; case 'v': cit_cmd = 0; break; case 'V': printf("Validate new users\n"); validate_users(1); break; case '\027': if (client) clientwho(); else cit_cmd = 0; break; case 'w': /* Short form of who's online */ show_online(3); break; case 'W': /* Who's online */ show_online(0); break; case 'x': express(); break; case 'X': change_express(1); break; case CTRL_X: old_express(); break; case 'y': case 'Y': if (!wanttoyell(cit_cmd)) break; (void)entermessage(-1, "", cit_cmd == 'y' ? 0 : 2); break; case 'Z': printf("Zap forum\n"); if (forgetroom()) { nextroom(); openroom(); ugtemp = ouruser->lastseen[curr]; } break; case '?': case '/': if (guest) help("guestforumlevel", NO); else help("doccmd", NO); break; case '#': readroom(cit_cmd); break; case '%': if (ouruser->f_elf && !ouruser->f_restricted && !ouruser->f_twit) if (mybtmp->xstat && !mybtmp->elf) printf("\n\nYou can't enable yourself as a guide while your X's are disabled.\n"); else if ((mybtmp->elf = !mybtmp->elf)) printf("\n\nYou are now marked as being available to help others.\n"); else printf("\n\nYou are no longer marked as being available to help others.\n"); else cit_cmd = 0; break; case '-': readroom(cit_cmd); break; case '@': printf("Sysops, programmers, and forum moderators\n"); more(AIDELIST, 0); break; case '"': { char work[20]; printf("Quote X messages to Sysop\n"); *work = 0; (void)entermessage(-1, work, -1); } break; default: break; } /* switch */ }