{"record":{"id":"a36edc51979c67a1","repo":"NationalSecurityAgency/ghidra","slug":"expecting-privilege-option-admin-or-user","errorCode":null,"errorMessage":"Expecting privilege option (admin or user)","messagePattern":"Expecting privilege option \\(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":989,"sourceCode":"\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\n\t * \n\t * @throws IOException if postgres cannot be started \n\t * @throws InterruptedException if the process fails during the run\n\t * @throws SAXException if the data directory cannot be initialized\n\t * @throws GeneralSecurityException if the authentication fails\n\t */\n\tprivate void startCommand()\n\t\t\tthrows IOException, InterruptedException, SAXException, GeneralSecurityException {\n\t\tdiscoverPostgresInstall();","sourceCodeStart":971,"sourceCodeEnd":1007,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java#L971-L1007","documentation":"Thrown by scanPrivilege() when the privilege argument is present but is neither `admin` nor `user`. BSim maps exactly those two strings to the adminPrivilegeRequested flag; anything else is rejected.","triggerScenarios":"Passing `bsim_ctl changeprivilege alice administrator`, `... readwrite`, `... true`, or any value other than `admin`/`user`.","commonSituations":"Using a synonym (administrator/superuser/readwrite); passing a boolean; case mismatch (Admin/USER); locale-specific word.","solutions":["Use exactly `admin` or `user` (lowercase).","Double-check spelling and case.","Consult usage help for the accepted literal values."],"exampleFix":"// before\nbsim_ctl changeprivilege alice administrator\n// after\nbsim_ctl changeprivilege alice admin","handlingStrategy":"type-guard","validationCode":"Set<String> allowed = Set.of(\"admin\", \"user\");\nif (!allowed.contains(args[privilegeSlot])) {\n    throw new IllegalArgumentException(\n        \"Privilege must be one of \" + allowed + \", got: \" + args[privilegeSlot]);\n}","typeGuard":"public boolean isValidPrivilege(String v) {\n    return \"admin\".equals(v) || \"user\".equals(v);\n}","tryCatchPattern":"try {\n    bsimControl.exec(args);\n} catch (IllegalArgumentException e) {\n    if (\"Expecting privilege option (admin or user)\".equals(e.getMessage())) {\n        throw new UserFacingException(\"Use exactly 'admin' or 'user' (lowercase)\", e);\n    }\n    throw e;\n}","preventionTips":["Normalize/sanity-check privilege to the exact literals before invoking.","Avoid synonyms like administrator/superuser in scripts."],"tags":["cli","arguments","authorization","validation","bsim"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}