예제 #1
0
DWORD
VMCAGetClientName(handle_t IDL_handle)
{
#if DEBUG_RPC
  rpc_binding_handle_t Srv;
  PSTR pszBinding = NULL;
  PSTR pszObjUUID = NULL;
  PSTR pszProtoSeq = NULL;
  PSTR pszNetworkAddress = NULL;
  PSTR pszEndPoint = NULL;
  PSTR pszNetworkOptions = NULL;


  unsigned32 rs = 0;
  rpc_binding_server_from_client (IDL_handle, &Srv, &rs);
  BAIL_ON_VMCA_ERROR(rs);
  rpc_binding_to_string_binding(Srv,
                        (unsigned char **) &pszBinding, &rs);
  printf("Binding Info : %s\n", pszBinding);
  rpc_binding_free(&Srv, &rs);

  rpc_string_binding_parse(pszBinding,
                        (unsigned_char_t **) &pszObjUUID,
                        (unsigned_char_t **) &pszProtoSeq,
                        (unsigned_char_t **) &pszNetworkAddress,
                        (unsigned_char_t **) &pszEndPoint,
                        (unsigned_char_t **) &pszNetworkOptions,
                        &rs);
  printf("Obj UUID : %s, Proto : %s, Network : %s, \
            EndPoint %s, Network Options : %s \n",
            pszObjUUID,
            pszProtoSeq,
            pszNetworkAddress,
            pszEndPoint,
            pszNetworkOptions);

    rpc_string_free((unsigned_char_t **) &pszBinding, &rs);
    rpc_string_free((unsigned_char_t **) &pszObjUUID, &rs);
    rpc_string_free((unsigned_char_t **) &pszProtoSeq, &rs);
    rpc_string_free((unsigned_char_t **) &pszNetworkAddress, &rs);
    rpc_string_free((unsigned_char_t **) &pszEndPoint, &rs);
    rpc_string_free((unsigned_char_t **) &pszNetworkOptions, &rs);
#endif
    return 0;
}
예제 #2
0
INTERNAL int is_unpriv_handle( handle_t h, error_status_t *st )
{

    error_status_t status,status1;
    rpc_binding_vector_p_t bv;
    handle_t binding;
    unsigned_char_p_t stb,our_netaddr,client_netaddr;
    unsigned32 i;
    static unsigned_char_p_t *local_netaddr = NULL;
    static unsigned32 addr_count = 0;
    unsigned32 prot_seq = 0;
    rpc_transport_info_handle_t info;
    unsigned32 uid = (unsigned32) -1;
    unsigned32 gid = (unsigned32) -1;

    rpc_binding_inq_prot_seq(h, &prot_seq, &status);

    if (! STATUS_OK(&status))
    {
        *st = status;
        return(1);
    }

    if (prot_seq == rpc_c_protseq_id_ncalrpc)
    {
        rpc_binding_inq_transport_info(h, &info, &status);

        if (! STATUS_OK(&status))
        {
            *st = status;
            return(1);
        }

        rpc_lrpc_transport_info_inq_peer_eid(info, &uid, &gid);

        *st = rpc_s_ok;

        return (uid != 0);
    }

/* Get client network address from binding handle (client_netaddr) */

    rpc_binding_server_from_client(h,&binding,&status);
    if (! STATUS_OK(&status))
    {
        *st = status;
        return(1);
    }
    rpc_binding_to_string_binding(binding,&stb,&status);

    if (! STATUS_OK(&status))
    {
        rpc_binding_free(&binding,&status1);
        *st = status;
        return(1);
    }
    rpc_binding_free(&binding,&status1);

    rpc_string_binding_parse(stb,NULL,NULL,&client_netaddr,NULL,NULL,&status);
    if (! STATUS_OK(&status))
    {
        rpc_string_free(&stb,&status1);
        *st = status;
        return(1);
    }
    rpc_string_free(&stb,&status1);

    /*
     * Lookup all of the addresses which this node answers to.
     * Cache these in static storage so we only do this work once.
     */
    if (addr_count == 0)
    {
        rpc_server_inq_bindings(&bv,&status);
        if (! STATUS_OK(&status))
        {
            rpc_string_free(&client_netaddr,&status1);
            *st = status;
            return(1);
        }

        addr_count = bv->count;
        local_netaddr = (unsigned_char_p_t *) malloc(
                        (size_t) (addr_count * sizeof(unsigned_char_p_t)));
        if (local_netaddr == NULL)
        {
            rpc_string_free(&client_netaddr,&status1);
            rpc_binding_vector_free(&bv,&status1);
            *st = ept_s_no_memory;
            return(1);
        }

        for ( i=0; i < bv->count; i++ )
        {
            rpc_binding_to_string_binding(bv->binding_h[i],&stb,&status);
            if (! STATUS_OK(&status))
            {
                rpc_binding_vector_free(&bv,&status1);
                rpc_string_free(&client_netaddr,&status1);
                *st = status;
                return(1);
            }
            rpc_string_binding_parse(stb,NULL,NULL,
                                     &our_netaddr,NULL,NULL,&status);
            if (! STATUS_OK(&status))
            {
                rpc_binding_vector_free(&bv,&status1);
                rpc_string_free(&stb,&status1);
                rpc_string_free(&client_netaddr,&status1);
                *st = status;
                return(1);
            }

            local_netaddr[i] = our_netaddr;
            rpc_string_free(&stb,&status1);
        }
        rpc_binding_vector_free(&bv,&status1);
    }

    /*
     * Compare the addresses with the client address
     */
    *st = rpc_s_ok;
    for ( i=0; i < addr_count; i++ )
    {
        if(strcmp((char*) client_netaddr, (char*) local_netaddr[i]) == 0)
        {
            rpc_string_free(&client_netaddr,&status1);
            return(0);
        }
    }
    rpc_string_free(&client_netaddr,&status1);
    return(1);

}