/* * Create the client des authentication object. Obsoleted by * authdes_seccreate(). */ AUTH * authdes_create(char *servername, u_int window, struct sockaddr *syncaddr, des_block *ckey) /* * char *servername; // network name of server * u_int window; // time to live * struct sockaddr *syncaddr; // optional hostaddr to sync with * des_block *ckey; // optional conversation key to use */ { AUTH *dummy; AUTH *nauth; char hostname[NI_MAXHOST]; if (syncaddr) { /* * Change addr to hostname, because that is the way * new interface takes it. */ if (getnameinfo(syncaddr, syncaddr->sa_len, hostname, sizeof hostname, NULL, 0, 0) != 0) goto fallback; nauth = authdes_seccreate(servername, window, hostname, ckey); return (nauth); } fallback: dummy = authdes_seccreate(servername, window, NULL, ckey); return (dummy); }
/* * Create a credential that we can send to the X server. */ static int auth_ezencode( char *servername, int window, char *cred_out, int *len) { AUTH *a; XDR xdr; #if defined(SVR4) && defined(sun) a = authdes_seccreate(servername, window, NULL, NULL); #else a = (AUTH *)authdes_create(servername, window, NULL, NULL); #endif if (a == (AUTH *)NULL) { perror("auth_create"); return 0; } xdrmem_create(&xdr, cred_out, *len, XDR_ENCODE); if (AUTH_MARSHALL(a, &xdr) == FALSE) { perror("auth_marshall"); AUTH_DESTROY(a); return 0; } *len = xdr_getpos(&xdr); AUTH_DESTROY(a); return 1; }
/* * Create the client des authentication object. Obsoleted by * authdes_seccreate(). */ AUTH * authdes_create(char *servername, uint_t window, struct sockaddr_in *syncaddr, des_block *ckey) { char *hostname = NULL; if (syncaddr) { /* * Change addr to hostname, because that is the way * new interface takes it. */ struct netconfig *nconf; struct netbuf nb_syncaddr; struct nd_hostservlist *hlist; AUTH *nauth; int fd; struct t_info tinfo; if ((nconf = __rpc_getconfip("udp")) == NULL && (nconf = __rpc_getconfip("tcp")) == NULL) goto fallback; /* Transform sockaddr_in to netbuf */ if ((fd = t_open(nconf->nc_device, O_RDWR, &tinfo)) == -1) { (void) freenetconfigent(nconf); goto fallback; } (void) t_close(fd); nb_syncaddr.maxlen = nb_syncaddr.len = __rpc_get_a_size(tinfo.addr); nb_syncaddr.buf = (char *)syncaddr; if (netdir_getbyaddr(nconf, &hlist, &nb_syncaddr)) { (void) freenetconfigent(nconf); goto fallback; } if (hlist && hlist->h_cnt > 0 && hlist->h_hostservs) hostname = hlist->h_hostservs->h_host; nauth = authdes_seccreate(servername, window, hostname, ckey); (void) netdir_free((char *)hlist, ND_HOSTSERVLIST); (void) freenetconfigent(nconf); return (nauth); } fallback: return (authdes_seccreate(servername, window, hostname, ckey)); }
void _Tt_db_client::createAuth () { #ifdef OPT_SECURE_RPC if (dbAuthLevel == AUTH_DES) { if (dbServer->cl_auth) { auth_destroy(dbServer->cl_auth); } const int CRED_EXPIRE = 10; #ifdef OPT_TLI dbServer->cl_auth = authdes_seccreate((char *)dbServerNetName, CRED_EXPIRE, (char *)dbServerNetName, 0); #else dbServer->cl_auth = authdes_create((char *)dbServerNetName, CRED_EXPIRE, &dbSocket, 0); #endif } #endif // OPT_SECURE_RPC }
int yp_update(char *domain, char *map, unsigned op, char *key, int keylen, char *data, int datalen) { struct ypupdate_args args; uint_t rslt; struct timeval total; CLIENT *client; char *ypmaster; char ypmastername[MAXNETNAMELEN+1]; enum clnt_stat stat; uint_t proc; switch (op) { case YPOP_DELETE: proc = YPU_DELETE; break; case YPOP_INSERT: proc = YPU_INSERT; break; case YPOP_CHANGE: proc = YPU_CHANGE; break; case YPOP_STORE: proc = YPU_STORE; break; default: return (YPERR_BADARGS); } if (yp_master(domain, map, &ypmaster) != 0) { debug("no master found"); return (YPERR_BADDB); } client = clnt_create(ypmaster, YPU_PROG, YPU_VERS, "circuit_n"); if (client == NULL) { #ifdef DEBUG /* CONSTCOND */ if (debugging) { clnt_pcreateerror("client create failed"); } #endif /* DEBUG */ free(ypmaster); return (YPERR_RPC); } if (!host2netname(ypmastername, ypmaster, domain)) { clnt_destroy(client); free(ypmaster); return (YPERR_BADARGS); } client->cl_auth = authdes_seccreate(ypmastername, WINDOW, ypmaster, NULL); free(ypmaster); if (client->cl_auth == NULL) { debug("auth create failed"); clnt_destroy(client); return (YPERR_RPC); } args.mapname = map; args.key.yp_buf_len = keylen; args.key.yp_buf_val = key; args.datum.yp_buf_len = datalen; args.datum.yp_buf_val = data; total.tv_sec = TOTAL_TIMEOUT; total.tv_usec = 0; clnt_control(client, CLSET_TIMEOUT, (char *)&total); stat = clnt_call(client, proc, xdr_ypupdate_args, (char *)&args, xdr_u_int, (char *)&rslt, total); if (stat != RPC_SUCCESS) { #ifdef DEBUG debug("ypupdate RPC call failed"); /* CONSTCOND */ if (debugging) clnt_perror(client, "ypupdate call failed"); #endif /* DEBUG */ rslt = YPERR_RPC; } auth_destroy(client->cl_auth); clnt_destroy(client); return (rslt); }