diff options
author | Kurt Jaeger <pi@FreeBSD.org> | 2016-06-16 05:44:04 +0000 |
---|---|---|
committer | Kurt Jaeger <pi@FreeBSD.org> | 2016-06-16 05:44:04 +0000 |
commit | 1106e92a54532b9ae6a49d8fe18ff9d43ebae8e8 (patch) | |
tree | cc1a0585662576eb69c76a0d83b12d4b87aa4fa7 /x11 | |
parent | a6a726d3dd7a0f26df351e980635a5097da27c9b (diff) |
x11/konsole: misc fixes and improvements
- fixes readArguments to get all instead of just the first
- implements readEnvironment of FreeBSD
- fixes handling of %c for remote sessions
- add %U (user@) for remote sessions
- fixes %D to handle symlinked homedirs
This started as a backport of Tobias's patch from
https://git.reviewboard.kde.org/r/127525/
No need to bump portrevision, pending update from PR#210255 will take
care of that.
PR: 209838
Submitted by: matthew@reztek.cz, Tobias C.Berner <tcberner@gmail.com> (kde)
Reviewed by: Ralf Nolden <nolden@kde.org> (kde)
Approved by: Adriaan de Groot <groot@kde.org> (kde)
Notes
Notes:
svn path=/head/; revision=416950
Diffstat (limited to 'x11')
-rw-r--r-- | x11/konsole/files/patch-src_CMakeLists.txt | 14 | ||||
-rw-r--r-- | x11/konsole/files/patch-src_ProcessInfo.cpp | 118 |
2 files changed, 132 insertions, 0 deletions
diff --git a/x11/konsole/files/patch-src_CMakeLists.txt b/x11/konsole/files/patch-src_CMakeLists.txt new file mode 100644 index 000000000000..5a79923fa3a6 --- /dev/null +++ b/x11/konsole/files/patch-src_CMakeLists.txt @@ -0,0 +1,14 @@ +--- src/CMakeLists.txt.orig 2014-11-01 04:17:02 UTC ++++ src/CMakeLists.txt +@@ -134,6 +134,11 @@ if(HAVE_LIBKONQ) + set(konsole_LIBS ${konsole_LIBS} ${LIBKONQ_LIBRARY}) + endif() + ++IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") ++ #procstat_getenvv() is in libprocstat ++ list(APPEND konsole_LIBS procstat) ++endif() ++ + ### Konsole Application + + kde4_add_ui_files(konsoleprivate_SRCS ColorSchemeEditor.ui diff --git a/x11/konsole/files/patch-src_ProcessInfo.cpp b/x11/konsole/files/patch-src_ProcessInfo.cpp new file mode 100644 index 000000000000..e26cfd0232d5 --- /dev/null +++ b/x11/konsole/files/patch-src_ProcessInfo.cpp @@ -0,0 +1,118 @@ +--- src/ProcessInfo.cpp.orig 2014-11-01 04:17:02 UTC ++++ src/ProcessInfo.cpp +@@ -60,6 +60,9 @@ + #include <sys/syslimits.h> + # if defined(Q_OS_FREEBSD) + # include <libutil.h> ++# include <sys/param.h> ++# include <sys/queue.h> ++# include <libprocstat.h> + # endif + #endif + +@@ -280,10 +283,8 @@ void ProcessInfo::setUserName(const QStr + void ProcessInfo::setUserHomeDir() + { + const QString& usersName = userName(); +- if (!usersName.isEmpty()) +- _userHomeDir = KUser(usersName).homeDir(); +- else +- _userHomeDir = QDir::homePath(); ++ const QDir& homeDir(usersName.isEmpty() ? QDir::homePath() : KUser(usersName).homeDir()); ++ _userHomeDir = homeDir.canonicalPath(); + } + + void ProcessInfo::setParentPid(int aPid) +@@ -664,26 +665,60 @@ private: + + managementInfoBase[0] = CTL_KERN; + managementInfoBase[1] = KERN_PROC; +- managementInfoBase[2] = KERN_PROC_PID; ++ managementInfoBase[2] = KERN_PROC_ARGS; + managementInfoBase[3] = aPid; + + len = sizeof(args); + if (sysctl(managementInfoBase, 4, args, &len, NULL, 0) == -1) + return false; + +- const QStringList& argumentList = QString(args).split(QChar('\0')); ++ const QStringList& argumentList = QString::fromLocal8Bit(args, len).split(QChar('\0')); + +- for (QStringList::const_iterator it = argumentList.begin(); it != argumentList.end(); ++it) { +- addArgument(*it); ++ foreach (const QString& value, argumentList) { ++ if (!value.isEmpty()) ++ addArgument(value); + } + + return true; + } + + virtual bool readEnvironment(int aPid) { +- Q_UNUSED(aPid); +- // Not supported in FreeBSD? +- return false; ++ ++ struct procstat *prstat = procstat_open_sysctl(); ++ if (prstat == NULL) { ++ return false; ++ } ++ ++ unsigned int cnt; ++ kinfo_proc *procinfo = procstat_getprocs(prstat, KERN_PROC_PID, aPid, &cnt); ++ if (procinfo == NULL || cnt != 1) { ++ procstat_close(prstat); ++ return false; ++ } ++ ++ // pass 0, as the third argument, as we want to have every environment ++ // variable defined -- code courtesy of procstats procstats_arg.c ++ char **envs = procstat_getenvv(prstat, procinfo, 0); ++ if (envs == NULL) { ++ procstat_close(prstat); ++ return false; ++ } ++ ++ for (int i = 0; envs[i] != NULL; i++) { ++ const QString& entry = QString::fromLocal8Bit(envs[i]); ++ const int splitPos = entry.indexOf('='); ++ ++ if (splitPos != -1) { ++ const QString& name = entry.mid(0, splitPos); ++ const QString& value = entry.mid(splitPos + 1, -1); ++ ++ addEnvironmentBinding(name, value); ++ } ++ } ++ ++ procstat_freeenvv(prstat); ++ procstat_close(prstat); ++ return true; + } + + virtual bool readCurrentDir(int aPid) { +@@ -1105,8 +1140,8 @@ SSHProcessInfo::SSHProcessInfo(const Pro + _host = args[i]; + } + } else { +- // host has already been found, this must be the command argument +- _command = args[i]; ++ // host has already been found, this must be part of the command arguments ++ _command += (_command.isEmpty() ? "" : " ") + args[i]; + } + } + } else { +@@ -1151,6 +1186,13 @@ QString SSHProcessInfo::format(const QSt + // search for and replace known markers + output.replace("%u", _user); + ++ // provide 'user@' if user is defined -- this makes nicer ++ // remote tabs possible: "%U%h %c" => User@Host Command ++ // => Host Command ++ // Depending on whether -l was passed to ssh (which is mostly not the ++ // case due to ~/.ssh/config). ++ output.replace(QLatin1String("%U"),_user.isEmpty() ? QString() : _user+"@"); ++ + if (isIpAddress) + output.replace("%h", _host); + else |