RTlocate_Options parse_rt_options (Pf *pf)
{
	RTlocate_Options o;
	char failure_dirs[STRSZ] ;
	o.work_db=pfget_string(pf,"RT_working_db");
	if(o.work_db  == NULL) o.work_db = strdup("orbgenloc");
	o.logdir=pfget_string(pf,"RT_logfile_directory");
	if(o.logdir == NULL) {
	    o.logdir = strdup(".");
	} else { 
	    makedir ( o.logdir ) ; 
	}
	o.failure_sdir = pfget_string(pf,"RT_failure_subdir");
	strcpy ( failure_dirs, o.logdir ) ; 
	strcat ( failure_dirs, "/" ) ; 
	strcat ( failure_dirs, o.failure_sdir ) ; 
	makedir ( failure_dirs ) ; 
	if(o.failure_sdir == NULL) o.failure_sdir = strdup("failure");
	o.minimum_distance = pfget_double(pf,"RT_minimum_distance");
	o.maximum_distance = pfget_double(pf,"RT_maximum_distance");

	o.db_record_skip_timeout = pfget_int(pf,"RT_db_record_skip_limit");

	return(o);
}
Exemple #2
0
int
fsinit1(time_t utime, mode_t mfsmode, uid_t mfsuid, gid_t mfsgid)
{
	union dinode node;

	/*
	 * Initialize the node
	 */
	memset(&node, 0, sizeof(node));
	node.dp1.di_atime = utime;
	node.dp1.di_mtime = utime;
	node.dp1.di_ctime = utime;

	/*
	 * Create the root directory.
	 */
	if (mfs) {
		node.dp1.di_mode = IFDIR | mfsmode;
		node.dp1.di_uid = mfsuid;
		node.dp1.di_gid = mfsgid;
	} else {
		node.dp1.di_mode = IFDIR | UMASK;
		node.dp1.di_uid = geteuid();
		node.dp1.di_gid = getegid();
	}
	node.dp1.di_nlink = PREDEFDIR;
	if (Oflag == 0)
		node.dp1.di_size = makedir((struct direct *)oroot_dir,
		    PREDEFDIR);
	else
		node.dp1.di_size = makedir(root_dir, PREDEFDIR);
	node.dp1.di_db[0] = alloc(sblock.fs_fsize, node.dp1.di_mode);
	if (node.dp1.di_db[0] == 0)
		return (1);

	node.dp1.di_blocks = btodb(fragroundup(&sblock, node.dp1.di_size));

	wtfs(fsbtodb(&sblock, node.dp1.di_db[0]), sblock.fs_fsize, iobuf);
	iput(&node, ROOTINO);

#ifdef notyet
	/*
	* Create the .snap directory.
	*/
	node.dp1.di_mode |= 020;
	node.dp1.di_gid = gid;
	node.dp1.di_nlink = SNAPLINKCNT;
	node.dp1.di_size = makedir(snap_dir, SNAPLINKCNT);

	node.dp1.di_db[0] = alloc(sblock.fs_fsize, node.dp1.di_mode);
	if (node.dp1.di_db[0] == 0)
		return (1);

	node.dp1.di_blocks = btodb(fragroundup(&sblock, node.dp1.di_size));

	wtfs(fsbtodb(&sblock, node.dp1.di_db[0]), sblock.fs_fsize, iobuf);
	iput(&node, ROOTINO + 1);
#endif
	return (0);
}
Exemple #3
0
/**
**  Create directories containing user settings and data.
**
**  More specifically: logs, saved games, preferences
*/
void CreateUserDirectories(void)
{
	std::string directory;
	UserDirectory = "";

	std::string s;
#ifdef USE_WIN32
	s = getenv("APPDATA");
#else
	s = getenv("HOME");
#endif
	if (!s.empty()) {
		UserDirectory = s + "/";
	}
	
	UserDirectory += STRATAGUS_HOME_PATH;
	makedir(UserDirectory.c_str(), 0777);
	
	// Create specific subdirectories
	directory = UserDirectory + "logs/";
	makedir(directory.c_str(), 0777);
	directory = UserDirectory + "save/";
	makedir(directory.c_str(), 0777);
	directory = UserDirectory + "patches/";
	makedir(directory.c_str(), 0777);
}
Exemple #4
0
FILE *openConfig(const char *configName, const char *flags) {
  FILE *result = NULL;
  char path[PATH_MAX];
  int vars_len = sizeof(ENV_VARS) / sizeof(ENV_VARS[0]);

  path[0] = 0;
  for (int i = 0; i < vars_len && result == NULL; i++) {
    const char *home = getenv(ENV_VARS[i]);
    if (home && access(home, R_OK) == 0) {
      strcpy(path, home);
      if (i == 1) {
        // unix path
        strcat(path, "/.config");
        makedir(path);
      }
      strcat(path, "/");
      strcat(path, configName);
      makedir(path);

      strcat(path, "/settings.txt");
      result = fopen(path, flags);
    }
  }
  return result;
}
/**************************************************************************
 * method CLocalProperties::LoadProperties
 *
 * written by moonknit
 *
 * @history
 * created 2005-12-??
 * modified 2006-02-22 :: 사용자 폴더 관리 변경 by moonknit
 *
 * @Description
 * 설정값을 레지스트리에서 읽어온다.
 * 설정 값은 CGnuDoc 과 CLocalProperties 두 곳에서 관리된다.
 *
 * @Parameters
 * (in CString) userid - 로그인 한 사용자의 id
 **************************************************************************/
void CLocalProperties::LoadProperties()
{
	CString tmp;

	// Read Use Inform Window
	tmp = ReadRegData(_T(""), REG_STR_USEINFORMWND);
	if(tmp == _T("1")) bUseInformWnd = TRUE;
	else bUseInformWnd = FALSE;

	// Read PPP
	tmp = ReadRegData(_T(""), REG_STR_PPP);
	if(tmp != _T(""))
	{
		ppp = _ttoi((LPCTSTR) tmp);
	}

	if(ppp < 2 || ppp > 10) ppp = 2;

	// Read Download Path
	DownloadPath = ReadRegData(_T(""), REG_STR_DOWNLOADPATH);
	if(DownloadPath == _T(""))
	{
		tmp.Format(_T("%s%s"), RunPath, DEFAULT_DOWNLOADPATH);
		SetDownloadPath(tmp);
	}

	if(UserPathParent == _T(""))
	{
		if(UserPathTemp == _T(""))
		{
			// 최초 사용자의 경우 실행경로로 부터 사용자 폴더를 설정한다.
			UserPathParent.Format(_T("%s%s"), RunPath, DEFAULT_USERPATH);
//			UserPath.Format(_T("%s%s\\"), UserPathParent, sUserID);
		}
		else
		{
			UserPathParent = UserPathTemp;
		}
	}

	if(UserPathParent != UserPathTemp)
		WriteRegData(_T(""), REG_STR_USERPATH, UserPathParent);				// 최종 사용자의 폴더 기록

	StyleFile = ReadRegData(_T(""), REG_STR_STYLE);

//	SaveDataPath = UserPathParent + DEFAULT_SAVEPATH;;
	TempDataPath = UserPathParent + DEFAULT_TEMPPATH;
	PostDataPath = UserPathParent + DEFAULT_POSTPATH;

//	makedir(SaveDataPath);
	makedir(TempDataPath);
	makedir(PostDataPath);

	bUserInit = TRUE;
}
int main(int ac,char *av[])
{
  int i=0;
  int j=0;
  int k=0;
  int l=0;
  char dir1[MAXN];
  char dir2[MAXN];
  char dir3[MAXN];
  char filename[MAXN];
  time_t t;
  int maxfiles=0xFFFFFF;
  int createfiles=0;

  if (ac > 1) {
    sscanf(av[1],"%x",&maxfiles);
    if (maxfiles==0) {
      printf("maxfile argument error (0 value)\n");
      exit(1);
    }
  }
  time(&t);
  srandom((unsigned int)getpid()^(((unsigned int)t<<16)| (unsigned int)t>>16));
  printf("Create files\n");
  for (i = 0 ; i < 0xFF ; i++) {
    sprintf(dir1,"%2.2x",i);
    makedir(dir1);
    changedir(dir1);
    for (j = 0 ; j < 0xFF ; j++) {
      sprintf(dir2,"%2.2x",j);
      makedir(dir2);
      changedir(dir2);
      for (k = 0 ; k < 0xFF ; k++) {
	sprintf(dir3,"%2.2x",k);
	makedir(dir3);
	changedir(dir3);
	for (l = 0 ; l < 0xFF ; l++) {
	  sprintf(filename,"%s%s%s%2.2x",dir1,dir2,dir3,l);
	  create_file(filename);
	  if (maxfiles < createfiles++) {
	    goto end;
	  }
	}
	changedir("../");
      }
      changedir("../");
    }
    changedir("../");
  }
end:
  fprintf(stderr,"\nTotal create files: %d\n",filecount);
  printf("Done\n");
        return 0;
}
Exemple #7
0
static void setup(void *UNUSED(arg))
{
#ifdef HAVE_DBUS
	_d("Starting D-Bus ...");
	makedir("/var/run/dbus", 0755);
	makedir("/var/lock/subsys/messagebus", 0755);
	run("dbus-uuidgen --ensure");
	erase("/var/run/dbus/pid");
	run_interactive("dbus-daemon --system", "Starting D-Bus");
#endif
}
Exemple #8
0
static void setup(void *UNUSED(arg))
{
	umask(0);

	_d("Starting D-Bus ...");
	makedir("/var/run/dbus", 0755);
	makedir("/var/lock/subsys", 0755);
	makedir("/var/lock/subsys/messagebus", 0755);
	run("dbus-uuidgen --ensure");
	erase("/var/run/dbus/pid");
	run_interactive("dbus-daemon --system", "Starting D-Bus");

	umask(022);
}
Exemple #9
0
static void GenerateStubs (Interface parse)
{
  char filename[1000];
  FILE *file;

  if (! makedir (OutputDirectory))
    {
      fprintf (stderr, "Couldn't create output directory %s.\n", OutputDirectory);
      exit (1);
    }

  if (GenerateClasses)
    {
      GenerateHeaders (parse);
      GenerateCode (parse);
    }

  if (GenerateImakefile)
    {
      sprintf (filename, "%s/Imakefile", OutputDirectory);
      possibleUnlink (filename);
      if ((file = fopen (filename, "w")) == NULL)
	{
	  fprintf (stderr, "Couldn't open output file %s.\n", filename);
	  exit (1);
	}
      printf ("ILU-style Imakefile to %s...\n", filename);
      generate_imakefile (parse, file);
      fclose (file);
    }
}
Exemple #10
0
int main()
{
	printf("Running CS470 Microshell...\nReady!\nType a command or type 'help' for assistance.\n");
	
	char inp[100];
	char *cmd[3];
	char *cmdToken;

	int lastExit = 0;
	
	while (getpid() > 0)
	{
		printf(ANSI_COLOR_MAGENTA "cwushell"  ANSI_COLOR_RESET);
		printf(":");
		printf(ANSI_COLOR_BLUE    "~ $ "  ANSI_COLOR_RESET);
		fgets(inp, 99, stdin);
		char *pos, *arg;
		if ((pos=strchr(inp, '\n')) != NULL) *pos = '\0';
		
		const char space[2] = " ";
		cmdToken = strtok(inp, space);

		int i = 0;
		while((cmdToken != NULL) && (i < 3))
		{
			cmd[i++] = cmdToken;
			cmdToken = strtok(NULL, space);
		}
        
        switch (hash(cmd[0]))
        {
            case 193416251: // cmp
                if (i > 2)
                {
                    if (vfork() == 0) lastExit = cmp(cmd[1],cmd[2]);
                }
                else
                {
                    printf("Need 2 arguments for the cmp command to execute.\n");
                }                
                break;
            case 2087435909: // exit
                return (atoi(cmd[1]) != 0) ? atoi(cmd[1]) : lastExit;
            case 2087804052: // help
                if (vfork() == 0) lastExit = help();
                break;
            case 5861018: // ls
                if ( vfork() == 0 )
                {
                    system("ls");
                    exit(getpid());
                }
                break;
            case 174437788: // mkdir
                arg = ((i > 1) ? cmd[1] : "DEFAULT");
                if (vfork() == 0) lastExit = makedir(arg);
                break;
        }
    }
}
Exemple #11
0
static int load_module(void) {
	char path[256], front[1024];

	load_config();
	if (front_ip == NULL || front_port == NULL || userid == NULL) {
		xcb_log(XCB_LOG_ERROR, "front_ip, front_port, userid can't be empty");
		return MODULE_LOAD_FAILURE;
	}
	mdspi = femas_mdspi_create();
	femas_mdspi_on_front_connected(mdspi, on_front_connected);
	femas_mdspi_on_front_disconnected(mdspi, on_front_disconnected);
	femas_mdspi_on_user_login(mdspi, on_user_login);
	femas_mdspi_on_error(mdspi, on_error);
	femas_mdspi_on_subscribe_market_data(mdspi, on_subscribe_market_data);
	femas_mdspi_on_deep_market_data(mdspi, on_deep_market_data);
	/* FIXME */
	snprintf(path, sizeof path, "/var/log/xcb/%s/", userid);
	makedir(path, 0777);
	mdapi = femas_mdapi_create(path);
	femas_mdapi_register_spi(mdapi, mdspi);
	/* FIXME */
	snprintf(front, sizeof front, "tcp://%s:%s", front_ip, front_port);
	femas_mdapi_register_front(mdapi, front);
	femas_mdapi_init(mdapi);
	tradingday = femas_mdapi_get_tradingday(mdapi);
	return register_application(app, femas_exec, desc, NULL, mod_info->self);
}
Exemple #12
0
DBTable *DB::table(const char *tname, int scode, int cols,
		   int access)
     /* throw(PosixError); */
{
  DBTable *ret = 0; /* keep compiler happy */

  switch(access){
  case CREATE:
    if(!isdir(f_name)){
      makedir(f_name);
    }

    ret = new DBTable(this, scode, cols, tname);
    break;

  case READ:
    ret = new DBTable(this, scode, cols, tname);
    ret->file(DB::READ);
    break;

  default:
    abort();
  }

  return ret;
}
Exemple #13
0
void exefs_process(exefs_context* ctx, u32 actions)
{
	u32 i;

	exefs_determine_key(ctx, actions);

	exefs_read_header(ctx, actions);

	if (actions & VerifyFlag)
	{	
		for(i=0; i<8; i++)
			ctx->hashcheck[i] = exefs_verify(ctx, i, actions)? Good : Fail;
	}

	if (actions & InfoFlag)
	{
		exefs_print(ctx);
	}

	if (actions & ExtractFlag)
	{
		filepath* dirpath = settings_get_exefs_dir_path(ctx->usersettings);

		if (dirpath && dirpath->valid)
		{
			makedir(dirpath->pathname);
			for(i=0; i<8; i++)
				exefs_save(ctx, i, actions);
		}
	}
}
    int extractToFile(const std::string& filename, ZipEntry& info)
    {
      int err = UNZ_ERRNO;

      /* If zip entry is a directory then create it on disk */
      makedir(parentDirectory(filename));

      /* Create the file on disk so we can unzip to it */
      std::ofstream output_file(filename.c_str(), std::ofstream::binary);

      if (output_file.good())
      {
        if (extractToStream(output_file, info))
          err = UNZ_OK;

        output_file.close();

        /* Set the time of the file that has been unzipped */
        tm_unz timeaux;
        memcpy(&timeaux, &info.unixdate, sizeof(timeaux));

        changeFileDate(filename, info.dosdate, timeaux);
      }
      else
        output_file.close();

      return err;
    }
Exemple #15
0
/*type tells what to do.  address1,2,3 are parameters - the values 
  passed in bx,cx, and dx */
void handleinterrupt21(char type, char* address1, char* address2, char* address3)
{
	if (type==1)
		bios_printstr(address1);
	else if (type==2)
		readstring(address1);
	else if (type==3)
		readfile(address1,address2);
	else if (type==4)
		writefile(address1,address2,address3);
	else if (type==5)
		delfile(address1);
	else if (type==6)
		executeprogram(address1,address2,0);
	else if (type==7)
		terminateprogram();	
	else if (type==8)
		executeprogram(address1,address2,1);
	else if (type==9)
		kill(address1);
	else if (type==10)
		makedir(address1,address2);
	else
		bios_printstr("ERROR: Invalid interrupt 21 code\r\n\0");
}
Exemple #16
0
int main(int argc, char ** argv) {
	int retval = 0;
	int parents = 0;
	int opt;

	while ((opt = getopt(argc, argv, "m:p")) != -1) {
		switch (opt) {
			case 'm':
				fprintf(stderr, "%s: -m unsupported\n", argv[0]);
				return 1;
			case 'p':
				parents = 1;
				break;
		}
	}

	if (optind == argc) {
		fprintf(stderr, "%s: expected argument\n", argv[0]);
		return 1;
	}

	for (int i = optind; i < argc; ++i) {
		if (makedir(argv[i], 0777, parents) < 0) {
			if (parents && errno == EEXIST) continue;
			fprintf(stderr, "%s: %s: %s\n", argv[0], argv[i], strerror(errno));
			retval = 1;
		}
	}

	return retval;
}
Exemple #17
0
void save_run_parameters(Dbptr db,Pf *pf)
{
	char *dir,*dfile;
	char filename[512];
	char *vm,*vm3d;
	int ierr;
	
	dir = pfget_string(pf,"pmelrun_archive_directory");
	if(dir==NULL)elog_die(0,"Parameter pmelrun_archive_directory not in parameter file\n");
	if(makedir(dir))
		elog_die(0,"makedir failed on directory %s\n",dir);
	dfile = pfget_string(pf,"pmel_run_name");

	
	vm = pfget_string(pf,"travel_time_model");
	vm3d=pfget_string(pf,"3Dreference_model");
	if( (vm==NULL) || (vm3d==NULL) )
		elog_die(0,"Missing required velocity model definitions\nCheck parameters travel_time model and 3Dreference_model\n");
	db = dblookup(db,0,"pmelruns",0,0);
	ierr=dbaddv(db,0,"pmelrun",dfile,
		"vmodel",vm,
		"vmodel3d",vm3d,
		"dir",dir,
		"dfile",dfile,0);
	if(ierr < 0) elog_die(0,
		   "dbaddv error on pmelrun table\nVerify schema extensions for dbpmel and that the pmel_run_name parameter is unique\n");

	strcpy(filename,dir);
	strcat(filename,"/");
	strcat(filename,dfile);
	if(pfwrite(filename,pf))
		elog_die(0,"pfwrite error for file %s\n",filename);
}
int main(int argc,char **argv)
{
  user = argv[1];
  if (!user) usage();
  loguser = argv[2];
  if (!loguser) usage();
  dir = argv[3];
  if (!dir) usage();
  if (dir[0] != '/') usage();
  myip = argv[4];
  if (!myip) usage();

  pw = getpwnam(loguser);
  if (!pw)
    strerr_die3x(111,FATAL,"unknown account ",loguser);

  init(dir,FATAL);
  makelog(loguser,pw->pw_uid,pw->pw_gid);

  makedir("env");
  perm(02755);
  start("env/ROOT"); outs(dir); outs("/root\n"); finish();
  perm(0644);
  start("env/IP"); outs(myip); outs("\n"); finish();
  perm(0644);

  start("run");
  outs("#!/bin/sh\nexec 2>&1\nexec chpst -U "); outs(user);
  outs(" -e ./env -d250000 ");
  outs(auto_home); outs("/bin/pickdns\n");
  finish();
  perm(0755);

  makedir("root");
  perm(02755);
  start("root/data");
  finish();
  perm(0644);
  start("root/Makefile");
  outs("data.cdb: data\n");
  outs("\t"); outs(auto_home); outs("/bin/pickdns-data\n");
  finish();
  perm(0644);

  _exit(0);
}
Exemple #19
0
			bool makepath(const char* dir) {
				if (dir == 0)
					return false;

				string xpath(dir);

				if (exists(xpath.c_str())) {
					if (!isdir(xpath.c_str())) {
						LOG_ERROR("ERROR: trying to create dir '%s', but it's a file!", dir);
						return false;
					}

					return true;
				}

				// grab first part, create it if needed; move string pointer forward, loop
				string currpart;

				const char* at = xpath.c_str();

				while (*at) {
					const char* next = strchr(at, '/');

					if (next == at) {
						++at;
						continue;
					}

					if (next) {
						currpart.assign(xpath.c_str(), next - xpath.c_str());
						if (!makedir(currpart.c_str()))
							return false;
					}
					// last part!
					else {
						if (!makedir(xpath.c_str()))
							return false;
						break;
					}

					at = next + 1;
				}
				return true;
			}
Exemple #20
0
void makelog(const char *user,int uid,int gid)
{
  makedir("log");
  perm(02755);
  makedir("log/main");
  owner(uid,gid);
  perm(02755);
  start("log/status");
  finish();
  owner(uid,gid);
  perm(0644);

  start("log/run");
  outs("#!/bin/sh\nexec");
  outs(" chpst -u "); outs(user);
  outs(" svlogd -tt ./main\n");
  finish();
  perm(0755);
}
Exemple #21
0
int
maildir_make(char *maildir)
{
	int	dirfd, oldmask, r, se;

	oldmask = umask(077);
	dirfd = open_read(".");
	if (dirfd == -1)
		return ERRNO;
	if (chdir(maildir) == -1) {
		if ((r = makedir(maildir)) != OK) goto fail;
		if (chdir(maildir) == -1) {
			if (errno == ENOTDIR) {
				r = MAILDIR_CORRUPT;
				goto fail;
			} else {
				r = ERRNO;
				goto fail;
			}
		}
	}
	if ((r = makedir("tmp")) != OK) goto fail;
	if ((r = makedir("cur")) != OK) goto fail;
	if ((r = makedir("new")) != OK) goto fail;

	umask(oldmask);
	if (fchdir(dirfd) == -1) {
		r = ERRNO;
		goto fail;
	}
	close(dirfd);
	return OK;

fail:
	se = errno;
	umask(oldmask);
	fchdir(dirfd);
	close(dirfd);
	errno = se;
	return r;
}
Exemple #22
0
	void mkpath(const char* filename)
	{
		if (filename == 0)
			return;

		std::string xpath(path(filename));

		if (exists(xpath.c_str()))
		{
			if (!is_dir(xpath.c_str()))
			{
				printerr("ERROR: trying to create dir '%s', but it's a file!", filename);
				return;
			}

			return;
		}

		// grab first part, create it if needed; move string pointer forward, loop
		std::string currpart;

		const char* at = xpath.c_str();

		while (*at)
		{
			const char* next = strchr(at, '/');

			if (next)
			{
				currpart.assign(xpath.c_str(), next - xpath.c_str());
				makedir(currpart.c_str());
			}
			else // last part!
			{
				makedir(at);
				break;
			}

			at = next + 1;
		}
	}
Exemple #23
0
void *doftp(void *sd)
{
	int req, msg_ok, ret = 0,dump;
	long ssock = (long)sd;

	ret = auth_user(ssock);
	if (ret == -1)
	{
		close(ssock);
		return;
	}

	while(1)
	{
		req = 0;

		if((readn(ssock,(char *)&req,sizeof(req))) < 0)
		{
			printf("server: read error %d\n",errno);
			return;
		}

		req = ntohs(req);
		switch(req)
		{
			case STOREFILE:
				status=sendfile(ssock);
				break;
			case REQUESTFILE:
				status=recvfile(ssock);
				break;
			case MKDIR:
				status=makedir(ssock);
				break;
			case LIST:
				status=listdir(ssock);
				break;
			case DELETEFILE:
				status=deletefile(ssock);
				break;
			case END:
				printf("Client sent request to end connection.\n");
				close(ssock);
				return;
			default:
				break;
		}
		if(status==-1)
			break;
	}
	return;
}
Exemple #24
0
bool isValidPath(char *name)
{
    bool ret = false;
    char *l, *path;
    if (!(l = strrchr(name, '/')))
        return ret;

    path = strndup(name, l+1-name);
    if(makedir(path)) // attempt to make dir
        ret = true;
    free(path);
    return ret;
}
Exemple #25
0
// Create DDD state directory
static void create_session_state_dir(std::ostream& msg)
{
    // Create or find state directory
    if (!is_directory(session_state_dir()) && 
	makedir(session_state_dir(), msg, true) == 0)
    {
	// Check for DDD 2.1 `~/.dddinit' and `~/.ddd_history' files; 
	// copy them to new location if needed
	copy(string(gethome()) + "/.dddinit",
	     session_state_file(DEFAULT_SESSION), msg);
	copy(string(gethome()) + "/.ddd_history",
	     session_history_file(DEFAULT_SESSION), msg);
    }

    // Create session base directory
    if (!is_directory(session_base_dir()))
	makedir(session_base_dir(), msg);

    // Create themes directory
    if (!is_directory(session_themes_dir()))
	makedir(session_themes_dir(), msg);
}
Exemple #26
0
static void CreateNandPath(const char *path, ...)
{
	char *tmp = NULL;
	va_list va;
	va_start(va, path);
	if((vasprintf(&tmp, path, va) >= 0) && tmp)
	{
		gprintf("Creating Nand Path: %s\n", tmp);
		makedir(tmp);
	}
	va_end(va);
	SAFE_FREE(tmp);
}
Exemple #27
0
static void setup(void *UNUSED(arg))
{
#ifdef PAM_CONSOLE
	int fd;
#endif
	char line[LINE_SIZE];

	makedir("/var/run/console", 01777);
	snprintf(line, sizeof(line), "/var/run/console/%s", username);
	touch(line);

#ifdef PAM_CONSOLE
	if ((fd = open("/var/run/console/console.lock", O_CREAT|O_WRONLY|O_TRUNC, 0644)) >= 0) {
		write(fd, username, strlen(username));
		close(fd);
		run("/sbin/pam_console_apply");
	}
#endif

	makedir("/tmp/.X11-unix", 01777);
	makedir("/tmp/.ICE-unix", 01777);
}
Exemple #28
0
int main(int argc,char **argv)
{
  user = argv[1];
  if (!user) usage();
  loguser = argv[2];
  if (!loguser) usage();
  dir = argv[3];
  if (!dir) usage();
  if (dir[0] != '/') usage();
  myip = argv[4];
  if (!myip) usage();

  pw = getpwnam(loguser);
  if (!pw)
    strerr_die3x(111,FATAL,"unknown account ",loguser);

  init(dir,FATAL);
  makelog(loguser,pw->pw_uid,pw->pw_gid);

  makedir("env");
  perm(02755);
  start("env/ROOT"); outs(dir); outs("/root\n"); finish();
  perm(0644);
  start("env/IP"); outs(myip); outs("\n"); finish();
  perm(0644);

  start("run");
  outs("#!/bin/sh\nexec 2>&1\nexec envuidgid "); outs(user);
  outs(" envdir ./env softlimit -d250000 ");
  outs(auto_home); outs("/bin/walldns\n");
  finish();
  perm(0755);

  makedir("root");
  perm(02755);

  _exit(0);
}
Exemple #29
0
int main(int argc,char **argv)
{
  user = argv[1];
  if (!user) usage();
  loguser = argv[2];
  if (!loguser) usage();
  dir = argv[3];
  if (!dir) usage();
/*  if (dir[0] != '/') usage(); */
  tinydns = argv[4];
  if (!tinydns) usage();
/*  if (tinydns[0] != '/') usage(); */
  myip = argv[5];
  if (!myip) usage();

  pw = getpwnam(loguser);
  if (!pw)
    strerr_die3x(111,FATAL,"unknown account ",loguser);

  init(dir,FATAL);
  makelog(loguser,pw->pw_uid,pw->pw_gid);

  makedir("env");
  perm(02755);
  start("env/ROOT"); outs(tinydns); outs("/root\n"); finish();
  perm(0644);
  start("env/IP"); outs(myip); outs("\n"); finish();
  perm(0644);

  start("run");
  outs("#!/bin/sh\nexec 2>&1\nexec envdir ./env sh -c '\n  exec envuidgid "); outs(user);
  outs(" softlimit -d300000 tcpserver -vDRHl0 -x tcp.cdb -- \"$IP\" 53 ");
  outs(auto_home); outs("/bin/axfrdns\n'\n");
  finish();
  perm(0755);

  start("Makefile");
  outs("tcp.cdb: tcp\n");
  outs("\ttcprules tcp.cdb tcp.tmp < tcp\n");
  finish();
  perm(0644);

  start("tcp");
  outs("# sample line:  1.2.3.4:allow,AXFR=\"heaven.af.mil/3.2.1.in-addr.arpa\"\n");
  outs(":deny\n");
  finish();
  perm(0644);

    return 0;
}
Exemple #30
0
string HomeDirPlugin::buildFileName(const char *name)
{
    QString s = QFile::decodeName(m_homeDir.c_str());
#ifdef WIN32
    s += '\\';
#else
    s += '/';
#endif
    s += QFile::decodeName(name);
    string res;
    res = QFile::encodeName(s);
    makedir((char*)(res.c_str()));
    return res;
}