liudan
asked on
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_fl avor);
if(rqstp->rq_cred.oa_flavo r==AUTH_SY S)
{
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_gi d);
}
sleep(5);
outp->res1=inp->arg1*inp-> arg1;
printf("thread %ld done\n",pr_thread_id(NULL) );
return(TRUE);
}
int
square_prog_2_freeresult(S VCXPRT *transp,xdrproc_t xdr_result,caddr_t result)
{
xdr_free(xdr_result,result );
return(1);
}
mail:great_liudan@hotmail. com
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
{
printf("thread %ld started,arg=%ld,auth=%d\n"
if(rqstp->rq_cred.oa_flavo
{
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
}
sleep(5);
outp->res1=inp->arg1*inp->
printf("thread %ld done\n",pr_thread_id(NULL)
return(TRUE);
}
int
square_prog_2_freeresult(S
{
xdr_free(xdr_result,result
return(1);
}
mail:great_liudan@hotmail.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And by the way, I should mention that this is not a Linux programming question. It's a C language question.
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.
ASKER
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!!!
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!!!
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.