Your message dated Thu, 16 Oct 2014 07:04:20 +0000
with message-id <[email protected]>
and subject line Bug#757178: fixed in fgrun 3.0.0-2
has caused the Debian Bug report #757178,
regarding fgrun: does not export environment variables to fgfs
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
757178: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=757178
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: fgrun
Version: 3.0.0-1
Severity: normal

I have a laptop with hybrid graphics (Intel integrated and ATI Radeon
discrete) and I have finally taken the time to enable the discrete
graphics for FlightGear.  In a shell:

$ xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x80 cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 
3 outputs: 8 associated providers: 1 name:Intel
Provider 1: id: 0x55 cap: 0xf, Source Output, Sink Output, Source Offload, Sink 
Offload crtcs: 6 outputs: 0 associated providers: 1 name:radeon
$ xrandr --setprovideroffloadsink radeon Intel
$ DRI_PRIME=1 fgfs --enable-fullscreen

This works with a compositing window manager such as xfvwm4 (not
ratpoison, unfortunately).  (The next version of mesa should make this
work also in non-fullscreen and with non-compositing window managers).

Now I would like to do the same thing from fgrun.  In the last page, I
click "Advanced" then "Environment" then "New" then I type "DRI_PRIME=1"
then OK.

When I then click "Run", fgrun fails to pass the environment variable to
fgfs, resulting it its still using the Intel integrated graphics.  The
workaround is to call "DRI_PRIME=1 fgrun" from a command line but then
the 3D Preview on page 2 does not work because it is not fullscreen.

Browsing the sources of fgrun on gitorious, I have traced this to the
following buggy piece of code near run_posix.cxx:119:

// "export" any environment variables.
int iVal;
prefs.get( "env-count", iVal, 0 );
for (int i = 1; i <= iVal; ++i)
{
    buf[0] = 0;
    prefs.get( Fl_Preferences::Name("env-var-%d", i),
    buf, "", buflen-1 );
    char* s = strdup( buf );
    putenv( s );
    free( s );
}

The use of putenv(3) is buggy because its man page says: "In particular,
this string becomes part of the environment; changing it later will
change the environment.  (Thus, it is an error is to call putenv() with
an automatic variable as the argument, then return from the calling
function while string is still part of the environment.)".

fgrun passes the string to the environment and then deallocates it.

The man page of setenv(3) says: "This function makes copies of the
strings pointed to by name and value (by contrast with putenv(3))."
Therefore, fgrun should call setenv(3), not putenv(3).

Here is a suggested patch but note that I have not even tried to compile
it.

--- /tmp/run_posix.cxx.old      2014-08-06 03:13:53.351947269 +0200
+++ /tmp/run_posix.cxx  2014-08-06 03:25:49.983116275 +0200
@@ -124,9 +124,16 @@
            buf[0] = 0;
            prefs.get( Fl_Preferences::Name("env-var-%d", i),
                       buf, "", buflen-1 );
-           char* s = strdup( buf );
-           putenv( s );
-            free( s );
+            const char* equals = strchr(buf, '=');
+            if (equals == NULL) { /* environment variable name without a 
value; unset it. */
+              unsetenv(buf);
+            }
+            else { /* value exists */
+              *equals = '\0'; /* replace '=' with a new terminator; the value 
follows. */
+              setenv(/* name: */ buf,
+                     /* value: */ equals + 1,
+                     /* overwrite: */ TRUE);
+            }
        }
        vector<string> argv;
        argv.push_back( arg0 );

-- System Information:
Debian Release: jessie/sid
  APT prefers testing
  APT policy: (10000, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 3.14-2-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages fgrun depends on:
ii  libc6                 2.19-7
ii  libfltk-forms1.3      1.3.2-6
ii  libfltk-gl1.3         1.3.2-6
ii  libfltk-images1.3     1.3.2-6
ii  libfltk1.3            1.3.2-6
ii  libgcc1               1:4.9.1-1
ii  libopenscenegraph99   3.2.0~rc1-5.1
ii  libopenthreads14      3.2.0~rc1-5.1
ii  libsimgearcore3.0.0   3.0.0-4
ii  libsimgearscene3.0.0  3.0.0-4
ii  libstdc++6            4.9.1-1
ii  zlib1g                1:1.2.8.dfsg-1

Versions of packages fgrun recommends:
ii  flightgear  3.0.0-2

fgrun suggests no packages.

-- no debconf information

--- End Message ---
--- Begin Message ---
Source: fgrun
Source-Version: 3.0.0-2

We believe that the bug you reported is fixed in the latest version of
fgrun, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Markus Wanner <[email protected]> (supplier of updated fgrun package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Tue, 14 Oct 2014 21:53:17 +0200
Source: fgrun
Binary: fgrun
Architecture: source
Version: 3.0.0-2
Distribution: unstable
Urgency: medium
Maintainer: Debian FlightGear Crew <[email protected]>
Changed-By: Markus Wanner <[email protected]>
Description:
 fgrun      - graphical frontend for running FlightGear
Closes: 757178
Changes:
 fgrun (3.0.0-2) unstable; urgency=medium
 .
   * Add patch export-env.patch. Closes: #757178.
   * Bump S-V: No changes required.
Checksums-Sha1:
 21583067abe8e5dd1d60f6908e520082be4d4c21 2705 fgrun_3.0.0-2.dsc
 703499f06791f6fc1e39c416573fdcde0ea39165 5352 fgrun_3.0.0-2.debian.tar.xz
Checksums-Sha256:
 25e1d1c06b27688241c308fa8cf3bd9ab0613d80b872cfdaf20e6a6d0bf09f7d 2705 
fgrun_3.0.0-2.dsc
 e15921c0867973855de111ea7233c18ca40b4765a2fa1655ac33a1cc87f0e61b 5352 
fgrun_3.0.0-2.debian.tar.xz
Files:
 532645d8dc28e34d89a82f7f1624bdac 2705 games optional fgrun_3.0.0-2.dsc
 f9ca1cefc80a13a03fe67d17a818f979 5352 games optional 
fgrun_3.0.0-2.debian.tar.xz

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQQcBAEBCgAGBQJUP2TFAAoJEOh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