properly refuse a connection in the -c case if the client ip's subdirectory
does not exist. PR: bin/38303 Submitted by: Woei-Luen, Shyu <m8535@cn.ee.ccu.edu.tw> the committed patch differs from the submitted one, any inaccuracies are mine.
This commit is contained in:
parent
7220a9e779
commit
a273f3ae41
@ -171,7 +171,7 @@ main(int argc, char *argv[])
|
||||
dirs->name = "/";
|
||||
dirs->len = 1;
|
||||
}
|
||||
if (ipchroot && chroot_dir == NULL) {
|
||||
if (ipchroot > 0 && chroot_dir == NULL) {
|
||||
syslog(LOG_ERR, "-c requires -s");
|
||||
exit(1);
|
||||
}
|
||||
@ -245,7 +245,7 @@ main(int argc, char *argv[])
|
||||
* be a problem. See the above comment about system clogging.
|
||||
*/
|
||||
if (chroot_dir) {
|
||||
if (ipchroot) {
|
||||
if (ipchroot > 0) {
|
||||
char *tempchroot;
|
||||
struct stat sb;
|
||||
int statret;
|
||||
@ -258,9 +258,10 @@ main(int argc, char *argv[])
|
||||
hbuf, sizeof(hbuf), NULL, 0,
|
||||
NI_NUMERICHOST | NI_WITHSCOPEID);
|
||||
asprintf(&tempchroot, "%s/%s", chroot_dir, hbuf);
|
||||
statret = stat(tempchroot, &sb);
|
||||
if ((sb.st_mode & S_IFDIR) &&
|
||||
(statret == 0 || (statret == -1 && ipchroot == 1)))
|
||||
if (ipchroot == 2)
|
||||
statret = stat(tempchroot, &sb);
|
||||
if (ipchroot == 1 ||
|
||||
(statret == 0 && (sb.st_mode & S_IFDIR)))
|
||||
chroot_dir = tempchroot;
|
||||
}
|
||||
/* Must get this before chroot because /etc might go away */
|
||||
|
Loading…
Reference in New Issue
Block a user