setuid postgres (114) failed - Inappropriate ioctl for device

Feb 5, 2018
16
0
41
53
Hi all,

I tried to install the most recent proxmox-mailgateway from the pmg-no-subscription repo. however the installation fails when configuring pmg-api:

Setting up pmg-api (5.0-61) ...
setuid postgres (114) failed - Inappropriate ioctl for device

the problem occurs when

pmgdb init

is called from the postinst script. manually executing

sudo pmgdb init

results in the same error message.

any hints are welcome.

Best regards,
Hp
 
how did you install your Debian Stretch base, what is your hardware/virt platform?

just test on top of a Strech netinstall, works here without issues.
 
thanks for the fast reply.

i am using proxmox ve :)

and yes, I basically also use stretch netinstall.

could this be a filesystem issue? I am using btrfs.

works here, also with btrfs.

pls post your VM config.

> qm config VMID
 
bootdisk: scsi0
cores: 2
memory: 2048
name: gwyneth
net0: virtio=4A:B6:8B:E8:98:0E,bridge=vmbr0
numa: 0
ostype: l26
scsi0: addison-vg:vm-125-disk-1,size=64G
scsihw: virtio-scsi-pci
smbios1: uuid=75ccfabd-6c47-4e16-889a-62df69870007
sockets: 1
 
I let pgmdb init run in an strace. immediately before the error I see:

open("/etc/locale.gen", O_RDONLY) = 4
ioctl(4, TCGETS, 0x7ffe4eaa90a0) = -1 ENOTTY (Inappropriate ioctl for device)
lseek(4, 0, SEEK_CUR) = 0
fstat(4, {st_mode=S_IFREG|0644, st_size=9266, ...}) = 0
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
read(4, "# this file is managed by puppet"..., 8192) = 8192
lseek(4, 154, SEEK_SET) = 154
lseek(4, 0, SEEK_CUR) = 154
close(4) = 0
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4
connect(4, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = 0
sendto(4, "\2\0\0\0\0\0\0\0\t\0\0\0postgres\0", 21, MSG_NOSIGNAL, NULL, 0) = 21
poll([{fd=4, events=POLLIN|POLLERR|POLLHUP}], 1, 5000) = 1 ([{fd=4, revents=POLLIN|POLLHUP}])
read(4, "\2\0\0\0\1\0\0\0\t\0\0\0\2\0\0\0r\0\0\0y\0\0\0\34\0\0\0\24\0\0\0"..., 36) = 36
read(4, "postgres\0x\0PostgreSQL administra"..., 69) = 69
close(4) = 0
geteuid() = 0
setresuid(-1, 0, -1) = 0
setresuid(-1, 114, -1) = 0
setresuid(-1, 0, -1) = 0
write(2, "setuid postgres (114) failed - I"..., 62setuid postgres (114) failed - Inappropriate ioctl for device

I am not really an expert in this but it seems to me that the "setuid postgres" actually works (3rd line from the bottom). pgmdb seems to abort because of an error message occurred much earlier (2nd line). As I understand it, this error should be ignored.
 
was this ever corrected?
i too am seeing this problem. our eval system is stuck trying to upgrade to pmg-api 5.1-3. so far i have traced the issue to a call from 'pmgdb init' during postinstall.
in a perl debug trace i have drilled down to this call:
PMG:: DBTools:: postgres_admin_cmd('psql', ref(HASH), '--list', '--quiet', '--tuples-only') from /usr/share/perl5/PMG/DBTools.pm:110
mine dies with:
setuid postgres (109) failed - Inappropriate ioctl for device

let me know if and what you need from me.
 
was this ever corrected?
i too am seeing this problem. our eval system is stuck trying to upgrade to pmg-api 5.1-3. so far i have traced the issue to a call from 'pmgdb init' during postinstall.
in a perl debug trace i have drilled down to this call:
PMG:: DBTools:: postgres_admin_cmd('psql', ref(HASH), '--list', '--quiet', '--tuples-only') from /usr/share/perl5/PMG/DBTools.pm:110
mine dies with:
setuid postgres (109) failed - Inappropriate ioctl for device

let me know if and what you need from me.


i think i got it.

in /usr/share/perl5/PMG/DBTools.pm, in sub postgres_admin_cmd, i changed this...
original
local $> = $uid;
$! && die "setuid postgres ($uid) failed - $!\n";

to
local $> = $uid || die "setuid postgres ($uid) failed - $!\n";
 
  • Like
Reactions: ward
i think i got it.

in /usr/share/perl5/PMG/DBTools.pm, in sub postgres_admin_cmd, i changed this...
original
local $> = $uid;
$! && die "setuid postgres ($uid) failed - $!\n";

to
local $> = $uid || die "setuid postgres ($uid) failed - $!\n";

If it's really an error, be so kind to open a bug at bugzilla.proxmox.com and/or contribute your adjustments to pmg-devel@pve.proxmox.com
 
i think i got it.

in /usr/share/perl5/PMG/DBTools.pm, in sub postgres_admin_cmd, i changed this...
original
local $> = $uid;
$! && die "setuid postgres ($uid) failed - $!\n";

to
local $> = $uid || die "setuid postgres ($uid) failed - $!\n";

This actually works, i had the exactly same issue upgrading a proxmox install from debian packages on stretch.

Was this ever filed as a bug?
 
no @ward. i have been working with the dev team recently. while my change does work, it has the potential to mute legitimate problems at that spot in the code. we have been discussing possible proper resolution.

the dev team learned that the component that is behind the failure is the package/tool nscd. when it is installed and running the code fails, for reasons that have not been fully identified. our internal workaround (for now) is not to used my code change above. the simple reason is the change will be overwritten when the package containing the pm file is updated. here is what we are doing internally for a debian code base:

Code:
# hold back any upgrades to nscd that would cause the service to restart
# stop the service
apt-mark hold nscd
service nscd stop

# upgrade all other packages
apt update && apt list --upgradable
apt upgrade

# release nscd. upgrade again. restart the service
apt-mark unhold nscd
apt upgrade
service nscd start

We are a debian shop so we have not tested Red Hat, but something like this would probably do the same:
Code:
yum -x nscd update
yum update
 
  • Like
Reactions: Stoiko Ivanov
Hi Patanne

I chose proxmox because it is a debian shop ;)

Thanks for the detailed clarification, i was indeed guessing your fix is just a temporary thing.

Also thanks for the thorough follow up, I'll patiently await a release where this is fixed. My knowledge of the internals is too limited to be of any help.

Success!
 
Hi,

Thanks for reporting the issue @all, and thanks for working with us to get it resolved @patanne !

The patch got merged yesterday and pmg-api version 5.2-2 will contain the fix!
I'll notify you here, once the package has reached our test repository.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!