Exemple #1
0
static int mavis_parse_in(mavis_ctx * mcx, struct sym *sym)
{
    while (1) {
	switch (sym->code) {
	case S_script:
	    mavis_script_parse(mcx, sym);
	    continue;
	case S_chroot:
	    sym_get(sym);
	    parse(sym, S_equal);
	    mcx->ftp_chroot = parse_bool(sym);
	    continue;
	case S_service:
	    sym_get(sym);
	    parse(sym, S_equal);
	    strset(&mcx->service, sym->buf);
	    sym_get(sym);
	    continue;
	case S_eof:
	case S_closebra:
	    return MAVIS_CONF_OK;
	default:
	    parse_error_expect(sym, S_script, S_service, S_chroot, S_closebra, S_unknown);
	}
    }
}
Exemple #2
0
static int mavis_parse_in(mavis_ctx * mcx, struct sym *sym)
{
    while (1) {
	switch (sym->code) {
	case S_script:
	    mavis_script_parse(mcx, sym);
	    continue;
	case S_eof:
	case S_closebra:
	    return MAVIS_CONF_OK;
	default:
	    parse_error_expect(sym, S_script, S_closebra, S_unknown);
	}
    }
}
Exemple #3
0
static int mavis_parse_in(mavis_ctx * mcx, struct sym *sym)
{
    while (1) {
	switch (sym->code) {
	case S_script:
	    mavis_script_parse(mcx, sym);
	    continue;
	case S_userid:
	    parse_userid(sym, &mcx->uid, &mcx->gid);
	    continue;
	case S_groupid:
	    parse_groupid(sym, &mcx->gid);
	    continue;
	case S_home:
	    sym_get(sym);
	    parse(sym, S_equal);
	    strset(&mcx->home, sym->buf);
	    sym_get(sym);
	    continue;
	case S_root:
	    sym_get(sym);
	    parse(sym, S_equal);
	    strset(&mcx->root, sym->buf);
	    sym_get(sym);
	    continue;
	case S_upload:
	    sym_get(sym);
	    parse(sym, S_equal);
	    strset(&mcx->incoming, sym->buf);
	    sym_get(sym);
	    continue;
	case S_eof:
	case S_closebra:
	    {
		int bye = 0;
		if (!mcx->uid || !mcx->gid || !mcx->root) {
		    struct passwd *pw;

		    pw = getpwnam("ftp");
		    if (pw) {
			if (!mcx->uid)
			    mcx->uid = pw->pw_uid;
			if (!mcx->gid)
			    mcx->gid = pw->pw_gid;
			if (!mcx->root)
			    mcx->root = Xstrdup(pw->pw_dir);
		    }
		}

		if (!mcx->uid) {
		    logmsg("%s: Fatal: anonymous ftp uid not set!", MAVIS_name);
		    bye++;
		}
		if (!mcx->gid) {
		    logmsg("%s: Fatal: anonymous ftp gid not set!", MAVIS_name);
		    bye++;
		}
		if (!mcx->root) {
		    logmsg("%s: Fatal: anonymous ftp root not set!", MAVIS_name);
		    bye++;
		}
		if (bye)
		    return -1;

		if (!mcx->home)
		    mcx->home = Xstrdup("/");

		return MAVIS_CONF_OK;
	    }
	default:
	    parse_error_expect(sym, S_script, S_userid, S_groupid, S_path, S_mode, S_closebra, S_unknown);
	}
    }
}
Exemple #4
0
static int mavis_parse_in(mavis_ctx * mcx, struct sym *sym)
{
    while (1) {
	switch (sym->code) {
	case S_script:
	    mavis_script_parse(mcx, sym);
	    continue;
	case S_chroot:
	    sym_get(sym);
	    parse(sym, S_equal);
	    mcx->ftp_chroot = parse_bool(sym);
	    continue;
	case S_passwd:
	    sym_get(sym);
	    parse(sym, S_file);
	    parse(sym, S_equal);
	    strset(&mcx->passwordfile, sym->buf);
	    sym_get(sym);
	    continue;
	case S_ftpusers:
	    sym_get(sym);
	    parse(sym, S_file);
	    parse(sym, S_equal);
	    strset(&mcx->ftpuserspath, sym->buf);
	    sym_get(sym);
	    continue;
	case S_shells:
	    sym_get(sym);
	    parse(sym, S_file);
	    parse(sym, S_equal);
	    strset(&mcx->shellpath, sym->buf);
	    sym_get(sym);
	    continue;
	case S_sslusers:
	    sym_get(sym);
	    parse(sym, S_file);
	    parse(sym, S_equal);
	    strset(&mcx->ssluserspath, sym->buf);
	    sym_get(sym);
	    continue;
	case S_check:
	    sym_get(sym);
	    switch (sym->code) {
	    case S_ftpusers:
		sym_get(sym);
		parse(sym, S_equal);
		mcx->honour_ftpusers = parse_bool(sym);
		break;
	    case S_shells:
		sym_get(sym);
		parse(sym, S_equal);
		mcx->require_valid_shell = parse_bool(sym);
		break;
	    case S_sslusers:
		sym_get(sym);
		parse(sym, S_equal);
		mcx->lookup_sslusers = parse_bool(sym);
		break;
	    default:
		parse_error_expect(sym, S_ftpusers, S_shells, S_sslusers, S_unknown);
	    }
	    continue;
	case S_eof:
	case S_closebra:
	    return MAVIS_CONF_OK;
	default:
	    parse_error_expect(sym, S_script, S_userid, S_groupid, S_path, S_mode, S_closebra, S_unknown);
	}
    }
}
Exemple #5
0
static int mavis_parse_in(mavis_ctx * mcx, struct sym *sym)
{
    u_int line;
    char *env_name;
    size_t len;
    struct stat st;

    while (1) {
	switch (sym->code) {
	case S_script:
	    mavis_script_parse(mcx, sym);
	    continue;
	case S_userid:
	    parse_userid(sym, &mcx->uid, &mcx->gid);
	    continue;
	case S_groupid:
	    parse_groupid(sym, &mcx->gid);
	    continue;
	case S_home:
	    sym_get(sym);
	    parse(sym, S_equal);
	    strset(&mcx->home, sym->buf);
	    sym_get(sym);
	    continue;
	case S_childs:
	    sym_get(sym);
	    switch (sym->code) {
	    case S_min:
		sym_get(sym);
		parse(sym, S_equal);
		mcx->child_min = parse_int(sym);
		continue;
	    case S_max:
		sym_get(sym);
		parse(sym, S_equal);
		mcx->child_max = parse_int(sym);
		continue;
	    default:
		parse_error_expect(sym, S_min, S_max, S_unknown);
	    }

	case S_setenv:
	    sym_get(sym);
	    env_name = alloca(strlen(sym->buf) + 1);
	    strcpy(env_name, sym->buf);
	    sym_get(sym);
	    parse(sym, S_equal);
	    len = strlen(env_name) + strlen(sym->buf) + 2;
	    mcx->env = Xrealloc(mcx->env, (mcx->envcount + 2) * sizeof(char *));
	    mcx->env[mcx->envcount] = Xcalloc(1, len);
	    snprintf(mcx->env[mcx->envcount++], len, "%s=%s", env_name, sym->buf);
	    mcx->env[mcx->envcount] = NULL;
	    sym_get(sym);
	    continue;

	case S_exec:{
		char buf[MAX_INPUT_LINE_LEN];
		sym_get(sym);
		parse(sym, S_equal);
		mcx->argv = calloc(1, sizeof(char *));
		line = sym->line;
		ostypef(sym->buf, buf, sizeof(buf));
		if (stat(buf, &st))
		    parse_error(sym, "%s: %s", buf, strerror(errno));
		strset(&mcx->path, buf);
		sym_get(sym);
		while (sym->line == line) {
		    mcx->argv = realloc(mcx->argv, (mcx->argc + 2) * sizeof(char *));
		    mcx->argv[mcx->argc] = strdup(sym->buf);
		    mcx->argc++;
		    mcx->argv[mcx->argc] = NULL;
		    sym_get(sym);
		}
		if (!mcx->argv[0]) {
		    mcx->argv = realloc(mcx->argv, 2 * sizeof(char *));
		    mcx->argv[0] = strdup(mcx->path);
		    mcx->argv[1] = NULL;
		}
		continue;
	    }
	case S_eof:
	case S_closebra:
	    if (!mcx->argv)
		parse_error(sym, "Missing \"exec\" declaration.");
	    return MAVIS_CONF_OK;
	default:
	    parse_error_expect(sym, S_script, S_userid, S_groupid, S_home, S_childs, S_setenv, S_exec, S_closebra, S_unknown);
	}
    }
}