NationalSecurityAgency/ghidra · error · IllegalArgumentException

Missing desired privilege (admin or user)

Error message

Missing desired privilege (admin or user)

What it means

Thrown by scanPrivilege(params, slot) when the positional privilege argument is missing for changeprivilege/adduser. BSim expects exactly `admin` or `user` to decide whether to grant administrator rights.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java:980

	 * @throws IllegalArgumentException if the user name is not in the given params
	 */
	private void scanUsername(String[] params, int slot) throws IllegalArgumentException {
		if (params.length <= slot) {
			throw new IllegalArgumentException("Missing username");
		}
		specifiedUserName = params[slot];
	}

	/**
	 * Scan command-line for a particular privilege level. Administrator privileges are
	 * requested with the exact String "admin", anything is a request for a read-only user 
	 * @param params are the command-line arguments
	 * @param slot is the position to retrieve the user name argument
	 * @throws IllegalArgumentException the privilege parameter is missing
	 */
	private void scanPrivilege(String[] params, int slot) throws IllegalArgumentException {
		if (params.length <= slot) {
			throw new IllegalArgumentException("Missing desired privilege (admin or user)");
		}
		if (params[slot].equals("admin")) {
			adminPrivilegeRequested = true;
		}
		else if (params[slot].equals("user")) {
			adminPrivilegeRequested = false;
		}
		else {
			throw new IllegalArgumentException("Expecting privilege option (admin or user)");
		}
	}

	/**
	 * Start a PostgreSQL server, configured for BSim, on the local host.
	 * If the data directory is already populated, the server process is simply restarted.
	 * If the data directory is empty, a new server configuration is established, and the server is started.
	 * Authentication may be necessary, either via password or certificate, in order to enable
	 * the BSim extension on the server

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Append `admin` or `user` as the final positional argument.
  2. Review the command's expected argument count.
  3. Use `admin` for write privileges, `user` for read-only.

Example fix

// before
bsim_ctl changeprivilege alice
// after
bsim_ctl changeprivilege alice admin
Defensive patterns

Strategy: validation

Validate before calling

if (args.length <= privilegeSlot) {
    throw new IllegalArgumentException(
        "Missing <admin|user> privilege argument for " + command);
}

Type guard

public boolean hasPrivilegeArg(String[] args, int slot) {
    return args != null && args.length > slot;
}

Try / catch

try {
    bsimControl.exec(args);
} catch (IllegalArgumentException e) {
    if ("Missing desired privilege (admin or user)".equals(e.getMessage())) {
        usage();
        return;
    }
    throw e;
}

Prevention

When it happens

Trigger: Running `bsim_ctl changeprivilege <username>` (or adduser) without the trailing privilege argument; params.length <= slot.

Common situations: Omitted the privilege level; assumed a default; argument consumed by a preceding option value.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/319e19af6d0c8b48. Report an issue: GitHub.