Пример #1
0
int
write_persist_users(sys_data_t *sys)
{
    unsigned int i, j;

    for (i = 0; i < IPMI_MAX_MCS; i++) {
	lmc_data_t *mc = sys->ipmb_addrs[i];
	user_t *users;
	persist_t *p;

	if (!mc || !ipmi_mc_users_changed(mc))
	    continue;

	p = alloc_persist("users.mc%2.2x", ipmi_mc_get_ipmb(mc));
	if (!p)
	    return ENOMEM;

	users = ipmi_mc_get_users(mc);
	for (j = 0; j <= MAX_USERS; j++) {
	    add_persist_int(p, users[j].valid, "%d.valid", j);
	    add_persist_int(p, users[j].link_auth, "%d.link_auth", j);
	    add_persist_int(p, users[j].cb_only, "%d.cb_only", j);
	    add_persist_data(p, users[j].username, sizeof(users[j].username),
			     "%d.username", j);
	    add_persist_data(p, users[j].pw, sizeof(users[j].pw),
			     "%d.passwd", j);
	    add_persist_int(p, users[j].privilege, "%d.privilege", j);
	    add_persist_int(p, users[j].max_sessions, "%d.max_sessions", j);
	    add_persist_int(p, users[j].allowed_auths, "%d.allowed_auths", j);
	}
	write_persist(p);
	free_persist(p);
    }
    return 0;
}
Пример #2
0
void
read_persist_users(sys_data_t *sys)
{
    unsigned int i, j;

    for (i = 0; i < IPMI_MAX_MCS; i++) {
	lmc_data_t *mc = sys->ipmb_addrs[i];
	user_t *users;
	persist_t *p;
	long iv;

	if (!mc)
	    continue;

	p = read_persist("users.mc%2.2x", ipmi_mc_get_ipmb(mc));
	if (!p)
	    continue;

	users = ipmi_mc_get_users(mc);
	for (j = 0; j <= MAX_USERS; j++) {
	    void *data;
	    unsigned int len;

	    if (!read_persist_int(p, &iv, "%d.valid", j))
		users[j].valid = iv;
	    if (!read_persist_int(p, &iv, "%d.link_auth", j))
		users[j].link_auth = iv;
	    if (!read_persist_int(p, &iv, "%d.cb_only", j))
		users[j].cb_only = iv;
	    if (!read_persist_data(p, &data, &len, "%d.username", j)) {
		if (len == sizeof(users[j].username))
		    memcpy(users[j].username, data, len);
		free_persist_data(data);
	    }
	    if (!read_persist_data(p, &data, &len, "%d.passwd", j)) {
		if (len == sizeof(users[j].pw))
		    memcpy(users[j].pw, data, len);
		free_persist_data(data);
	    }
	    if (!read_persist_int(p, &iv, "%d.privilege", j))
		users[j].privilege = iv;
	    if (!read_persist_int(p, &iv, "%d.max_sessions", j))
		users[j].max_sessions = iv;
	    if (!read_persist_int(p, &iv, "%d.allowed_auths", j))
		users[j].allowed_auths = iv;
	}
	free_persist(p);
    }
}
Пример #3
0
int
read_sol_config(sys_data_t *sys)
{
    unsigned int i;
    int rv;

    for (i = 0; i < IPMI_MAX_MCS; i++) {
	lmc_data_t *mc = sys->ipmb_addrs[i];
	ipmi_sol_t *sol;
	persist_t *p;
	long iv;

	if (!mc)
	    continue;
	sol = ipmi_mc_get_sol(mc);
	if (!sol->configured)
	    continue;

	sys->sol_present = 1;

	sol->solparm.enabled = 1;
	sol->solparm.bitrate_nonv = 0;

	p = read_persist("sol.mc%2.2x", ipmi_mc_get_ipmb(mc));
	if (p) {
	    if (!read_persist_int(p, &iv, "enabled"))
		sol->solparm.enabled = iv;

	    if (!read_persist_int(p, &iv, "bitrate"))
		sol->solparm.bitrate_nonv = iv;

	    sol->solparm.bitrate = sol->solparm.bitrate_nonv;

	    free_persist(p);
	}
	rv = sol_init_mc(sys, mc);
	if (rv)
	    return rv;
    }

    return 0;
}
Пример #4
0
int
write_sol_config(lmc_data_t *mc)
{
    ipmi_sol_t *sol;
    persist_t *p;

    sol = ipmi_mc_get_sol(mc);

    p = alloc_persist("sol.mc%2.2x", ipmi_mc_get_ipmb(mc));
    if (!p)
	return ENOMEM;

    sol = ipmi_mc_get_sol(mc);

    add_persist_int(p, sol->solparm.enabled, "enabled");
    add_persist_int(p, sol->solparm.bitrate_nonv, "bitrate");

    write_persist(p);
    free_persist(p);
    return 0;
}