diff options
author | Mavridis Philippe <mavridisf@gmail.com> | 2021-02-26 16:37:03 +0200 |
---|---|---|
committer | Mavridis Philippe <mavridisf@gmail.com> | 2021-03-03 17:43:48 +0200 |
commit | 87b6ec150e8954a33bee21f3409ca0e9562c74ad (patch) | |
tree | e0e549f0aefaf5bed1c0ad347f636b3844d61fca | |
parent | cf38aaa0d9074ffc26414e5ca845137381085164 (diff) | |
download | klamav-87b6ec150e8954a33bee21f3409ca0e9562c74ad.tar.gz klamav-87b6ec150e8954a33bee21f3409ca0e9562c74ad.zip |
Schedule script: $DISPLAY check.
This relates to discussion of issue #22.
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
-rw-r--r-- | src/schedule.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/schedule.cpp b/src/schedule.cpp index 2a89381..75e18b9 100644 --- a/src/schedule.cpp +++ b/src/schedule.cpp @@ -363,8 +363,14 @@ TQString Schedule::createScanScript() ts << "#!/bin/bash" << "\n"; ts << "export HOSTNAME=`hostname`" << "\n"; ts << TQString("export PATH=%1").arg(TQString(getenv("PATH"))) << "\n"; - ts << "export DCOPSERVER=`cat ${HOME}/.DCOPserver_${HOSTNAME}_:0 | grep local`" << "\n"; - ts << "export DISPLAY=:0" << "\n"; + /* The following inspired by https://unix.stackexchange.com/a/17278 */ + ts << "if [ -z \"$DISPLAY\" ]; then" << "\n"; + ts << " for d in /tmp/.X11-unix/X*" << "\n"; + ts << " do" << "\n"; + ts << " export DISPLAY=$(echo $d|sed \"s!/tmp/.X11-unix/X!:!\")" << "\n"; + ts << " done" << "\n"; + ts << "fi" << "\n"; + ts << "export DCOPSERVER=`cat ${HOME}/.DCOPserver_${HOSTNAME}_${DISPLAY} | grep local`" << "\n"; ts << "# Execution starts here" << "\n"; ts << "if [ \"$1\" = \"\" ]; then" << "\n"; ts << " exit 1" << "\n"; |