Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to change group from ... to ...: Operation not permitted (wrong $LOGNAME) #88

Open
eserte opened this issue Dec 29, 2017 · 1 comment

Comments

@eserte
Copy link

eserte commented Dec 29, 2017

The test suite fails on all my FreeBSD 11 and 12 smokers:

#   Failed test 'Ubic::Cmd logged something on start'
#   at t/cmd.t line 25.
#                   'Starting sleeping-daemon... Failed to change group from cpansand to wheel: Operation not permitted at lib/Ubic/Credentials/OS/POSIX.pm line 178.
#
# '
#     doesn't match '(?^:^Starting\ sleeping\-daemon\.\.\.\ started\ \(pid\ \d+\)\n$)'
Failed to change group from cpansand to wheel: Operation not permitted at lib/Ubic/Credentials/OS/POSIX.pm line 178.

# Looks like your test exited with 1 just after 1.
t/cmd.t ........................
Dubious, test returned 1 (wstat 256, 0x100)
Failed 8/8 subtests
(etc)

I don't see this failure on FreeBSD 9 + 10 smokers. In all cases the user "cpansand" is not member of the "wheel" group.

@eserte
Copy link
Author

eserte commented Dec 29, 2017

OK, I found the issue: this happens because I use sudo su cpansand to change the user before starting the smokers etc. On FreeBSD systems it seems that sudo changes $LOGNAME, but the subsequent su does not change it, so $LOGNAME stays as root which leads to the problems.

I see two solutions:

  • use $USERNAME instead of $LOGNAME --- this one has the correct value
  • use (getpwuid($<))[0]

I would prefer the latter. In my experience getpwuid (if it's available) gives the most accurate results.

@eserte eserte changed the title FreeBSD 11+12: Failed to change group from ... to ...: Operation not permitted Failed to change group from ... to ...: Operation not permitted (wrong $LOGNAME) Dec 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant