After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 649302 - Add support for GNU/FreeBSD
Add support for GNU/FreeBSD
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other FreeBSD
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-05-03 17:30 UTC by Laurent Bigonville
Modified: 2012-11-02 14:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (6.67 KB, patch)
2011-05-03 17:30 UTC, Laurent Bigonville
needs-work Details | Review
updated patch (with the same "whitelist of OSs" approach as before) (6.18 KB, patch)
2012-10-31 13:03 UTC, Simon McVittie
accepted-commit_now Details | Review

Description Laurent Bigonville 2011-05-03 17:30:27 UTC
Created attachment 187137 [details] [review]
Patch

Hi,

Could you please add support for GNU/FreeBSD platform like the debian port on freebsd kernel (GNU glibc and freebsd kernel)

Please find a patch made by Debarshi Ray attached to this bug report.
Comment 1 Matthias Clasen 2011-05-04 03:43:51 UTC
Looks like __FreeBSD_kernel__ means just the same as __FreeBSD__ ?
Comment 2 Laurent Bigonville 2011-05-04 08:18:54 UTC
__FreeBSD__ is defined when a complete freebsd system (kernel + libC) is used.

__FreeBSD_kernel__ is only defined when a freebsd kernel is used (and the GNU libC)


Some information from debian http://glibc-bsd.alioth.debian.org/porting/PORTING
Comment 3 Dan Winship 2011-05-04 12:12:22 UTC
Other than the gthread-posix change, it looks like all of these are related to credentials stuff. Maybe we should just have a configure check for HAVE_STRUCT_CMSGCRED, and use that. (I was going to add "and then maybe it will work on NetBSD, OpenBSD, and OS X too", but from googling, it looks like each one is different here...)
Comment 4 Matthias Clasen 2011-05-05 19:45:17 UTC
(In reply to comment #3)
> Other than the gthread-posix change, it looks like all of these are related to
> credentials stuff. Maybe we should just have a configure check for
> HAVE_STRUCT_CMSGCRED, and use that. (I was going to add "and then maybe it will
> work on NetBSD, OpenBSD, and OS X too", but from googling, it looks like each
> one is different here...)

Yeah, I think I'd like that approach better.
Comment 5 Simon McVittie 2012-10-24 13:21:07 UTC
The thread priority stuff is obsolete now, since GLib no longer supports thread priorities.

In Debian we've recently had to (re-)apply essentially the same change as the credentials stuff here, to make GDBus able to connect to D-Bus on kFreeBSD at all - it seems the other authentication code path, using cookie files in the home directory, doesn't work there, or something? (I haven't debugged it yet, but I suspect it's less reliable for unusual uses where there might not be a home directory, like the gdm3 mini-GNOME-session, in any case.) So I'd like to not make the perfect the enemy of the good here.

(In reply to comment #3)
> Maybe we should just have a configure check for
> HAVE_STRUCT_CMSGCRED, and use that.

libdbus does this sort of thing. It has the disadvantage that it's impossible for a non-guru to tell which mechanism(s) we expect to use on which platform(s). We seem to have at least 5½ mechanisms:

* send via struct cmsgcred in SOL_SOCKET SCM_CREDS header,
  receive struct cmsgcred
* send via setsockopt(0, LOCAL_CREDS), receive struct cmsgcred
* send implicitly (?), receive via getsockopt(SOL_SOCKET, SO_PEERCRED)
  into struct sockpeercred (for OpenBSD)
* send implicitly (?), receive via getsockopt(SOL_SOCKET, SO_PEERCRED)
  into struct ucred (for some unspecified non-OpenBSD OS - this is the ½)
* send implicitly (?), receive via getpeereid()
* send implicitly (?), receive via getpeerucred() and possibly
  a Solaris audit session

but all I can tell about platforms from that is that sockpeercred is OpenBSD, and getpeerucred() is presumably Solaris.

Worse, there apparently exist platforms where more than one of those exists, so we have code like this where the order matters:

    #if defined(HAVE_CMSGCRED)
      /* NOOP just to make sure only one codepath is used
       *      and to prefer CMSGCRED
       */
    #elif defined(LOCAL_CREDS)

As a result, I prefer GLib's current approach. There seem to be nearly as many versions of credentials-passing as there are OSs, so I don't expect many code paths can be shared in practice; and credentials-passing seems to be hairy enough that we can't really claim it works on any OS where it hasn't explicitly been tested.
Comment 6 Simon McVittie 2012-10-31 13:03:16 UTC
Created attachment 227719 [details] [review]
updated patch (with the same "whitelist of OSs" approach as before)
Comment 7 Dan Winship 2012-11-02 12:38:12 UTC
Comment on attachment 227719 [details] [review]
updated patch (with the same "whitelist of OSs" approach as before)

ok, given that every single BSD implements creds differently, it seems like having the explicit kernel ifdef is better than trying to figure it out based on HAVE_whatever_data_type.

(though maybe the GNU/FreeBSD people should get FreeBSD to #define __FreeBSD_kernel_ too...)
Comment 8 Simon McVittie 2012-11-02 14:00:15 UTC
Fixed in git:

1afaea3 for 2.35.2
11f26aa for 2.34.2
7a3f70e for 2.32.5 (if there is one), since Debian 7 will have 2.32