From a9c86d12884566a44ab3a5b2ece7f96e63c225c4 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 28 Nov 2024 15:54:07 +0600 Subject: [PATCH] Added checking for default password --- source/ubinstall-gtk.c | 45 +++++++++++++++++------------------------- source/ubinstall-gtk.h | 3 ++- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index f44098c..792e8f8 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -117,25 +117,6 @@ void _yon_saving_threaded(char *final_command){ free(result); } -char *yon_save_command_prepare(char *command, char *target){ - int size; - config_str parsed = yon_char_parse(command,&size," "); - free(parsed[2]); - parsed[2]=yon_char_new(target); - free(parsed[3]); - parsed[3]=yon_char_new("set"); - for (int i=5;iUserNameEntry),""); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->UsernameSensitiveCheck),0); } - if (!yon_char_is_empty(user_password)){ - gtk_entry_set_text(GTK_ENTRY(widgets->PasswordEntry),user_password); - gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->PasswordCombo),1); - } else { + int def_size; + config_str default_password = NULL; + if (!getuid()){ + default_password = yon_config_load(get_default_password_command, &def_size); + if (def_size){ + yon_char_remove_last_symbol(default_password[0],'\n'); + } + } + if ((def_size&&!strcmp(default_password[0],user_password))||yon_char_is_empty(user_password)){ gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->PasswordCombo),0); gtk_entry_set_text(GTK_ENTRY(widgets->PasswordEntry),""); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->PasswordSensitiveCheck),0); + + } else if (!yon_char_is_empty(user_password)){ + gtk_entry_set_text(GTK_ENTRY(widgets->PasswordEntry),user_password); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->PasswordCombo),1); } - if (!yon_char_is_empty(root_password)){ - gtk_entry_set_text(GTK_ENTRY(widgets->AdminPasswordEntry),root_password); - gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->AdminPasswordCombo),1); - } else { + if ((def_size&&!strcmp(default_password[0],user_password))||yon_char_is_empty(user_password)){ gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->AdminPasswordCombo),0); gtk_entry_set_text(GTK_ENTRY(widgets->AdminPasswordEntry),""); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RootPasswordSensitiveCheck),0); + + } else if (!yon_char_is_empty(root_password)){ + gtk_entry_set_text(GTK_ENTRY(widgets->AdminPasswordEntry),root_password); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->AdminPasswordCombo),1); } if (!yon_char_is_empty(autologin)){ if (!strcmp(autologin,"yes")) diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 6dbb515..a5930d3 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -124,6 +124,8 @@ NULL #define set_user_config_command(parameters) yon_char_unite("ubconfig --target system set [autoinstall] ",parameters,";nice ubinstall2 autoconfig",NULL) #define save_additional_config_command(parameters) yon_char_unite("ubconfig --target system set [autoinstall] ",parameters,NULL) +#define get_default_password_command "ubconfig --raw --conarg --default --source global get [users] NOSECUREROOTPASSWD" + #define open_gparted_command "gparted" @@ -467,7 +469,6 @@ void on_password_accept(GtkWidget *self, dictionary *dict); char* yon_debug_output(char *pattern,char*text); -char *yon_save_command_prepare(char *command, char *target); void yon_interface_update(main_window *widgets); void on_summary_log_view(GtkWidget *,main_window *widgets); -- 2.35.1