Bug #51276 Workbench doesn't use sudo to execute the status script
Submitted: 18 Feb 2010 8:58 Modified: 19 Apr 2010 14:53
Reporter: Giuseppe Maxia Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: Administration Severity:S2 (Serious)
Version:5.2.16 OS:MacOS
Assigned to: Maksym Yehorov CPU Architecture:Any
Tags: Administration, STATUS, workbench

[18 Feb 2010 8:58] Giuseppe Maxia
Description:
In the Server Administration section, WB provides three hooks to OS scripts that start, stop, and check the server status.

The default script for checking the status will only work if there is only one instance of the server running. 
The help says that users can provide a script that returns zero on success to determine if the server is running. 
So I modified the /usr/local/mysql/support-files/mysql.server script to give the correct information. Unfortunately, it only works with root access, and WB executes only the start/stop scripts with "sudo", not the status script.

WB should also run the status script with "sudo". In some cases, it's the only way a status script can access the pid file.

How to repeat:
create a status script that reads the (privilege restricted) .pid file and reports if the server is running.
Try to run it without sudo.
[18 Feb 2010 12:12] Susanne Ebrecht
Giuseppe,

sorry, that I have to ask, but you start/stop server as root?
Usually this should be done as another user then root. Per default user mysql is used here.

Do you really need sudo here or do you need su mysql here?
[18 Feb 2010 13:23] Giuseppe Maxia
Susanne,
no, I don't run MySQL as root. 
I use sudo to run the start/stop/status scripts. The server runs as "mysql". The administrative commands need a sudo if invoked from a normal user
[18 Feb 2010 20:37] Mike Frank
So a simple solution for is to make sudo an option for status check as well.
Thus
under current 
Use sudo to execute start/stop and write confuration data.

add 
a checkbox with - 
Use sudo to Check MySQL Status.  (Default off)
[19 Feb 2010 10:35] Susanne Ebrecht
Sudo should be used for all of this:

start
stop
restart
reload
force-reload
status
[16 Mar 2010 2:30] Alfredo Kojima
sudo for executing status script is likely to only be needed in Linux/Mac, not Windows. Therefore I propose that the following simple changes are implemented:

- allow user to specify sudo in front of any of the start/stop or status commands
- if sudo is the first token in the command, it should be stripped off by WBA and the rest of the command should be executed as if the "enable sudo" checkbox has been enabled ie, according to following pseudo-code:

use_sudo = instance.serverInfo["sys.usesudo"]
if command.startswith("sudo "):
    command = command[5:]
    use_sudo = True

execute(command, use_sudo)
[17 Mar 2010 9:49] Maksym Yehorov
sudo for status added. Linux and OSX only.
[1 Apr 2010 23:58] Johannes Taxacher
sudo option has been added in repository
[19 Apr 2010 14:53] Tony Bedford
An entry has been added to the 5.2.17 changelog:

MySQL Workbench has been changed so that it is possible to run the start, stop, and check status scripts executed from the Administrator, with administrator privileges. A checkbox has been provided to allow you the option of acquiring the administrator rights in order to execute the commands. This option is switched off by default for the check status command.