{"record":{"id":"319e19af6d0c8b48","repo":"NationalSecurityAgency/ghidra","slug":"missing-desired-privilege-admin-or-user","errorCode":null,"errorMessage":"Missing desired privilege (admin or user)","messagePattern":"Missing desired privilege \\(admin or user\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java","lineNumber":980,"sourceCode":"\t * @throws IllegalArgumentException if the user name is not in the given params\n\t */\n\tprivate void scanUsername(String[] params, int slot) throws IllegalArgumentException {\n\t\tif (params.length <= slot) {\n\t\t\tthrow new IllegalArgumentException(\"Missing username\");\n\t\t}\n\t\tspecifiedUserName = params[slot];\n\t}\n\n\t/**\n\t * Scan command-line for a particular privilege level. Administrator privileges are\n\t * requested with the exact String \"admin\", anything is a request for a read-only user \n\t * @param params are the command-line arguments\n\t * @param slot is the position to retrieve the user name argument\n\t * @throws IllegalArgumentException the privilege parameter is missing\n\t */\n\tprivate void scanPrivilege(String[] params, int slot) throws IllegalArgumentException {\n\t\tif (params.length <= slot) {\n\t\t\tthrow new IllegalArgumentException(\"Missing desired privilege (admin or user)\");\n\t\t}\n\t\tif (params[slot].equals(\"admin\")) {\n\t\t\tadminPrivilegeRequested = true;\n\t\t}\n\t\telse if (params[slot].equals(\"user\")) {\n\t\t\tadminPrivilegeRequested = false;\n\t\t}\n\t\telse {\n\t\t\tthrow new IllegalArgumentException(\"Expecting privilege option (admin or user)\");\n\t\t}\n\t}\n\n\t/**\n\t * Start a PostgreSQL server, configured for BSim, on the local host.\n\t * If the data directory is already populated, the server process is simply restarted.\n\t * If the data directory is empty, a new server configuration is established, and the server is started.\n\t * Authentication may be necessary, either via password or certificate, in order to enable\n\t * the BSim extension on the server","sourceCodeStart":962,"sourceCodeEnd":998,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java#L962-L998","documentation":"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.","triggerScenarios":"Running `bsim_ctl changeprivilege <username>` (or adduser) without the trailing privilege argument; params.length <= slot.","commonSituations":"Omitted the privilege level; assumed a default; argument consumed by a preceding option value.","solutions":["Append `admin` or `user` as the final positional argument.","Review the command's expected argument count.","Use `admin` for write privileges, `user` for read-only."],"exampleFix":"// before\nbsim_ctl changeprivilege alice\n// after\nbsim_ctl changeprivilege alice admin","handlingStrategy":"validation","validationCode":"if (args.length <= privilegeSlot) {\n    throw new IllegalArgumentException(\n        \"Missing <admin|user> privilege argument for \" + command);\n}","typeGuard":"public boolean hasPrivilegeArg(String[] args, int slot) {\n    return args != null && args.length > slot;\n}","tryCatchPattern":"try {\n    bsimControl.exec(args);\n} catch (IllegalArgumentException e) {\n    if (\"Missing desired privilege (admin or user)\".equals(e.getMessage())) {\n        usage();\n        return;\n    }\n    throw e;\n}","preventionTips":["Treat username and privilege as a required trailing pair in wrappers.","Surface the accepted literals (admin/user) in usage text."],"tags":["cli","arguments","authorization","usage","bsim"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}