salt icon indicating copy to clipboard operation
salt copied to clipboard

Authentication failure of type "user" occurred

Open vladvasiliu opened this issue 12 years ago • 12 comments

This is an issue for a problem reported on the mailing list: https://groups.google.com/forum/#!msg/salt-users/nyFmw7fUb5I/YJ2E2GsEZ_wJ

On FreeBSD, when running salt '*' test.ping I get an error:

on the client: Failed to authenticate, is this user permitted to execute commands? in the master log: [WARNING ] Authentication failure of type "user" occurred.

The command is run as root. I get root via su -

If I start the master in foreground, it works. However, the logs show the user as vlad.

The workaround Chas mentions in the mailing list works: LOGNAME=root; salt '*' test.ping works both when the master is running in the foreground and when it's started via the init script. The user is also correctly logged as root in the logs.

The system is freebsd 9.2 running salt 2014.1.1 installed via ports.

Vlad

vladvasiliu avatar Mar 28 '14 18:03 vladvasiliu

Have you defined a user in your master config?

basepi avatar Mar 31 '14 15:03 basepi

And thanks for the report. Glad you have a workaround, but we'll investigate a real fix.

basepi avatar Mar 31 '14 15:03 basepi

I cannot replicate this on Ubuntu 13.10. This may be a FreeBSD thing. @terminalmage may have a good idea since he's a BSD person.

cachedout avatar Mar 31 '14 18:03 cachedout

No user was defined in master config. The daemon runs as root.

I haven't had any problems while running on Ubuntu.

vladvasiliu avatar Apr 01 '14 11:04 vladvasiliu

@vladvasiliu The issue is with how we're detecting the user running the salt command. We're using the getpass.getuser() function for portability, since the pwd module is not available on Windows. On FreeBSD, getpass.getuser() does not return the effective username.

FreeBSD

erik@virtubsd:~% su -
Password:
virtubsd# python -c 'import getpass; print getpass.getuser()'
erik
virtubsd# python -c 'import pwd, os; print pwd.getpwuid(os.geteuid()).pw_name'
root

Linux

erik@saltmine:~% su -
Password:
root@saltmine:~# python2 -c 'import getpass; print getpass.getuser()'
root
root@saltmine:~# python2 -c 'import pwd, os; print pwd.getpwuid(os.geteuid()).pw_name'
root

The root cause of this appears to be that in FreeBSD su - does not set LOGNAME to the effective username, and this environment variable is the first one checked by getpass.getuser(), which checks LOGNAME, USER, LNAME and USERNAME, in that order.

FreeBSD

erik@virtubsd:~% su -
Password:
virtubsd# echo $LOGNAME
erik
virtubsd# echo $USER
root
virtubsd# echo $LNAME

virtubsd# echo $USERNAME
root

Linux

erik@saltmine:~% su -
Password:
root@saltmine:~# echo $LOGNAME
root
root@saltmine:~# echo $USER
root
root@saltmine:~# echo $LNAME

root@saltmine:~# echo $USERNAME
root

To resolve this, I am writing a function which uses the pwd module if present, and otherwise uses getpass.

terminalmage avatar Apr 01 '14 19:04 terminalmage

@vladvasiliu Are you by chance using zsh? This LOGNAME issue doesn't seem to apply to csh or tcsh, but it does apply to zsh. So the root cause of this issue might be a zsh bug.

terminalmage avatar Apr 01 '14 21:04 terminalmage

@terminalmage Yes, I am using ZSH. The problem doesn't seem to apply to sh either, as LOGNAME is not set. I guess the problem comes from su rather than zsh, as according to this post, LOGNAME will be the "real username". On a debian box with zsh, LOGNAME is set to root after su -

vladvasiliu avatar Apr 02 '14 08:04 vladvasiliu

@vladvasiliu Just as a follow-up here, I posted to the ZSH mailing list about this, and they are using the getlogin C function, which apparently has a different behavior in FreeBSD libc than in glibc when the user is su'ed.

It's not likely that ZSH will change how they get the username, so this behavioral difference is likely to persist for the forseeable future. However, the fix that I made for this a couple weeks ago will be in 2014.1.2, which should be released soon, so even with your current setup (and without your workaround), this difference will be worked around in the future as the pwd python module will be used to get the user on non-Windows platforms.

terminalmage avatar Apr 15 '14 20:04 terminalmage

OK, thanks for your help!

vladvasiliu avatar Apr 17 '14 13:04 vladvasiliu

I am getting the same error:

2015-11-18 23:48:59,976 [salt.master ][WARNING ][1166] Authentication failure of type "user" occurred.

salt --versions Salt Version: Salt: 2015.8.1

Dependency Versions: Jinja2: 2.7.2 M2Crypto: Not Installed Mako: 0.9.1 PyYAML: 3.10 PyZMQ: 14.4.0 Python: 2.7.6 (default, Mar 22 2014, 22:59:56) RAET: Not Installed Tornado: 4.2.1 ZMQ: 4.0.4 cffi: Not Installed cherrypy: Not Installed dateutil: 2.4.2 gitdb: 0.5.4 gitpython: 0.3.2 RC1 ioflo: Not Installed libnacl: Not Installed msgpack-pure: Not Installed msgpack-python: 0.3.0 mysql-python: 1.2.3 pycparser: Not Installed pycrypto: 2.6.1 pygit2: Not Installed python-gnupg: Not Installed smmap: 0.8.2 timelib: Not Installed

System Versions: dist: Ubuntu 14.04 trusty machine: x86_64 release: 3.13.0-48-generic system: Ubuntu 14.04 trusty

syedaali avatar Nov 19 '15 03:11 syedaali

@syedaali This issue has been closed for over 18 months. Please open a new issue and provide more information, including what command you ran to trigger the error and how you started Salt (in the foreground on the CLI, via upstart, etc.).

terminalmage avatar Nov 19 '15 03:11 terminalmage

Opened #29031, thanks.

syedaali avatar Nov 19 '15 04:11 syedaali