客户端上的 UNIX 认证
要使用 UNIX 身份验证,程序员首先要创建远程过程调用(RPC)客户端句柄,然后设置身份验证参数。
将按如下所示创建 RPC 客户机句柄:
clnt = clntudp_create (address, prognum, versnum, wait, sockp)
UNIX 认证参数设置如下:
clnt->cl_auth = authunix_create_default();
与客户机关联的每个远程过程调用(clnt)然后携带以下 UNIX 样式的认证凭证结构:
/*
* UNIX style credentials.
*/
struct authunix_parms {
u_long aup_time; /* credentials creation time */
char *aup_machname; /* host name where client is */
int aup_uid; /* client's UNIX effective uid */
int aup_gid; /* client's current group id */
u_int aup_len; /* element length of aup_gids */
int *aup_gids; /* array of groups user is in */
};
authunix_create_default 子例程通过调用相应的子例程来设置这些字段。 在使用以下例程销毁之前, UNIX 样式的认证有效:
auth_destroy(clnt->cl_auth);