Skip to content

Commit

Permalink
users: Correctly catch errors from "useradd -D"
Browse files Browse the repository at this point in the history
When the "catch" is before the "then", the "then" will still run when
an error occurs, with "defaults === undefined", and crash.
  • Loading branch information
mvollmer committed May 27, 2024
1 parent ae1a4e3 commit 5d603a0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/users/account-create-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ export function account_create_dialog(accounts, min_uid, max_uid, shells) {

function get_defaults() {
return cockpit.spawn(["useradd", "-D"], { superuser: "require", err: "message" })
.catch(e => console.warn("Could not get useradd defaults: ", e.message))
.then(defaults => {
let shell = "";
let base_home_dir = null;
Expand All @@ -300,6 +299,7 @@ export function account_create_dialog(accounts, min_uid, max_uid, shells) {
change("shell", shell);
change("base_home_dir", base_home_dir);
})
.catch(e => console.warn("Could not get useradd defaults: ", e.message))
.finally(() => change("dialogLoading", false));
}

Expand Down

0 comments on commit 5d603a0

Please sign in to comment.