Пример #1
0
struct directory *mk_entry(const dos_name_t *dn, char attr,
			   unsigned int fat, size_t size, time_t date,
			   struct directory *ndir)
{
	struct tm *now;
	time_t date2 = date;
	unsigned char hour, min_hi, min_low, sec;
	unsigned char year, month_hi, month_low, day;

	now = localtime(&date2);
	dosnameToDirentry(dn, ndir);
	ndir->attr = attr;
	ndir->ctime_ms = 0;
	hour = now->tm_hour << 3;
	min_hi = now->tm_min >> 3;
	min_low = now->tm_min << 5;
	sec = now->tm_sec / 2;
	ndir->ctime[1] = ndir->time[1] = hour + min_hi;
	ndir->ctime[0] = ndir->time[0] = min_low + sec;
	year = (now->tm_year - 80) << 1;
	month_hi = (now->tm_mon + 1) >> 3;
	month_low = (now->tm_mon + 1) << 5;
	day = now->tm_mday;
	ndir -> adate[1] = ndir->cdate[1] = ndir->date[1] = year + month_hi;
	ndir -> adate[0] = ndir->cdate[0] = ndir->date[0] = month_low + day;

	set_word(ndir->start, fat & 0xffff);
	set_word(ndir->startHi, fat >> 16);
	set_dword(ndir->size, size);
	return ndir;
}
Пример #2
0
static char *
add_resin_script(CComPtr <IMSAdminBase> pIMeta, TCHAR *name, char *script_path)
{
	HRESULT hRes = 0; 
	METADATA_HANDLE MyHandle;
	TCHAR *scripts = TEXT("/scripts");
	char data[256];

	hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, name,
			       METADATA_PERMISSION_READ|METADATA_PERMISSION_WRITE, 20, &MyHandle);
	if (FAILED(hRes)) {
		return "Can't open script";
	}

	data[0] = 0;
	if (get_string(pIMeta, MyHandle, scripts, IIS_MD_UT_SERVER, MD_KEY_TYPE, data) < 0) {
		pIMeta->AddKey(MyHandle, scripts);
	}
	set_type(pIMeta, MyHandle, scripts, "IIsWebVirtualDir");
	set_data(pIMeta, MyHandle, scripts, MD_APP_ROOT, IIS_MD_UT_FILE, "/LM/W3SVC/1/Root/scripts");
	set_data(pIMeta, MyHandle, scripts, MD_VR_PATH, IIS_MD_UT_FILE, script_path);
	set_data(pIMeta, MyHandle, scripts, MD_APP_FRIENDLY_NAME, IIS_MD_UT_WAM, "scripts");
	set_dword(pIMeta, MyHandle, scripts, MD_ACCESS_PERM, MD_ACCESS_EXECUTE);
	set_dword_data(pIMeta, MyHandle, scripts, MD_APP_ISOLATED, IIS_MD_UT_WAM, 2);

	pIMeta->CloseKey(MyHandle);

	return 0;
}
Пример #3
0
static char *
remove_resin_filter(CComPtr <IMSAdminBase> pIMeta, METADATA_HANDLE MyHandle)
{
	set_dword(pIMeta, MyHandle, TEXT("/Resin"), MD_FILTER_ENABLED, 0);
	pIMeta->DeleteKey(MyHandle, TEXT("/Resin"));

	char filterLoad[1024];
	if (! get_string(pIMeta, MyHandle, TEXT("/"), IIS_MD_UT_SERVER, MD_FILTER_LOAD_ORDER, filterLoad))
		return 0;

	char *resin = strstr(filterLoad, "Resin");
	if (! resin)
		return 0;

	char newFilter[1024];
	memset(newFilter, 0, sizeof(newFilter));
	if (filterLoad != resin) {
		int i = -1;
		for (; resin - filterLoad + i >= 0 && (resin[i] == ' ' || resin[i] == ','); i--) {
		}
		strncpy(newFilter, filterLoad, resin - filterLoad + i + 1);
		newFilter[resin - filterLoad + i + 1] = 0;
		strcat(newFilter, resin + 5);
	}
	else {
		int i;
		for (i = 5; resin[i] == ' ' || resin[i] == ','; i++) {
		}
		strcpy(newFilter, resin + i);
	}

	if (! set_data(pIMeta, MyHandle, TEXT("/"), MD_FILTER_LOAD_ORDER, IIS_MD_UT_SERVER, newFilter))
		return "Can't set IIS filter order";

	return 0;
}
Пример #4
0
void mlabel(int argc, char **argv, int type)
{

	char *newLabel;
	int verbose, clear, interactive, show;
	direntry_t entry;
	int result=0;
	char longname[VBUFSIZE];
	char shortname[45];
	ClashHandling_t ch;
	struct MainParam_t mp;
	Stream_t *RootDir;
	int c;
	int mangled;
	enum { SER_NONE, SER_RANDOM, SER_SET }  set_serial = SER_NONE;
	long serial = 0;
	int need_write_boot = 0;
	int have_boot = 0;
	char *eptr;
	union bootsector boot;
	Stream_t *Fs=0;
	int r;
	struct label_blk_t *labelBlock;
	int isRo=0;
	int *isRop=NULL;

	init_clash_handling(&ch);
	ch.name_converter = label_name;
	ch.ignore_entry = -2;

	verbose = 0;
	clear = 0;
	show = 0;

	if(helpFlag(argc, argv))
		usage(0);
	while ((c = getopt(argc, argv, "i:vcsnN:h")) != EOF) {
		switch (c) {
			case 'i':
				set_cmd_line_image(optarg, 0);
				break;
			case 'v':
				verbose = 1;
				break;
			case 'c':
				clear = 1;
				break;
			case 's':
				show = 1;
				break;
			case 'n':
				set_serial = SER_RANDOM;
				srandom((long)time (0));
				serial=random();
				break;
			case 'N':
				set_serial = SER_SET;
				serial = strtol(optarg, &eptr, 16);
				if(*eptr) {
					fprintf(stderr,
						"%s not a valid serial number\n",
						optarg);
					exit(1);
				}
				break;
			case 'h':
				usage(0);
			default:
				usage(1);
			}
	}

	if (argc - optind != 1 || !argv[optind][0] || argv[optind][1] != ':')
		usage(1);

	init_mp(&mp);
	newLabel = argv[optind]+2;
	if(strlen(newLabel) > VBUFSIZE) {
		fprintf(stderr, "Label too long\n");
		FREE(&RootDir);
		exit(1);
	}

	interactive = !show && !clear &&!newLabel[0] &&
		(set_serial == SER_NONE);
	if(!clear && !newLabel[0]) {
		isRop = &isRo;
	}
	RootDir = open_root_dir(argv[optind][0], isRop ? 0 : O_RDWR, isRop);
	if(isRo) {
		show = 1;
		interactive = 0;
	}	
	if(!RootDir) {
		fprintf(stderr, "%s: Cannot initialize drive\n", argv[0]);
		exit(1);
	}

	initializeDirentry(&entry, RootDir);
	r=vfat_lookup(&entry, 0, 0, ACCEPT_LABEL | MATCH_ANY,
		      shortname, longname);
	if (r == -2) {
		FREE(&RootDir);
		exit(1);
	}

	if(show || interactive){
		if(isNotFound(&entry))
			printf(" Volume has no label\n");
		else if (*longname)
			printf(" Volume label is %s (abbr=%s)\n",
			       longname, shortname);
		else
			printf(" Volume label is %s\n",  shortname);

	}

	/* ask for new label */
	if(interactive){
		newLabel = longname;
		fprintf(stderr,"Enter the new volume label : ");
		if(fgets(newLabel, VBUFSIZE, stdin) == NULL) {
			newLabel[0] = '\0';
			fprintf(stderr, "\n");
		}
		if(newLabel[0])
			newLabel[strlen(newLabel)-1] = '\0';
	}

	if((!show || newLabel[0]) && !isNotFound(&entry)){
		/* if we have a label, wipe it out before putting new one */
		if(interactive && newLabel[0] == '\0')
			if(ask_confirmation("Delete volume label (y/n): ")){
				FREE(&RootDir);
				exit(0);
			}
		entry.dir.attr = 0; /* for old mlabel */
		wipeEntry(&entry);
	}

	if (newLabel[0] != '\0') {
		ch.ignore_entry = 1;
		result = mwrite_one(RootDir,newLabel,0,labelit,NULL,&ch) ?
		  0 : 1;
	}

	have_boot = 0;
	if( (!show || newLabel[0]) || set_serial != SER_NONE) {
		Fs = GetFs(RootDir);
		have_boot = (force_read(Fs,boot.characters,0,sizeof(boot)) ==
			     sizeof(boot));
	}

	if(WORD_S(fatlen)) {
	    labelBlock = &boot.boot.ext.old.labelBlock;
	} else {
	    labelBlock = &boot.boot.ext.fat32.labelBlock;
	}

	if(!show || newLabel[0]){
		dos_name_t dosname;
		const char *shrtLabel;
		doscp_t *cp;
		if(!newLabel[0])
			shrtLabel = "NO NAME    ";
		else
			shrtLabel = newLabel;
		cp = GET_DOSCONVERT(Fs);
		label_name(cp, shrtLabel, verbose, &mangled, &dosname);

		if(have_boot && boot.boot.descr >= 0xf0 &&
		   labelBlock->dos4 == 0x29) {
			strncpy(labelBlock->label, dosname.base, 11);
			need_write_boot = 1;

		}
	}

	if((set_serial != SER_NONE) & have_boot) {
		if(have_boot && boot.boot.descr >= 0xf0 &&
		   labelBlock->dos4 == 0x29) {
			set_dword(labelBlock->serial, serial);	
			need_write_boot = 1;
		}
	}

	if(need_write_boot) {
		force_write(Fs, (char *)&boot, 0, sizeof(boot));
	}

	FREE(&RootDir);
	exit(result);
}
Пример #5
0
void mboot_setinfo( uint32 pMultiboot )
{
    // Do some janky address shifting because we haven't set up paging yet
    
    set_dword( (uint32)(&pMultibootHeader) - PAGING_KERNEL_OFFSET, pMultiboot + PAGING_KERNEL_OFFSET );
}