Bug 22968

Summary: [fixed in 0.9] Non-portable Linux credentials passing not guarded by #ifdef
Product: Telepathy Reporter: jack fink <jackfink>
Component: gabbleAssignee: Simon McVittie <smcv>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium CC: tk
Version: unspecified   
Hardware: PowerPC   
OS: Mac OS X (All)   
URL: http://git.collabora.co.uk/?p=user/smcv/telepathy-gabble-smcv.git;a=shortlog;h=refs/heads/credentials
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 22970    

Description jack fink 2009-07-27 11:00:47 UTC
libtool: compile:  /sw/bin/gcc-4 -std=gnu99 -DHAVE_CONFIG_H -I. -I../.. -I/sw/include -Wall -Wdeclaration-after-statement -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -I/sw/include/glib-2.0 -I/sw/lib/glib-2.0/include -Os -c gibber-tcp-transport.c -o gibber-tcp-transport.o >/dev/null 2>&1
/bin/sh ../../libtool --tag=CC   --mode=compile /sw/bin/gcc-4 -std=gnu99 -DHAVE_CONFIG_H -I. -I../..   -I/sw/include -Wall -Wdeclaration-after-statement -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations  -I/sw/include/glib-2.0 -I/sw/lib/glib-2.0/include -Os -c -o gibber-unix-transport.lo gibber-unix-transport.c
libtool: compile:  /sw/bin/gcc-4 -std=gnu99 -DHAVE_CONFIG_H -I. -I../.. -I/sw/include -Wall -Wdeclaration-after-statement -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -I/sw/include/glib-2.0 -I/sw/lib/glib-2.0/include -Os -c gibber-unix-transport.c  -fno-common -DPIC -o .libs/gibber-unix-transport.o
gibber-unix-transport.c: In function 'gibber_unix_transport_send_credentials':
gibber-unix-transport.c:207: error: invalid application of 'sizeof' to incomplete type 'struct ucred'
gibber-unix-transport.c:225: error: invalid application of 'sizeof' to incomplete type 'struct ucred'
gibber-unix-transport.c:227: error: 'SCM_CREDENTIALS' undeclared (first use in this function)
gibber-unix-transport.c:227: error: (Each undeclared identifier is reported only once
gibber-unix-transport.c:227: error: for each function it appears in.)
gibber-unix-transport.c:230: error: dereferencing pointer to incomplete type
gibber-unix-transport.c:231: error: dereferencing pointer to incomplete type
gibber-unix-transport.c:232: error: dereferencing pointer to incomplete type
gibber-unix-transport.c: In function 'gibber_unix_transport_read':
gibber-unix-transport.c:259: error: invalid application of 'sizeof' to incomplete type 'struct ucred'
gibber-unix-transport.c:272: error: 'SO_PASSCRED' undeclared (first use in this function)
gibber-unix-transport.c:329: error: dereferencing pointer to incomplete type
gibber-unix-transport.c:330: error: dereferencing pointer to incomplete type
gibber-unix-transport.c:331: error: dereferencing pointer to incomplete type
make[4]: *** [gibber-unix-transport.lo] Error 1


it's gcc4.3, but the same occurs with 4.0.1.
Comment 1 jack fink 2009-07-27 11:44:00 UTC
ok, after adding #include <sys/ucred.h> to lib/gibber/gibber-unix-transport.c, i get this:
gibber-unix-transport.c: In function 'gibber_unix_transport_send_credentials':
gibber-unix-transport.c:228: error: 'SCM_CREDENTIALS' undeclared (first use in this function)
gibber-unix-transport.c:228: error: (Each undeclared identifier is reported only once
gibber-unix-transport.c:228: error: for each function it appears in.)
gibber-unix-transport.c:231: error: 'struct ucred' has no member named 'pid'
gibber-unix-transport.c:232: error: 'struct ucred' has no member named 'uid'
gibber-unix-transport.c:233: error: 'struct ucred' has no member named 'gid'
gibber-unix-transport.c: In function 'gibber_unix_transport_read':
gibber-unix-transport.c:273: error: 'SO_PASSCRED' undeclared (first use in this function)
gibber-unix-transport.c:330: error: 'struct ucred' has no member named 'pid'
gibber-unix-transport.c:331: error: 'struct ucred' has no member named 'uid'
gibber-unix-transport.c:332: error: 'struct ucred' has no member named 'gid'
make[4]: *** [gibber-unix-transport.lo] Error 1

...seems like our struct ucred is pretty different :(
Comment 2 Simon McVittie 2009-07-27 13:19:17 UTC
We currently assume that all Unix platforms can pass credentials around just like Linux. I'm working on making this optional.
Comment 3 Simon McVittie 2009-07-27 14:14:45 UTC
http://git.collabora.co.uk/?p=user/smcv/telepathy-gabble-smcv.git;a=shortlog;h=refs/heads/darwin should hopefully compile and work (I tried changing the check for __linux__ to always fail, and the tests passed, with the credentials ones disabled).

It would be interesting to see whether "make check" works on Darwin - if not, please paste or attach the output.
Comment 4 Guillaume Desmottes 2009-07-28 02:44:57 UTC
The code you added inhttp://git.collabora.co.uk/?p=user/smcv/telepathy-gabble-smcv.git;a=commitdiff;h=e7a8069afccb1ed221c84f7e8e3b5bc478fbbedc 
could be a function in tubetestutil.py.

In tests, we could use sys.platform and assert that Credentials is supported if the OS is Linux.


exec_stream_tube_test() should be modified to not try to use Credentials if the OS is not Linux.
Comment 5 Simon McVittie 2009-08-24 13:08:26 UTC
*** Bug 23346 has been marked as a duplicate of this bug. ***
Comment 6 Simon McVittie 2009-09-10 04:11:55 UTC
I've renamed the branch to be more accurately named (capabilities rather than darwin, since this change is necessary but not sufficient to compile on Darwin) and redone the patch against the tests.
Comment 7 Guillaume Desmottes 2009-09-10 06:11:13 UTC
++
Comment 8 Simon McVittie 2009-09-10 06:29:11 UTC
Thanks. Fixed in git, will be in 0.9.0. Not backporting to 0.8, at least for now, since this change isn't sufficient to compile on Darwin/BSD/etc. anyway.
Comment 9 Thomas Klausner 2009-09-11 04:18:57 UTC
Just for the record: 0.7.21 compiles fine on NetBSD, only the 0.8 series introduced the compilation problem. So there probably _is_ a point in backporting it.
I'm not sure it's worth the effort -- when's 0.9 due?
Comment 10 Simon McVittie 2009-09-11 04:44:24 UTC
(In reply to comment #9)
> Just for the record: 0.7.21 compiles fine on NetBSD

That would be because it was less featureful, and the non-portable code had not yet been introduced :-)

Any further compilation-failure reports for git master would be welcome (note that asyncns.[ch] comes from a different upstream - http://0pointer.de/lennart/projects/libasyncns/ - so we'd prefer to fix any portability problems there by sending patches to Lennart, rather than unilaterally changing things ourselves).

I'd prefer to wait til platform-independent bugfixing on 0.8.x has slowed down a bit (or at least until git master compiles on misc platforms without patching!) before backporting portability fixes to it.
Comment 11 Simon McVittie 2009-11-23 05:59:33 UTC
Was fixed in 0.9.0.

The Windows-compatibility changes on Bug #24395 (an as-yet unmerged branch for 0.8, including a 0.8 backport of this patch) might help BSD/Darwin too, since they're mostly "don't assume everything is Linux".

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.