From owner-freebsd-hackers@FreeBSD.ORG Sun May 18 20:13:34 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 80A101065687 for ; Sun, 18 May 2008 20:13:34 +0000 (UTC) (envelope-from prvs=1024cbb3dd=killing@multiplay.co.uk) Received: from mail1.multiplay.co.uk (core6.multiplay.co.uk [85.236.96.23]) by mx1.freebsd.org (Postfix) with ESMTP id 12AA98FC19 for ; Sun, 18 May 2008 20:13:33 +0000 (UTC) (envelope-from prvs=1024cbb3dd=killing@multiplay.co.uk) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=multiplay.co.uk; s=Multiplay; t=1211140563; x=1211745363; q=dns/txt; h=Received: Message-ID:From:To:Subject:Date:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=8qc+1tqRbLKPapYsFyL+O4TZ+/yYF2iwxw 70jmIuDM0=; b=jNkUrJhhJsnUdOQgy/1e2HzDlkaJ340uYWYBaKT7SVqw93W67i TV6RgIa5eBccMZhO3eCe4UvX7Z1s3uwV7NQYU2q8EuHmuHSkLoCJ4JVhbw4ufjzs L4aOn+HX/zGvtWJCtYJzvwfOXWrOI+yKt4jjD+5KLQ+KrP/3S5llutz94= X-Spam-Checker-Version: SpamAssassin 3.1.8 (2007-02-13) on mail1.multiplay.co.uk X-Spam-Level: X-Spam-Status: No, score=-14.7 required=6.0 tests=BAYES_00, FORGED_MUA_OUTLOOK, USER_IN_WHITELIST,USER_IN_WHITELIST_TO autolearn=ham version=3.1.8 Received: from r2d2 by mail1.multiplay.co.uk (MDaemon PRO v9.6.5) with ESMTP id md50005635508.msg for ; Sun, 18 May 2008 20:56:02 +0100 X-Authenticated-Sender: Killing@multiplay.co.uk X-MDRemoteIP: 212.135.219.182 X-Return-Path: prvs=1024cbb3dd=killing@multiplay.co.uk X-Envelope-From: killing@multiplay.co.uk X-MDaemon-Deliver-To: freebsd-hackers@freebsd.org Message-ID: From: "Steven Hartland" To: Date: Sun, 18 May 2008 20:56:01 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 X-Spam-Processed: mail1.multiplay.co.uk, Sun, 18 May 2008 20:56:02 +0100 X-MDAV-Processed: mail1.multiplay.co.uk, Sun, 18 May 2008 20:56:03 +0100 Subject: Using sendmsg for SCM_CREDS results in EINVAL on PF_INET socket X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 May 2008 20:13:34 -0000 sendmsg is not documented as ever returning EINVAL but yet when using the following code to send credentials to a remote host results in EINVAL from sendmsg. I suspect that SCM_CREDS is only valid for PF_LOCAL / PF_UNIX sockets and not PF_INET sockets and hence the code in dbus is actually invalid. Can anyone confirm this is the case or not? [code from dbus-sysdeps-unix.c] write_credentials_byte (int server_fd, DBusError *error) { int bytes_written; char buf[1] = { '\0' }; #if defined(HAVE_CMSGCRED) union { struct cmsghdr hdr; char cred[CMSG_SPACE (sizeof (struct cmsgcred))]; } cmsg; struct iovec iov; struct msghdr msg; iov.iov_base = buf; iov.iov_len = 1; memset (&msg, 0, sizeof (msg)); msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = (caddr_t) &cmsg; msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred)); memset (&cmsg, 0, sizeof (cmsg)); cmsg.hdr.cmsg_len = CMSG_LEN (sizeof (struct cmsgcred)); cmsg.hdr.cmsg_level = SOL_SOCKET; cmsg.hdr.cmsg_type = SCM_CREDS; #endif _DBUS_ASSERT_ERROR_IS_CLEAR (error); again: #if defined(HAVE_CMSGCRED) bytes_written = sendmsg (server_fd, &msg, 0); #else bytes_written = write (server_fd, buf, 1); #endif if (bytes_written < 0 && errno == EINTR) goto again; if (bytes_written < 0) { dbus_set_error (error, _dbus_error_from_errno (errno), "Failed to write credentials byte: %s", _dbus_strerror (errno)); return FALSE; } else if (bytes_written == 0) { dbus_set_error (error, DBUS_ERROR_IO_ERROR, "wrote zero bytes writing credentials byte"); return FALSE; } else { _dbus_assert (bytes_written == 1); _dbus_verbose ("wrote credentials byte\n"); return TRUE; } } [/code from dbus-sysdeps-unix.c] ================================================ This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it. In the event of misdirection, illegible or incomplete transmission please telephone +44 845 868 1337 or return the E.mail to postmaster@multiplay.co.uk.