Beispiel #1
0
int edit_record(char *device_name, uint64_t offset) {
    if (offset == 0) {
        mbr_t mbr;

        read_mbr(device_name, &mbr);

        if (OKAY == edit_mbr_loop(&mbr) && are_you_sure() == YES) {
            write_mbr(device_name, &mbr);
        }
    }
    else {
        ebr_t ebr;

        read_ebr(device_name, offset, &ebr);

        if (OKAY == edit_ebr_loop(&ebr) && are_you_sure() == YES) {
            write_ebr(device_name, offset, &ebr);
        }
    }
    return OKAY;
} 
Beispiel #2
0
void options(tb1_state *game_state)
{

    int opbarpos=0,ch=0,redraw=1,not_saved=0;
     
    vmwFont *tb1_font;
    char *dir_name;
    char file_name[BUFSIZ];
    FILE *fff;
  
    tb1_font=game_state->graph_state->default_font;
   
    while(ch!=VMW_ESCAPE) {
       if (redraw) {
          vmwClearScreen(game_state->virtual_1,8);
          coolbox(0,0,319,199,0,game_state->virtual_1);
          vmwTextXY("UP,DOWN=MOVE.  RIGHT,LEFT=CHANGE.",25,170,32,0,1,tb1_font,game_state->virtual_1);
          vmwTextXY("ENTER ACTIVATES.  ESC QUITS",80,180,32,0,1,tb1_font,game_state->virtual_1);
          redraw=0;
       }
       
       vmwTextXY("SOUND OPTIONS:",10,10,9,8,1,tb1_font,game_state->virtual_1);
       vmwTextXY("SOUND FX:",40,20,10,8,1,tb1_font,game_state->virtual_1);
       put_on_off(game_state->sound_enabled,(opbarpos==0),
		  120,20,tb1_font,game_state->virtual_1);
       vmwTextXY("MUSIC   :",40,30,10,8,1,tb1_font,game_state->virtual_1);
       put_on_off(game_state->music_enabled,(opbarpos==1),
		  120,30,tb1_font,game_state->virtual_1);
       vmwTextXY("SOUND VOLUME:",40,40,10,8,1,tb1_font,game_state->virtual_1);
       put_number(game_state->sound_volume,(opbarpos==2),150,40,
		  tb1_font,game_state->virtual_1);
       vmwTextXY("MUSIC VOLUME:",40,50,10,8,1,tb1_font,game_state->virtual_1);
       put_number(game_state->music_volume,(opbarpos==3),150,50,
		  tb1_font,game_state->virtual_1);
       
       vmwTextXY("HIGH SCORE LIST:",10,60,9,8,1,tb1_font,game_state->virtual_1);
       put_string("VIEW LIST",(opbarpos==4),40,70,tb1_font,game_state->virtual_1);
       put_string("WIPE LIST",(opbarpos==5),40,80,tb1_font,game_state->virtual_1);
       
       vmwTextXY("DEFAULT DISPLAY OPTIONS:",10,90,9,8,1,tb1_font,game_state->virtual_1);
       vmwTextXY("RUN DOUBLESIZE:",40,100,10,8,1,tb1_font,game_state->virtual_1);
       put_yes_no(game_state->default_double_size,(opbarpos==6),180,100,
		  tb1_font,game_state->virtual_1);      
       vmwTextXY("RUN FULLSCREEN:",40,110,10,8,1,tb1_font,game_state->virtual_1);
       put_yes_no(game_state->default_fullscreen,(opbarpos==7),180,110,
		  tb1_font,game_state->virtual_1);
       
       put_string("SAVE TO DISK AS DEFAULT VALUES",
		  (opbarpos==8),10,130,tb1_font,game_state->virtual_1);
       
       vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
       
       while(!(ch=vmwGetInput()) ) usleep(30);
       
       if (ch==VMW_DOWN) opbarpos++;
       if (ch==VMW_UP) opbarpos--;
       if (ch==VMW_RIGHT) {
	  switch(opbarpos) {
	   case 0:  game_state->sound_enabled=!game_state->sound_enabled;
	            break;
	   case 1:  game_state->music_enabled=!game_state->music_enabled;
	            break;
	   case 2:  game_state->sound_volume++;
	            if (game_state->sound_volume>9) game_state->sound_volume=9;
	            break;
	   case 3:  game_state->music_volume++;
	            if (game_state->music_volume>9) game_state->music_volume=9;
	            break;
	   case 6:  game_state->default_double_size=!game_state->default_double_size;
	            break;
	   case 7:  game_state->default_fullscreen=!game_state->default_fullscreen;
	            break;
	     
	  }
       }
       if (ch==VMW_LEFT){
	  switch(opbarpos) {
	   case 0:  game_state->sound_enabled=!game_state->sound_enabled;
	            break;
	   case 1:  game_state->music_enabled=!game_state->music_enabled;
	            break;
	   case 2:  game_state->sound_volume--;
	            if (game_state->sound_volume<0) game_state->sound_volume=0;
	            break;
	   case 3:  game_state->music_volume--;
	            if (game_state->music_volume<0) game_state->music_volume=0;
	            break;
	   case 6:  game_state->default_double_size=!game_state->default_double_size;
	            break;
	   case 7:  game_state->default_fullscreen=!game_state->default_fullscreen;
	            break;
	     
	  }
       }
       
       if (ch==VMW_ENTER) {
	  switch(opbarpos) {
	   case 4: /* View High Score List */
	     showhiscore(game_state,1,0);
	     redraw=1;
	     break;
	   case 5: /* Wipe High Score List */
	    if (are_you_sure(game_state,"WIPE HIGH SCORES?",
				           "ARE YOU SURE?",
				           "YES!",
				           "NO!") )
	     
	        write_hs_list(game_state,0,"Vince",1);
	    redraw=1;
	    break;
	     
	   case 8: /* Save Game State */
	       /* If ~/.tb1 does not exist, and wasn't made, then exit */
	    not_saved=0;
	    if ((dir_name=check_for_tb1_directory(game_state,1))==NULL) not_saved=1;
	    
	    if (!not_saved) {
	       sprintf(file_name,"%s/options.tb1",dir_name);
	       fff=fopen(file_name,"w");
	       if (fff==NULL) {
		  not_saved=1;
	       }
	       else {
	          fprintf(fff,"%i\n%i\n%i\n%i\n%i\n%i\n",
		  game_state->sound_enabled,
		  game_state->music_enabled,
		  game_state->sound_volume,
		  game_state->music_volume,
		  game_state->default_double_size,
		  game_state->default_fullscreen);
	          fclose(fff);
	       }
	    }
	    coolbox(90,75,250,105,1,game_state->virtual_1);
	    if (not_saved) vmwTextXY("ERROR WHILE SAVING",97,82,9,7,0,
				     tb1_font,game_state->virtual_1);
	    else vmwTextXY("OPTIONS SAVED",97,82,9,7,0,tb1_font,
			    game_state->virtual_1);
            vmwBlitMemToDisplay(game_state->graph_state,game_state->virtual_1);
	     
	    pauseawhile(15); 
	     
	    redraw=1;
	    break;
	  }
        }    
       if (opbarpos>8) opbarpos=0;
       if (opbarpos<0) opbarpos=8;
    }
}
Beispiel #3
0
void
kdb5_update_princ_encryption(int argc, char *argv[])
{
    struct update_enc_mkvno data = { 0 };
    char *name_pattern = NULL;
    int force = 0;
    int optchar;
    krb5_error_code retval;
    krb5_actkvno_node *actkvno_list = 0;
    krb5_db_entry *master_entry;
    char *mkey_fullname = 0;
#ifdef BSD_REGEXPS
    char *msg;
#endif
    char *regexp = NULL;
    krb5_keyblock *act_mkey;
    krb5_keylist_node *master_keylist = krb5_db_mkey_list_alias(util_context);

    while ((optchar = getopt(argc, argv, "fnv")) != -1) {
        switch (optchar) {
        case 'f':
            force = 1;
            break;
        case 'n':
            data.dry_run = 1;
            break;
        case 'v':
            data.verbose = 1;
            break;
        case '?':
        case ':':
        default:
            usage();
        }
    }
    if (argv[optind] != NULL) {
        name_pattern = argv[optind];
        if (argv[optind+1] != NULL)
            usage();
    }

    retval = krb5_unparse_name(util_context, master_princ, &mkey_fullname);
    if (retval) {
        com_err(progname, retval, _("while formatting master principal name"));
        exit_status++;
        goto cleanup;
    }

    if (master_keylist == NULL) {
        com_err(progname, retval, _("master keylist not initialized"));
        exit_status++;
        goto cleanup;
    }

    /* The glob_to_regexp code only cares if the "realm" parameter is
       NULL or not; the string data is irrelevant.  */
    if (name_pattern == NULL)
        name_pattern = "*";
    if (glob_to_regexp(name_pattern, "hi", &regexp) != 0) {
        com_err(progname, ENOMEM,
                _("converting glob pattern '%s' to regular expression"),
                name_pattern);
        exit_status++;
        goto cleanup;
    }

    if (
#ifdef SOLARIS_REGEXPS
        ((data.expbuf = compile(regexp, NULL, NULL)) == NULL)
#endif
#ifdef POSIX_REGEXPS
        ((regcomp(&data.preg, regexp, REG_NOSUB)) != 0)
#endif
#ifdef BSD_REGEXPS
        ((msg = (char *) re_comp(regexp)) != NULL)
#endif
    ) {
        /* XXX syslog msg or regerr(regerrno) */
        com_err(progname, 0, _("error compiling converted regexp '%s'"),
                regexp);
        exit_status++;
        goto cleanup;
    }

    retval = krb5_db_get_principal(util_context, master_princ, 0,
                                   &master_entry);
    if (retval != 0) {
        com_err(progname, retval, _("while getting master key principal %s"),
                mkey_fullname);
        exit_status++;
        goto cleanup;
    }

    retval = krb5_dbe_lookup_actkvno(util_context, master_entry, &actkvno_list);
    if (retval != 0) {
        com_err(progname, retval, _("while looking up active kvno list"));
        exit_status++;
        goto cleanup;
    }

    retval = krb5_dbe_find_act_mkey(util_context, actkvno_list, &new_mkvno,
                                    &act_mkey);
    if (retval) {
        com_err(progname, retval, _("while looking up active master key"));
        exit_status++;
        goto cleanup;
    }
    new_master_keyblock = *act_mkey;

    if (!force &&
        !data.dry_run &&
        !are_you_sure(_("Re-encrypt all keys not using master key vno %u?"),
                      new_mkvno)) {
        printf(_("OK, doing nothing.\n"));
        exit_status++;
        goto cleanup;
    }
    if (data.verbose) {
        if (data.dry_run) {
            printf(_("Principals whose keys WOULD BE re-encrypted to master "
                     "key vno %u:\n"), new_mkvno);
        } else {
            printf(_("Principals whose keys are being re-encrypted to master "
                     "key vno %u if necessary:\n"), new_mkvno);
        }
    }

    if (!data.dry_run) {
        /* Grab a write lock so we don't have to upgrade to a write lock and
         * reopen the DB while iterating. */
        retval = krb5_db_lock(util_context, KRB5_DB_LOCKMODE_EXCLUSIVE);
        if (retval != 0 && retval != KRB5_PLUGIN_OP_NOTSUPP) {
            com_err(progname, retval, _("trying to lock database"));
            exit_status++;
        }
    }

    retval = krb5_db_iterate(util_context, name_pattern,
                             update_princ_encryption_1, &data);
    /* If exit_status is set, then update_princ_encryption_1 already
       printed a message.  */
    if (retval != 0 && exit_status == 0) {
        com_err(progname, retval, _("trying to process principal database"));
        exit_status++;
    }
    if (!data.dry_run)
        (void)krb5_db_unlock(util_context);
    (void) krb5_db_fini(util_context);
    if (data.dry_run) {
        printf(_("%u principals processed: %u would be updated, %u already "
                 "current\n"),
               data.re_match_count, data.updated, data.already_current);
    } else {
        printf(_("%u principals processed: %u updated, %u already current\n"),
               data.re_match_count, data.updated, data.already_current);
    }

cleanup:
    free(regexp);
    memset(&new_master_keyblock, 0, sizeof(new_master_keyblock));
    krb5_free_unparsed_name(util_context, mkey_fullname);
    krb5_dbe_free_actkvno_list(util_context, actkvno_list);
}