Example #1
0
BD_AACS *libaacs_load(void)
{
    BD_AACS *p = calloc(1, sizeof(BD_AACS));

    p->h_libaacs = _open_libaacs();
    if (!p->h_libaacs) {
        X_FREE(p);
        return NULL;
    }

    BD_DEBUG(DBG_BLURAY, "Loading aacs library (%p)\n", p->h_libaacs);

    *(void **)(&p->decrypt_unit) = dl_dlsym(p->h_libaacs, "aacs_decrypt_unit");
    *(void **)(&p->get_vid)      = dl_dlsym(p->h_libaacs, "aacs_get_vid");
    *(void **)(&p->get_pmsn)     = dl_dlsym(p->h_libaacs, "aacs_get_pmsn");
    *(void **)(&p->get_device_binding_id) = dl_dlsym(p->h_libaacs, "aacs_get_device_binding_id");
    *(void **)(&p->get_device_nonce)      = dl_dlsym(p->h_libaacs, "aacs_get_device_nonce");

    if (!p->decrypt_unit) {
        BD_DEBUG(DBG_BLURAY | DBG_CRIT, "libaacs dlsym failed! (%p)\n", p->h_libaacs);
        libaacs_unload(&p);
        return NULL;
    }

    BD_DEBUG(DBG_BLURAY, "Loaded libaacs (%p)\n", p->h_libaacs);

    if (file_open != file_open_default()) {
        BD_DEBUG(DBG_BLURAY, "Registering libaacs filesystem handler %p (%p)\n", (void *)(intptr_t)file_open, p->h_libaacs);
        DL_CALL(p->h_libaacs, aacs_register_file, file_open);
    }

    return p;
}
Example #2
0
static void _libaacs_close(BD_AACS *p)
{
    if (p->aacs) {
        DL_CALL(p->h_libaacs, aacs_close, p->aacs);
        p->aacs = NULL;
    }
}
Example #3
0
static void _libbdplus_close(BD_BDPLUS *p)
{
    if (p->bdplus) {
        DL_CALL(p->h_libbdplus, bdplus_free, p->bdplus);
        p->bdplus = NULL;
    }
}
Example #4
0
int libbdplus_init(BD_BDPLUS *p, const char *root,
                   void *file_open_handle, void *file_open_fp,
                   const uint8_t *vid, const uint8_t *mk)
{
    fptr_p_void    bdplus_init;
    fptr_void      set_fopen;

    _libbdplus_close(p);

    *(void **)(&bdplus_init) = dl_dlsym(p->h_libbdplus, "bdplus_init");
    *(void **)(&set_fopen)   = dl_dlsym(p->h_libbdplus, "bdplus_set_fopen");

    if (!bdplus_init) {
        BD_DEBUG(DBG_BLURAY | DBG_CRIT, "libbdplus dlsym(bdplus_init) failed! (%p)\n", p->h_libbdplus);
        return -1;
    }

    if (set_fopen) {
        p->bdplus = bdplus_init(NULL, NULL, vid);
        set_fopen(p->bdplus, file_open_handle, file_open_fp);
    } else {
        p->bdplus = bdplus_init(root, NULL, vid);
    }

    if (!p->bdplus) {
        BD_DEBUG(DBG_BLURAY | DBG_CRIT, "bdplus_init() failed! (%p)\n", p->h_libbdplus);
        return -1;
    }

    DL_CALL(p->h_libbdplus, bdplus_set_mk, p->bdplus, mk);

    return 0;
}
Example #5
0
static BD_AACS *_load(int impl_id)
{
    BD_AACS *p = calloc(1, sizeof(BD_AACS));
    if (!p) {
        return NULL;
    }
    p->impl_id = impl_id;

    p->h_libaacs = _open_libaacs(&p->impl_id);
    if (!p->h_libaacs) {
        X_FREE(p);
        return NULL;
    }

    BD_DEBUG(DBG_BLURAY, "Loading aacs library (%p)\n", p->h_libaacs);

    *(void **)(&p->decrypt_unit) = dl_dlsym(p->h_libaacs, "aacs_decrypt_unit");
    *(void **)(&p->decrypt_bus)  = dl_dlsym(p->h_libaacs, "aacs_decrypt_bus");

    if (!p->decrypt_unit) {
        BD_DEBUG(DBG_BLURAY | DBG_CRIT, "libaacs dlsym failed! (%p)\n", p->h_libaacs);
        libaacs_unload(&p);
        return NULL;
    }

    BD_DEBUG(DBG_BLURAY, "Loaded libaacs (%p)\n", p->h_libaacs);

    if (file_open != file_open_default()) {
        BD_DEBUG(DBG_BLURAY, "Registering libaacs filesystem handler %p (%p)\n", (void *)(intptr_t)file_open, p->h_libaacs);
        DL_CALL(p->h_libaacs, aacs_register_file, file_open);
    }

    return p;
}
/*****************************************************************************
 函 数 名  : ws__addAuthConfigUser
 功能描述  : 添加或修改 本地认证用户信息
 输入参数  : ws_env       ---- web service执行环境
             username     ---- 用户名
             userPwd     ---- 用户密码
             userDesc         ---- 用户描述
             userGroupId   ----用户分组(与username是1对1的关系)
             userStatus       ----用户状态

 输出参数  : ret        ---- 返回结果
 返 回 值  : WS_OK      ---- 执行成功
             soapFault  ---- 执行失败
 调用函数  :
 被调函数  :
 --------------------------------------------------------------------------------
上一次修改记录 :
 修改作者   :      王群
 修改目的   :      新添加函数
 修改日期   : 2010年12月13日

 最近一次修改记录 :
 修改作者   :      于昊
 修改目的   :      增加用户组列
 修改日期   : 2011年2月16日
*****************************************************************************/
int ws__addAuthConfigUser(WS_ENV* ws_env, char* userName, char* userPwd, char* userDesc, int userGroupId, int userStatus, int loginStatus, int *ret)
{
    s32 res = ERROR_SUCCESS;
    s8 cmd[SQLITE_SQL_BUF_SIZE];
    sqlite3 * db = NULL;
	(void)ws_env; /* for pclint */
    accout_user_proc_add_func account_add = NULL;

    /*如果用户组id不为空,调用用户组增加用户的接口	*/
	if(access(NETUSER_SO_FILE_PATH, F_OK) == 0)
	{
		db = sqlite3_open_ex (2, "/config/db/web_pass_cfg.db", DB_NETUSER);
	}
	else
	{
		db = sqlite3_open_ex(1, "/config/db/web_pass_cfg.db");
	}
	if (NULL == db)
    {
        res = ERR_SQL_OPEN_DATABASE;
        goto label_ret;
    }

	if((access(NETUSER_SO_FILE_PATH, F_OK) == 0) && 0 != userGroupId)
	{
        /*动态加载账号用户so中函数,将一个用户增加到用户组下*/
        DL_CALL(res, NETUSER_SO_FILE_PATH, "account_add_user_to_group", 
                account_add, db, userGroupId, userName, userDesc);         
        /*增加失败*/
		if(ERROR_SUCCESS != res && ERR_ACCOUNT_NAME_EXIST != res)
		{
            res = ERR_ACCOUNTUSERGROUP_ADD;
			goto label_ret;
		}
	}  

    snprintf(cmd, SQLITE_SQL_BUF_SIZE, "INSERT INTO tb_pam_user(username, password, service, enable, passwdstate, usergroupid, description) VALUES ('%s', '%s', 1, '%d','%d', '%d', '%s');", 
              userName, userPwd, userStatus, loginStatus, userGroupId, userDesc);
    res = sqlite3_exec_ex(db, cmd);
    if(SQLITE_OK != res)
    {
        res = ERR_SQL_EXEC_CMD;
    }

label_ret:
    SQLITE_CLOSE_DB(db);    
    if (SQLITE_OK != res)
    {
        return ws_send_soap_error(ws_env, localauth_user_error_string[res]);
    }

    *ret = 0;
    
    return WS_OK;
}
Example #7
0
int libaacs_open(BD_AACS *p, const char *device,
                   void *file_open_handle, void *file_open_fp,
                   const char *keyfile_path)

{
    int error_code = 0;

    fptr_p_void open;
    fptr_p_void open2;
    fptr_p_void init;
    fptr_int    open_device;
    fptr_int    aacs_get_mkb_version;
    fptr_p_void aacs_get_disc_id;

    _libaacs_close(p);

    *(void **)(&open)  = dl_dlsym(p->h_libaacs, "aacs_open");
    *(void **)(&open2) = dl_dlsym(p->h_libaacs, "aacs_open2");
    *(void **)(&init)  = dl_dlsym(p->h_libaacs, "aacs_init");
    *(void **)(&aacs_get_mkb_version) = dl_dlsym(p->h_libaacs, "aacs_get_mkb_version");
    *(void **)(&aacs_get_disc_id)     = dl_dlsym(p->h_libaacs, "aacs_get_disc_id");
    *(void **)(&open_device)          = dl_dlsym(p->h_libaacs, "aacs_open_device");

    if (init && open_device) {
        p->aacs = init();
        DL_CALL(p->h_libaacs, aacs_set_fopen, p->aacs, file_open_handle, file_open_fp);
        error_code = open_device(p->aacs, device, keyfile_path);
    } else if (open2) {
        BD_DEBUG(DBG_BLURAY, "Using old aacs_open2(), no UDF support available\n");
        p->aacs = open2(device, keyfile_path, &error_code);
    } else if (open) {
        BD_DEBUG(DBG_BLURAY, "Using old aacs_open(), no verbose error reporting available\n");
        p->aacs = open(device, keyfile_path);
    } else {
        BD_DEBUG(DBG_BLURAY, "aacs_open() not found\n");
    }

    if (p->aacs) {
        if (aacs_get_mkb_version) {
            p->mkbv = aacs_get_mkb_version(p->aacs);
        }
        if (aacs_get_disc_id) {
            p->disc_id = (const uint8_t *)aacs_get_disc_id(p->aacs);
        }
        return error_code;
    }

    return error_code ? error_code : 1;
}
Example #8
0
BD_BDPLUS *libbdplus_load(void)
{
    BD_BDPLUS *p = calloc(1, sizeof(BD_BDPLUS));

    BD_DEBUG(DBG_BDPLUS, "attempting to load libbdplus\n");

    p->h_libbdplus = _libbdplus_open();
    if (!p->h_libbdplus) {
        X_FREE(p);
        return NULL;
    }

    BD_DEBUG(DBG_BLURAY, "Loading libbdplus (%p)\n", p->h_libbdplus);

    *(void **)(&p->event)      = dl_dlsym(p->h_libbdplus, "bdplus_event");
    *(void **)(&p->m2ts)       = dl_dlsym(p->h_libbdplus, "bdplus_m2ts");
    *(void **)(&p->seek)       = dl_dlsym(p->h_libbdplus, "bdplus_seek");
    *(void **)(&p->fixup)      = dl_dlsym(p->h_libbdplus, "bdplus_fixup");
    *(void **)(&p->m2ts_close) = dl_dlsym(p->h_libbdplus, "bdplus_m2ts_close");
    if (!p->m2ts) {
        /* Old API */
        *(void **)(&p->title)  = dl_dlsym(p->h_libbdplus, "bdplus_set_title");
        if (!p->title) {
            *(void **)(&p->title)  = dl_dlsym(p->h_libbdplus, "bdplus_set_m2ts");
        }
    }

    if (!p->seek || !p->fixup || !((p->m2ts && p->m2ts_close) || p->title)) {
        BD_DEBUG(DBG_BLURAY | DBG_CRIT, "libbdplus dlsym failed! (%p)\n", p->h_libbdplus);
        libbdplus_unload(&p);
        return NULL;
    }

    BD_DEBUG(DBG_BLURAY, "Loaded libbdplus (%p)\n", p->h_libbdplus);

    if (file_open != file_open_default()) {
        BD_DEBUG(DBG_BLURAY, "Registering libbdplus filesystem handler %p (%p)\n", (void *)(intptr_t)file_open, p->h_libbdplus);
        DL_CALL(p->h_libbdplus, bdplus_register_file, file_open);
    }

    return p;
}
Example #9
0
void libbdplus_mmap(BD_BDPLUS *p, uint32_t region_id, void *mem)
{
    if (p && p->bdplus) {
        DL_CALL(p->h_libbdplus, bdplus_mmap, p->bdplus, region_id, mem);
    }
}
Example #10
0
/*******************************************************************************
 函数名称    : if_template2ppp_restore
 功能描述    : 该函数实现添加主地址
 输入参数    : ifname     ---- 接口名
               addr_str   ---- 地址字符串
 输出参数    : ret        ---- 返回结果
 返 回 值    : ERROR_SUCCESS---- 执行成功
               soapFault  ---- 执行失败
--------------------------------------------------------------------------------
 最近一次修改记录 : 
 修改作者   : wangsongbo
 修改目的   : 新生成函数
 修改日期   : 2010年4月1日
*******************************************************************************/
s32 if_template2ppp_restore(void)
{
	s32 ret = ERROR_SUCCESS;
	s32 sql_ret = SQLITE_OK;
	sqlite3* db= NULL;
	sqlite3_res res = NULL;
	s32 template_index;
	s32 i = 0;
	s32 num = 0;
	s8 *pppname = NULL;
	s8 *templatename = NULL;
	s32 (* pppoe_ppp_refer_template_dl)(s8 *pppname, s32 template_index) = NULL;
	
	db = sqlite3_open_ex(1, LOGICIF_DB_FILE);
	if(NULL == db)
	{
		return ERROR_SYSTEM;
	}
	snprintf(g_sqlite_sql_buf, sizeof(g_sqlite_sql_buf), 
					"SELECT count(*) as count FROM tb_templateif;");
	sqlite3_exec_query_ex(db, g_sqlite_sql_buf, &res);

	sqlite3_get_s32_ex(res, 0, "count", &num);
	if(0 == num)
	{
		goto error;
	}
	
	sqlite3_res_free_ex(res);
	res = NULL;
	
	snprintf(g_sqlite_sql_buf, sizeof(g_sqlite_sql_buf), 
					"SELECT * FROM tb_templateif;");
	sql_ret = sqlite3_exec_query_ex(db, g_sqlite_sql_buf, &res);
	if(SQLITE_OK != sql_ret)
	{
		ret = ERROR_SYSTEM;
		goto error;
	}
	if(num > 0)
	{
		for(i = 0; i < num; i++)
		{
			sqlite3_get_str_ex(res,i,"ifname",&templatename);
			sqlite3_get_str_ex(res,i,"to_pppname",&pppname);
			if(pppname)
			{
				if_get_index_by_name(templatename, &template_index);				
                DL_CALL(ret, "/usr/lib/libpppoe.so", "pppoe_ppp_refer_template", pppoe_ppp_refer_template_dl,pppname,template_index);

			}
		}
	}

error:
	sqlite3_res_free_ex(res);
	res = NULL;
	sqlite3_close_ex(db);
	db = NULL;
	return ret;    
	return ERROR_SUCCESS;

}
Example #11
0
*****************************************************************************/
s32 pos_port_restore(void)
{
    s32 ret, port_slot;
    u32 size, port_num, board_num, i;
    struct drv_cli_board_info board_info;
    s32 *board_status = NULL; /*目前最多用13个槽 */
	pos_port_info_s pos_port_info;
    pos_proto_info_s pos_proto_info;
	pos_proto_info_s pos_hdlc_proto_info;
	struct ifm_name_index_info *port_info = NULL;
	s32 (*parp_solidify)(char * ip, char * mac, u16 vlan, char *interface);
	
	/*将接口存在状态置0*/
	ret = pos_dba_init();
    if(ERROR_SUCCESS != ret)
    {		
        goto label_ret;
    }
	/*获取接口个数*/
	ret = ifm_get_port_num_by_type(IF_TYPE_POS, &port_num);
	if(ERROR_SUCCESS != ret || 0 == port_num)
	{
		goto label_ret;
	}
	size = port_num * sizeof(struct ifm_name_index_info);	
    port_info = malloc(size);
    if (NULL == port_info)
    {
        ret = ERROR_FAIL;
        goto label_ret;
    }
	memset(port_info, 0, size);

	/*获取接口列表*/
	ret = ifm_get_port_by_type(IF_TYPE_POS, port_num, port_info);
    if(ERROR_SUCCESS != ret)
    {		
        goto label_ret;
    }

    /* 取所有槽位的信息,只对存在的槽上的端口作配置恢复 */
    ret = ifm_get_slot_num(&board_num);
    if (ERROR_SUCCESS != ret)
    {	    		
        goto label_ret;
    }

    board_status = (s32 *)malloc(board_num*sizeof(s32));
    for(i = 0; i < board_num; i++)
    {
        board_info.slot_no = i;
        ret = sys_read_board_info(DRV_DEV_BOARD_BOARD_INFO, &board_info, sizeof(struct drv_cli_board_info));
        if (RET_WEAK_FUNC != ret && DRV_RET_OK != ret)
        {
            goto label_ret;
        }
        board_status[i] = board_info.status;
    }
    /*针对每个接口名作判断*/
    for (i = 0; i < port_num; i ++)
    {
        port_slot = get_pos_slot_by_name(port_info[i].ifname);
        if (port_slot < 0 || DRV_DEV_BOARD_OK != board_status[port_slot])
        {
            continue;
        }
        strncpy(pos_port_info.port_name, port_info[i].ifname, IFNAMSIZ-1);
        pos_port_info.port_name[IFNAMSIZ - 1] = '\0';
		pos_proto_info.ifindex = port_info[i].ifindex;
		pos_hdlc_proto_info.ifindex = port_info[i].ifindex;
		
		/*获取基本信息*/
        ret = (s32)pos_dba_get_basic_info_by_name(&pos_port_info);
		if(ERROR_SUCCESS == ret)
		{
			/*获取协议信息*/
			pos_proto_info.link_type = pos_port_info.link_type;
			ret = pos_dba_get_proto_info_by_ifindex(&pos_proto_info);
			if (ERROR_SUCCESS != ret)
			{
				goto label_ret;
			}
		}
		/*初始化数据库*/
		else if(ERR_POS_FAIL_NO_DATA == ret)
		{
        	/*获取默认接口信息*/
            ret = pos_dba_get_default_basic_info(&pos_port_info, port_info[i].ifname);
            if(ERROR_SUCCESS != ret)
            {
                goto label_ret;
            }
			/*保存接口信息*/
            ret = (s32)pos_dba_save_phy_info(&pos_port_info, POS_RESTORE);
            if (ERROR_SUCCESS != ret)
            {
                goto label_ret;
            }
			
        	/*获取默认接口协议ppp 信息*/
            ret = pos_dba_get_default_ppp_proto_info(&pos_proto_info);
            if(ERROR_SUCCESS != ret)
            {
                goto label_ret;
            }
			
			/*保存ppp协议信息*/
            ret = (s32)pos_dba_save_ppp_info(&pos_proto_info);
            if (ERROR_SUCCESS != ret)
            {
                goto label_ret;
            }

			/*获取默认接口协议hdlc 信息*/
            ret = pos_dba_get_default_hdlc_proto_info(&pos_hdlc_proto_info);
            if(ERROR_SUCCESS != ret)
            {
                goto label_ret;
            }
			
			/*保存hdlc 协议信息*/
            ret = (s32)pos_dba_save_hdlc_info(&pos_hdlc_proto_info);
            if (ERROR_SUCCESS != ret)
            {
                goto label_ret;
            }
		}
		/*失败返回*/
		else
		{
			goto label_ret;
		}

		/*给pos口添加一个静态arp*/
		DL_CALL(ret, "libarpsafety.so", "arp_solidify", parp_solidify,"0.0.0.0","00:00:00:00:00:00",0,pos_port_info.port_name);
		
		/*设置pos信息*/
        ret = pos_set_phy_info(&pos_port_info, 0);
        if (ERROR_SUCCESS != ret)
        {    
            goto label_ret;
        }
		
		/*设置pos IP*/
		ret = pos_set_ip_info(pos_port_info.port_name, pos_port_info.ip4_addr);
        if (ERROR_SUCCESS != ret)
        {
            goto label_ret;
        }

		/*设置配置恢复标志*/
		pos_proto_info.config_flag = POS_CONF_RESTORE;
		/*设置pos协议*/
		ret = pos_set_proto_info(&pos_proto_info);
        if (ERROR_SUCCESS != ret)
        {
            goto label_ret;
        }
    }

label_ret:

	/*释放内存*/
	if(NULL != board_status)
	{
		free(board_status);
	}	
    if (port_info)
    {
        free(port_info);
    }
    return (s32)ret;    
Example #12
0
/*******************************************************************************
 函数名称  : webauth_send_offline_msg
 功能描述  : 发送用户下线消息
 输入参数  : res      ------ 数据库结果集
             count    ------ 在线消息个数
 输出参数  : 无
 返 回 值  : 无
--------------------------------------------------------------------------------
 最近一次修改记录 :
 修改作者   :      王群
 修改目的   :      新添加函数
 修改日期   :      2010-08-18
*******************************************************************************/
void webauth_send_offline_msg(sqlite3_res res, u32 counter)
{
    s8 offline_time[TIME_MAX_LEN] = {0};
    s8 msg_buf[2048] = {0};
    struct tm now_time;
    time_t time_var;
    s8 * serv_code = NULL;
    s8 * user_name_tmp = NULL;
    s8   user_name[USER_REAL_NAME_MAX_LEN] = {0};
    s8 * cert_type = NULL;
    s8 * cert_code = NULL;
    s8 * client_name_tmp = NULL;
    s8   client_name[CLIENT_NAME_MAX_LEN] = {0};
    s8 * client_mac_tmp = NULL;
    s8   client_mac[CLIENT_MAC_MAX_LEN] = {0};
    s8 * client_ip_tmp = NULL;
    s8   client_ip[IP_MAX_LEN] = {0};
    s8   client_note[CLIENT_NOTE_MAX_LEN] = {0};
    s8   online_time[TIME_MAX_LEN] = {0};
    s8   org_name[ORG_NAME_MAX_LEN] = {0};
    s8   country_name[COUNTRY_NAME_MAX_LEN] = {0};
    u32 i = 0;
    pumt_webauth_send_msg pumt_msg      = NULL;
    s32 ret = 0;

    for (i = 0; i < counter; i++)
    {
        if (SQLITE_OK != sqlite3_get_str_ex(res, (s32)i, "service_code", &serv_code))
        {
            return;
        }
        if (SQLITE_OK != sqlite3_get_str_ex(res, (s32)i, "user_name", &user_name_tmp))
        {
            return;
        }
        if (SQLITE_OK != sqlite3_get_str_ex(res, (s32)i, "certificate_type", &cert_type))
        {
            return;
        }
        if (SQLITE_OK != sqlite3_get_str_ex(res, (s32)i, "certificate_code", &cert_code))
        {
            return;
        }
        if (SQLITE_OK != sqlite3_get_str_ex(res, (s32)i, "net_ending_name", &client_name_tmp))
        {
            return;
        }
        if (SQLITE_OK != sqlite3_get_str_ex(res, (s32)i, "net_ending_ip", &client_ip_tmp))
        {
            return;
        }
        if (SQLITE_OK != sqlite3_get_str_ex(res, (s32)i, "net_ending_mac", &client_mac_tmp))
        {
            return;
        }
        time_var = time(NULL);
        localtime_r(&time_var, &now_time);
        snprintf (offline_time, TIME_MAX_LEN, "%d%02d%02d%02d%02d%02d", (int)now_time.tm_year+1900, now_time.tm_mon+1, now_time.tm_mday, now_time.tm_hour, now_time.tm_min, now_time.tm_sec);
        snprintf (user_name, USER_REAL_NAME_MAX_LEN, "%s", user_name_tmp);
        snprintf (client_name, CLIENT_NAME_MAX_LEN, "%s", client_name_tmp);
        snprintf (client_ip, IP_MAX_LEN, "%s", client_ip_tmp);
        snprintf (client_mac, CLIENT_MAC_MAX_LEN, "%s", client_mac_tmp);
        snprintf (user_name, USER_REAL_NAME_MAX_LEN, "%s", iconv_utf8_to_gbk(user_name));
        snprintf (client_name, CLIENT_NAME_MAX_LEN, "%s", iconv_utf8_to_gbk(client_name));
        snprintf (msg_buf, 2048, offline_msg_fmt, serv_code, serv_code, user_name, cert_type,
            cert_code, online_time, offline_time, client_name, ip_string_handle(client_ip, "."), mac_string_handle(client_mac, ":"), org_name, country_name, client_note);
        DL_CALL(ret, LIBNET_MONITOR_PATH, "umt_webauth_send_msg", pumt_msg, msg_buf, strlen(msg_buf));
    }

    return;
}
Example #13
0
/******************************************************************************
功能:主函数,完成用户态模块的初始化
******************************************************************************/        
int main(int argc, char *argv[])
{
    int ret = 0;
    int phase;
    int pid = 0;
    int pid2 = 0;
    char *p = NULL;
    char dev_type;
    int cur_line_num;
    FILE *fd = NULL;
    int phase_number = 0;
    int start_line_num = 0;
    int end_line_num = 0;
    sigset_t newmask,oldmask;
    char line_buf[256] = {0};
    char com_buf[256] = {0};
	int (*pfunc)(void) = NULL;
    char *string[STARTUP_FIELD_NUM] = {NULL};
    char *startup_list[STARTUP_PHASE_NUM] = {"/etc/startup_1_init",
		                                     "/etc/startup_2_begin",
		                                     "/etc/startup_3_int_up",
		                                     "/etc/startup_4_pkt_in",
		                                     "/etc/startup_5_end",
		                                     "/etc/startup_6_running"};
    
    /*传参处理*/
    if (2 == argc)
    {
        if (!strcmp(argv[1], "-i"))
        {
            /*顺序执行启动*/
            ;
        }
        else if (!strcmp(argv[1], "-I"))
        {
            /*屏蔽ctrl+c信号*/
            sigemptyset(&newmask);
            sigaddset(&newmask, SIGINT);
            if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0)
            {
                printf("SIG_BLOCK error!\n");
                return 0;
            }
        }
        else
        {
            ret = !ret;
        }
    }
    else if ((4 == argc && !strcmp(argv[1], "-p")) || (5 == argc && !strcmp(argv[1], "-e")))
    {
        /*指定启动某阶段的某行*/
        phase_number = atoi(argv[2]);
        start_line_num = atoi(argv[3]);
        if(4 == argc && !strcmp(argv[1], "-p"))
        {
            /*指定启动某阶段的某行*/
            end_line_num = atoi(argv[3]);
        }
        else
        {
            /*指定启动某阶段的某行到某行*/
            end_line_num = atoi(argv[4]);
        }
        if (phase_number < 1 || phase_number > STARTUP_FIELD_NUM || start_line_num < 1 || 
					start_line_num > end_line_num)
        {
            ret = !ret;
        }
    }
    else
    {
        ret = !ret;
    }
    if(ret)
    {
        return startup_print_help();
    }

     /*获取设备类型*/
    dev_type = startup_get_dev_type();

    /*设备启动*/
    for(phase = 0; phase < STARTUP_PHASE_NUM; phase ++)
    {
        /*指定执行某阶段某行时*/
        if(0 != phase_number)
        {
            phase = phase_number - 1;
        }
        /*打开文件*/
        fd = startup_open_file(startup_list[phase]);
        if(NULL == fd)
        {
            printf("Open file failed\n");
            return 0;
        }

        cur_line_num = 0;
        /*读取并执行程序*/
        while(NULL != (p = fgets(line_buf, sizeof(line_buf), fd)))
        {
            cur_line_num ++;
            /*如果指定启动某行到某行, 则跳至指定的起始行开始执行*/
            if(start_line_num != 0 && cur_line_num != start_line_num)
            {
                continue;
            }
            start_line_num = 0;

            /*跳过注释行*/
            if('#' == *p)
            {
                continue;
            }
            /*如果指定某行到某行, 则执行完指定的最后一行跳出循环*/
            if(end_line_num != 0 && cur_line_num > end_line_num)
            {
                break;
            }

            /*以":"拆分字符串*/
            startup_str_analyse(p, string);

            /*判断设备类型*/
            if('\0' != *string[STARTUP_DEV_TYPE] && (NULL == strchr(string[STARTUP_DEV_TYPE], dev_type)))
            {
                continue;
            }
            /*判断脚本文件或者so文件是否存在*/
            if(access(string[STARTUP_EXE_PATH], F_OK))
            {
               continue;
            }
            /*打印启动信息*/
            if('\0' != *string[STARTUP_INIT_INFO] && 'y' == *string[STARTUP_PRINT_OR_NOT])
            {
                printf("%s:", string[STARTUP_INIT_INFO]);
                fflush(stdout);
            }

            /*创建子进程执行启动项*/
            pid = fork();
            if(pid < 0)
            {
                fclose(fd);
                printf("Fork error!\n");
                return 0;
            }
            else if(pid == 0)
            {
				switch (*string[STARTUP_EXE_TYPE])
				{
					case 'c': /*直接通过so找到函数执行流程*/
						DL_CALL(ret, string[STARTUP_EXE_PATH], string[STARTUP_EXE_ARG], pfunc); 
						return ret;
					case 'v': /*vtysh专用流程*/
						pid2 = fork();
						if(pid2 < 0)
						{
							printf("Fork error!\n");
							return -1;
						}
						else if(pid2 == 0)
						{
							/*子进程等待3s使父进程继续启动vtysh,
							子进程继续执行第6阶段*/
							sleep(3);
						}
						else
						{
							/*恢复vtysh的信号屏蔽集,为vtysh解除SIGINT信号屏蔽*/
							if(!strcmp(argv[1], "-I") && sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0)
							{
								printf("SIG_SETMASK error!\n");
								exit(0);
							}
							/* 父进程执行vtysh,并停留在vtysh中  */
							sprintf(com_buf, "%s %s", string[STARTUP_EXE_PATH], string[STARTUP_EXE_ARG]);
							execl("/bin/sh", "sh", "-c", com_buf, (char *)0);
							wait(NULL);
						}
						break;
					default : /*bin,脚本执行流程*/
						sprintf(com_buf, "%s %s", string[STARTUP_EXE_PATH], string[STARTUP_EXE_ARG]);
						execl("/bin/sh", "sh", "-c", com_buf, (char *)0);
						_exit(-1);
				}
            }
            else/*父进程等待子进程结束,并获取结束状态*/
            {
                if('v' == *string[STARTUP_EXE_TYPE])
                {
                	/*设备启动成功之后,startup进程不能再被SIGINT信号退出*/
                	signal(SIGINT, SIG_IGN);
                    fclose(fd);
                }
                wait(&ret);
            }

            /*失败时记录启动日志*/
            if(0 != ret)
            {
                startup_write_log(ret, phase, cur_line_num, string);
            }
            /*打印结果*/
            startup_print_result(ret, string);
        }
        fclose(fd);
        /*执行某阶段某行时不进行循环*/
        if(0 != phase_number)
        {
            break;
        }
    }

    return 0;
}
/*****************************************************************************
 函 数 名  : ws__removeAuthConfigUser
 功能描述  : 修改用户的的权限, 删除认证用户
 输入参数  : ws_env       ---- web service执行环境
             username     ---- 用户名

 输出参数  : ret        ---- 返回结果
 返 回 值  : WS_OK      ---- 执行成功
             soapFault  ---- 执行失败
 --------------------------------------------------------------------------------
 最近一次修改记录 :
 修改作者   :      于昊
 修改目的   :      增加通知账号组代码
 修改日期   : 2011年4月29日
********************************************************************************/
int ws__removeAuthConfigUser(WS_ENV* ws_env, char* userName, int* ret)
{
    s32 res = ERROR_SUCCESS;
    s8 cmd[SQLITE_SQL_BUF_SIZE];
    sqlite3 * db = NULL;
    sqlite3_res sql_res = NULL;   
    s32 userGroupId;
    accout_user_proc_del_func account_del = NULL;
    (void)ws_env; 

	if(access(NETUSER_SO_FILE_PATH, F_OK) == 0)
	{
		db = sqlite3_open_ex (2, "/config/db/web_pass_cfg.db", DB_NETUSER);
	}
	else
	{
		db = sqlite3_open_ex(1, "/config/db/web_pass_cfg.db");
	}
	if (NULL == db)
    {
        res = ERR_SQL_OPEN_DATABASE;
        goto label_ret;
    }
  
    if(access (NETUSER_SO_FILE_PATH, F_OK) == 0)
    {  
        /*查找该用户所属账号用户组的id*/
        memset(cmd, 0, sizeof(cmd));
        snprintf(cmd, SQLITE_SQL_BUF_SIZE, 
                 "select usergroupid, description from tb_pam_user where username='******';", userName);
        res = sqlite3_exec_query_ex(db, cmd, &sql_res);
        if(SQLITE_OK != res)
        {
            res = ERR_SQL_EXEC_CMD;
            goto label_ret;
        }

        res = sqlite3_get_s32_ex(sql_res, 0, "usergroupid", &userGroupId);
        if(SQLITE_OK != res)
        {
            res = ERR_SQL_EXEC_CMD;
            goto label_ret;
        }
       
        SQLITE_FREE_RES(sql_res);

        /* 
               * 调用账号用户组so中的account_del_user_from_group,
               * 将该用户从账号用户组中删除。
               */
        if(0 != userGroupId)
        {
            DL_CALL(res, NETUSER_SO_FILE_PATH, "account_del_user_from_group",  
                    account_del, db, userGroupId, userName);                
            
            /*删除失败*/
            if(ERR_ACCOUNT_SUCCESS != res && ERR_ACCOUNT_ID_NO_EXIST != res && ERR_ACCOUNT_PARAM != res)
            {
                res = ERR_ACCOUNTUSERGROUP_DEL;
                goto label_ret;
            }
        }
    }

    memset(cmd, 0, sizeof(cmd));
    snprintf (cmd, SQLITE_SQL_BUF_SIZE, "DELETE FROM tb_pam_user WHERE username = '******';", userName);
    res = sqlite3_exec_ex(db, cmd);
    if(SQLITE_OK != res)
    {
        res = ERR_SQL_EXEC_CMD;
    }

    *ret = 0;

label_ret:

    SQLITE_FREE_RES(sql_res);
    SQLITE_CLOSE_DB(db);
    if (SQLITE_OK != res)
    {
        return ws_send_soap_error(ws_env, localauth_user_error_string[res]);
    }
    if(access (CFG_MACIPFIX_DBFILE, F_OK) == 0)
    {
        macip_del_usrMac_cfg(userName);
    }
    return WS_OK;
}
Example #15
0
int libaacs_open(BD_AACS *p, const char *device,
                   void *file_open_handle, void *file_open_fp,
                   const char *keyfile_path)

{
    int error_code = 0;

    fptr_p_void open;
    fptr_p_void open2;
    fptr_p_void init;
    fptr_int    open_device;
    fptr_int    aacs_get_mkb_version;
    fptr_p_void aacs_get_disc_id;

    _libaacs_close(p);

    *(void **)(&open)  = dl_dlsym(p->h_libaacs, "aacs_open");
    *(void **)(&open2) = dl_dlsym(p->h_libaacs, "aacs_open2");
    *(void **)(&init)  = dl_dlsym(p->h_libaacs, "aacs_init");
    *(void **)(&aacs_get_mkb_version) = dl_dlsym(p->h_libaacs, "aacs_get_mkb_version");
    *(void **)(&aacs_get_disc_id)     = dl_dlsym(p->h_libaacs, "aacs_get_disc_id");
    *(void **)(&open_device)          = dl_dlsym(p->h_libaacs, "aacs_open_device");

    if (init && open_device) {
        p->aacs = init();
        DL_CALL(p->h_libaacs, aacs_set_fopen, p->aacs, file_open_handle, file_open_fp);
        error_code = open_device(p->aacs, device, keyfile_path);
    } else if (open2) {
        BD_DEBUG(DBG_BLURAY, "Using old aacs_open2(), no UDF support available\n");
        p->aacs = open2(device, keyfile_path, &error_code);

        /* libmmbd needs dev: for devices */
        if (!p->aacs && p->impl_id == IMPL_LIBMMBD && !strncmp(device, "/dev/", 5)) {
            char *tmp_device = str_printf("dev:%s", device);
            if (tmp_device) {
                p->aacs = open2(tmp_device, keyfile_path, &error_code);
                X_FREE(tmp_device);
            }
        }
    } else if (open) {
        BD_DEBUG(DBG_BLURAY, "Using old aacs_open(), no verbose error reporting available\n");
        p->aacs = open(device, keyfile_path);
    } else {
        BD_DEBUG(DBG_BLURAY, "aacs_open() not found\n");
    }

    if (error_code) {
        /* failed. try next aacs implementation if available. */
        BD_AACS *p2 = _load(p->impl_id + 1);
        if (p2) {
            if (!libaacs_open(p2, device, file_open_handle, file_open_fp, keyfile_path)) {
                /* succeed - swap implementations */
                _unload(p);
                *p = *p2;
                X_FREE(p2);
                return 0;
            }
            /* failed - report original errors */
            libaacs_unload(&p2);
        }
    }

    if (p->aacs) {
        if (aacs_get_mkb_version) {
            p->mkbv = aacs_get_mkb_version(p->aacs);
        }
        if (aacs_get_disc_id) {
            p->disc_id = (const uint8_t *)aacs_get_disc_id(p->aacs);
        }
        return error_code;
    }

    return error_code ? error_code : 1;
}
/*******************************************************************************
 函数名称  : ws__modAuthConfigUser
 功能描述  : 修改本地认证用户信息
 输入参数  : ws_env         ---- web service执行环境
             oldUsername    ---- 新用户名
             newUsername    ---- 新用户名
             userPwd        ---- 用户密码
             userDesc       ---- 用户描述
             userGroupId   ----用户分组
             userStatus     ----用户状态
 输出参数  : ret            ---- 返回结果
 返 回 值  : WS_OK          ---- 执行成功
             soapFault      ---- 执行失败
--------------------------------------------------------------------------------

最近一次修改记录 :
修改作者   :	  于昊
修改目的   :	  增加用户组列
修改日期   : 2011年2月16日

*******************************************************************************/
int ws__modAuthConfigUser(WS_ENV* ws_env, char* oldUserName, char* newUserName, char* userPwd, char* userDesc, int userGroupId, int userStatus, int loginStatus, int *ret)
{
    s32 res = ERROR_SUCCESS;
    s8 cmd[SQLITE_SQL_BUF_SIZE];
    sqlite3 * db = NULL;    
    sqlite3_res sql_res = NULL;
    s8 * oldUserPwd = NULL;	
    (void)ws_env; 
	s32 oldUserGroupId = 0;    /*原用户所在账号用户 组userGroupID	*/
	accout_user_proc_add_func account_add = NULL;  
    accout_user_proc_del_func account_del = NULL; 
    
    /* set local user info */
	if(access(NETUSER_SO_FILE_PATH, F_OK) == 0)
	{
		db = sqlite3_open_ex (2, "/config/db/web_pass_cfg.db", DB_NETUSER);
	}
	else
	{
		db = sqlite3_open_ex(1, "/config/db/web_pass_cfg.db");
	}
	if (NULL == db)
    {
        res = ERR_SQL_OPEN_DATABASE;
        goto label_ret;
    }
    if (0 == strcmp ("******", userPwd))
    {
        memset(cmd, 0, sizeof(cmd));
        snprintf (cmd, SQLITE_SQL_BUF_SIZE, "SELECT password AS pwd FROM tb_pam_user WHERE username = '******';", oldUserName);
        /* 执行查询语句,查询得到结果集  */
        res = sqlite3_exec_query_ex (db, cmd, &sql_res);
        /* 执行出错,则准备退出 */
        if (SQLITE_OK != res)
        {
            res = ERR_SQL_EXEC_CMD;
            goto label_ret;
        }
        res = sqlite3_get_str_ex (sql_res, 0, "pwd", &oldUserPwd);
        if (SQLITE_OK != res)
        {
            res = ERR_SQL_EXEC_CMD;
            goto label_ret;
        }
        userPwd = ws_strdup (ws_env,oldUserPwd);

        SQLITE_FREE_RES(sql_res);
    }

    /*如果旧名称存在,先删除旧名称的记录*/
    if (0 != strcmp (oldUserName, "null"))
    {
	    /*查找此user的usergroupid和实名*/
		memset(cmd, 0, sizeof(cmd));
		snprintf(cmd, SQLITE_SQL_BUF_SIZE, "select usergroupid,description from tb_pam_user where username = '******' " , oldUserName);
		res = sqlite3_exec_query_ex(db, cmd, &sql_res);
		if (SQLITE_OK != res)
	    {
            res = ERR_SQL_EXEC_CMD;
	        goto label_ret;
	    }
		res = sqlite3_get_s32_ex(sql_res, 0, "usergroupid", &oldUserGroupId);
		if (SQLITE_OK != res)
	    {
            res = ERR_SQL_EXEC_CMD;
	        goto label_ret;
	    }     
        
        SQLITE_FREE_RES(sql_res);
        
		/*如果存在usergroupid,即有用户分组,调用用户组删除用户的接口*/
		if((access (NETUSER_SO_FILE_PATH, F_OK) == 0) && 0 != oldUserGroupId)
		{
            /*调用账号用户组so中的account_del_user_from_group,将用户组中用户名称等于userName的用户删除*/
            DL_CALL(res, NETUSER_SO_FILE_PATH, "account_del_user_from_group",  
                  account_del, db, oldUserGroupId, oldUserName);                
            
			/*删除失败*/
			if(ERR_ACCOUNT_SUCCESS != res && ERR_ACCOUNT_ID_NO_EXIST != res && ERR_ACCOUNT_PARAM != res)
			{
				res = ERR_ACCOUNTUSERGROUP_DEL;
                goto label_ret;
			}          
		}

        /*如果新的用户组id不为空,调用用户组增加用户的接口*/
        if(0 != userGroupId)
        {
            /*动态加载账号用户so中函数,将一个用户增加到用户组下*/
            DL_CALL(res, NETUSER_SO_FILE_PATH, "account_add_user_to_group",  
                    account_add,  db, userGroupId, newUserName, userDesc);
                       
        	/*添加失败*/
        	if(ERROR_SUCCESS != res && ERR_ACCOUNT_NAME_EXIST != res)
        	{
        	    res = ERR_ACCOUNTUSERGROUP_ADD;
                goto label_ret;
        	}			
        }
        /*删除旧的用户*/
        memset(cmd, 0, sizeof(cmd));
        snprintf (cmd, SQLITE_SQL_BUF_SIZE, "DELETE from tb_pam_user WHERE username = '******';", oldUserName);        
        res = sqlite3_exec_ex(db, cmd);
        if (SQLITE_OK != res)
        {
            res = ERR_SQL_EXEC_CMD;
            goto label_ret;
        }	
    }

    memset(cmd, 0, sizeof(cmd));
    snprintf(cmd, SQLITE_SQL_BUF_SIZE, "INSERT INTO tb_pam_user(username, password, service, enable, passwdstate, usergroupid, description) VALUES ('%s', '%s', 1, %d, %d, %d, '%s') ;",
        newUserName, userPwd, userStatus, loginStatus, userGroupId, userDesc);
    
    res = sqlite3_exec_ex(db, cmd);
    if (SQLITE_OK != res)
    {
        res = ERR_SQL_EXEC_CMD;
    }

label_ret:

    SQLITE_FREE_RES(sql_res);
    SQLITE_CLOSE_DB(db);
    
    *ret = 0;
    if (SQLITE_OK != res)
    {
        return ws_send_soap_error(ws_env, localauth_user_error_string[res]);
    }

    return WS_OK;
}
int ws__removeAllLocalAuthUser(WS_ENV * ws_env, int *ret)
{    
    sqlite3 * db = NULL;
    sqlite3_res sql_res = NULL;
    s32 res = ERROR_SUCCESS;
    s32 userTotal = 0; /*查到的用户总数*/
    s32 count = 0;
    s8 * username = NULL;
    s8 *user_desc = NULL;
    s32 usergroupid = 0;
    accout_user_proc_del_func account_del = NULL;

	if(access(NETUSER_SO_FILE_PATH, F_OK) == 0)
	{
		db = sqlite3_open_ex (2, "/config/db/web_pass_cfg.db", DB_NETUSER);
	}
	else
	{
		db = sqlite3_open_ex(1, "/config/db/web_pass_cfg.db");
	}

    if(NULL == db)
    {
        return ws_send_soap_error(ws_env, "Can't open localauth db.");
    }

    /*开启事务*/
    SQLITE_TRANSC_BEGIN(db);
    
    /*查询表中有多少个用户*/
    snprintf(g_sqlite_sql_buf, SQLITE_SQL_BUF_SIZE, "SELECT COUNT(*) AS count FROM tb_pam_user ");
    /*返回结果集的东西*/
    res = sqlite3_exec_query_ex(db, g_sqlite_sql_buf, &sql_res);
    if (SQLITE_OK != res)
    {
        res = ERR_SQL_EXEC_CMD;
        goto label_ret;
    }
    res = sqlite3_get_s32_ex(sql_res, 0, "count", &userTotal);    
    if (SQLITE_OK != res)
    {
        res = ERR_SQL_EXEC_CMD;
        goto label_ret;
    }
    if (NULL != sql_res)
    {
        sqlite3_res_free_ex(sql_res);
        sql_res = NULL;
    }
    snprintf(g_sqlite_sql_buf, SQLITE_SQL_BUF_SIZE, "SELECT * FROM tb_pam_user");
    res = sqlite3_exec_query_ex(db, g_sqlite_sql_buf, &sql_res);
    if (SQLITE_OK != res)
    {   
        res = ERR_SQL_EXEC_CMD;
        goto label_ret;
    }
    /*遍历所有用户调用账号用户组提供的接口,删除用户组中包含本地认证用户的用户名*/
    for ( count = 0; count < userTotal; count++)
    {
        res = sqlite3_get_str_ex(sql_res, count, "username", &username);
        if (SQLITE_OK != res)
        {
            res = ERR_SQL_EXEC_CMD;
            goto label_ret;
        }
        res = sqlite3_get_s32_ex(sql_res, count, "usergroupid", &usergroupid);
        if (SQLITE_OK != res)
        {
            res = ERR_SQL_EXEC_CMD;
            goto label_ret;
        } 
         /*获取实名*/
        res = sqlite3_get_str_ex(sql_res, count, "description", &user_desc);
        if (SQLITE_OK != res)
        {
            goto label_ret;
        }

        /* 
               * 调用账号用户组so中的account_del_user_from_group,
               * 将该用户从账号用户组中删除。
               */
		if((access (NETUSER_SO_FILE_PATH, F_OK) == 0)  && (0 != usergroupid))
		{
            DL_CALL(res, NETUSER_SO_FILE_PATH, "account_del_user_from_group", 
                    account_del, db, usergroupid, username);                
            
            /*删除失败*/
    		if(ERR_ACCOUNT_SUCCESS != res && ERR_ACCOUNT_ID_NO_EXIST != res && ERR_ACCOUNT_PARAM != res)
    		{
    			res = ERR_ACCOUNTUSERGROUP_DEL;
                goto label_ret;
    		}
		}
    }
    SQLITE_FREE_RES(sql_res);
    
    snprintf(g_sqlite_sql_buf, SQLITE_SQL_BUF_SIZE, "delete from tb_pam_user;");
    res = sqlite3_exec_ex(db, g_sqlite_sql_buf);
    if(SQLITE_OK != res)
    {
        res = ERR_DELETE_ALL_USER; 
        goto label_ret;
    }
    SQLITE_TRANSC_COMMIT(db);
    
label_ret:
    SQLITE_FREE_RES(sql_res);
    SQLITE_CLOSE_DB(db);
    if(res != ERROR_SUCCESS)
    {
        return ws_send_soap_error(ws_env, localauth_user_error_string[res]);
    }
    *ret = 0;

    return WS_OK;
}
Example #18
0
s32 ifm_process_ipv4_notify(void *rcv,s32 ipv4_flag)
{
    
    s32 ret  = ERROR_SUCCESS;
    u32 ip_addr = 0;
    s8  *c_addr =NULL;
    s32 rta_len = 0;
	s8 serial[32] = {0};
    struct in_addr addr_temp;    
    struct rtattr *attr;
	struct rcv_message *rsp;
	struct ifaddrmsg *ifm; 
    s8 if_name[INTERFACE_NAME_MAX_LENGTH];
	struct if_stat *ifstat=NULL;
	ifstat=if_stat_list;
	
	rsp = (struct rcv_message *)rcv;
	ifm = NLMSG_DATA(&rsp->n);
	attr = (struct rtattr *) (NLMSG_DATA(&rsp->n) + NLMSG_ALIGN(sizeof(struct ifaddrmsg)));
	rta_len = RTA_ALIGN(sizeof(struct rtattr));
	if (attr->rta_type == IFA_ADDRESS)
	{
		ip_addr = nla_get_u32((struct nlattr *) attr);
        addr_temp.s_addr = ip_addr; 
		c_addr = inet_ntoa(addr_temp);
	}
    ret = if_get_name_by_index(if_name ,INTERFACE_NAME_MAX_LENGTH ,ifm->ifa_index);
    if( ret)
    {
        return ERROR_FAIL;
    }
    ret = sys_read_device_serial(serial ,sizeof(serial));
    if(ret)
    {
         return ERROR_FAIL;
    }
	if((rsp->n.nlmsg_type == RTM_NEWADDR)&&(ipv4_flag==RTM_NEWADDR))
	{
		syslogex_syslog_send("ifmd" ,LOG_NOTICE|LOG_DAEMON ,LOG_INTERFACE_ADD_IP ,c_addr,if_name,serial);
		if(strncmp(if_name,"ppp",3) == 0)
		{
			dnat_netip_update dnat_ip_update = NULL;
			DL_CALL(ret, "/usr/lib/libnat.so", "dnat_netip_update", dnat_ip_update, if_name);
		}
	}
	else if((rsp->n.nlmsg_type == RTM_DELADDR)&&(ipv4_flag==RTM_DELADDR))
	{
		syslogex_syslog_send("ifmd" ,LOG_NOTICE|LOG_DAEMON ,LOG_INTERFACE_DEL_IP ,c_addr,if_name,serial);
    }
	else
	{
		return ERROR_SUCCESS;
	}
	
	while(ifstat!=NULL)
	{
		if((strcmp(ifstat->name,if_name)==0)&&(ifstat->use_flag==IFMD_INFO_USE))
		{
		    if(ipv4_flag==RTM_NEWADDR)
		    {
				ifstat->addr=ip_addr;
		    }
			else if(ipv4_flag==RTM_DELADDR)
			{
			    ifstat->addr=0;
			}
			ifm_update_if_stat(if_name);
			break;
		}
		else
		{
			ifstat=ifstat->next;
		}
	}
    return ERROR_SUCCESS;
}
Example #19
0
void libaacs_select_title(BD_AACS *p, uint32_t title)
{
    if (p && p->aacs) {
        DL_CALL(p->h_libaacs, aacs_select_title, p->aacs, title);
    }
}
Example #20
0
void libbdplus_psr(BD_BDPLUS *p, void *regs, void *read, void *write)
{
    if (p && p->bdplus) {
        DL_CALL(p->h_libbdplus, bdplus_psr, p->bdplus, regs, read, write);
    }
}
/*******************************************************************************
 函数名称  :localUserCfgUpload
 功能描述  : 上传用户信息CSV文件
 输入参数  : 无
 输出参数  : 无
 返 回 值  :ERROR_SUCCESS	---- 执行成功
            否则返回全局错误码
--------------------------------------------------------------------------------
 上一次修改记录 :2009年10月3日
 修改作者   :魏甲博
 修改目的   : 实现批量导入用户信息
 修改日期   :2009年10月3日

 最近一次修改记录 :
 修改作者   :于昊
 修改目的   : 导入加入新列用户组
 修改日期   :2011年02月17日
*******************************************************************************/
s32 localUserCfgUpload(struct sub_env_t * sub_env, WS_ENV * ws_env, WS_REQ_RES * ws_req_res)
{

    u32 size;
    s32 counter = 0;
    s32 flag = 0;
    s32 res = ERROR_SUCCESS;
    u32 sys_err_code = ERROR_SUCCESS;
    const char *name = NULL;
    char cmd[512];
    char userName[USERNAME_LENGTH];
    char passWord[PASSWORD_LENGTH];
    char user_desc[DESCRIPTION_LENGTH];
    char fp_frist_buf[LOCAL_FP_FIRST_BUF_LEN];
	s32 state;
	s32 passwdstate;
	char userGroupName[USERNAME_LENGTH];
    s32 userGroupId = 0;
    s32 isUserNameRepeat = 0;
    s32 isUserDescRepeat = 0;
    sqlite3_res sql_res = NULL;
    FILE * fp = NULL;
    MEMBUFF * buff = NULL;
    char * token = NULL;
    char * delim = ",\r\n";
    char * saveptr = NULL;
    char * str = NULL;
    s32 desc_count = 0;  
    sqlite3 * db = NULL;
    s32 netuser_so_is_exist = 0;
    accout_user_proc_add_func account_add = NULL;
    s8 err_string[LOCAL_ERR_STRING_LENGTH] = {0};
    (void)sub_env;
    (void)ws_req_res;
    
    if(HTTP_PARA_FOUND != http_get_upload_file_info("filepath", &name, &size)
      || HTTP_PARA_FOUND != http_move_upload_file("filepath", LOCAL_AUTH_USER_CFG_PATH))
    {
        return (u32)ws_send_soap_error(ws_env, "Upload file fail!");
    }
    if(access(NETUSER_SO_FILE_PATH, F_OK) == 0)
    {
        netuser_so_is_exist = 1;
    }
      
    fp = fopen(LOCAL_AUTH_USER_CFG_PATH, "r");
    if (NULL == fp)
    {
        return ws_send_soap_error(ws_env, "Open file fail!");
    }
    
	if(NULL == fgets(fp_frist_buf, LOCAL_FP_FIRST_BUF_LEN, fp))
    {
        fclose(fp);
        return ws_send_soap_error(ws_env, "Open file fail!");
    }
    buff = membuff_readfile (fp);
    fclose (fp);
    if (NULL == buff)
    {
        return ws_send_soap_error(ws_env, "Read into buffer from file fail!");
    }
    membuff_tolineformat(buff, FORMAT_NOTRIM);
    counter = 0;
    /* 打开一个连接,出错则返回 */
	if(access(NETUSER_SO_FILE_PATH, F_OK) == 0)
	{
    	db = sqlite3_open_ex (2, "/config/db/web_pass_cfg.db", DB_NETUSER);
	}
	else
	{
		db = sqlite3_open_ex(1, "/config/db/web_pass_cfg.db");
	}
    /*开启事务*/
	SQLITE_TRANSC_BEGIN(db);

    if (NULL == db)
    {
        return ws_new_soap_fault (ws_env, SQLITE_FAILD_OPEN);
    }
	
    while (counter < buff->len)
    {
        memset (userName, 0, USERNAME_LENGTH);
        memset (passWord, 0, PASSWORD_LENGTH);
        memset (user_desc, 0, DESCRIPTION_LENGTH);
        memset (userGroupName, 0, USERNAME_LENGTH);
        userGroupId = 0;
        desc_count = 0;
        
        str = buff->array[counter]->buff;
        /*get user name*/
        token = strtok_r (str, delim, &saveptr);
        if (NULL == token || USERNAME_LENGTH < strlen(token))
        {
            flag = ERR_USERNAME_LENGTH;
            break;
        }
        strncpy (userName, token, USERNAME_LENGTH - 1);
        userName[USERNAME_LENGTH - 1] = '\0';
        
        /*get password*/
        token = strtok_r (NULL, delim, &saveptr);
        if (NULL == token || PASSWORD_LENGTH < strlen(token))
        {
            flag = ERR_PASSWORD_LENGTH;
            break;
        }
        strncpy (passWord, token, PASSWORD_LENGTH - 1);
        passWord[PASSWORD_LENGTH - 1] = '\0';
        
        /*get user group name*/
        token = strtok_r (NULL, delim, &saveptr);
		if (NULL == token)
		{
			flag = ERR_UPLOAD_FILE_FORMAT;
			break;
		}		
        strncpy (userGroupName, token, USERNAME_LENGTH - 1);
        userGroupName[USERNAME_LENGTH - 1] = '\0';
        strncpy (userGroupName, ws_iconv_gbk_to_utf8 (ws_env, userGroupName), USERNAME_LENGTH - 1);
        userGroupName[USERNAME_LENGTH - 1] = '\0';
        
        /*如果用户组名称不为默认的0,去查对应的用户组ID */
        if(0 != strcmp("0", userGroupName))
        {
            snprintf (cmd, SQLITE_SQL_BUF_SIZE, "select group_id from group_info where group_name = '%s';", userGroupName);
            res = sqlite3_exec_query_ex(db, cmd, &sql_res);
            if(ERROR_SUCCESS != res)
            {   
                flag = ERR_ACCOUNTUSERGROUP_ADD;
                break;
            }

            res = sqlite3_get_s32_ex(sql_res, 0, "group_id", &userGroupId);
            if(ERROR_SUCCESS != res)
            {   
                flag = ERR_ACCOUNTUSERGROUP_ADD;
                break;
            }
            
            SQLITE_FREE_RES(sql_res);
        }             
        
        /*get user status*/
        token = strtok_r (NULL, delim, &saveptr);
		if (NULL == token)
		{
			flag = ERR_UPLOAD_FILE_FORMAT;
			break;
		}
		state = atoi(token);
        if(state != 0 && state != 1)
        {
            flag = ERR_STATE_ERROR;
            break;
        }
        
        /*get password status*/
		token = strtok_r (NULL, delim, &saveptr);
		if (NULL == token)
		{            
			flag = ERR_UPLOAD_FILE_FORMAT;
			break;
		}
        passwdstate = atoi(token);
		if(passwdstate < 0 && passwdstate > 3)
		{    
			flag = ERR_PASSWD_STATE_ERROR;
			break;
		}
        
        /*get user description*/
		token = strtok_r (NULL, "\r\n", &saveptr);
		if(NULL != token)
        {
            if(DESCRIPTION_LENGTH < strlen(token))
            {
                flag = ERR_DESCRIPTION_LENGTH;
                break;
            }
            strncpy (user_desc, token, DESCRIPTION_LENGTH - 1);
            user_desc[DESCRIPTION_LENGTH - 1] = '\0';
            strncpy (user_desc, ws_iconv_gbk_to_utf8 (ws_env, user_desc), DESCRIPTION_LENGTH - 1);
            user_desc[DESCRIPTION_LENGTH - 1] = '\0';
        }		
        
        /*检测是否有重复的用户名*/
        if(ERR_CODE_SUCCESS != local_user_check_repeat_username(userName, &isUserNameRepeat))
        {
            break;
        }
        if(LOCAL_USER_NAME_UNIQUE != isUserNameRepeat)
        {
            flag = ERR_USERNAME_REPEAT;
            break;
        }

        /*检测是否有重复的描述,空描述不做检测*/
        if(0 != strlen(user_desc))
        {
            if(ERR_CODE_SUCCESS != local_user_check_repeat_user_desc(user_desc, &isUserDescRepeat))
            {
                break;
            }
            if(LOCAL_USER_DESC_UNIQUE != isUserDescRepeat)
            {
                flag = ERR_USERDESCRIPTION_REPEAT;
                break;
            }
        }      

        /*如果用户组id不为空,调用用户组增加用户的接口	*/
        if(netuser_so_is_exist && 0 != userGroupId)
        {   
            /*动态加载账号用户so中函数,将一个用户增加到用户组下*/
            DL_CALL(res, NETUSER_SO_FILE_PATH, "account_add_user_to_group", 
                    account_add, db, userGroupId, userName, user_desc);
            /*增加失败*/
            if((ERROR_SUCCESS != res) && (ERR_ACCOUNT_ID_NO_EXIST != res) && 
               (ERR_ACCOUNT_NAME_EXIST != res))
            {    
                flag = ERR_ACCOUNTUSERGROUP_ADD;
                break;
            }
        }

        /*向数据库中添加一个新用户*/
        memset (cmd, 0, sizeof(cmd));
        snprintf (cmd, 512, "INSERT OR REPLACE INTO tb_pam_user(username, password, service, enable, passwdstate, usergroupid, description) VALUES ('%s', '%s', '%d', '%d', '%d', '%d', '%s');", 
                  userName, passWord, LOCAL_AUTH_USER_DEF_SERVICE, state, 
                  passwdstate, userGroupId, user_desc);
        sys_err_code = (u32) sqlite3_exec_ex (db, cmd);
        if (SQLITE_OK != sys_err_code)
        {
            flag = ERR_USERNAME_REPEAT;
            break;
        }
        
        counter++;
    }

	if(0 != flag)
	{	
		SQLITE_TRANSC_ROLLBACK(db); 
	}
	else
	{
        SQLITE_TRANSC_COMMIT(db);
	}
    
    SQLITE_CLOSE_DB(db);    
    membuff_free(buff);

    /*删除临时文件*/
    memset (cmd, 0, sizeof(cmd));
    sprintf (cmd, "rm %s", LOCAL_AUTH_USER_CFG_PATH);
    system (cmd);

    snprintf(err_string, LOCAL_ERR_STRING_LENGTH, "Line %d %s", counter + 2, localauth_user_error_string[flag]);
    err_string[LOCAL_ERR_STRING_LENGTH - 1] = 0;

    if (flag)
    {
        return ws_send_soap_error(ws_env, localauth_user_error_string[flag]);
    }
    
    return (s32) sys_err_code;
}
Example #22
0
void libbdplus_start(BD_BDPLUS *p)
{
    if (p && p->bdplus) {
        DL_CALL(p->h_libbdplus, bdplus_start, p->bdplus);
    }
}