mirror of
https://github.com/lldap/lldap.git
synced 2026-04-25 16:25:55 +03:00
[GH-ISSUE #86] Error: This error results from an error during password verification #34
Labels
No labels
backend
blocked
bug
cleanup
dependencies
docker
documentation
duplicate
enhancement
enhancement
frontend
github_actions
good first issue
help wanted
help wanted
integration
invalid
ldap
pull-request
question
rust
rust
tests
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/lldap-lldap#34
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kaysond on GitHub (Nov 24, 2021).
Original GitHub issue: https://github.com/lldap/lldap/issues/86
Originally assigned to: @nitnelave on GitHub.
If its not obvious by now I've been slowly trying to get this up and running all night XD
I'm now stuck on the following error:
Error: This error results from an error during password verificationCouldn't find that error text in the repo so I guess its a dependency? I'm wondering if it's a permissions problem because the image is built depending on being run as uid 10001
My compose file is:
and my config is
@kaysond commented on GitHub (Nov 24, 2021):
So it was sort of a permissions issue - originally I was getting a different error that lldap couldn't write to
/data/private_key, because the directory wasn't writeable by 10001. So I did atouch private_key && chmod a+w private_key. Apparently the library (opaque?) doesn't like it if the private_key file exists but is empty!@nitnelave commented on GitHub (Nov 24, 2021):
I see. And you didn't have issues with the
users.db,users.db.shmand related files?I'll try to add a more explicit (and fatal) error if we can't write to the server key.
@kaysond commented on GitHub (Nov 24, 2021):
No. The order of events was:
/data/data/private_key"touch private_key && chmod a+w private_keyprivate_key, and dochown 10001 /dataThen everything starts up just fine because it can create files in
/data, and there's no emptyprivate_key.@kaysond commented on GitHub (Nov 24, 2021):
So now I'm trying to run it as a different user (via docker-compose
user:) so I can use the existing permissions setup of my storage, and I get the following:It's interesting because it says its loading the configuration, and it has permissions to read that file, but it's using what appears to be the default value for
key_fileEdit: looks like the issue here is that
get_server_setupautomatically writes to the location atkey_fileif the path doesn't exist, and since the first call toConfigurationBuilderis used to build the defaults, it's trying to write to/app/server_key, which my user doesn't have permissions forgithub.com/nitnelave/lldap@ba7848d043/server/src/infra/configuration.rs (L217-L222)github.com/nitnelave/lldap@ba7848d043/server/src/infra/configuration.rs (L80-L93)github.com/nitnelave/lldap@ba7848d043/server/src/infra/configuration.rs (L105-L121)@kaysond commented on GitHub (Nov 24, 2021):
This also explains the original error I was seeing - the problem is that
get_server_setupsees that theprivate_keyfile exists, so it loads it, but then provides a totally empty config to the rest of the program. I think there probably needs to be some validation to ensure there are no problems with the file contents before continuing.@JaneJeon commented on GitHub (Nov 24, 2021):
I, too, am also stuck on the
thing (not just
touching the file, but also creating a valid private key and directly mounting it on it, in which case it complains that it can't read it). I'm pretty sure there's some deep underlying permissions issue at play here.Tried like 50000 different things (including different directories and permissions) :/
@JaneJeon commented on GitHub (Nov 24, 2021):
And given how severe this issue is (it's preventing me from even spinning up the container in the first place) and given that nobody apparently complained about this before us, I'm guessing it's a somewhat recent regression. If that's the case, when would be the last "safe" image?
@kaysond commented on GitHub (Nov 24, 2021):
@JaneJeon what you are describing seems like a configuration/permissions issue, not a container issue. Once I set proper write permissions on the data directory (e.g.
chown -R 10001 /data && chmod -R u+w /data), the container started up with no issues.I do think, though, that the way the container is set up is prone to confuse users because permissions handling is fairly opaque. It would probably be better overall to make it compatible with docker-compose
user:or allow forPUIDandPGIDenv vars to set the process user/group.@JaneJeon commented on GitHub (Nov 25, 2021):
As I have mentioned above, I have run those commands that you mentioned and it still doesn't work. I've ran it within the container and I thought maybe the issue is that I"m mounting the data directory from the outside (i.e. I'm mounting from a host folder to
/datawithin the directory), but even after I have run the commands on the host folder I'm mounting, it stil spits out the same error.Either way, I'm ready to throw in the towel. I host like 7 different docker containers that I mount a host directory onto, and lldap seems to be the only one absolutely screeching at it.
@JaneJeon commented on GitHub (Nov 25, 2021):
btw @nitnelave I'm pretty sure I found where the actual error message came from: https://docs.rs/opaque-ke/0.5.0/opaque_ke/errors/enum.ProtocolError.html#variant.VerificationError
Dunno if it helps, but
@kaysond commented on GitHub (Nov 25, 2021):
Is that the error message you're seeing? Your comment mentioned the other error. If you're getting the password verification error it's probably the same thing I saw - whatever you've put in the
private_keyfile is invalid.I also mount a host directory (
/var/lib/lldap/data) to/datain the container. If I empty the directory (rm /var/lib/lldap/data/*) then give the default user perms (chown 10001 + chmod /var/lib/lldap/data), it works.@JaneJeon commented on GitHub (Nov 25, 2021):
Okay, just checked again. I had generated a valid pem key but it looks like having any key in there triggers the error you mentioned above.
Deleting it seems to work, but it's still... idk, quite dirty of a solution imho
@nitnelave commented on GitHub (Nov 25, 2021):
Yeah, I'm aware that the permissions stuff is not super well handled right now. I think I'll build on #89 and introduce better user support, including the docker-compose
user, UID and so on. I'll have to look up how it's done elsewhere, unless someone wants to take it up.@kaysond commented on GitHub (Nov 25, 2021):
I'm happy to work on that next after we close #89!
@nitnelave commented on GitHub (Nov 25, 2021):
That would be of great help, thanks!
@kaysond commented on GitHub (Nov 26, 2021):
So what linuxserver.io does in their containers, is create a user called
abc, and in their base image init scripts, dousermod -o -u "$PUID" abc(and similar for groups). They then doexec s6-setuidgid abc:abcin the container to drop privileges on the process.You could do something similar here, though you don't have busybox
setuidgidin alpine, or s6 (you could add it to the container, though). I think you should be able to just do it withsubut I haven't tried that yet.But if we fix the initial server_key write bug, you could just use docker's built in user parameter. What I'd propose is to change the default for
key_fileto be/data/server_key, anddatabase_urltosqlite:///data/users.db?mode=rwc(which would match the config template anyways). Then in the container we make a/datadirectory with0777permissions.This way, the initial config can get written there no problem if you don't set the user, or if you set
key_fileto another location. If you mount a host directory, then the container will see the permissions of the host directory.I did a quick test and it seems to work just fine, and by doing
--userI can set the process uid to whatever I want@nitnelave commented on GitHub (Nov 26, 2021):
Rather than change the defaults in the source code, how about this: the start script checks if /data/lldap_config.toml exists, otherwise it creates it (copying from the template). That way we can make sure that the folder is writeable even before we start lldap.
WDYT?
@kaysond commented on GitHub (Nov 26, 2021):
I think thats a good idea in general, but it doesnt quite solve the permissions problem. The problem is you're running the
lldapbinary from inside/app. So whenconfiguration.rstries to write the initial key file toserver_key, it actually writes it to/app/server_key, which is owned by theappuser (uid 10001). If you set--user, then it can't write there and it crashes. It always tries to write there when you start the container up when it loads the defaultsMaybe the "right" thing to do here is actually fix the "bug" - we don't actually want
get_server_setupto write the server config to file until after the defaults are loaded, the toml is merged, and the env vars are mergedgithub.com/nitnelave/lldap@ba7848d043/server/src/infra/configuration.rs (L115)@nitnelave commented on GitHub (Nov 26, 2021):
But... It does wait until the config is loaded. It's just that in the cases mentioned above, there was no (readable) config to load, so it reverted to the defaults. I think it's better to make sure there's a config, and if it's copied from the template it'll have the correct location for the server_key file
@kaysond commented on GitHub (Nov 26, 2021):
I'm new to rust, so its very possible I'm reading the code wrong, but this is my understanding of configuration.rs
initgets calledgithub.com/nitnelave/lldap@5b5395103a/server/src/infra/configuration.rs (L206)This creates the configuration, which starts with a call to
ConfigurationBuilder::default().build().unwrap()on L128, then afterwards merges in the config file and env varsgithub.com/nitnelave/lldap@5b5395103a/server/src/infra/configuration.rs (L217-L222)The initial
ConfigurationBuilder::build()callsget_server_setup(self.key_file.as_deref().unwrap_or("server_key"))?;(L82) but at this point,self.key_filehas not yet been defined from the config file, so it's using "server_key" from either theunwrap_oror from the macro (again - rust noob so not sure which, but theyre the same value!)github.com/nitnelave/lldap@5b5395103a/server/src/infra/configuration.rs (L80-L84)Macro:
github.com/nitnelave/lldap@5b5395103a/server/src/infra/configuration.rs (L63-L64)So the result is that
get_server_setup("server_key")is called, and since/app/server_keydoesn't exist, it tries to write there. If the process uid is not10001, this will always fail.github.com/nitnelave/lldap@5b5395103a/server/src/infra/configuration.rs (L105-L121)After the defaults are loaded as described above, user-supplied values get merged in, and then there's another call to
get_server_setup, but this time its with correctly loaded value ofkey_file(assuming you can even get here).github.com/nitnelave/lldap@5b5395103a/server/src/infra/configuration.rs (L228)This lines up with the behavior I observed - the config file was properly mounted and readable just fine, but if i changed
--user, it would fail trying to write toserver_key, despite that in the config file I setkey_file: /data/private_key.Please let me know if my rust understanding is off :D
@nitnelave commented on GitHub (Nov 26, 2021):
Don't sell yourself short, you're one up on me on this one :D
get_server_setupshould not be called from the build, indeed. Right now, it tries to read/write 2 server keys, one next to the binary and one in the correct place.I'll fix that when i get the chance.
@kaysond commented on GitHub (Nov 26, 2021):
Awesome! I bet that, along with maybe some more explicit info on permissions in the docs should solve most of the issues
@nitnelave commented on GitHub (Nov 27, 2021):
Just pushed a fix, feel free to try it, you can add
user: 1000:1000(or whatever your uid/gid is) in the docker compose.@kaysond commented on GitHub (Nov 29, 2021):
This is fixed on my end. Thanks!