コード例 #1
0
ファイル: fsctl.c プロジェクト: BackupTheBerlios/livecd
struct fs_ctl*
lu_fsctl_create(struct list_head *conf){
    struct fs_ctl *ctl;
    const char *fs_name, *user_name;

    TRACE("creating fs_ctl");
    
    if(!(ctl = (struct fs_ctl*)malloc(sizeof(struct fs_ctl))))
	return NULL;

    memset(ctl, 0, sizeof(struct fs_ctl));

    ctl->cache = lu_cache_create(conf);
    ctl->cfg = conf;

    if(!(fs_name = lu_opt_getchar(conf, "MOUNT", "fs"))){
	ERROR("you need to specify a file system!");
	free(ctl);
	return NULL;
    }

     if(!(ctl->fs_ops = get_filesystem(ctl, (char*)fs_name))){ 
 	ERROR("unsupported file system: %s", fs_name); 
 	free(ctl); 
 	return NULL; 
     }

    if((user_name = lu_opt_getchar(conf, "MOUNT", "username")))
	strcpy(ctl->cred.user, user_name);

    return ctl;
}
コード例 #2
0
ファイル: livecdfs.cpp プロジェクト: BackupTheBerlios/livecd
LiveCDFS *
LiveCDFS::create(struct list_head *cfg, 
		 struct dir_cache *cache, 
		 struct credentials *cred)
{
	FUNC_START("cfg=%p, cache=%p, cred=%p", cfg, cache, cred);
	
	const char *opt = lu_opt_getchar(cfg, "MOUNT", "ro_root");
	if (opt == NULL) {
		ERROR("FATAL: Please specify '-o ro_root=<point>', defining the ro root (underlay) as a mount option");
		FUNC_RET("%p", NULL, NULL);
	}
	string root = string(opt);
	
	opt = lu_opt_getchar(cfg, "MOUNT", "rw_tmp");
	if (opt == NULL) {
		ERROR("FATAL: Please specify '-o rw_tmp=<point>', defining the temporary rw workspace, as a mount option");
		FUNC_RET("%p", NULL, NULL);
	}
	string tmp = string(opt);
	
	opt = lu_opt_getchar(cfg, "MOUNT", "mount");
	if (opt == NULL) {
		ERROR("FATAL: Please specify '-o mount=<point>', defining the final mountpoint, as a mount option");
		FUNC_RET("%p", NULL, NULL);
	}
	string mount = string(opt);

	t_active_livecdfs *active = findActive(root, tmp);
	LiveCDFS *fs = NULL;
	if (active == NULL) {
		Path *path = NULL;
		Whiteout *wo = NULL;
		
		if (((path = Path::create(root, tmp)) != NULL) && 
		    ((wo = Whiteout::create(tmp)) != NULL)) {
			fs = new LiveCDFS(cfg, cache, cred, mount, path, wo);
		}
		
		if (fs == NULL) {
			if (path != NULL) {
				delete path;
			}
			if (wo != NULL) {
				delete wo;
			}
			ERROR("Could not create new LiveCDFS instance");
		}
		else {
			activefs.push_back((t_active_livecdfs){mount,root,tmp,1,fs});
			TRACE("Created new LiveCDFS instance, fs=%p", fs);
		}
	}
	else {
		fs = active->fs;
		active->count++;
	}
	FUNC_RET("%p", fs, fs);
}
コード例 #3
0
ファイル: cryptofs.c プロジェクト: reboot/cryptofs
void *cryptofs_init(struct list_head *cfg, struct dir_cache *cache, struct credentials *cred, void **global_ctx)
{
    if (!(*global_ctx)) {
	gchar *cryptofs_cfg;
	char *root;
	const char *cipheralgo, *mdalgo;
	long int fileblocksize;
	long int num_of_salts;

	root = g_strdup(lu_opt_getchar(cfg, "MOUNT", "root"));
	if (root[strlen(root) - 1] == '/')
	    root[strlen(root) - 1] = '\0';

	cryptofs_cfg = g_strconcat(root, "/.cryptofs", NULL);
	if (lu_opt_loadcfg(cfg, cryptofs_cfg) < 0) {
	    printf("cryptofs cfg not found");
	    g_free(cryptofs_cfg);
	    return NULL;
	}
        g_free(cryptofs_cfg);

	if ((cipheralgo = lu_opt_getchar(cfg, "CRYPTOFS", "cipher")) == NULL) {
    	    printf("CRYPTOFS::cipher missing in config file\n");
    	    return NULL;
	}
	if ((mdalgo = lu_opt_getchar(cfg, "CRYPTOFS", "md")) == NULL) {
	    printf("CRYPTOFS::md missing in config file\n");
	    return NULL;
	}
	if (lu_opt_getint(cfg, "CRYPTOFS", "blocksize", &fileblocksize, 0) < 0) {
	    printf("CRYPTOFS::blocksize missing in config file\n");
	    return NULL;
	}
	if (lu_opt_getint(cfg, "CRYPTOFS", "salts", &num_of_salts, 0) < 0) {
	    printf("CRYPTOFS::salts missing in config file\n");
	    return NULL;
	}

	*global_ctx = crypto_create_global_ctx(cipheralgo, mdalgo, fileblocksize, num_of_salts, root);
	g_free(root);
	if (*global_ctx == NULL) {
	    TRACE("creating global context failed");
	    return NULL;
	}
    }

    return crypto_create_local_ctx(*global_ctx);
}
コード例 #4
0
ファイル: cryptofs.c プロジェクト: reboot/cryptofs
void *cryptofs_init(struct list_head *cfg, struct dir_cache *cache, struct credentials *cred, void **global_ctx)
{
    Ctx *ctx;

    if (!(*global_ctx)) {
	gchar *cryptofs_cfg;
	const char *root;
	const gchar *cipheralgo, *mdalgo;
	long int fileblocksize;
	long int num_of_salts;

        g_slice_set_config(G_SLICE_CONFIG_ALWAYS_MALLOC, TRUE);

	root = lu_opt_getchar(cfg, "MOUNT", "root");

	cryptofs_cfg = g_strconcat(root, G_DIR_SEPARATOR_S, CONFIGFILE, NULL);
	if (!read_config(cryptofs_cfg, &cipheralgo, &mdalgo, &fileblocksize, &num_of_salts)) {
	    /* Try old config file */
	    if (lu_opt_loadcfg(cfg, cryptofs_cfg) < 0) {
		printf("cryptofs cfg not found");
	        g_free(cryptofs_cfg);
	        return NULL;
	    }

	    if ((cipheralgo = lu_opt_getchar(cfg, "CRYPTOFS", "cipher")) == NULL) {
    		printf("CRYPTOFS::cipher missing in config file\n");
    	        return NULL;
	    }
	    if ((mdalgo = lu_opt_getchar(cfg, "CRYPTOFS", "md")) == NULL) {
		printf("CRYPTOFS::md missing in config file\n");
	        return NULL;
	    }
	    if (lu_opt_getint(cfg, "CRYPTOFS", "blocksize", &fileblocksize, 0) < 0) {
		printf("CRYPTOFS::blocksize missing in config file\n");
	        return NULL;
	    }
	    if (lu_opt_getint(cfg, "CRYPTOFS", "salts", &num_of_salts, 0) < 0) {
		printf("CRYPTOFS::salts missing in config file\n");
		return NULL;
	    }
	}
        g_free(cryptofs_cfg);

	*global_ctx = crypto_create_global_ctx_default(cipheralgo, mdalgo, fileblocksize, num_of_salts);
	if (*global_ctx == NULL) {
	    TRACE("creating global context failed");
	    return NULL;
	}
    }

    ctx = g_new0(Ctx, 1);
    ctx->cryptoctx = crypto_create_local_ctx(*global_ctx);
    if (ctx->cryptoctx == NULL) {
        TRACE("creating global context failed");
	g_free(ctx);
	return NULL;
    }
    ctx->root = g_strdup(lu_opt_getchar(cfg, "MOUNT", "root"));
    if (ctx->root[strlen(ctx->root) - 1] == '/')
        ctx->root[strlen(ctx->root) - 1] = '\0';
    return ctx;
}