Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
/*	$NetBSD: pam_unix.c,v 1.17 2018/05/16 13:55:39 joerg Exp $	*/

/*-
 * Copyright 1998 Juniper Networks, Inc.
 * All rights reserved.
 * Copyright (c) 2002-2003 Networks Associates Technology, Inc.
 * All rights reserved.
 *
 * Portions of this software was developed for the FreeBSD Project by
 * ThinkSec AS and NAI Labs, the Security Research Division of Network
 * Associates, Inc.  under DARPA/SPAWAR contract N66001-01-C-8035
 * ("CBOSS"), as part of the DARPA CHATS research program.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote
 *    products derived from this software without specific prior written
 *    permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#include <sys/cdefs.h>
#ifdef __FreeBSD__
__FBSDID("$FreeBSD: src/lib/libpam/modules/pam_unix/pam_unix.c,v 1.49 2004/02/10 10:13:21 des Exp $");
#else
__RCSID("$NetBSD: pam_unix.c,v 1.17 2018/05/16 13:55:39 joerg Exp $");
#endif


#include <sys/types.h>

#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
#include <grp.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <login_cap.h>
#include <time.h>
#include <tzfile.h>
#include <unistd.h>

#include <util.h>

#ifdef YP
#include <rpc/rpc.h>
#include <rpcsvc/ypclnt.h>
#include <rpcsvc/yppasswd.h>
#endif

#define PAM_SM_AUTH
#define PAM_SM_ACCOUNT
#define	PAM_SM_PASSWORD

#include <security/pam_appl.h>
#include <security/pam_modules.h>
#include <security/pam_mod_misc.h>

/*
 * authentication management
 */
PAM_EXTERN int
/*ARGSUSED*/
pam_sm_authenticate(pam_handle_t *pamh, int flags __unused,
    int argc __unused, const char *argv[] __unused)
{
	login_cap_t *lc;
	struct passwd *pwd, pwres;
	int retval;
	const char *pass, *user, *realpw;
	char pwbuf[1024];

	pwd = NULL;
	if (openpam_get_option(pamh, PAM_OPT_AUTH_AS_SELF)) {
		(void) getpwnam_r(getlogin(), &pwres, pwbuf, sizeof(pwbuf),
				  &pwd);
	} else {
		retval = pam_get_user(pamh, &user, NULL);
		if (retval != PAM_SUCCESS)
			return (retval);
		PAM_LOG("Got user: %s", user);
		(void) getpwnam_r(user, &pwres, pwbuf, sizeof(pwbuf), &pwd);
	}

	if (pwd != NULL) {
		PAM_LOG("Doing real authentication");
		realpw = pwd->pw_passwd;
		if (realpw[0] == '\0') {
			if (!(flags & PAM_DISALLOW_NULL_AUTHTOK) &&
			    openpam_get_option(pamh, PAM_OPT_NULLOK))
				return (PAM_SUCCESS);
			realpw = "*";
		}
	} else {
		PAM_LOG("Doing dummy authentication");
		realpw = "*";
	}
	lc = login_getpwclass(pwd);
	retval = pam_get_authtok(pamh, PAM_AUTHTOK, &pass, NULL);
	login_close(lc);
	if (retval != PAM_SUCCESS)
		return (retval);
	PAM_LOG("Got password");
	if (strcmp(crypt(pass, realpw), realpw) == 0)
		return (PAM_SUCCESS);

	PAM_VERBOSE_ERROR("UNIX authentication refused");
	return (PAM_AUTH_ERR);
}

PAM_EXTERN int
/*ARGSUSED*/
pam_sm_setcred(pam_handle_t *pamh __unused, int flags __unused,
    int argc __unused, const char *argv[] __unused)
{

	return (PAM_SUCCESS);
}

/*
 * account management
 */
PAM_EXTERN int
/*ARGSUSED*/
pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused,
    int argc __unused, const char *argv[] __unused)
{
	struct passwd *pwd, pwres;
	struct timeval now;
	login_cap_t *lc;
	time_t warntime;
	int retval;
	const char *user;
	char pwbuf[1024];

	retval = pam_get_user(pamh, &user, NULL);
	if (retval != PAM_SUCCESS)
		return (retval);

	if (user == NULL ||
	    getpwnam_r(user, &pwres, pwbuf, sizeof(pwbuf), &pwd) != 0 ||
	    pwd == NULL)
		return (PAM_SERVICE_ERR);

	PAM_LOG("Got user: %s", user);

	if (*pwd->pw_passwd == '\0' &&
	    (flags & PAM_DISALLOW_NULL_AUTHTOK) != 0)
		return (PAM_NEW_AUTHTOK_REQD);

	lc = login_getpwclass(pwd);
	if (lc == NULL) {
		PAM_LOG("Unable to get login class for user %s", user);
		return (PAM_SERVICE_ERR);
	}

	PAM_LOG("Got login_cap");

	if (pwd->pw_change || pwd->pw_expire)
		(void) gettimeofday(&now, NULL);

	warntime = (time_t)login_getcaptime(lc, "password-warn",
	    (quad_t)(_PASSWORD_WARNDAYS * SECSPERDAY),
	    (quad_t)(_PASSWORD_WARNDAYS * SECSPERDAY));

	/*
	 * Check pw_expire before pw_change - no point in letting the
	 * user change the password on an expired account.
	 */

	if (pwd->pw_expire) {
		if (now.tv_sec >= pwd->pw_expire) {
			login_close(lc);
			return (PAM_ACCT_EXPIRED);
		} else if (pwd->pw_expire - now.tv_sec < warntime &&
		    (flags & PAM_SILENT) == 0) {
			pam_error(pamh, "Warning: your account expires on %s",
			    ctime(&pwd->pw_expire));
		}
	}

	if (pwd->pw_change) {
		/* XXX How to handle _PASSWORD_CHGNOW?  --thorpej */
		if (now.tv_sec >= pwd->pw_change) {
			login_close(lc);
			return (PAM_NEW_AUTHTOK_REQD);
		} else if (pwd->pw_change - now.tv_sec < warntime &&
		    (flags & PAM_SILENT) == 0) {
			pam_error(pamh, "Warning: your password expires on %s",
			    ctime(&pwd->pw_change));
		}
	}

	login_close(lc);

	return (PAM_SUCCESS);
}

#ifdef YP
/*
 * yp_check_user:
 *
 *	Helper function; check that a user exists in the NIS
 *	password map.
 */
static int
yp_check_user(const char *domain, const char *user)
{
	char *val;
	int reason, vallen;

	val = NULL;
	reason = yp_match(domain, "passwd.byname", user, (int)strlen(user),
	    &val, &vallen);
	if (reason != 0) {
		if (val != NULL)
			free(val);
		return (0);
	}
	free(val);
	return (1);
}

static int
/*ARGSUSED*/
yp_set_password(pam_handle_t *pamh, struct passwd *opwd,
    struct passwd *pwd, const char *old_pass, const char *domain)
{
	char *master;
	int r, rpcport, status;
	enum clnt_stat r2;
	struct yppasswd yppwd;
	CLIENT *client;
	uid_t uid;
	int retval = PAM_SERVICE_ERR;
	struct timeval tv;

	/*
	 * Find the master for the passwd map; it should be running
	 * rpc.yppasswdd.
	 */
	if ((r = yp_master(domain, "passwd.byname", &master)) != 0) {
		pam_error(pamh, "Can't find master NIS server.  Reason: %s",
		    yperr_string(r));
		return (PAM_SERVICE_ERR);
	}

	/*
	 * Ask the portmapper for the port of rpc.yppasswdd.
	 */
	if ((rpcport = getrpcport(master, YPPASSWDPROG,
				  YPPASSWDPROC_UPDATE, IPPROTO_UDP)) == 0) {
		pam_error(pamh,
		    "Master NIS server not runing yppasswd daemon.\n\t"
		    "Can't change NIS password.");
		return (PAM_SERVICE_ERR);
	}

	/*
	 * Be sure the port is privileged.
	 */
	if (rpcport >= IPPORT_RESERVED) {
		pam_error(pamh, "yppasswd daemon is on an invalid port.");
		return (PAM_SERVICE_ERR);
	}

	uid = getuid();
	if (uid != 0 && uid != pwd->pw_uid) {
		pam_error(pamh, "You may only change your own password: %s",
		    strerror(EACCES));
		return (PAM_SERVICE_ERR);
	}

	/*
	 * Fill in the yppasswd structure for yppasswdd.
	 */
	memset(&yppwd, 0, sizeof(yppwd));
	yppwd.oldpass = strdup(old_pass);
	if ((yppwd.newpw.pw_passwd = strdup(pwd->pw_passwd)) == NULL)
		goto malloc_failure;
	if ((yppwd.newpw.pw_name = strdup(pwd->pw_name)) == NULL)
		goto malloc_failure;
	yppwd.newpw.pw_uid = (int)pwd->pw_uid;
	yppwd.newpw.pw_gid = (int)pwd->pw_gid;
	if ((yppwd.newpw.pw_gecos = strdup(pwd->pw_gecos)) == NULL)
		goto malloc_failure;
	if ((yppwd.newpw.pw_dir = strdup(pwd->pw_dir)) == NULL)
		goto malloc_failure;
	if ((yppwd.newpw.pw_shell = strdup(pwd->pw_shell)) == NULL)
		goto malloc_failure;

	client = clnt_create(master, YPPASSWDPROG, YPPASSWDVERS, "udp");
	if (client == NULL) {
		pam_error(pamh, "Can't contact yppasswdd on %s: Reason: %s",
		    master, yperr_string(YPERR_YPBIND));
		goto out;
	}

	client->cl_auth = authunix_create_default();
	tv.tv_sec = 2;
	tv.tv_usec = 0;
	r2 = clnt_call(client, YPPASSWDPROC_UPDATE,
	    xdr_yppasswd, &yppwd, xdr_int, &status, tv);
	if (r2 != RPC_SUCCESS)
		pam_error(pamh, "RPC to yppasswdd failed.");
	else if (status)
		pam_error(pamh, "Couldn't change NIS password.");
	else {
		pam_info(pamh, "The NIS password has been changed on %s, "
		    "the master NIS passwd server.", master);
		retval = PAM_SUCCESS;
	}

 out:
	if (yppwd.oldpass != NULL)
		free(yppwd.oldpass);
	if (yppwd.newpw.pw_passwd != NULL)
		free(yppwd.newpw.pw_passwd);
	if (yppwd.newpw.pw_name != NULL)
		free(yppwd.newpw.pw_name);
	if (yppwd.newpw.pw_gecos != NULL)
		free(yppwd.newpw.pw_gecos);
	if (yppwd.newpw.pw_dir != NULL)
		free(yppwd.newpw.pw_dir);
	if (yppwd.newpw.pw_shell != NULL)
		free(yppwd.newpw.pw_shell);
	return (retval);

 malloc_failure:
	pam_error(pamh, "memory allocation failure");
	goto out;
}
#endif /* YP */

static int
local_set_password(pam_handle_t *pamh, struct passwd *opwd,
    struct passwd *pwd)
{
	char errbuf[200];
	int tfd, pfd;

	pw_init();
	tfd = pw_lock(0);
	if (tfd < 0) {
		pam_error(pamh, "The password file is busy, waiting...");
		tfd = pw_lock(10);
		if (tfd < 0) {
			pam_error(pamh, "The password file is still busy, "
			    "try again later.");
			return (PAM_SERVICE_ERR);
		}
	}

	pfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0);
	if (pfd < 0) {
		pam_error(pamh, "%s: %s", _PATH_MASTERPASSWD, strerror(errno));
		pw_abort();
		return (PAM_SERVICE_ERR);
	}

	if (pw_copyx(pfd, tfd, pwd, opwd, errbuf, sizeof(errbuf)) == 0) {
		pam_error(pamh, "Unable to update password entry: %s",
		    errbuf);
		pw_abort();
		return (PAM_SERVICE_ERR);
	}

	if (pw_mkdb(pwd->pw_name, opwd->pw_change == pwd->pw_change) < 0) {
		pam_error(pamh, "Unable to rebuild local password database.");
		pw_abort();
		return (PAM_SERVICE_ERR);
	}

	return (PAM_SUCCESS);
}

/*
 * password management
 *
 * standard Unix and NIS password changing
 */
PAM_EXTERN int
/*ARGSUSED*/
pam_sm_chauthtok(pam_handle_t *pamh, int flags,
    int argc __unused, const char *argv[] __unused)
{
	struct passwd *pwd, new_pwd, old_pwd;
	login_cap_t *lc;
	const char *user, *passwd_db, *new_pass, *old_pass, *p;
	int retval, tries, min_pw_len = 0, pw_expiry = 0;
	char salt[_PASSWORD_LEN+1];
	char old_pwbuf[1024];
#ifdef YP
	char *domain;
	int r;
#endif

	pwd = NULL;
	if (openpam_get_option(pamh, PAM_OPT_AUTH_AS_SELF)) {
		if ((user = getlogin()) == NULL) {
			pam_error(pamh, "Unable to determine user.");
			return (PAM_SERVICE_ERR);
		}
		(void) getpwnam_r(user, &old_pwd, old_pwbuf,
				  sizeof(old_pwbuf), &pwd);
	} else {
		retval = pam_get_user(pamh, &user, NULL);
		if (retval != PAM_SUCCESS)
			return (retval);
		(void) getpwnam_r(user, &old_pwd, old_pwbuf,
				  sizeof(old_pwbuf), &pwd);
	}

	if (pwd == NULL)
		return (PAM_AUTHTOK_RECOVERY_ERR);

	PAM_LOG("Got user: %s", user);

	/*
	 * Determine which password type we're going to change, and
	 * remember it.
	 *
	 * NOTE: domain does not need to be freed; its storage is
	 * allocated statically in libc.
	 */
	passwd_db = openpam_get_option(pamh, "passwd_db");
	if (passwd_db == NULL) {
#ifdef YP
		/* Prefer YP, if configured. */
		if (_yp_check(NULL)) {
			/* If _yp_check() succeeded, then this must. */
			if ((r = yp_get_default_domain(&domain)) != 0) {
				pam_error(pamh,
				    "Unable to get NIS domain, reason: %s",
				    yperr_string(r));
				return (PAM_SERVICE_ERR);
			}
			if (yp_check_user(domain, user))
				passwd_db = "nis";
		}
#endif
		/* Otherwise we always use local files. */
		if (passwd_db == NULL) {
			/* XXX Any validation to do here? */
			passwd_db = "files";
		}

		if ((retval = openpam_set_option(pamh, "passwd_db",
		    passwd_db)) != PAM_SUCCESS) {
			return (retval);
		}
	} else {
		/* Check to see if the specified password DB is usable. */
#ifdef YP
		if (strcmp(passwd_db, "nis") == 0) {
			if (_yp_check(NULL) == 0) {
				pam_error(pamh, "NIS not in use.");
				return (PAM_SERVICE_ERR);
			}
			if ((r = yp_get_default_domain(&domain)) != 0) {
				pam_error(pamh,
				    "Unable to get NIS domain, reason: %s",
				    yperr_string(r));
				return (PAM_SERVICE_ERR);
			}
			if (yp_check_user(domain, user) == 0) {
				pam_error(pamh,
				    "User %s does not exist in NIS.", user);
				return (PAM_USER_UNKNOWN);
			}
			goto known_passwd_db;
		}
#endif
		if (strcmp(passwd_db, "files") == 0) {
			/* XXX Any validation to do here? */
			goto known_passwd_db;
		}
		pam_error(pamh, "Unknown Unix password DB: %s", passwd_db);
		return (PAM_SERVICE_ERR);
	}
 known_passwd_db:

	if (flags & PAM_PRELIM_CHECK) {
		PAM_LOG("PRELIM round");

		if (strcmp(passwd_db, "files") == 0) {
			if (getuid() == 0) {
				/* Root doesn't need the old password. */
				return (pam_set_item(pamh, PAM_OLDAUTHTOK, ""));
			}
			/*
			 * Apparently we're not root, so let's forbid editing
			 * root.
			 * XXX Check for some flag to indicate if this
			 * XXX is the desired behavior.
			 */
			if (pwd->pw_uid == 0)
				return (PAM_PERM_DENIED);
		}

		if (pwd->pw_passwd[0] == '\0') {
			/*
			 * No password case.
			 * XXX Are we giviing too much away by not prompting
			 * XXX for a password?
			 * XXX Check PAM_DISALLOW_NULL_AUTHTOK
			 */
			return (pam_set_item(pamh, PAM_OLDAUTHTOK, ""));
		} else {
			retval = pam_get_authtok(pamh, PAM_OLDAUTHTOK,
			    &old_pass, NULL);
			if (retval != PAM_SUCCESS)
				return (retval);
			if (strcmp(crypt(old_pass, pwd->pw_passwd),
				   pwd->pw_passwd) != 0)
				return (PAM_PERM_DENIED);
			return (PAM_SUCCESS);
		}
	}

	if (flags & PAM_UPDATE_AUTHTOK) {
		char option[LINE_MAX], *key, *opt;

		PAM_LOG("UPDATE round");

		if ((lc = login_getpwclass(pwd)) != NULL) {
			min_pw_len = (int) login_getcapnum(lc,
			    "minpasswordlen", (quad_t)0, (quad_t)0);
			pw_expiry = (int) login_getcapnum(lc,
			    "passwordtime", (quad_t)0, (quad_t)0);
			login_close(lc);
		}

		retval = pam_get_authtok(pamh, PAM_OLDAUTHTOK, &old_pass, NULL);
		if (retval != PAM_SUCCESS)
			return (retval);

		/* Get the new password. */
		for (tries = 0;;) {
			retval = pam_get_authtok(pamh, PAM_AUTHTOK, &new_pass,
			    NULL);
			if (retval == PAM_TRY_AGAIN) {
				pam_error(pamh,
				    "Mismatch; try again, EOF to quit.");
				continue;
			}
			if (retval != PAM_SUCCESS) {
				PAM_VERBOSE_ERROR("Unable to get new password");
				return (retval);
			}
			/* Successfully got new password. */
			if (new_pass[0] == '\0') {
				pam_info(pamh, "Password unchanged.");
				return (PAM_SUCCESS);
			}
			if (min_pw_len > 0 && strlen(new_pass) < (size_t)min_pw_len) {
				pam_error(pamh, "Password is too short.");
				goto retry;
			}
			if (strlen(new_pass) <= 5 && ++tries < 2) {
				pam_error(pamh,
				    "Please enter a longer password.");
				goto retry;
			}
			for (p = new_pass; *p && islower((unsigned char)*p); ++p);
			if (!*p && ++tries < 2) {
				pam_error(pamh,
				    "Please don't use an all-lower case "
				    "password.\nUnusual capitalization, "
				    "control characters or digits are "
				    "suggested.");
				goto retry;
			}
			/* Password is OK. */
			break;
retry:
			pam_set_item(pamh, PAM_AUTHTOK, NULL);
		}
		pw_getpwconf(option, sizeof(option), pwd, 
#ifdef YP
		    strcmp(passwd_db, "nis") == 0 ? "ypcipher" :
#endif
		    "localcipher");
		opt = option;
		key = strsep(&opt, ",");

		if (pw_gensalt(salt, _PASSWORD_LEN, key, opt) == -1) {
			pam_error(pamh, "Couldn't generate salt.");
			return (PAM_SERVICE_ERR);
		}

		new_pwd = old_pwd;
		pwd = &new_pwd;
		pwd->pw_passwd = crypt(new_pass, salt);
		pwd->pw_change = pw_expiry ? pw_expiry + time(NULL) : 0;

		retval = PAM_SERVICE_ERR;
		if (strcmp(passwd_db, "files") == 0)
			retval = local_set_password(pamh, &old_pwd, pwd);
#ifdef YP
		if (strcmp(passwd_db, "nis") == 0)
			retval = yp_set_password(pamh, &old_pwd, pwd, old_pass,
			    domain);
#endif
		return (retval);
	}

	PAM_LOG("Illegal flags argument");
	return (PAM_ABORT);
}

PAM_MODULE_ENTRY("pam_unix");