Make chrootdir global and use it in log messages

regarding restricted users.

MFC after:	2 weeks
This commit is contained in:
Yaroslav Tykhiy 2004-11-18 14:15:32 +00:00
parent 2b7eb1c076
commit 215a9f9de5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=137862

View file

@ -130,6 +130,7 @@ int paranoid = 1; /* be extra careful about security */
int anon_only = 0; /* Only anonymous ftp allowed */
int guest;
int dochroot;
char *chrootdir;
int dowtmp = 1;
int stats;
int statfd = -1;
@ -1328,7 +1329,6 @@ pass(char *passwd)
#ifdef USE_PAM
int e;
#endif
char *chrootdir;
char *residue = NULL;
char *xpasswd;
@ -1468,7 +1468,7 @@ pass(char *passwd)
if (chrootdir[0] != '/')
asprintf(&chrootdir, "%s/%s", pw->pw_dir, chrootdir);
else
chrootdir = strdup(chrootdir); /* so it can be freed */
chrootdir = strdup(chrootdir); /* make it permanent */
if (chrootdir == NULL)
fatalerror("Ran out of memory.");
}
@ -1487,9 +1487,6 @@ pass(char *passwd)
if ((homedir = strstr(chrootdir, "/./")) != NULL) {
*(homedir++) = '\0'; /* wipe '/' */
homedir++; /* skip '.' */
/* so chrootdir can be freed later */
if ((homedir = strdup(homedir)) == NULL)
fatalerror("Ran out of memory.");
} else {
/*
* We MUST do a chdir() after the chroot. Otherwise
@ -1593,8 +1590,6 @@ pass(char *passwd)
#ifdef LOGIN_CAP
login_close(lc);
#endif
if (chrootdir)
free(chrootdir);
if (residue)
free(residue);
return;
@ -1603,8 +1598,6 @@ pass(char *passwd)
#ifdef LOGIN_CAP
login_close(lc);
#endif
if (chrootdir)
free(chrootdir);
if (residue)
free(residue);
end_login();
@ -3188,6 +3181,8 @@ logcmd(char *cmd, char *file1, char *file2, off_t cnt)
appendf(&msg, " = %jd bytes", (intmax_t)cnt);
if (wd[0])
appendf(&msg, " (wd: %s)", wd);
if (guest || dochroot)
appendf(&msg, " (chroot: %s)", chrootdir);
syslog(LOG_INFO, "%s", msg);
free(msg);
}