Sample Header Ad - 728x90

Allow a sudo sub process to update Zenity running as original user

1 vote
1 answer
178 views
1. A script run by user 'staffer' runs [zenity --progress](https://help.gnome.org/users/zenity/3.24/progress.html.en) . 2. It then calls sudo -u adminBod adminScript (and the STDOUT and STDERR are collected to logger) 3. I want adminScript which is running as adminBod to be able to write to zenity's STDIN, in order to provide updates. ## Try 1 I thought I could pipe channel 3 to zenity's STDIN then write to that from my sudo process:
#!/bin/bash
# Main script, run by 'staffer'
{
  echo "# Starting work"
  exec 3>&1
  sudo -u adminBod adminScript 2>&1 | logger -t myTag
  exec 3>&-
  echo "100" # tells Zenity we're at 100% and it can close
} zenity --progress --auto-close
#!/bin/bash
# adminScript, run by adminBod
echo "# some message for zenity" >/dev/fd/3
echo "# some message for zenity" >&3
This doesn't work because /dev/fd/3 doesn't exist for adminBod. ## Try 2 Then I thought I could use a named pipe, like
staffer% mkfifo -m666 thePipe
staffer% zenity --progress --auto-close /home/staffer/thePipe
This works in that the message gets received by Zenity, but then it seems to close the channel/pipe (sorry unsure of correct term) so that no further updates can be written.
Asked by artfulrobot (3059 rep)
May 26, 2023, 09:48 AM
Last activity: May 26, 2023, 12:14 PM