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

Unable to run installer if userid 301 already exists #842

Open
SeanAMartin opened this issue Feb 9, 2024 · 3 comments
Open

Unable to run installer if userid 301 already exists #842

SeanAMartin opened this issue Feb 9, 2024 · 3 comments
Labels
MacOS Darwin/MacOS

Comments

@SeanAMartin
Copy link

As the install script isn't directly exposed in the determinate systems installer, there is no way to override the variable when installing. As a result:

Error

Error: 
   0: Install failure
   1: Error executing action
   2: Action `create_users_and_group` errored
   3: Action `create_user` errored
   4: Failed to execute command with status 55 `"/usr/bin/dscl" "." "-create" "/Users/_nixbld1" "UniqueID" "301"`, stdout: 
      stderr: <main> attribute status: eDSRecordAlreadyExists
      <dscl_cmd> DS Error: -14135 (eDSRecordAlreadyExists)


Metadata

key value
version 0.16.1
os macos
arch aarch64
@Hoverbear Hoverbear added the MacOS Darwin/MacOS label Feb 9, 2024
@Hoverbear
Copy link
Contributor

There is a way to override which user ID the installer starts at, the --nix-build-user-id-base flag or NIX_INSTALLER_NIX_BUILD_USER_ID_BASE environment:

/// The Nix build user base UID (ascending)
#[cfg_attr(
feature = "cli",
clap(long, env = "NIX_INSTALLER_NIX_BUILD_USER_ID_BASE", global = true)
)]
#[cfg_attr(
all(target_os = "macos", feature = "cli"),
doc = "Service users on Mac should be between 200-400"
)]
#[cfg_attr(all(target_os = "macos", feature = "cli"), clap(default_value_t = 300))]
#[cfg_attr(
all(target_os = "linux", feature = "cli"),
clap(default_value_t = 30_000)
)]
pub nix_build_user_id_base: u32,

This is documented in nix-installer install --help:

      --nix-build-user-id-base <NIX_BUILD_USER_ID_BASE>
          The Nix build user base UID (ascending)
          
          [env: NIX_INSTALLER_NIX_BUILD_USER_ID_BASE=]
          [default: 30000]

In your case, you could set NIX_INSTALLER_NIX_BUILD_USER_ID_BASE=302.

I am a bit confused why we did not detect this in the planning phase, do you happen to know what the username of UID 301 is?

dscl . -list /Users UniqueID | grep 301

I believe we can make the planner code a bit more robust to avoid this in the future, it should probably check by ID as well:

// Ensure user does not exists
if let Some(user) = User::from_name(name.as_str())
.map_err(|e| ActionErrorKind::GettingUserId(name.clone(), e))
.map_err(Self::error)?
{
if user.uid.as_raw() != uid {
return Err(Self::error(ActionErrorKind::UserUidMismatch(
name.clone(),
user.uid.as_raw(),
uid,
)));
}
if user.gid.as_raw() != gid {
return Err(Self::error(ActionErrorKind::UserGidMismatch(
name.clone(),
user.gid.as_raw(),
gid,
)));
}
tracing::debug!("Creating user `{}` already complete", this.name);
return Ok(StatefulAction::completed(this));
}

@quot
Copy link

quot commented Feb 27, 2024

I hit this same issue. Running export NIX_INSTALLER_NIX_BUILD_USER_ID_BASE=302 before the install fixed the problem.

I am a bit confused why we did not detect this in the planning phase, do you happen to know what the username of UID 301 is?

UID 301 on my machine was taken by user _defendpoint, which seems to have been created by an install of BeyondTrust Endpoint Privilege Management. I do have BeyondTrust software installed on this machine, but I can't find much about that user online. This is the only thing I could find saying that their software manages that user in their MacOS installs: https://www.beyondtrust.com/docs/release-notes/privilege-management/windows-and-mac/mac/pm-mac-22-9.htm

@elefantes
Copy link

I hit the same issue because I had some packages installed by MacPorts which used some UIDs in the default range.
The installer options weren't clear immediately because you have to specify the subcommand before issuing --help to see the right ones.

Hopefully the installer can check this in the future prior to performing any actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MacOS Darwin/MacOS
Projects
None yet
Development

No branches or pull requests

4 participants