View | Details | Raw Unified | Return to bug 209838
Collapse All | Expand All

(-)x11/konsole/files/patch-src_CMakeLists.txt (+14 lines)
Line 0 Link Here
1
--- src/CMakeLists.txt.orig	2014-11-01 04:17:02 UTC
2
+++ src/CMakeLists.txt
3
@@ -134,6 +134,11 @@ if(HAVE_LIBKONQ)
4
   set(konsole_LIBS ${konsole_LIBS} ${LIBKONQ_LIBRARY})
5
 endif()
6
 
7
+IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
8
+    #procstat_getenvv() is in libprocstat
9
+    list(APPEND konsole_LIBS procstat)
10
+endif()
11
+
12
 ### Konsole Application
13
 
14
 kde4_add_ui_files(konsoleprivate_SRCS ColorSchemeEditor.ui
(-)x11/konsole/files/patch-src_ProcessInfo.cpp (+118 lines)
Line 0 Link Here
1
--- src/ProcessInfo.cpp.orig	2014-11-01 04:17:02 UTC
2
+++ src/ProcessInfo.cpp
3
@@ -60,6 +60,9 @@
4
 #include <sys/syslimits.h>
5
 #   if defined(Q_OS_FREEBSD)
6
 #   include <libutil.h>
7
+#   include <sys/param.h>
8
+#   include <sys/queue.h>
9
+#   include <libprocstat.h>
10
 #   endif
11
 #endif
12
 
13
@@ -280,10 +283,8 @@ void ProcessInfo::setUserName(const QStr
14
 void ProcessInfo::setUserHomeDir()
15
 {
16
     const QString& usersName = userName();
17
-    if (!usersName.isEmpty())
18
-        _userHomeDir = KUser(usersName).homeDir();
19
-    else
20
-        _userHomeDir = QDir::homePath();
21
+    const QDir& homeDir(usersName.isEmpty() ? QDir::homePath() : KUser(usersName).homeDir());
22
+    _userHomeDir = homeDir.canonicalPath();
23
 }
24
 
25
 void ProcessInfo::setParentPid(int aPid)
26
@@ -664,26 +665,60 @@ private:
27
 
28
         managementInfoBase[0] = CTL_KERN;
29
         managementInfoBase[1] = KERN_PROC;
30
-        managementInfoBase[2] = KERN_PROC_PID;
31
+        managementInfoBase[2] = KERN_PROC_ARGS;
32
         managementInfoBase[3] = aPid;
33
 
34
         len = sizeof(args);
35
         if (sysctl(managementInfoBase, 4, args, &len, NULL, 0) == -1)
36
             return false;
37
 
38
-        const QStringList& argumentList = QString(args).split(QChar('\0'));
39
+        const QStringList& argumentList = QString::fromLocal8Bit(args, len).split(QChar('\0'));
40
 
41
-        for (QStringList::const_iterator it = argumentList.begin(); it != argumentList.end(); ++it) {
42
-            addArgument(*it);
43
+        foreach (const QString& value, argumentList) {
44
+            if (!value.isEmpty())
45
+                addArgument(value);
46
         }
47
 
48
         return true;
49
     }
50
 
51
     virtual bool readEnvironment(int aPid) {
52
-        Q_UNUSED(aPid);
53
-        // Not supported in FreeBSD?
54
-        return false;
55
+
56
+        struct procstat *prstat = procstat_open_sysctl();
57
+        if (prstat == nullptr) {
58
+            return false;
59
+        }
60
+
61
+        unsigned int cnt;
62
+        kinfo_proc *procinfo = procstat_getprocs(prstat, KERN_PROC_PID, aPid, &cnt);
63
+        if (procinfo == nullptr || cnt != 1) {
64
+            procstat_close(prstat);
65
+            return false;
66
+        }
67
+
68
+        // pass 0, as the third argument, as we want to have every environment
69
+        // variable defined -- code courtesy of procstats procstats_arg.c
70
+        char **envs = procstat_getenvv(prstat, procinfo, 0);
71
+        if (envs == nullptr) {
72
+            procstat_close(prstat);
73
+            return false;
74
+        }
75
+
76
+        for (int i = 0; envs[i] != nullptr; i++) {
77
+            const QString& entry = QString::fromLocal8Bit(envs[i]);
78
+            const int splitPos = entry.indexOf('=');
79
+
80
+            if (splitPos != -1) {
81
+                const QString& name = entry.mid(0, splitPos);
82
+                const QString& value = entry.mid(splitPos + 1, -1);
83
+
84
+                addEnvironmentBinding(name, value);
85
+            }
86
+         }
87
+
88
+         procstat_freeenvv(prstat);
89
+         procstat_close(prstat);
90
+         return true;
91
     }
92
 
93
     virtual bool readCurrentDir(int aPid) {
94
@@ -1105,8 +1140,8 @@ SSHProcessInfo::SSHProcessInfo(const Pro
95
                     _host = args[i];
96
                 }
97
             } else {
98
-                // host has already been found, this must be the command argument
99
-                _command = args[i];
100
+                // host has already been found, this must be part of the command arguments
101
+                _command += (_command.isEmpty() ? "" : " ") + args[i];
102
             }
103
         }
104
     } else {
105
@@ -1151,6 +1186,13 @@ QString SSHProcessInfo::format(const QSt
106
     // search for and replace known markers
107
     output.replace("%u", _user);
108
 
109
+    // provide 'user@' if user is defined -- this makes nicer
110
+    // remote tabs possible: "%U%h %c" => User@Host Command
111
+    //                                 => Host Command
112
+    // Depending on whether -l was passed to ssh (which is mostly not the
113
+    // case due to ~/.ssh/config).
114
+    output.replace(QLatin1String("%U"),_user.isEmpty() ? QString() : _user+"@");
115
+
116
     if (isIpAddress)
117
         output.replace("%h", _host);
118
     else

Return to bug 209838