Ejemplo n.º 1
0
void stage1(void) {
	DIR *dp;
	struct dirent *dt;
	calculate_mem();
	fprintf_stdout("* Creating Mybox filesystem (%d kB) on shared memory...\n",RAMSIZE);
	xsystem("mount -t tmpfs -o \"rw,size=%dk\" virtual /ramd",RAMSIZE);
	chmod("/ramd",S_IREAD | S_IWRITE | S_IEXEC);
	chdir("/ramd");
	if((dp=opendir("/")) == NULL) {
		perror("opendir");
		exit(1);
        }
	while((dt=readdir(dp))!=NULL) {
		if(!strcmp(dt->d_name,".") || !strcmp(dt->d_name,"..") ||
			!strcmp(dt->d_name,"lost+found") || 
			!strcmp(dt->d_name,"ramd") || 
			!strcmp(dt->d_name,"proc") || 
			!strcmp(dt->d_name,"dev") || 
			!strcmp(dt->d_name,"sys")) continue;
			xsystem("cp -dpR /%s /ramd/",dt->d_name);
	}
	closedir(dp);
	xmkdir("dev/pts");
	xmkdir("initrd");
	umount("/proc");
	umount("/sys");
}
Ejemplo n.º 2
0
int get_archive_list(const char *archive, const char *list_file) /* Создание списка файлов в архиве */
{
  char *command = NULL;
  int asprintf_result;
  switch (file_type_of(archive)) /* Архивно-зависимая часть */
  {
    case ZIP_FILE:
      #ifdef debug_printf
      printf("File type ZIP: '%s'\n", archive);
      #endif
      asprintf_result=asprintf(&command, "zipinfo -1 \"%s\" | %s > /tmp/ziplist; xargs -n1 dirname < /tmp/ziplist | uniq | sed '/^.$/d;s $ / g' > /tmp/list ; grep -v /$ /tmp/ziplist >> /tmp/list ; %s < /tmp/list > %s", archive, SORT_COMMAND, SORT_COMMAND, list_file); /* Злоебучая команда, потому как бывают архивы, которые не содержат каталогов, только файлы (каталоги в каноничном списке необходимы!) */
      if (asprintf_result == -1 || command == NULL)
      {
        #ifdef debug_printf
        printf("asprintf() failed in get_archive_list (no memory?)\n");
        #endif
        shutdown(FALSE);
      }
      else
        xsystem(command); /* Получаем список каталогов и файлов в каноничном формате (каталоги должны завершаться слэшем) */
        xfree(&command);
      (void)remove("/tmp/ziplist");
      (void)remove("/tmp/list");
      return TRUE;

    case RAR_FILE:
      #ifdef debug_printf
      printf("File type RAR: '%s'\n", archive);
      #endif
      asprintf_result=asprintf(&command, "unrar vt \"%s\" > /tmp/rarlist ; grep -B1 -- 'd[r-][w-][x-][r-][w-][x-][r-][w-][x-]\\|\\.D\\.' /tmp/rarlist | grep -v '^--$\\|d[r-][w-][x-][r-][w-][x-][r-][w-][x-]\\|\\.D\\.'  | cut -c 2- | sed 's $ / g' > /tmp/list ; grep -B1 -- '-[r-][w-][x-][r-][w-][x-][r-][w-][x-]\\|\\.*A\\.' /tmp/rarlist | grep -v '^--$\\|-[r-][w-][x-][r-][w-][x-][r-][w-][x-]\\|\\.*A\\.'  | sed '1d;$d'| cut -c 2- >> /tmp/list; %s < /tmp/list > %s", archive, SORT_COMMAND, list_file); /* Злоебучая команда, ага. Но зато экономим аж три дорогущих вызова system() */
      if (asprintf_result == -1 || command == NULL)
      {
        #ifdef debug_printf
        printf("asprintf() failed in get_archive_list (no memory?)\n");
        #endif
        shutdown(FALSE);
      }
      else /* Получаем список каталогов и файлов в каноничном формате (каталоги должны завершаться слэшем) */
        xsystem(command);
      xfree(&command);
      (void)remove("/tmp/rarlist");
      (void)remove("/tmp/list");
      return TRUE;

    default:
      #ifdef debug_printf
      printf("Unknown file type:%s\n", archive);
      #endif
      return FALSE;
  }
}
Ejemplo n.º 3
0
static void wait_prog(const char *msg, const char *path,const char *prog, const char *argz) {
	FILE *f;
	char spin[]={'-','\\','|','/','-','\\','|','/'};
	int numspin=sizeof(spin);
	int i=0, ok=0, pt=0;
	char filetmp[1024], buf[1024];
	memset(filetmp,0x0,sizeof(filetmp));
	snprintf(filetmp,sizeof(filetmp),"/tmp/%s.log",prog);
	save_to_file(filetmp,"");
	xsystem("php -q %s/%s %s >> %s 2>&1 && rm -f %s >>/dev/null 2>&1 &",path,prog,argz,filetmp,filetmp);
	while(file_exists(filetmp)) {
		for(i=0;i<numspin;i++) {
			fprintf_stdout("\r-> %s [%c]",msg,spin[i]);
			usleep(100000);
		}
		memset(buf,0x0,sizeof(buf));
		if((f=fopen(filetmp,"r"))!=NULL) {
			while(fgets(buf,sizeof(buf),f)!=NULL) {
				trim(buf);
				if(buf[0]=='\0') continue;
				if(strstr(buf,"unlicensed")) {
					fprintf_stdout("\r* %s Unlicensed.\n",msg);
					unlink(filetmp);ok=1;
				} else if(strstr(buf,"Internal error")) {
					fprintf_stdout("\r* %s Internal error.\n",msg);
					unlink(filetmp);ok=1;
				} else if(strstr(buf,"failed") || strstr(buf,"Failed") ) {
					fprintf_stdout("\r* %s Failed.\n",msg);
					unlink(filetmp);ok=1;
				} else if(strstr(buf,"disabled") || strstr(buf,"Disabled")) {
					fprintf_stdout("\r* %s Disabled.\n",msg);
					unlink(filetmp);ok=1;
				}
				memset(buf,0x0,sizeof(buf));	
			}
			fclose(f);
		}
		// more than 1 minutes
		if(pt > 60) {
			fprintf_stdout("\r* %s Timeout.\n",msg);
			unlink(filetmp);ok=1;
		}
		pt++;
		sleep(1);
	}
	if(ok==0) {
		fprintf_stdout("\r* %s Done.\n",msg);
		unlink(filetmp);
	}
}
Ejemplo n.º 4
0
void archive_extract_file(const char *archive, const char *file, const char *to)
{
  const char *archiver;
  char *command = NULL, *name=NULL;
  switch (file_type_of(archive)) {
    case ZIP_FILE:
      archiver="unzip -o ";
      name=escape(file);
      break;
    case RAR_FILE:
      archiver="unrar x -y -kb ";
      name=strdup(file);
      break;
    default:
      #ifdef debug_printf
      printf("Unknown file type:%s\n", archive);
      #endif
      return;
  }
  asprintf(&command, "%s \"%s\" \"%s\" -d \"%s\"", archiver, archive, name, to);
  xsystem(command);
  xfree(&command);
  free(name);
}
Ejemplo n.º 5
0
int
opkg_download(const char *src, const char *dest_file_name,
	curl_progress_func cb, void *data, const short hide_error)
{
    int err = 0;

    char *src_basec = xstrdup(src);
    char *src_base = basename(src_basec);
    char *tmp_file_location;

    opkg_msg(NOTICE,"Downloading %s.\n", src);

    if (str_starts_with(src, "file:")) {
	const char *file_src = src + 5;
	opkg_msg(INFO, "Copying %s to %s...", file_src, dest_file_name);
	err = file_copy(file_src, dest_file_name);
	opkg_msg(INFO, "Done.\n");
        free(src_basec);
	return err;
    }

    sprintf_alloc(&tmp_file_location, "%s/%s", conf->tmp_dir, src_base);
    free(src_basec);
    err = unlink(tmp_file_location);
    if (err && errno != ENOENT) {
	opkg_perror(ERROR, "Failed to unlink %s", tmp_file_location);
	free(tmp_file_location);
	return -1;
    }

    if (conf->http_proxy) {
	opkg_msg(DEBUG, "Setting environment variable: http_proxy = %s.\n",
		conf->http_proxy);
	setenv("http_proxy", conf->http_proxy, 1);
    }
    if (conf->ftp_proxy) {
	opkg_msg(DEBUG, "Setting environment variable: ftp_proxy = %s.\n",
		conf->ftp_proxy);
	setenv("ftp_proxy", conf->ftp_proxy, 1);
    }
    if (conf->no_proxy) {
	opkg_msg(DEBUG,"Setting environment variable: no_proxy = %s.\n",
		conf->no_proxy);
	setenv("no_proxy", conf->no_proxy, 1);
    }

#ifdef HAVE_CURL
    CURLcode res;
    FILE * file = fopen (tmp_file_location, "w");

    curl = opkg_curl_init (cb, data);
    if (curl)
    {
	curl_easy_setopt (curl, CURLOPT_URL, src);
	curl_easy_setopt (curl, CURLOPT_WRITEDATA, file);

	res = curl_easy_perform (curl);
	fclose (file);
	if (res)
	{
	    long error_code;
	    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &error_code);
	    opkg_msg(hide_error?DEBUG2:ERROR, "Failed to download %s: %s.\n",
		    src, curl_easy_strerror(res));
	    free(tmp_file_location);
	    return -1;
	}

    }
    else
    {
	free(tmp_file_location);
	return -1;
    }
#else
    {
      int res;
      const char *argv[8];
      int i = 0;

      argv[i++] = "wget";
      argv[i++] = "-q";
      if (conf->http_proxy || conf->ftp_proxy) {
	argv[i++] = "-Y";
	argv[i++] = "on";
      }
      argv[i++] = "-O";
      argv[i++] = tmp_file_location;
      argv[i++] = src;
      argv[i++] = NULL;
      res = xsystem(argv);

      if (res) {
	opkg_msg(ERROR, "Failed to download %s, wget returned %d.\n", src, res);
	free(tmp_file_location);
	return -1;
      }
    }
#endif

    err = file_move(tmp_file_location, dest_file_name);

    free(tmp_file_location);

    return err;
}
Ejemplo n.º 6
0
static int run_daemon(char *pname,char *prog) {
	if(file_exists("/bin/start-stop-daemon")) {
		return xsystem("/bin/start-stop-daemon -S -q -b -m -p /var/run/%s.pid -x %s",pname,prog);
	}
	return 1;
}
Ejemplo n.º 7
0
int bootup_main(int argc, char **argv) {
    FILE *fp;
    DIR *dp;
    struct dirent *dt;
    int t=0, rc;
    char cmd[1024], buf[1024], name[1024];
    time_t curtime;
    struct tm *loctime;
    signal(SIGINT,SIG_IGN);
    putenv("PATH=/bin");
    putenv("TERM=linux");
    umask(0770);
    chdir("/");
    putchar('\n');
    print_banner();
    putchar('\n');
    xsystem("mount -t proc -o ro virtual /proc");
    xsystem("mount -t sysfs -o ro virtual /sys");

    // STAGE 1
    calculate_mem();
    fprintf_stdout("* Creating Mybox filesystem (%d kB) on shared memory...\n",RAMSIZE);
    xsystem("mount -t tmpfs -o \"rw,size=%dk\" virtual /ramd",RAMSIZE);
    chmod("/ramd",S_IREAD | S_IWRITE | S_IEXEC);
    chdir("/ramd");
    if((dp=opendir("/")) == NULL) {
        perror("opendir");
        exit(1);
    }
    while((dt=readdir(dp))!=NULL) {
        if(!strcmp(dt->d_name,".") || !strcmp(dt->d_name,"..") ||
                !strcmp(dt->d_name,"lost+found") ||
                !strcmp(dt->d_name,"ramd") ||
                !strcmp(dt->d_name,"proc") ||
                !strcmp(dt->d_name,"dev") ||
                !strcmp(dt->d_name,"sys")) continue;
        xsystem("cp -dpR /%s /ramd/",dt->d_name);
    }
    closedir(dp);
    xmkdir("dev/pts");
    xmkdir("initrd");
    umount("/proc");
    umount("/sys");

    // STAGE 2
    rc=pivot_root(".","initrd");
    if(rc==-1) {
        fprintf_stdout("#### ERROR: Change root file system failed!\n");
        exit(1);
    }
    chdir("/");
    xmkdir("proc");
    xmkdir("sys");
    xsystem("mount -t proc -o rw virtual /proc");
    xsystem("mount -t sysfs -o rw virtual /sys");
    save_to_file("/proc/sys/kernel/printk","0 0 0 0\n");
    if((dp=opendir("/tmp")) == NULL) {
        perror("opendir");
        exit(1);
    }
    fprintf_stdout("-> Extracting base tools: ");
    while((dt=readdir(dp))!=NULL) {
        if(!strcmp(dt->d_name,".") || !strcmp(dt->d_name,"..")) continue;
        if(strstr(dt->d_name,".mpk")) {
            fprintf_stdout("#");
            xsystem("tar -C / -axf /tmp/%s",dt->d_name);
        }
    }
    free(dt);
    closedir(dp);
    fprintf_stdout("\r* Extracting base tools. Done.%s\n",SPACE);
    save_to_file("/proc/sys/kernel/modprobe","/bin/modprobe\n");
    xsystem("depmod -a");

    // STAGE 3
    chdir("/");
    xsystem("mdev -s");
    xsystem("mount -t devpts /dev/devpts /dev/pts -o \"rw,gid=0,mode=620\"");
    rename("/dev/random","/dev/random-block");
    symlink("/dev/urandom","/dev/random");
    xsystem("chmod 700 *");
    if((fp=fopen("/etc/inittab","w"))!=NULL) {
        fprintf(fp,"::sysinit:/etc/init.boot/rc.init\n");
        fprintf(fp,"tty1::respawn:/bin/getty -h -n -L tty1 115200 linux\n");
        fprintf(fp,"ttyS0::respawn:/bin/getty -h -n -L ttyS0 115200 vt100\n");
        fprintf(fp,"tty7::respawn:/bin/chkprog\n");
        fprintf(fp,"tty8::respawn:/bin/trafficd\n");
        fprintf(fp,"::restart:/bin/init\n");
        fprintf(fp,"::ctrlaltdel:/bin/bootdown\n");
        fprintf(fp,"::ctrlaltdel:/bin/reset\n");
        fprintf(fp,"::ctrlaltdel:/bin/reboot\n");
        fprintf(fp,"::shutdown:/bin/bootdown\n");
        fclose(fp);
    }
    curtime=time(NULL);
    loctime=localtime(&curtime);
    strftime(cmd, sizeof(cmd), "[%d/%m/%Y %T] TYPE=INFO MSG=****** SYSTEM LOADING ******\n",loctime);
    append_to_file("/tmp/bootup",cmd);
    if(file_exists("/bin/getkey")) {
        if(system("getkey -c 3 -m \"-> Starting Init: %d\" R")==0) {
            fprintf_stdout("\r#### WARNING: LOGIN DISABLED\n");
            xtouch("/etc/noconsole");
        } else {
            fprintf_stdout("\r* Starting Init. Done.\n");
        }
    }
    memset(buf,0x0,sizeof(buf));
    snprintf(buf,sizeof(buf),"%s\n","/bin/mdev");
    save_to_file("/proc/sys/kernel/hotplug",buf);
    do_chroot();
    signal(SIGINT,SIG_DFL);
    fprintf_stdout("#### ERROR: Failed to boot file system!\n");
    fprintf_stdout("#### ERROR: Press Ctrl+Alt+Del or switch off/on for reboot.\n");
    while(1);
    exit(0);
}
Ejemplo n.º 8
0
/*
 * Note: openinfo is a function for reading info files, and putting
 * uncompressed content into a temporary filename.  For a flexibility, there
 * are two temporary files supported, i.e.  one for keeping opened info file,
 * and second for i.e. regexp search across info nodes, which are in other
 * info-subfiles.  The temporary file 1 is refrenced by number=0, and file 2 by
 * number=1 Openinfo by default first tries the path stored in char
 * *filenameprefix and then in the rest of userdefined paths.
 */
FILE *
openinfo(char *filename, int number)
{
	FILE *id = NULL;
#define BUF_LEN 1024
	char *buf = xmalloc(BUF_LEN);	/* holds local copy of filename */
	char *bufend;			/* points at the trailing 0 of initial name */
	char command[1128];		/* holds command to evaluate for decompression of file */
	int i, j;
	char *tmpfilename;

	if ((strncmp(filename, "dir", 3)==0)  &&  !isalnum(filename[3]))
	{
		xfree(buf);
		return opendirfile(number);
	}

	if (number == 0)		/* initialize tmp filename for file 1 */
	{
		if (tmpfilename1)
		{
			unlink(tmpfilename1);	/* erase old tmpfile */
			free(tmpfilename1);
		}
		tmpfilename1 = make_tempfile();
		tmpfilename = tmpfilename1;	/* later we will refere only to tmp1 */
	}
	else /* initialize tmp filename for file 2 */
	{
		if (tmpfilename2)
		{
			unlink(tmpfilename2);	/* erase old tmpfile */
			free(tmpfilename2);
		}
		tmpfilename2 = make_tempfile();
		tmpfilename = tmpfilename2;	/* later we will refere only to tmp2 */
	}

	for (i = -2; i < infopathcount; i++)	/* go through all paths */
	{
		if (i < 0)
		{
			/*
			 * no filenameprefix, we don't navigate around any specific
			 * infopage set, so simply scan all directories for a hit
			 */
			if (!filenameprefix)
				continue;
			/* build a filename: First (i == -2) try filenameprefix/filename,
			 * then try with a .info appended */
			if (i == -2)
				snprintf(buf, BUF_LEN, "%s/%s", filenameprefix, basename(filename));
			else
				snprintf(buf, BUF_LEN, "%s/%s.info", filenameprefix, basename(filename));
		}
		else
		{
			/* build a filename */
			strcpy(buf, infopaths[i]);
			/* no match found in this directory */
			if (! matchfile(&buf, filename))
				continue;
		}
		bufend = buf;
		/* remember the bufend to make it possible later to glue compression
		 * suffixes. */
		bufend += strlen(buf);
		for (j = 0; j < SuffixesNumber; j++)	/* go through all suffixes */
		{
			strcat(buf, suffixes[j].suffix);
			if ((id = fopen(buf, "r")) != NULL)
			{
				fclose(id);
				clearfilenameprefix();
				filenameprefix = strdup(buf);
				{			/* small scope for removal of filename */
					int prefixi, prefixlen = strlen(filenameprefix);
					for (prefixi = prefixlen; prefixi > 0; prefixi--)
						if (filenameprefix[prefixi] == '/')
						{
							filenameprefix[prefixi] = 0;
							break;
						}
				}
				buildcommand(command, suffixes[j].command, buf, tmpfilename);
				xsystem(command);
				id = fopen(tmpfilename, "r");
				if (id)
				{
					xfree(buf);
					return id;
				}
			}
			(*bufend) = 0;
		}

		/* if we have a nonzero filename prefix, that is we view a set of
		 * infopages, we don't want to search for a page in all
		 * directories, but only in the prefix directory.  Therefore break
		 * here. */
		if ((i == -1) &&(filenameprefix))
			break;
	}
	xfree(buf);


	return 0;
#undef BUF_LEN
}
Ejemplo n.º 9
0
FILE *
opendirfile(int number)
{
	FILE *id = NULL;
	char buf[1024];		/* holds local copy of filename */
	char *bufend;			/* points at the trailing 0 of initial name */
	char command[1128];		/* holds command to evaluate for decompression of file */
	int i, j;
	char *tmpfilename = NULL;
	size_t *fileendentries = xmalloc(infopathcount * sizeof(*fileendentries)); /* should really be off_t, but a signed type really doesn't make sense here */
	int dir_found = 0;
	int dircount = 0;
	int lang_found;
	struct stat status;

	if (number == 0)		/* initialize tmp filename for file 1 */
	{
		/* close and delete old tmp file */
		if (tmpfilename1)
		{
			unlink(tmpfilename1);	/* erase old tmpfile */
			free(tmpfilename1);
		}
		tmpfilename1 = make_tempfile();
		tmpfilename = tmpfilename1;	/* later we will refere only to tmp1 */
	}
	for (i = 0; i < infopathcount; i++)	/* go through all paths */
	{
		lang_found = 0;
		strcpy(buf, infopaths[i]);	/* build a filename */
		strcat(buf, "/");
		if (getenv("LANG") != NULL)
			strcat(buf, getenv("LANG"));
		strcat(buf, "/dir");
		/*
		 * remember the bufend to make it
		 * possible later to glue compression suffixes.
		 */
		bufend = buf;
		bufend += strlen(buf);
		for (j = 0; j < SuffixesNumber; j++)	/* go through all suffixes */
		{
			strcat(buf, suffixes[j].suffix);
			if ((id = fopen(buf, "r")) != NULL)
			{
				fclose(id);
				builddircommand(command, suffixes[j].command, buf, tmpfilename);
				xsystem(command);
				lstat(tmpfilename, &status);
				fileendentries[dircount] = status.st_size;
				dircount++;
				dir_found = 1;
				lang_found = 1;
			}
			(*bufend) = 0;
		}

		/* same as above, but without $LANG support */
		if (!lang_found)
		{
			strcpy(buf, infopaths[i]);	/* build a filename */
			strcat(buf, "/");
			strcat(buf, "dir");
			/*
			 * remember the bufend to make it possible later to glue
			 * compression suffixes.
			 */
			bufend = buf;
			bufend += strlen(buf);
			for (j = 0; j < SuffixesNumber; j++)	/* go through all suffixes */
			{
				strcat(buf, suffixes[j].suffix);
				if ((id = fopen(buf, "r")) != NULL)
				{
					fclose(id);
					builddircommand(command, suffixes[j].command, buf, tmpfilename);
					xsystem(command);
					lstat(tmpfilename, &status);
					fileendentries[dircount] = status.st_size;
					dircount++;
					dir_found = 1;
				}
				(*bufend) = 0;
			}
		}
	}
	if (dir_found)
		id = fopen(tmpfilename, "r");
	/*
	 * Filter the concatenated dir pages to exclude hidden parts of info
	 * entries
	 */
	if (id)
	{
		char *tmp;
		size_t filelen, l;
		int aswitch = 0;
		int firstswitch = 0;
		dircount = 0;

		fseek(id, 0, SEEK_END);
		filelen = ftell(id);

		tmp = xmalloc(filelen);
		fseek(id, 0, SEEK_SET);
		if (fread(tmp, 1, filelen, id)!=filelen)
		{
			printf(_("Error while reading file '%s'"), tmp);
			closeprogram();
			exit(1);
		}
		fclose(id);
		id = fopen(tmpfilename, "w");
		for (l = 0; l < filelen; l++)
		{
			if (tmp[l] == INFO_TAG)
			{
				aswitch ^= 1;
				if (!firstswitch)
					fputc(tmp[l], id);
				firstswitch = 1;
			}
			else if ((aswitch) ||(!firstswitch))
				fputc(tmp[l], id);
			if (l + 1 == fileendentries[dircount])
			{
				if (aswitch != 0)
					aswitch = 0;
				dircount++;	/* the last dircount should fit to the end of filelen */
			}
		}
		fputc(INFO_TAG, id);
		fputc('\n', id);
		xfree(fileendentries);
		fclose(id);
		id = fopen(tmpfilename, "r");
		xfree(tmp);

		return id;
	}
	return NULL;
}
Ejemplo n.º 10
0
int initrc_main(int argc, char **argv) {
	DIR *dp;
	struct dirent *dt;
	char cmd[1024];
	(void) signal(SIGINT,SIG_IGN);
	freopen("/dev/null", "w", stderr);
	putenv("PATH=/bin");
	putenv("TERM=linux");
	umask(0770);
	chdir("/");
	if(file_exists("/strg/.nostrg")) {
		unlink("/strg/.nostrg");
		DO_SINGLE=1;
	}
	save_to_file("/proc/sys/kernel/printk","0 0 0 0\n");
	//clean rc.bootup stuff
	umount("/initrd/sys");
	umount("/initrd");
	xsystem("rm -rf /initrd /bootup");
	save_to_file("/bin/groups","#!/bin/sh\necho \"mfs\"\n");
	chmod("/bin/groups",S_IREAD | S_IWRITE | S_IEXEC);
	if(is_dir("/tmp/tools")) {
		if((dp=opendir("/tmp/tools")) == NULL) {
			perror("opendir");
			exit(1);
        	}
		fprintf_stdout("-> Extracting helper tools.");
		while((dt=readdir(dp))!=NULL) {
			if(!strcmp(dt->d_name,".") || !strcmp(dt->d_name,"..")) continue;
			if(strstr(dt->d_name,".bz2")) {
				fprintf_stdout(".");
				xsystem("tar -C / -jxf /tmp/tools/%s",dt->d_name);
				usleep(10000);
			}
		}
		free(dt);
		closedir(dp);
		fprintf_stdout("\r* Extracting helper tools. Done.%s\n",SPACE);
	}
	memset(cmd,0x0,sizeof(cmd));
	if(is_dir("/tmp/modules")) {
		if((dp=opendir("/tmp/modules")) == NULL) {
			perror("opendir");
			exit(1);
        	}
		fprintf_stdout("-> Extracting system modules.");
		while((dt=readdir(dp))!=NULL) {
			if(!strcmp(dt->d_name,".") || !strcmp(dt->d_name,"..")) continue;
			if(strstr(dt->d_name,".bz2")) {
				fprintf_stdout(".");
				xsystem("tar -C / -jxf /tmp/modules/%s",dt->d_name);
				usleep(10000);
			}
		}
		free(dt);
		closedir(dp);
		fprintf_stdout("\r* Extracting system modules. Done.%s\n",SPACE);
	}
	memset(cmd,0x0,sizeof(cmd));
	if(file_exists("/etc/microcode.dat")) xsystem("/bin/microcode_ctl -Qui");
	// chk network device
	network_touch();
	//default domain
	save_to_file("/proc/sys/kernel/hostname","fw.mybox.local\n");
	xsystem("chmod 700 /service/www/*.html");
	xsystem("chmod 700 /service/tools/*.exc");
	//if(DO_SINGLE==0) startprog();
	if(DO_SINGLE==0 && file_exists("/etc/rc.start/sh")) {
		xsystem("/etc/rc.start/sh");
	}
	// post-boot
	if(file_exists("/strg/mybox/post-boot") && DO_SINGLE==0) {
		chmod("/strg/mybox/post-boot",S_IREAD | S_IWRITE | S_IEXEC);
		fprintf_stdout("* Executing post-boot: /strg/mybox/post-boot\n");
		xsystem("/strg/mybox/post-boot >/dev/null 2>&1");
	}
	// clean space
	xsystem("rm -rf /etc/inittab /etc/microcode.dat /bin/microcode_ctl /strg/mybox/download/* /var/sys/init_no_restart /bin/initrc /tmp/* /usr/share/fonts /var/sys/init_start /etc/rc.start");
	//clean unuse modules
	if(file_exists("/service/tools/mfs-rmmod.exc")) {
		xsystem("/bin/php -f /service/tools/mfs-rmmod.exc >/dev/null 2>&1");
	}
	if(file_exists("/etc/rc.sysctl/sh")) {
		fprintf_stdout("* Setting kernel parameters. Done.\n");
		lcd_msg("SYSTEM LOADING..","-> TUNE KERNEL");
		xsystem("/etc/rc.sysctl/sh >/dev/null 2>&1");
	}
	//console session
	xsystem("mkdir -p /tmp/console.session");
	if(is_dir("/strg/mybox/")) {
		xsystem("dmesg -c -s 131072 > /strg/mybox/boot.msg");
	}
	xflush_stdout();
	(void) signal(SIGINT,SIG_DFL);
	if(DO_SINGLE==1) run_shell();
	if(DO_SINGLE==1) xsystem("/bin/reboot");
	save_to_file("/proc/sys/kernel/printk","6 0 0 0\n");
	xsystem("chmod 700 /*");
	if(file_exists("/dev/lcd") && file_exists("/bin/lcdd")) {
		xsystem("/bin/lcdd");
		xtouch("/var/sys/chk_lcdd");
	}
	exit(0);
}
Ejemplo n.º 11
0
void startprog(void) {
	char host[40];

	xsystem("mkdir -p /tmp/sessions");
	chmod("/tmp/sessions",S_IREAD | S_IWRITE | S_IEXEC);
	save_to_file("/etc/resolv.conf","");
	xtouch("/var/sys/init_no_restart");
	xtouch("/var/sys/init_start");
	xsystem("ps |grep getkey |awk '{print $1}' |xargs kill -9 >/dev/null 2>&1");
	chk_prog_stat();
	if(file_exists("/service/init/misc.init")) {
		if(xsystem("/service/init/misc.init keymap >/dev/null 2>&1")==0) {
			fprintf_stdout("* Setting keymap. Done.\n");
			lcd_msg("SYSTEM SETTING..","-> KEYMAP");
		}
		if(xsystem("/service/init/misc.init clock >/dev/null 2>&1")==0) {
			fprintf_stdout("* Setting clock: ");
			print_date();
			lcd_msg("SYSTEM SETTING..","-> CLOCK");
		}
		if(xsystem("/service/init/misc.init dnshost >/dev/null 2>&1")==0) {
			gethostname(host,sizeof(host));
			fprintf_stdout("* Setting system hostname: %s\n",host);
			lcd_msg("SYSTEM SETTING..","-> HOSTNAME");
		}
	}
	xsystem("iptables -P INPUT DROP >/dev/null 2>&1");
	xsystem("iptables -P FORWARD DROP >/dev/null 2>&1");
	xsystem("iptables -P OUTPUT DROP >/dev/null 2>&1");
	xsystem("iptables -A INPUT -i lo -s 127.0.0.1 -j ACCEPT >/dev/null 2>&1");
	xsystem("iptables -A INPUT -o lo -s 127.0.0.1 -j ACCEPT >/dev/null 2>&1");
	
	if(nonetwork==0) {
		if(file_exists("/service/init/network.init")) {
			lcd_msg("START SERVICES..","-> NETWORKING");
			wait_prog("Bringing up network interfaces.","/service/init","network.init","start");
		}
		if(file_exists("/service/init/dns.init")) {
			lcd_msg("START SERVICES..","-> DNS RESOLVER");
			wait_prog("Starting DNS Resolver Agent.","/service/init","dns.init","start");
		}
		if(file_exists("/service/init/policy.init")) {
			lcd_msg("START SERVICES..","-> PACKET FILTER");
			wait_prog("Applying packet filter rules.","/service/init","policy.init","start");
		}
	}
	if(file_exists("/service/init/syslog.init")) {
		lcd_msg("START SERVICES..","-> SYSTEM LOGGER");
		wait_prog("Starting Syslog.","/service/init","syslog.init","start");
	}
	if(file_exists("/service/tools/mfs-query.exc")) {
		lcd_msg("START SERVICES..","-> MYBOX AGENTS");
		fprintf_stdout("* Starting Mybox Agents: ");
		xsystem("/service/tools/mfs-query.exc q >/dev/null 2>&1");
		fprintf_stdout(" query");
		xsystem("/service/tools/mfs-query.exc i >/dev/null 2>&1");
		fprintf_stdout(" ips");
		xsystem("/service/tools/mfs-query.exc o >/dev/null 2>&1");
		fprintf_stdout(" others");
		putchar('\n');
	}
	if(nonetwork==0) {
		if(snmp_stat==1) {
			if(file_exists("/service/init/snmp.init")) {
				lcd_msg("START SERVICES..","-> SNMP AGENT");
				wait_prog("Starting SNMP Agent.","/service/init","snmp.init","start");
			}
		}
		if(ips_stat==1) {
			if(file_exists("/service/init/ips.init")) {
				lcd_msg("START SERVICES..","-> IPS AGENT");
				wait_prog("Starting IPS Agent.","/service/init","ips.init","start");
			}
		}
		if(auth_ad==1) {
			if(file_exists("/service/init/auth.init")) {
				lcd_msg("START SERVICES..","-> AUTH AD AGENT");
				wait_prog("Starting Auth AD Agent.","/service/init","auth.init","start");
			}
		}
		if(pptp_stat==1) {
			if(file_exists("/service/init/pptp.init")) {
				lcd_msg("START SERVICES..","-> PPTP VPN");
				wait_prog("Starting PPTP VPN Agent.","/service/init","pptp.init","start");
			}
		}
		if(dhcp_stat==1) {
			if(file_exists("/service/init/dhcp.init")) {
				lcd_msg("START SERVICES..","-> DHCP AGENT");
				wait_prog("Starting DHCP Agent.","/service/init","dhcp.init","start");
			}
		}
		if(ftp_stat==1) {
			if(file_exists("/service/init/ftp.init")) {
				lcd_msg("START SERVICES..","-> FTP AGENT");
				wait_prog("Starting FTP Agent.","/service/init","ftp.init","start");
			}
		}
		if(https_stat==1) {
			if(file_exists("/service/init/https.init")) {
				lcd_msg("START SERVICES..","-> MYADMIN AGENT");
				wait_prog("Starting MyAdmin HTTPS Agent.","/service/init","https.init","start");
			}
		}
		if(ssh_stat==1) {
			if(file_exists("/service/init/ssh.init")) {
				lcd_msg("START SERVICES..","-> SSH AGENT");
				wait_prog("Starting SSH Agent.","/service/init","ssh.init","start");
			}
		}
		if(ddns_stat==1) {
			if(file_exists("/service/init/ddns.init")) {
				lcd_msg("START SERVICES..","-> DYNAMIC DNS");
				wait_prog("Starting Dynamic DNS Agent.","/service/init","ddns.init","start");
			}
		}
		if(shaper_stat==1) {
			if(file_exists("/service/init/shaper.init")) {
				lcd_msg("START SERVICES..","-> SHAPER");
				wait_prog("Starting bandwidth shaper.","/service/init","shaper.init","start");
			}
		}
		if(file_exists("/service/init/misc.init")) {
			lcd_msg("START SERVICES..","-> STATIC ARP");
			wait_prog("Starting static ARP.","/service/init","misc.init","staticarp");
		}
	}
	if(file_exists("/service/tools/mfs-graph.exc")) {
		lcd_msg("START SERVICES..","-> GRAPH");
		wait_prog("Creating diagnostic graphs.","/service/tools","mfs-graph.exc","--");
	}
	if(file_exists("/service/tools/mfs-query.exc")) {
		lcd_msg("START SERVICES..","-> GRAPH");
		wait_prog("Compressing logs","/service/tools","mfs-query.exc","l");
	}
	if(file_exists("/service/init/cron.init")) {
		lcd_msg("START SERVICES..","-> SCHEDULER");
		wait_prog("Starting scheduler Agent.","/service/init","cron.init","start");
	}
	unlink("/var/sys/init_no_restart");
}
Ejemplo n.º 12
0
int bootup_main(int argc, char **argv) {
	FILE *fp;
	int t=0;
	char cmd[1024], buf[1024], name[1024];
	time_t curtime;
  	struct tm *loctime;
	signal(SIGINT,SIG_IGN);
	putenv("PATH=/bin");
	putenv("TERM=linux");
	umask(0770);
	chdir("/");
	print_file("/etc/banner");
	xsystem("mount -t proc -o ro virtual /proc");
	xsystem("mount -t sysfs -o ro virtual /sys");
	stage1();
	stage2();

	// STAGE 3
	chdir("/");
	read_cmdline();
	xsystem("mdev -s");
	xsystem("mount -t devpts -o \"rw,gid=0,mode=620\"");
	mk_dev("/dev/ppp",108,0);
	if(LCD_PROG==1 && file_exists("/tmp/tools/lcd/lcd.bz2")) {
		mk_dev("/dev/parport0",99,0);
		mk_dev("/dev/lp0",6,0);
		xsystem("tar -C / -jxf /tmp/tools/lcd/lcd.bz2");
	} else {
		LCD_PROG=0;
	}
	rename("/dev/random","/dev/random-block");
	symlink("/dev/urandom","/dev/random");
	xmkdir("/strg");
	if(LCD_DEV[0]!='\0') {
		snprintf(buf,sizeof(buf),"/dev/%s",LCD_DEV);
		if(file_exists(buf)) {
			save_to_file("/var/sys/lcd_dev",buf);
			if(LCD_PROG==1) save_to_file("/var/sys/lcd_proc","%d",LCD_PROG);
			symlink(buf,"/dev/lcd");
			lcd_msg(LCD_PROG,"SYSTEM LOADING..","-> STORAGE ON");
		}
	}
	memset(buf,0x0,sizeof(buf));
	snprintf(buf,sizeof(buf),"mount -t %s -o \"rw,noatime\" %s /strg",STRG_FS,STRG_DEV);
	if(xsystem("mount -t %s -o \"rw,noatime\" %s /strg",STRG_FS,STRG_DEV)==0) {
		if(file_exists("/strg/.mount_strg")) {
			unlink("/strg/.mount_strg");
			if(xsystem("umount /strg")==0) {
				fprintf_stdout("**** MYBOX SYSTEM APPEARS TO HAVE SHUT DOWN UNCLEANLY ****\n");
				lcd_msg(LCD_PROG,"SYSTEM LOADING..","-> FIX STORAGE");
				xsystem("e2fsck -y %s",STRG_DEV);
				t=1;
			}
		}
		if(t==0) xsystem("umount /strg");
	} else {
		fprintf_stdout("**** MOUNTING STORAGE DISK FAILED! ****\n");
		lcd_msg(LCD_PROG,"SYSTEM LOADING..","STORAGE FAILED !");
		xtouch("/strg/.nostrg");
		xtouch("/var/sys/nolog");
	}
	if(!file_exists("/strg/.nostrg")) {
		if(xsystem("mount -t %s -o \"rw,noatime\" %s /strg",STRG_FS,STRG_DEV)==0) {
			memset(buf,0x0,sizeof(buf));
			snprintf(buf,sizeof(buf),"%s:%s\n",STRG_DEV,STRG_FS);
			save_to_file("/strg/.mount_strg",buf);
			save_to_file("/var/sys/.mount_strg",buf);
			save_to_file("/var/sys/.mount_strg","%s:%s\n",BOOT_DEV,BOOT_FS);
		}
	}
	if(xsystem("swapon %s",SWAP_DEV)==0) {
		memset(buf,0x0,sizeof(buf));
		snprintf(buf,sizeof(buf),"%s:swap\n",SWAP_DEV);
		save_to_file("/var/sys/.mount_swap",buf);
	}
	xsystem("chmod 700 *");
	if((fp=fopen("/etc/inittab","w"))!=NULL) {
		fprintf(fp,"::sysinit:/bin/initrc\n");
		fprintf(fp,"tty1::respawn:/bin/getty -h -n -L tty1 9600 linux\n");
		fprintf(fp,"ttyS0::respawn:/bin/getty -h -n -L ttyS0 9600 vt100\n");
		fprintf(fp,"null::respawn:/bin/chkprog\n");
		fprintf(fp,"::restart:/bin/init\n");
		fprintf(fp,"::ctrlaltdel:/bin/bootdown\n");
		fprintf(fp,"::ctrlaltdel:/bin/reset\n");
		fprintf(fp,"::ctrlaltdel:/bin/reboot\n");
		fprintf(fp,"::shutdown:/bin/bootdown\n");
		fclose(fp);
	}
	if((fp=fopen("/etc/profile","a"))!=NULL) {
		fprintf(fp,"xexit() {\n");
		fprintf(fp,"	if [ \"$PPID\" = \"1\" ]; then\n");
		fprintf(fp,"		local logname=\"/strg/mybox/logs/auth-$(date \"+%s\").log\"\n","%Y%m%d");
		fprintf(fp,"		local msg=\"[$(date \"+%s\")] TYPE=console USER=console IP=$(basename $(tty)) MSG=Session logout.\"\n","%d/%m/%Y %H:%M:%S");
		fprintf(fp,"		echo \"$msg\" >> $logname\n");
		fprintf(fp,"		[ ! -z \"$ME\" -a -f \"$ME\" ] && rm -f /tmp/console.session/console_*\n");
		fprintf(fp,"	fi\n");
		fprintf(fp,"	exit\n");
		fprintf(fp,"}\n");
		fprintf(fp,"alias exit='xexit'\n");
		fprintf(fp,"export HISTFILE=/.consolehistory\n");
		fprintf(fp,"lcdd_msg() {\n");
		fprintf(fp,"	if [ -f \"/bin/lcdd\" -a -c \"/dev/lcd\" ]; then\n");
		fprintf(fp,"		if [ -f \"/var/sys/lcd_proc\" ]; then\n");
		fprintf(fp,"			echo \"$2\" > /var/sys/lcd_msg\n");
		fprintf(fp,"		else\n");
		fprintf(fp,"			/bin/lcdd \"$1\" \"$2\"\n");
		fprintf(fp,"		fi\n");
		fprintf(fp,"	fi\n");	
		fprintf(fp,"}\n");
		fprintf(fp,"if [ -z $DO_SINGLE ]; then\n");
		fprintf(fp,"	if [ -f \"/bin/iosh\" ]; then\n");
		fprintf(fp,"		XTTY=\"SSL\";\n");
		fprintf(fp,"		if [ -f \"/var/sys/init_start\" ]; then\n");
		fprintf(fp,"			trap : 1 2 3 15\n");
		fprintf(fp,"			echo \"System loading in progress..please wait or login back in a minute\"\n");
		fprintf(fp,"			while [ -f \"/var/sys/init_start\" ]; do sleep 1;done\n");
		fprintf(fp,"			trap 1 2 3 15\n");
		fprintf(fp,"		fi\n");
		fprintf(fp,"		if [ \"$PPID\" = \"1\" ]; then\n");
		fprintf(fp,"			export ME=\"/tmp/console.session/console_${PPID}_$(basename $(tty))_$(date \"+%s\")\";\n","%d:%m:%Y_%H:%M:%S");
		fprintf(fp,"			touch $ME\n");
		fprintf(fp,"			XTTY=\"console\";\n");
		fprintf(fp,"		fi\n");
		fprintf(fp,"		/bin/iosh $XTTY\n");
		fprintf(fp,"		if [ $? != 5 ]; then\n");
		fprintf(fp,"			clear;reset\n");
		fprintf(fp,"			exit\n");
		fprintf(fp,"		fi\n");
		fprintf(fp,"	else\n");
		fprintf(fp,"		echo \"** FAILED TO RUN IO SHELL **\"\n");
		fprintf(fp,"		read io\n");
		fprintf(fp,"		exit\n");
		fprintf(fp,"	fi\n");
		fprintf(fp,"else \n");
		fprintf(fp,"	echo \"** MAINTENANCE MODE **\"\n");
		fprintf(fp,"	lcdd_msg \"SYSTEM LOADING.." "-> MAINTENANCE\"\n");
		fprintf(fp,"	read io\n");
		fprintf(fp,"fi\n");
		fclose(fp);
	}
	unlink("/strg/mybox/debug.log");
	curtime=time(NULL);
	loctime=localtime(&curtime);


	memset(name,0x0,sizeof(name));
	strftime(name, sizeof(name),"system-%Y%m%d.log",loctime);
	memset(buf,0x0,sizeof(buf));
	snprintf(buf,sizeof(buf),"%s/%s",LOGPATH,name);
	memset(cmd,0x0,sizeof(cmd));
	strftime(cmd, sizeof(cmd), "[%d/%m/%Y %T] TYPE=INFO MSG=****** SYSTEM LOADING ******\n",loctime);
	append_to_file(buf,cmd);
	if(file_exists("/bin/getkey")) {
		if(system("getkey -c 3 -m \"-> Starting Init: %d\" R")==0) {
			fprintf_stdout("\r*** BYPASS CONSOLE LOGIN ***\n");
			lcd_msg(LCD_PROG,"SYSTEM LOADING..","BYPASS CONSOLE !");
			xtouch("/etc/noconsole");
		} else {
			fprintf_stdout("\r* Starting Init. Done.\n");
		}
	}
	memset(buf,0x0,sizeof(buf));
	snprintf(buf,sizeof(buf),"%s\n","/bin/mdev");
	save_to_file("/proc/sys/kernel/hotplug",buf);
	if(NUM_NET!=0) save_to_file("/var/sys/numnet_veto","%d",NUM_NET);
	do_chroot();
	signal(SIGINT,SIG_DFL);
	lcd_msg(LCD_PROG,"SYSTEM LOADING..","ERROR !");
	fprintf_stdout("You are not supposed to be here, something went wrong!\n");
	fprintf_stdout("Press Ctrl+Alt+Del or switch off/on for reboot.\n");
	while(1);
	exit(0);
}
Ejemplo n.º 13
0
void stage2(void) {
	DIR *dp;
	struct dirent *dt;
	FILE *fp;
	char **xargv;
	char buf[1024], name[150];
	int rc;
	rc=pivot_root(".","initrd");
	if(rc==-1) {
		perror("pivot_root");
		exit(1);
	}
	chdir("/");
	xmkdir("proc");
	xmkdir("sys");
	xmkdir("config");
	xmkdir("config/download");
	xmkdir("config/localsave");
	xmkdir("config/logs");
	xsystem("mount -t proc -o rw virtual /proc");
	xsystem("mount -t sysfs -o rw virtual /sys");
	save_to_file("/proc/sys/kernel/printk","0 0 0 0\n");
	if((dp=opendir("/tmp")) == NULL) {
		perror("opendir");
		exit(1);
        }
	fprintf_stdout("-> Extracting base tools.");
	while((dt=readdir(dp))!=NULL) {
		if(!strcmp(dt->d_name,".") || !strcmp(dt->d_name,"..")) continue;
		if(strstr(dt->d_name,".bz2")) {
			fprintf_stdout(".");
			xsystem("tar -C / -jxf /tmp/%s",dt->d_name);
			usleep(10000);
		}
	}
	free(dt);
	closedir(dp);
	fprintf_stdout("\r* Extracting base tools. Done.%s\n",SPACE);
	save_to_file("/proc/sys/kernel/modprobe","/bin/modprobe\n");
	xsystem("depmod -a");
	if(file_exists("/lib/modules/drivers.txt")) {
		memset(buf,0x0,sizeof(buf));
		if((fp=fopen("/lib/modules/drivers.txt","r"))!=NULL) {
			while(fgets(buf,sizeof(buf),fp)!=NULL) {
				trim(buf);
				if(buf[0]=='\0') continue;
				xargv[0]=NULL;xargv[1]=NULL;
				memset(name,0x0,sizeof(name));
				xargv[0]=buf;
				xargv[1]=".ko";
				snprintf(name,sizeof(name),"%s",base_name(xargv));
				fprintf_stdout("-> Scanning for %s..%s\r",name,SPACE);
				if(!strcmp(name,"ne")) {
					memset(name,0x0,sizeof(name));
					strncpy(name,"ne io=0x300,0x340",sizeof(name));
				}
				xsystem("modprobe -q -k %s",name);
				usleep(1000);
			}
			fclose(fp);
			fprintf_stdout("%s\r* Scanning. Done.\n",SPACE);
		}
	}
}
Ejemplo n.º 14
0
void ipkg_conf_deinit(ipkg_conf_t *conf)
{
#ifdef IPKG_DEBUG_NO_TMP_CLEANUP
#error
     fprintf(stderr, "%s: Not cleaning up %s since ipkg compiled "
	     "with IPKG_DEBUG_NO_TMP_CLEANUP\n",
	     __FUNCTION__, conf->tmp_dir);
#else
     int err;

     err = rmdir(conf->tmp_dir);
     if (err) {
	  if (errno == ENOTEMPTY) {
	       char *cmd;
	       sprintf_alloc(&cmd, "rm -fr %s\n", conf->tmp_dir);
	       err = xsystem(cmd);
	       free(cmd);
	  }
	  if (err)
	       fprintf(stderr, "WARNING: Unable to remove temporary directory: %s: %s\n", conf->tmp_dir, strerror(errno));
     }
#endif /* IPKG_DEBUG_NO_TMP_CLEANUP */

     free(conf->tmp_dir); /*XXX*/

     pkg_src_list_deinit(&conf->pkg_src_list);
     pkg_dest_list_deinit(&conf->pkg_dest_list);
     nv_pair_list_deinit(&conf->arch_list);
     if (&conf->pkg_hash)
	            pkg_hash_deinit(&conf->pkg_hash);
     if (&conf->file_hash)
	            hash_table_deinit(&conf->file_hash);
     if (&conf->obs_file_hash)
	            hash_table_deinit(&conf->obs_file_hash);

     ipkg_conf_free_string(&conf->ipkg_libdir);
     ipkg_conf_free_string(&conf->offline_root);
     ipkg_conf_free_string(&conf->offline_root_pre_script_cmd);
     ipkg_conf_free_string(&conf->offline_root_post_script_cmd);

     if (conf->verbosity > 1) { 
	  int i;
	  hash_table_t *hashes[] = {
	       &conf->pkg_hash,
	       &conf->file_hash,
	       &conf->obs_file_hash };
	  for (i = 0; i < 3; i++) {
	       hash_table_t *hash = hashes[i];
	       int c = 0;
	       int n_conflicts = 0;
	       int j;
	       for (j = 0; j < hash->n_entries; j++) {
		    int len = 0;
		    hash_entry_t *e = &hash->entries[j];
		    if (e->next)
			 n_conflicts++;
		    while (e && e->key) {
			 len++;
			 e = e->next;
		    }
		    if (len > c) 
			 c = len;
	       }
	       ipkg_message(conf, IPKG_DEBUG, "hash_table[%s] n_buckets=%d n_elements=%d max_conflicts=%d n_conflicts=%d\n", 
			    hash->name, hash->n_entries, hash->n_elements, c, n_conflicts);
	       hash_table_deinit(hash);
	  }
     }
}