From 54cd7a8f0be1f0af69828c837846f64661ca2c14 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Tue, 7 Aug 2012 09:37:24 -0700 Subject: [PATCH] rspreload: Add fstat support vsftpd calls fstat on a socket. Fake it out. Signed-off-by: Sean Hefty --- src/preload.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/preload.c b/src/preload.c index c6cf1761..ec62e693 100644 --- a/src/preload.c +++ b/src/preload.c @@ -87,6 +87,8 @@ struct socket_calls { int (*fcntl)(int socket, int cmd, ... /* arg */); int (*dup2)(int oldfd, int newfd); ssize_t (*sendfile)(int out_fd, int in_fd, off_t *offset, size_t count); + int (*fxstat64)(int ver, int fd, struct stat64 *buf); + int (*fxstat)(int ver, int fd, struct stat *buf); }; static struct socket_calls real; @@ -280,6 +282,8 @@ static void init_preload(void) real.fcntl = dlsym(RTLD_NEXT, "fcntl"); real.dup2 = dlsym(RTLD_NEXT, "dup2"); real.sendfile = dlsym(RTLD_NEXT, "sendfile"); + real.fxstat64 = dlsym(RTLD_NEXT, "__fxstat64"); + real.fxstat = dlsym(RTLD_NEXT, "__fxstat"); rs.socket = dlsym(RTLD_DEFAULT, "rsocket"); rs.bind = dlsym(RTLD_DEFAULT, "rbind"); @@ -1033,3 +1037,23 @@ ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count) munmap(file_addr, count); return ret; } + +int __fxstat64(int ver, int socket, struct stat64 *buf) +{ +// int fd, ret; + +// if (fd_get(socket, &fd) == fd_rsocket) { +// ret = real.fxstat64(ver, socket, buf); +// if (!ret) +// buf->st_mode = (buf->st_mode & ~S_IFMT) | __S_IFSOCK; +// } else { +// ret = real.fxstat64(ver, fd, buf); +// } +// return ret; + return real.fxstat64(ver, socket, buf); +} + +int __fxstat(int ver, int socket, struct stat *buf) +{ + return real.fxstat(ver, socket, buf); +} -- 2.45.2