Make sure our recvmsg() is a SCM_RIGHTS message when

we receive a link from another ppp.
This commit is contained in:
Brian Somers 1998-06-18 23:38:04 +00:00
parent 1181eb8216
commit ad5b0e8be6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=37054

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: bundle.c,v 1.18 1998/06/16 19:40:24 brian Exp $
* $Id: bundle.c,v 1.19 1998/06/16 19:40:34 brian Exp $
*/
#include <sys/param.h>
@ -1449,18 +1449,19 @@ bundle_ReceiveDatalink(struct bundle *bundle, int s, struct sockaddr_un *sun)
}
write(s, "!", 1); /* ACK */
close(s);
if (cmsg->cmsg_type == SCM_RIGHTS) {
/* We've successfully received an open file descriptor through our socket */
log_Printf(LogDEBUG, "Receiving non-tty device\n");
link_fd = *(int *)CMSG_DATA(cmsg);
} else {
/* It's a ``controlling'' tty device via CATPROG */
log_Printf(LogDEBUG, "Receiving tty device\n");
link_fd = dup(s);
fcntl(link_fd, F_SETFL, fcntl(link_fd, F_GETFL, 0) | O_NONBLOCK);
if (cmsg->cmsg_type != SCM_RIGHTS) {
log_Printf(LogERROR, "Recvmsg: no descriptor received !\n");
while (niov--)
free(iov[niov].iov_base);
return;
}
/* We've successfully received an open file descriptor through our socket */
log_Printf(LogDEBUG, "Receiving device descriptor\n");
link_fd = *(int *)CMSG_DATA(cmsg);
if (strncmp(Version, iov[0].iov_base, iov[0].iov_len)) {
log_Printf(LogWARN, "Cannot receive datalink, incorrect version"
" (\"%.*s\", not \"%s\")\n", (int)iov[0].iov_len,
@ -1480,7 +1481,6 @@ bundle_ReceiveDatalink(struct bundle *bundle, int s, struct sockaddr_un *sun)
close(link_fd);
free(iov[0].iov_base);
close(s);
}
void