DISPLAY=:0 zenity --info --text '!'
DISPLAY=:0
necessary, since there is no display in my session, and I want to show a message on the main screen. DISPLAY=:0 zenity --warning --text ' .'
logan.html
and an “action page” zenity.php
: <!-- logan.html --> <html> <head> <style type="text/css"> form button { font-size: 20px; } div.explanation { width: 400px; } </style> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="HandheldFriendly" content="true"> </head> <body> <form method="POST" action="/zenity.php"> <button> </button> </form> </body> </html>
meta
tags to adapt the page for mobiles (remember that I make it easy to use on the go?) For those who can't render HTML in their head, I’ll see what it looks like: <?php /* zenity.php */ $messages = Array( " .", " .", " .", " .", " .", " .", " .", " .", " .", " .", " and has recovered.", " .", " .", " .", " .", " .", " .", " NVIDIA .", "NVIDIA - . ( 43)", " wlx10bef54d395c." ); $statuses = Array("error", "warning"); $msg = $messages[array_rand($messages)]; $status = $statuses[array_rand($statuses)]; $timeout = "--timeout 10"; exec("sudo -u thedisplayuser /usr/sbin/zenity --$status --display=:0 --text ': $msg' $timeout > /dev/null &"); include 'logan.html'; ?> <div class="explanation"> , . , // .. </div> <br /> <img src='/logan.jpg' />
www-data
) can execute commands as a display user ( thedisplayuser
), you might be happy to know that I strictly limited it to sudoers
file: # /etc/sudoers www-data ALL=(thedisplayuser) NOPASSWD: /usr/bin/zenity
zenity.php
. I quickly removed it (until Logan didn’t hear that he was being played) and decided that the fun was over. It was not there./usr/sbin/zenity
instead of /usr/bin/zenity
(the system default), and sudoers
had the corresponding permission record. So what is this /usr/sbin/zenity
? Shell script: #!/bin/bash echo '.' >> /tmp/log.txt if [ 0 -eq $((RANDOM % 100)) ]; then /usr/bin/zenity --error --display=:0 --text " ." --timeout 10 > /dev/null & else /usr/bin/zenity "$@" fi
sudoers
, brought the zenity.php
into its original form. Messages stopped appearing. But then they came back.zenity.php
. Nothing new. /usr/sbin/zenity
? Disappeared I am discouraged. Then I decided to look inside /usr/bin/zenity
: #!/bin/bash # --- --- # --- --- # --- --- # --- --- # --- --- if [ 0 -eq $((RANDOM % 70)) ]; then /usr/bin/rpmdb-client --error --display=:0 --text """"" """""" """""""""""" """"""""." --timeout 10 > /dev/null & else /usr/bin/rpmdb-client "$@" fi
rpmdb-client
is it all about? So, I fought back by changing it: # <> if [ 0 -eq $((RANDOM % 70)) ]; then /usr/sbin/rpmdb-client --error --display=:0 --text """"" """""" """""""""""" """"""""." --timeout 10 > /dev/null & else /usr/bin/rpmdb-client "$@" fi
/usr/sbin/rpmdb-client
instead of /usr/bin/rpmdb-client
, which runs a non-doing bash script. With enough luck, he will not notice the extra character and his message will never appear./usr/sbin/zenity
and /usr/bin/rpmdb-client
, which Chris created. There are some strange differences in binaries, which I have not yet understood.zenity
instead. A deep thanks to Tom Hebba (as in every technical post I have) for helping me with this. Here is what I did:apt
to download sources (in this case, add deb-src
to /etc/apt/sources.list
)apt-get source zenity
quilt
:quilt new myPatch.diff
src/msg.c
, which determines the presence of the word "Max" in the message text: Index: zenity-3.18.1.1/src/msg.c =================================================================== --- zenity-3.18.1.1.orig/src/msg.c +++ zenity-3.18.1.1/src/msg.c @@ -21,6 +21,8 @@ * Authors: Glynn Foster <glynn.foster@sun.com> */ +#include <string.h> + #include "config.h" #include "zenity.h" @@ -85,6 +87,11 @@ zenity_msg (ZenityData *data, ZenityMsgD GObject *text; GObject *image; + if (strstr(msg_data->dialog_text, "Max") + || strstr(msg_data->dialog_text, "max")) { + return; + } + switch (msg_data->mode) { case ZENITY_MSG_WARNING: builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL);
quilt add src/msg.c
quilt pop
dpkg-source --commit
dpkg-buildpackage -us -uc
rpmdb-client
binary (its zenity
) with my versionzenity
in such a way that, as soon as the word “Max” appears in the message text, the application silently does nothing.Source: https://habr.com/ru/post/417915/
All Articles