npd_ypfwd.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
#include <syslog.h>
#include <rpcsvc/yppasswd.h>
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* NPD routine to forward password update request to YP
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* This function is pretty much lifted from
* lib/scheme/pm_scheme/pam_update_authtok_nis.c:update_authtok_nis().
*
* The only difference is that we are taking requests from NPD to
* forward a password change to a YP database after the NIS+ database
* has already been updated. If this change fails, then we must undo
* the NIS+ change as well. Only at Sun can something like this exist...
*
* This function is called only from npd_svc.c:nispasswd_update_1_svc()
* or npd_svc.c:yppasswd_update_1_svc(). The set of variables are similar
* so I've provided a translation table below:
*
* variable nispasswd yppasswd what is it?
* -------- --------- -------- -----------
* usrname entry->ul_user newpass->pw_name user name
* newpwe newpass newpass->pw_passwd encr new passwd
* XX oldpwe old_pass old_pass encr old passwd
* oldpwu entry->ol_oldpass yppass->oldpass clear old passwd
* XX newpwu pass <N/A> clear new passwd
* master ypfwd ypfwd YP master to fwd
* gecos old_gecos old_gecos original gecos
* shell old_shell old_shell original shell
*/
int
char *usrname, /* user name */
char *newpwe, /* encrypted new passwd */
char *oldpwu, /* clear old passwd */
char *master, /* passwd master YP machine */
char *gecos, /* (unchanged) general comments */
char *shell) /* (unchanged) login shell */
{
int retval = 0; /* value to return */
int ok; /* update return status */
const char *fnam = "update_authok_nis_fwd";
/* function name */
/* NPD uses 55 seconds */
/*
* ck_passwd() already checked the old passwd. It won't get here
* if the old passwd is not matched. We are just preparing the
* yppasswd update packet here.
*/
"udp"))) {
return (-1);
}
"%s: can't change NIS(YP) passwd for %s on %s (err: %d)\n",
if (ans != RPC_SUCCESS) {
"RPC call failed -- client may have timed-out.");
"%s: client could not make RPC call.\n", fnam);
retval = -1;
}
} else {
}
(void) clnt_destroy(client);
return (retval);
}