From 8862c7be4eaef4df90a1739de00d2dfe06f73ed5 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 8 Apr 2003 16:12:47 +0300 Subject: [PATCH] Tru64 fixes. More comments. --HG-- branch : HEAD --- src/lib/fdpass.c | 25 +++++++++++++++++++++---- src/master/login-process.c | 3 ++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/lib/fdpass.c b/src/lib/fdpass.c index 26e9bc86ab..6ff10217f9 100644 --- a/src/lib/fdpass.c +++ b/src/lib/fdpass.c @@ -1,7 +1,15 @@ /* - fdpass.c - FD passing + fdpass.c - File descriptor passing between processes via UNIX sockets - Copyright (c) 2002 Timo Sirainen + This isn't fully portable, but pretty much all UNIXes nowadays should + support this. If you're having runtime problems, check the end of fd_read() + and play with the if condition. + + If this file doesn't compile at all, you should check if this is supported + in your system at all. It may require some extra #define to enable it. + If not, you're pretty much out of luck. Cygwin didn't last I checked. + + Copyright (c) 2002-2003 Timo Sirainen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -107,9 +115,18 @@ ssize_t fd_read(int handle, void *data, size_t size, int *fd) return ret; } - /* at least one byte transferred - we should have the fd now */ + /* at least one byte transferred - we should have the fd now. + do extra checks to make sure it really is an fd that is being + transferred to avoid potential DoS conditions. some systems don't + set all these values correctly however: + + Linux 2.0.x - cmsg_len, cmsg_level, cmsg_type are not set + Tru64 - msg_controllen isn't set */ cmsg = CMSG_FIRSTHDR(&msg); - if (msg.msg_controllen < CMSG_SPACE(sizeof(int)) || + if ( +#ifndef __osf__ + msg.msg_controllen < CMSG_SPACE(sizeof(int)) || +#endif cmsg == NULL || cmsg->cmsg_len < CMSG_LEN(sizeof(int)) || cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) *fd = -1; diff --git a/src/master/login-process.c b/src/master/login-process.c index a67d337883..8cd11806be 100644 --- a/src/master/login-process.c +++ b/src/master/login-process.c @@ -138,7 +138,8 @@ static void login_process_mark_nonlistening(struct login_process *p) { if (!p->listening) { i_error("login: received another \"not listening\" " - "notification"); + "notification (if you can't login at all, " + "see src/lib/fdpass.c)"); return; } -- 2.47.3