static int get_pwnam (pwd_drv_t *drv, char *cmd) { struct passwd *pwd = getpwnam (cmd); if (!pwd) { fprintf (drv->log, "getpwnam returns NULL for %s\n", cmd); fflush (drv->log); return send_error (drv, "error", "unknown_name"); } size_t result_count = 0; ErlDrvTermData *result = make_passwd (drv, pwd, &result_count); if (!result) { return send_error (drv, "error", "Couldn't allocate memory"); } int r = driver_output_term (drv->port, result, result_count); driver_free (result); return r; }
static int get_pwuid (pwd_drv_t *drv, char *cmd) { __uid_t uid = atoi (cmd); struct passwd *pwd = getpwuid (uid); if (!pwd) { fprintf (drv->log, "getpwuid returns NULL for %s\n", cmd); fflush (drv->log); return send_error (drv, "error", "unknown_uid"); } size_t result_count = 0; ErlDrvTermData *result = make_passwd (drv, pwd, &result_count); if (!result) { return send_error (drv, "error", "Couldn't allocate memory"); } int r = send_wrapped (driver_mk_port(drv->port), result, result_count); driver_free (result); return r; }
/* ARGSUSED */ int * yppasswdproc_update_1_svc(yppasswd *argp, struct svc_req *rqstp, SVCXPRT *transp) { static int res; bzero((char *)&res, sizeof(res)); res = make_passwd(argp); if (!svc_sendreply(transp, xdr_int, (char *)&res)) svcerr_systemerr(transp); if (!svc_freeargs(transp, xdr_yppasswd, (caddr_t) argp)) { syslog(LOG_ERR, "unable to free arguments"); exit(1); } return ((void *)&res); }