Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

Why it show when i complie this program with rpc function?

Somebody can help me!! :-)
Why it show when i complie this program with rpc function?
server.c:19: dereferencing pointer to incomplete type!!

server.c:
#include ....

bool_t
squareproc_2_svc(square_in *inp,square_out *outp,struct     svc_req *rqstp)
{
     printf("thread %ld started,arg=%ld,auth=%d\n",pr_thread_id(NULL),inp->arg1,rqstp->rq_cred.oa_flavor);
     
     if(rqstp->rq_cred.oa_flavor==AUTH_SYS)
     {
          struct     authsys_parms     *au;
         
          au=(struct authsys_parms *)rqstp->rq_clntcred;
//#line 19    
          printf("AUTH_SYS:host %s,uid %ld,gid %ld\n",au->aup_machname,au->aup_uid,au->aup_gid);
     }
     
     sleep(5);
     
     outp->res1=inp->arg1*inp->arg1;
     
     printf("thread %ld done\n",pr_thread_id(NULL));
     
     return(TRUE);
}

int    
square_prog_2_freeresult(SVCXPRT *transp,xdrproc_t xdr_result,caddr_t result)
{
     xdr_free(xdr_result,result);
     
     return(1);
}

mail:great_liudan@hotmail.com
0
liudan
Asked:
liudan
  • 2
  • 2
1 Solution
 
rfr1tzCommented:
So you think this is an easy problem? I think it's a homework problem.

However, assuming that line 19 is the printf statement, au is a pointer to an authsys_parms structure and then you point it at rqstp->rq_clntcred by type casting.

So au is pointing at rqstp->rq_clntcred.... (whatever that is.) But then you try to print out fields from au. But au is pointing at some junk (rqstp->rq_clntred) which I am sure is not a authsys_parms structure. So boom, you blow up.

By the way, I don't know who's picking your variable names (I know some are system names), but they are just awful - the code looks like it's encrypted.

0
 
bryanhCommented:
No, rfr1tz, that's not it.  This is a compilation failure.  The compiler has no way to know (and neither do you) that rqstp->rq_clntcred is not a struct authsys_parms.  The coder has explicitly said (via that type cast) that it is, and the compiler believes it.

The problem is that the compiler doesn't know what struct authsys_parms is.  So it can't access the "aup_machname" field of it.  The structure has not been declared.

It is presumably supposed to be declared in one of the elided (omitted) #include statements.  But the compiler is telling is that it isn't.
0
 
bryanhCommented:
And by the way, I should mention that this is not a Linux programming question.  It's a C language question.
0
 
rfr1tzCommented:
hmm, you're right bryanh, I'm wrong. As she mentions, it's a compile time problem. I was fooled by which line is line 19. I assumed it was the printf statement.
0
 
liudanAuthor Commented:
Thank you!!
I find the reason:gcc complier can't find struct authsys_parms.

struct authsys_parms {
         u_long aup_stamp;
         char *aup_machinename;
         uid_t aup_uid;
         gid_t aup_gid;
         u_int aup_len;
         gid_t *aup_gids;
      };

So i replace struct authsys_parms with struct authunix_parms in rpc/auth_unix.h.

/*
 * Unix style credentials.
 */
struct authunix_parms
  {
    u_long aup_time;
    char *aup_machname;
    __uid_t aup_uid;
    __gid_t aup_gid;
    u_int aup_len;
    __gid_t *aup_gids;
  };

This problem is solved~~~!!!
Thank bryanh & rfr1tz!!! Without your help,I can't do it!!!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now