ubuntu / aad-auth

Azure AD authentication module for Ubuntu
GNU Lesser General Public License v3.0
143 stars 22 forks source link

Issue: podman with "--userns=keep-id" failes. #399

Open johne8 opened 9 months ago

johne8 commented 9 months ago

Is there an existing issue for this?

Describe the issue

Seems like the ownership for the filesystem get spoofed when using podman with "--userns=keep-id"

in the logfile i get aad_auth[7954]: nss_aad: database error: invalid ownership for /var/lib/aad/cache/passwd.db, expected 0:0 but got 65534:65534 where "7954" equals the PID of podman (non-root)

I can fix this by doing the following changes to nss/src/cache/mod.rs (line 369):

            // skip ownership check if detected owned by nobody.
            if stat.uid() != 65534 {
                // Checks ownership
                if stat.uid() != file.expected_uid || stat.gid() != file.expected_gid {
                    return Err(CacheError::DatabaseError(format!(
                        "invalid ownership for {}, expected {}:{} but got {}:{}",
                        file.path.to_str().unwrap(),
                        file.expected_uid,
                        file.expected_gid,
                        stat.uid(),
                        stat.gid()
                    )));
                }
            }

Steps to reproduce it

Ubuntu users: System information and logs

journalctl -f | grep "_aad" aad_auth[7954]: nss_aad: database error: invalid ownership for /var/lib/aad/cache/passwd.db, expected 0:0 but got 65534:65534

Non Ubuntu users: System information and logs

im using ubuntu

Relevant information

No response

Double check your logs

johne8 commented 9 months ago

I added a pull request for the workaround.