summaryrefslogtreecommitdiff
path: root/device-functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'device-functions.c')
-rw-r--r--device-functions.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/device-functions.c b/device-functions.c
index ac4a9b4..061f759 100644
--- a/device-functions.c
+++ b/device-functions.c
@@ -4492,25 +4492,32 @@ int change_password(gchar *old_password, gchar *new_password)
struct lu_error *error = NULL;
struct lu_ent *ent;
+ int result;
+ result = OK;
+
+ remount_root_as_writeable ();
+
ctx = lu_start(user, lu_user, NULL, NULL, lu_prompt_console_quiet, NULL, &error);
if (ctx == NULL ) {
- return password_change_error;
+ result = password_change_error;
}
ent = lu_ent_new();
- if (lu_user_lookup_name(ctx, user, ent, &error) == FALSE) {
- return password_change_error; // user doesn't exist
+ if (!result && (lu_user_lookup_name(ctx, user, ent, &error) == FALSE)) {
+ result = password_change_error; // user doesn't exist
}
- if (lu_user_setpass(ctx, ent, new_password, FALSE, &error) == FALSE) {
- return password_change_error;
+ if (!result && (lu_user_setpass(ctx, ent, new_password, FALSE, &error) == FALSE)) {
+ result = password_change_error;
}
lu_end(ctx);
- return OK;
+ remount_root_as_not_writeable ();
+
+ return result;
} else {
return password_change_error;
}