Bug 1146473 - pkexec can't find usermod
Summary: pkexec can't find usermod
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: glib2
Version: 21
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Matthias Clasen
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-09-25 10:14 UTC by Marius Vollmer
Modified: 2014-11-15 02:59 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-11-15 02:59:32 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Reproducer (471 bytes, text/x-csrc)
2014-09-25 13:08 UTC, Miloslav Trmač
no flags Details

Description Marius Vollmer 2014-09-25 10:14:10 UTC
polkit-0.112-7.fc21.x86_64

Trying to execute "pkexec usermod ..." as a user in the wheel group fails, while other programs from /usr/sbin work as expected:

[admin@f21 ~]$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/admin/.local/bin:/home/admin/bin
[admin@f21 ~]$ pkexec usermod --help
Cannot run program usermod: No such file or directory
[admin@f21 ~]$ pkexec lvs
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/usr/sbin/lvs' as the super user
Authenticating as: Administrator (admin)
Password: 
==== AUTHENTICATION COMPLETE ===
  LV   VG     Attr       LSize   [...]
                    
The reason seems to be that /usr/sbin/usermod is not world-executable.

Comment 1 Miloslav Trmač 2014-09-25 13:08:04 UTC
Created attachment 941076 [details]
Reproducer

Comment 2 Miloslav Trmač 2014-09-25 13:15:39 UTC
Thanks for your report.

As a workaround for now, you can use (pkexec /usr/sbin/usermod …).

The underlying issue is a bug in g_find_program_in_path().  It is documented as “Locates the first executable named @program in the user's path, in the same way that execvp() would locate it.”, but is actually inconsistent with execvp().

execvp(3p) refers to the documentation of PATH at http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08 , which says “… until an executable file with the specified name and appropriate execution permissions is found”, but g_find_program_in_path() is implemented using g_file_test(), which is using the _real_ UID/GID instead of the _effective_ UID/GID.

To reproduce:

> $ gcc -O2 -Wall -Wextra $(pkg-config --cflags --libs glib-2.0) foo.c -o foo
(as root)
> # chown root foo
> # chmod u+s foo
(as unprivileged user)
> $ LC_ALL=en_US.UTF-8 ./foo usermod
> g_find_program_in_path(): (not found)
> Usage: usermod [options] LOGIN
…

shows that g_find_program_in_path() returns NULL but execlp() can find it fine.

Comment 3 Matthias Clasen 2014-11-15 02:59:12 UTC
Filed upstream: https://bugzilla.gnome.org/show_bug.cgi?id=740155


Note You need to log in before you can comment on or make changes to this bug.