[X2Go-Commits] [x2goclient] 20/45: x2goclient.cpp: fix compile problems introduced with the last commit.

git-admin at x2go.org git-admin at x2go.org
Mon May 25 02:41:19 CEST 2015


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch bugfix/osx
in repository x2goclient.

commit c5561392a9b90b0b39c39b11eb48f18b14ac1a5f
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Wed Mar 18 03:06:15 2015 +0100

    x2goclient.cpp: fix compile problems introduced with the last commit.
---
 debian/changelog   |    1 +
 src/x2goclient.cpp |   25 +++++++++++++++++--------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 65fa27e..ce391cd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -460,6 +460,7 @@ x2goclient (4.0.4.0-0x2go1) UNRELEASED; urgency=low
       re-execute the main binary with this new option to indicate that the
       UNIX cleanup helper tool is requested. It is necessary to call exec()
       after fork on virtually all operating system, especially on OS X.
+    - x2goclient.cpp: fix compile problems introduced with the last commit.
 
   [ Fernando Pedemonte ]
   * New upstream release (4.0.4.0):
diff --git a/src/x2goclient.cpp b/src/x2goclient.cpp
index 2aff41f..cd13406 100644
--- a/src/x2goclient.cpp
+++ b/src/x2goclient.cpp
@@ -26,6 +26,7 @@
 #include <algorithm>
 #include <cctype>
 #include <vector>
+#include <csignal>
 
 #include "unixhelper.h"
 #include "ongetpass.h"
@@ -43,16 +44,23 @@ int fork_helper (int argc, char **argv) {
   if (0 == tmp_pid) {
     /* Starting unixhelper. */
     std::vector<std::string> new_argv;
-    new_argv.push (std::string (argv[0]));
-    new_argv.push ("--unixhelper");
+    new_argv.push_back (std::string (argv[0]));
+    new_argv.push_back ("--unixhelper");
 
-    std::vector<const char *> new_argv_c_str;
-    for (const_iterator it = new_argv.begin (); it != new_argv.end (); ++it) {
-      new_argv_c_str.push ((*it).c_str ());
+    std::vector<char *> new_argv_c_str;
+    for (std::vector<std::string>::iterator it = new_argv.begin (); it != new_argv.end (); ++it) {
+      const char *elem = (*it).c_str ();
+      new_argv_c_str.push_back (strndup (elem, std::strlen (elem)));
     }
-    new_argv_c_str.push ("");
 
-    if (0 != execv (new_argv_c_str.data (), new_argv_c_str.data ())) {
+    /* Add null pointer as last element. */
+    {
+      std::vector<char> tmp;
+      tmp.push_back (0);
+      new_argv_c_str.push_back (&tmp.front ());
+    }
+
+    if (0 != execv (new_argv_c_str.front (), &(new_argv_c_str.front ()))) {
       std::cerr << "Failed to re-execute process as UNIX cleanup helper tool: " << std::strerror (errno) << "\n"
                 << "Terminating and killing parent." << "\n"
                 << "Please report a bug, refer to this documentation: http://wiki.x2go.org/doku.php/wiki:bugs" << std::endl;
@@ -66,6 +74,7 @@ int fork_helper (int argc, char **argv) {
     }
 
     /* Anything here shall be unreachable. */
+    return (0);
   }
   /* Error. */
   else if (-1 == tmp_pid) {
@@ -90,7 +99,7 @@ int main (int argc, char **argv) {
     std::string cur_arg (argv[i]);
 
     /* Make the current argument lowercase. */
-    std::transform (cur_arg.begin (), cur_arg.end (), cur_arg.begin (), std::tolower);
+    std::transform (cur_arg.begin (), cur_arg.end (), cur_arg.begin (), ::tolower);
 
     if ((!cur_arg.empty ()) && (cur_arg.compare ("--unixhelper"))) {
       unix_helper_request = 1;

--
Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git


More information about the x2go-commits mailing list