FS#35167 - postgresql groupadd not found when run under sudo

Attached to Project: Arch Linux
Opened by Neale Swinnerton (sw1nn) - Thursday, 09 May 2013, 10:47 GMT
Last edited by Dave Reisner (falconindy) - Friday, 10 May 2013, 12:42 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To No-one
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

When installing postgresl via sudo, PATH does not include groupadd

The necessary executables are installed, via the shadow package, but are not on the PATH when invoked via sudo.

A similar problem occurs when removing the package via sudo

if logged in as root, pacman -S postgresql completes without error.

Additional info:

postgresql-9.2.4-1


Steps to reproduce:

--------------------------------------------
% pacman -Q shadow
shadow 4.1.5.1-5

% sudo pacman -S postgresql
resolving dependencies...
looking for inter-conflicts...

Packages (1): postgresql-9.2.4-1

Total Installed Size: 26.23 MiB

:: Proceed with installation? [Y/n]
(1/1) checking keys in keyring [######################] 100%
(1/1) checking package integrity [######################] 100%
(1/1) loading package files [######################] 100%
(1/1) checking for file conflicts [######################] 100%
(1/1) checking available disk space [######################] 100%
(1/1) installing postgresql [######################] 100%
/tmp/alpm_EF0UdJ/.INSTALL: line 6: groupadd: command not found
/tmp/alpm_EF0UdJ/.INSTALL: line 9: useradd: command not found
passwd: user 'postgres' does not exist
error: command failed to execute correctly
Optional dependencies for postgresql
python2: for PL/Python support [installed]
perl: for PL/Perl support [installed]
tcl: for PL/Tcl support [installed]
postgresql-old-upgrade: upgrade from previous major version using pg_upgrade

----------------------------------------------------------------
If I do the following, all is well...

% sudo su -

# pacman -S postgresql
resolving dependencies...
looking for inter-conflicts...

Packages (1): postgresql-9.2.4-1

Total Installed Size: 26.23 MiB

:: Proceed with installation? [Y/n]
(1/1) checking keys in keyring [######################] 100%
(1/1) checking package integrity [######################] 100%
(1/1) loading package files [######################] 100%
(1/1) checking for file conflicts [######################] 100%
(1/1) checking available disk space [######################] 100%
(1/1) installing postgresql [######################] 100%
Optional dependencies for postgresql
python2: for PL/Python support [installed]
perl: for PL/Perl support [installed]
tcl: for PL/Tcl support [installed]
postgresql-old-upgrade: upgrade from previous major version using pg_upgrade
This task depends upon

Closed by  Dave Reisner (falconindy)
Friday, 10 May 2013, 12:42 GMT
Reason for closing:  Not a bug
Additional comments about closing:  Working as intended given the user's shell config.
Comment by Eric Belanger (Snowman) - Thursday, 09 May 2013, 18:11 GMT
Works here. Are you doing something unusual with the PATH variable? What's the output of 'sudo echo $PATH'?
Comment by Dave Reisner (falconindy) - Thursday, 09 May 2013, 18:13 GMT
FYI that isn't going to work so well because $PATH will be expanded before the command is executed.

perhaps...
$ sudo bash -c 'echo $PATH'
Comment by Neale Swinnerton (sw1nn) - Thursday, 09 May 2013, 19:04 GMT
Not doing anything unusual that I know about. Note that the groupadd only occurs if the group doesn't already exist, so if you re-install over an existing installation you don't see the error.

Here's the PATH stuff...

sudo bash -c 'echo $PATH'
[sudo] password for neale:
/home/neale/bin:/home/neale/.rvm/bin:/opt/java/bin:/home/neale/bin:/home/neale/.rvm/bin:/opt/java/bin:/bin:/usr/bin:/usr/local/bin

sudo bash --login -c 'echo $PATH'
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/java/bin:/opt/java/db/bin:/opt/java/jre/bin:/usr/bin/vendor_perl:/usr/bin/core_perl

Comment by Dave Reisner (falconindy) - Thursday, 09 May 2013, 19:15 GMT
So in other words, your user environment is clobbering your PATH, rather than appending/prepending to it.
Comment by Neale Swinnerton (sw1nn) - Friday, 10 May 2013, 10:08 GMT
right, this is me not knowing sudo properly I guess, my bad.

From the sudo man page for the benefit of others:

Note, however, that the actual PATH environment variable is not modified and is passed unchanged to the program that sudo executes.

Loading...