Bug 1575352

Summary: mock --version requires administrative privileges
Product: [Fedora] Fedora Reporter: Georg Sauthoff <fedora>
Component: mockAssignee: Miroslav Suchý <msuchy>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 27CC: jdisnard, jkeating, mebrown, msimacek, msuchy, praiskup, williams
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-05-09 07:49:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Georg Sauthoff 2018-05-06 08:23:56 UTC
Description of problem:
Invoking a simple `mock --version` command yields a root password prompt, if your user isn't in the 'mock' group.

Sure, one can work around this via `rpm -q mock`. But this also breaks fedora-review which unconditionally calls `mock --version` even if it doesn't need to use mock - e.g. with `fedora-review --help`, `fedora-review --version` or `fedora-review --prebuilt ...`.

One could argue that fedora-review should be fixed instead but requiring root for displaying the version string is just the most surprising thing and thus clearly violates the principle of least astonishment. See also https://bugzilla.redhat.com/show_bug.cgi?id=366711#c3 for another surprised user.

Version-Release number of selected component (if applicable):
mock-1.4.9-1.fc27.noarch

How reproducible:
always

Steps to Reproduce:
1. make sure that your user isn't a member of the 'mock' group
2. mock --version
3.

Actual results:
You are attempting to run "mock" which requires administrative
privileges, but more information is needed in order to do so.
Authenticating as "root"
Password:

Expected results:
The trivial output of the version number.

Additional info:

Comment 1 Miroslav Suchý 2018-05-09 07:49:50 UTC
This will be very complicated to implement. The checking of privilege is done consolehelper before mock is actually executed. So I cannot really done there some "if args[0] == '--version' then do not ask for root"

If fedora-review needs this (and do not want to run 'rpm -q' for some reason') you can run:
  /usr/libexec/mock/mock --version
This executable is run by consolehelper itself and does not check for the root.