This is sources Bugzilla
Bugzilla Version 2.17.5
Bugzilla Bug 6545
  struct ucred ifdefined behind __USE_GNU Last modified: 2008-12-09 23:25:34
     Query page      Enter new bug
Bug#: 6545   Hardware:   Reporter: Luca Scamoni <luca.scamoni@sys-net.it>
Host: Target: Build:
Product:     Add CC:
Component:   Version:   CC:
Remove selected CCs
Status: RESOLVED   Priority:  
Resolution: FIXED   Severity:  
Assigned To: Ulrich Drepper <drepper@redhat.com>   Target Milestone:  
Flags: Requestee:
  backport ()
  examined ()
  testsuite ()
Summary:
Keywords:

Attachment Description Type Created Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 6545 depends on: Show dependency tree
Show dependency graph
Bug 6545 blocks:

Additional Comments:


Leave as RESOLVED FIXED
Reopen bug
Mark bug as VERIFIED

View Bug Activity   |   Format For Printing


Description:   Last confirmed: 0000-00-00 00:00 Opened: 2008-05-22 08:40
sysdeps/unix/sysv/linux/bits/socket.h defines struct ucred behind #ifdef
__USE_GNU but ucred is not a GNU-specific extension.
This breaks compiling a number of sources if -D_GNU_SOURCE is not specified in
CFLAGS.
This modification has been introduced in revision 1.61 of MAIN trunk (tagged as
glibc-2_8-branch)

------- Additional Comment #1 From Ulrich Drepper 2008-05-22 14:16 -------
This is a POSIX header and ucred is not in the POSIX namespace.  Fix you app to
pass the correct flags.

------- Additional Comment #2 From Howard Chu 2008-06-03 18:56 -------
The ifdef is clearly wrong:

/* Socket level message types.  This must match the definitions in
   <linux/socket.h>.  */
enum
  {
    SCM_RIGHTS = 0x01           /* Transfer file descriptors.  */
#define SCM_RIGHTS SCM_RIGHTS
#ifdef __USE_BSD
    , SCM_CREDENTIALS = 0x02    /* Credentials passing.  */
# define SCM_CREDENTIALS SCM_CREDENTIALS
#endif
  };

#ifdef __USE_GNU
/* User visible structure for SCM_CREDENTIALS message */
struct ucred
{
  pid_t pid;                    /* PID of sending process.  */
  uid_t uid;                    /* UID of sending process.  */
  gid_t gid;                    /* GID of sending process.  */
};
#endif

The comment says the struct is used for the SCM_CREDENTIALS message. Therefore
it should at least be #ifdef __USE_BSD or #ifdef SCM_CREDENTIALS, not #ifdef
__USE_GNU.

Since the structure is also used by getsockopt(...SO_PEERCRED) it should probably be

#if defined(SO_PEERCRED) || defined(SCM_CREDENTIALS)

The comment should probably also be extended to indicate that it's also used for
the Linux-specific SO_PEERCRED sockopt.

------- Additional Comment #3 From Ulrich Drepper 2008-12-09 23:25 -------
I've changed the header to make SCM_CREDENTIALS only available wen __USE_GNU is
defined.  BSD doesn't use this symbol/

     Query page      Enter new bug
Actions: New | Query | bug # | Reports | Requests   New Account | Log In