Bug 95234 - regression in the 1.18.1 update breaks logfile command line argument when used with displayfd
Summary: regression in the 1.18.1 update breaks logfile command line argument when use...
Alias: None
Product: xorg
Classification: Unclassified
Component: Server/DDX/Xorg (show other bugs)
Version: unspecified
Hardware: All All
: medium major
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
Depends on:
Reported: 2016-05-02 06:09 UTC by Antoine Martin
Modified: 2018-06-13 19:25 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:

this patch fixes the bug (393 bytes, patch)
2017-08-05 10:11 UTC, Antoine Martin
no flags Details | Splinter Review

Description Antoine Martin 2016-05-02 06:09:52 UTC
As per:

If you launch Xorg with -displayfd and specify the logfile you want to use, the server gets confused, tries to rename the logfile to itself, fails and logs a warning.
The logfile name specified will be created then quickly renamed with the ".old" suffix, which means the filename specified as argument cannot be found.

That's because the code goes through LogFilePrep twice with the same filename.
This new function in 1.18.1 should probably not be used when the "-logfile" command line argument is present.
Maybe there should also be a check to avoid trying to rename the log file if the filename is unchanged. (though that should just not happen if the code is fixed)

To see the problem in action, you can knock up a demonstration using a shell script and an extra file descriptor for displayfd, or just run: "xpra start --no-daemon |& grep Failed" on Fedora or Debian.
Comment 1 Antoine Martin 2017-08-05 10:11:47 UTC
Created attachment 133253 [details] [review]
this patch fixes the bug

Don't try to add the pidstring to the log filename if it doesn't contain
the "%s" placeholder for it.
Comment 2 Adam Jackson 2018-06-13 19:25:58 UTC
commit c95361465ee98dd97a99778d8a31be88fe9e4c4f
Author: Antoine Martin <antoine@nagafix.co.uk>
Date:   Wed Mar 28 15:16:02 2018 -0400

    os: Fix -logfile when used with -displayfd
    Trivial way to reproduce the bug:
    $ Xorg -logfile /tmp/mylog -config /etc/xpra/xorg.conf -displayfd 2
    The server then moans:
    Failed to rename log file "/tmp/mylog" to "/tmp/mylog": No such file or directory
    And the log file is created but immediately renamed to "/tmp/mylog.old".
    This is caused by the changes to the log file handling introduced by
    this commit:
    To fix this, only rename the logfile if the log filename contains the
    magic substitution string "%s".
    Signed-off-by: Antoine Martin <antoine@nagafix.co.uk>
    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>

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.