ftpd.c (674400eb20b65369a88b1cb778d729bc297832c9) ftpd.c (0aa2700123e22c2b0a977375e087dc2759b8e980)
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1985, 1988, 1990, 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 63 unchanged lines hidden (view full) ---

72#include <err.h>
73#include <errno.h>
74#include <fcntl.h>
75#include <glob.h>
76#include <limits.h>
77#include <netdb.h>
78#include <pwd.h>
79#include <grp.h>
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1985, 1988, 1990, 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 63 unchanged lines hidden (view full) ---

72#include <err.h>
73#include <errno.h>
74#include <fcntl.h>
75#include <glob.h>
76#include <limits.h>
77#include <netdb.h>
78#include <pwd.h>
79#include <grp.h>
80#include <opie.h>
81#include <signal.h>
82#include <stdint.h>
83#include <stdio.h>
84#include <stdlib.h>
85#include <string.h>
86#include <syslog.h>
87#include <time.h>
88#include <unistd.h>

--- 86 unchanged lines hidden (view full) ---

175
176static char wtmpid[20];
177
178#ifdef USE_PAM
179static int auth_pam(struct passwd**, const char*);
180pam_handle_t *pamh = NULL;
181#endif
182
80#include <signal.h>
81#include <stdint.h>
82#include <stdio.h>
83#include <stdlib.h>
84#include <string.h>
85#include <syslog.h>
86#include <time.h>
87#include <unistd.h>

--- 86 unchanged lines hidden (view full) ---

174
175static char wtmpid[20];
176
177#ifdef USE_PAM
178static int auth_pam(struct passwd**, const char*);
179pam_handle_t *pamh = NULL;
180#endif
181
183static struct opie opiedata;
184static char opieprompt[OPIE_CHALLENGE_MAX+1];
185static int pwok;
186
187char *pid_file = NULL; /* means default location to pidfile(3) */
188
189/*
190 * Limit number of pathnames that glob can return.
191 * A limit of 0 indicates the number of pathnames is unlimited.
192 */
193#define MAXGLOBARGS 16384
194#

--- 865 unchanged lines hidden (view full) ---

1060 remotehost, name);
1061 pw = NULL;
1062 return;
1063 }
1064 }
1065 if (logging)
1066 strlcpy(curname, name, sizeof(curname));
1067
182char *pid_file = NULL; /* means default location to pidfile(3) */
183
184/*
185 * Limit number of pathnames that glob can return.
186 * A limit of 0 indicates the number of pathnames is unlimited.
187 */
188#define MAXGLOBARGS 16384
189#

--- 865 unchanged lines hidden (view full) ---

1055 remotehost, name);
1056 pw = NULL;
1057 return;
1058 }
1059 }
1060 if (logging)
1061 strlcpy(curname, name, sizeof(curname));
1062
1068 pwok = 0;
1069#ifdef USE_PAM
1070 /* XXX Kluge! The conversation mechanism needs to be fixed. */
1071#endif
1072 if (opiechallenge(&opiedata, name, opieprompt) == 0) {
1073 pwok = (pw != NULL) &&
1074 opieaccessfile(remotehost) &&
1075 opiealways(pw->pw_dir);
1076 reply(331, "Response to %s %s for %s.",
1077 opieprompt, pwok ? "requested" : "required", name);
1078 } else {
1079 pwok = 1;
1080 reply(331, "Password required for %s.", name);
1081 }
1063 reply(331, "Password required for %s.", name);
1082 askpasswd = 1;
1083 /*
1084 * Delay before reading passwd after first failed
1085 * attempt to slow down passwd-guessing programs.
1086 */
1087 if (login_attempts)
1088 sleep(login_attempts);
1089}

--- 298 unchanged lines hidden (view full) ---

1388 if (!guest) { /* "ftp" is only account allowed no password */
1389 if (pw == NULL) {
1390 rval = 1; /* failure below */
1391 goto skip;
1392 }
1393#ifdef USE_PAM
1394 rval = auth_pam(&pw, passwd);
1395 if (rval >= 0) {
1064 askpasswd = 1;
1065 /*
1066 * Delay before reading passwd after first failed
1067 * attempt to slow down passwd-guessing programs.
1068 */
1069 if (login_attempts)
1070 sleep(login_attempts);
1071}

--- 298 unchanged lines hidden (view full) ---

1370 if (!guest) { /* "ftp" is only account allowed no password */
1371 if (pw == NULL) {
1372 rval = 1; /* failure below */
1373 goto skip;
1374 }
1375#ifdef USE_PAM
1376 rval = auth_pam(&pw, passwd);
1377 if (rval >= 0) {
1396 opieunlock();
1397 goto skip;
1398 }
1399#endif
1378 goto skip;
1379 }
1380#endif
1400 if (opieverify(&opiedata, passwd) == 0)
1401 xpasswd = pw->pw_passwd;
1402 else if (pwok) {
1403 xpasswd = crypt(passwd, pw->pw_passwd);
1404 if (passwd[0] == '\0' && pw->pw_passwd[0] != '\0')
1405 xpasswd = ":";
1406 } else {
1407 rval = 1;
1408 goto skip;
1409 }
1381 xpasswd = crypt(passwd, pw->pw_passwd);
1382 if (passwd[0] == '\0' && pw->pw_passwd[0] != '\0')
1383 xpasswd = ":";
1410 rval = strcmp(pw->pw_passwd, xpasswd);
1411 if (pw->pw_expire && time(NULL) >= pw->pw_expire)
1412 rval = 1; /* failure */
1413skip:
1414 /*
1415 * If rval == 1, the user failed the authentication check
1416 * above. If rval == 0, either PAM or local authentication
1417 * succeeded.

--- 2061 unchanged lines hidden ---
1384 rval = strcmp(pw->pw_passwd, xpasswd);
1385 if (pw->pw_expire && time(NULL) >= pw->pw_expire)
1386 rval = 1; /* failure */
1387skip:
1388 /*
1389 * If rval == 1, the user failed the authentication check
1390 * above. If rval == 0, either PAM or local authentication
1391 * succeeded.

--- 2061 unchanged lines hidden ---