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 342084 - Portability problem: **environ
Portability problem: **environ
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: [obsolete] Builds
2.21.x
Other Mac OS
: Normal normal
: 2.24.x
Assigned To: Christian Neumair
Nautilus Maintainers
: 344197 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-05-17 05:27 UTC by Daniel Macks
Modified: 2008-03-20 11:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
darwin work-around for environ** symbol (483 bytes, patch)
2006-05-17 05:32 UTC, Daniel Macks
none Details | Review
Proposed patch (1.35 KB, patch)
2007-10-03 21:56 UTC, Christian Neumair
none Details | Review
patch (7.21 KB, patch)
2008-03-14 19:03 UTC, Cosimo Cecchi
none Details | Review
patch v2 (22.62 KB, patch)
2008-03-17 20:22 UTC, Cosimo Cecchi
none Details | Review
patch v3 (24.00 KB, patch)
2008-03-19 00:18 UTC, Cosimo Cecchi
none Details | Review

Description Daniel Macks 2006-05-17 05:27:37 UTC
libnautilus-private/nautilus-program-choosing.c uses

extern char **environ;

to access the environment in my_gdk_spawn_make_environment_for_screen and make_spawn_environment_for_sn_context. However, OS X doesn't have that symbol. It remains undefined in the compiled binaries, which leads to linker or runtime errors when it is used. For a work-alike, we have *_NSGetEnviron() in crt_externs.h. For more discussion and solutions, search bugzilla for nsgetenviron:

http://bugzilla.gnome.org/buglist.cgi?long_desc_type=substring&long_desc=nsgetenviron&cmdtype=doit
Comment 1 Daniel Macks 2006-05-17 05:32:14 UTC
Created attachment 65637 [details] [review]
darwin work-around for environ** symbol

The source contains a comment that the code was taken from gdkspawn-x11.c, so here is the patch I use for gtk+2 on darwin. There are better patches in the other bugzilla items. Better to test for the .h and _NS symbol and use them if present than to use a platform test; even better to rewrite to use the g_*env funtions from glib2...
Comment 2 Christian Kellner 2006-07-13 13:34:49 UTC
Nautilus bug -> Reassigning!
Comment 3 Fabio Bonelli 2006-07-27 20:52:17 UTC
*** Bug 344197 has been marked as a duplicate of this bug. ***
Comment 4 Christian Neumair 2007-10-03 21:56:07 UTC
Created attachment 96598 [details] [review]
Proposed patch

Proposed patch attached, which duplicates glib's code. There is no glib helper to obtain the environment variable, so we'll have to redefine it ourselves.
Comment 5 Paolo Borelli 2007-10-03 22:15:24 UTC
I should probably be reporting this separately, but I noticed while taking a look at your patch: I think the AC_CHECK_FUNCS(setenv unsetenv putenv) check can be removed from configure.in while at it, a quick grep suggests that they are not used anymore in nautilus (the corrisponding glib functions are used).
Comment 6 Hans Petter Jansson 2007-10-03 23:01:49 UTC
Can't you use g_listenv(), g_getenv(), g_setenv()?

http://library.gnome.org/devel/glib/stable/glib-Miscellaneous-Utility-Functions.html#g-listenv
Comment 7 Paolo Borelli 2007-10-04 07:44:10 UTC
hpj: that's exactly what I meant. We *do* use them, so we can remove the old check from configure.in
Comment 8 Cosimo Cecchi 2008-03-01 12:21:42 UTC
I think this can be solved in a better way using GAppInfos and GDesktopAppInfos instead of setting our own envp and using gnome_desktop_item_launch_with_env ()...modifying fields.
Comment 9 Cosimo Cecchi 2008-03-14 19:03:34 UTC
Created attachment 107311 [details] [review]
patch

Attached patch replaces the use of gnome_* functions in nautilus-program-choosing.c using of GDesktopAppInfos, getting rid of |environ|.
Comment 10 Alexander Larsson 2008-03-17 10:57:14 UTC
I think thats a generally good approach. Comments:
* You don't need slowly_and_stupidly_obtain_timestamp(), as the eel app launch context will do that by default
* I think it makes more sense to change the args to nautilus_launch_desktop_file() to be a list of GFiles. That is what almost all uses have already, and we never use this API to pass in weird external uris that are problematic wrt roundtripping via GFile.
Comment 11 Cosimo Cecchi 2008-03-17 20:22:41 UTC
Created attachment 107478 [details] [review]
patch v2

Attached patch reworks a bit the handling of DnD selection of this code path using GFiles instead of char uris from as early as we can, as for last comment from Alex.
Comment 12 Alexander Larsson 2008-03-18 16:35:09 UTC
I don't have time to do a full review atm, but it seems kinda weird that functions like icon_view_move_copy_items() frees passed in arguments. Thats totally against expected behaviour, passed in arguments are generally owned by the caller.
Comment 13 Cosimo Cecchi 2008-03-19 00:18:03 UTC
Created attachment 107579 [details] [review]
patch v3

You're right...Updated patch according to your last comment.
Comment 14 Alexander Larsson 2008-03-20 09:24:59 UTC
Hmm, there is a duoble free of a file in fm_directory_view_handle_netscape_url_dr.. (both in list and manually freed).

However, looking at this patch it seems i was wrong. We do in fact end up with this code when dropping a uri from an external source (like firefox or whatnot) onto a launcher, so converting it to gfile is wrong (since that would mangle e.g. a mailto link). So, i guess its back to fixing the first patch instead. However, it does seem like you found a leak of item_uris in paste_clipboard_data that needs fixing.
Comment 15 Alexander Larsson 2008-03-20 11:19:37 UTC
I commited that with some leak fixes and coding style cleanups.