From 6476b44930d17aff76f992ee1637bd80aac6acc7 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 22 Jan 2024 12:51:31 +0600 Subject: [PATCH] Added 'Default' value to hash combo box --- source/ubl-settings-usergroups.c | 22 ++++++++++++++++++---- source/ubl-settings-usergroups.h | 3 ++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index 5ddb99b..3d9902b 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -399,9 +399,13 @@ void on_expiration_clicked(GtkWidget *self, ubl_settings_usergroups_user_window } else { yon_config_register("ADDADM","users","no"); } - char *hash = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->PasswordHashCombo)); - if (!yon_char_is_empty(hash)){ - yon_config_register("HASHPASSWD","users",hash); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(window->PasswordHashCombo))!=0){ + char *hash = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->PasswordHashCombo)); + if (!yon_char_is_empty(hash)){ + yon_config_register("HASHPASSWD","users",hash); + } + }else { + yon_config_remove_by_key("HASHPASSWD"); } } @@ -438,6 +442,16 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_ yon_window_config_custom_window_setup(GTK_WINDOW(window->Window),"AdditionalSettingsWindow"); gtk_window_set_title(GTK_WINDOW(window->Window),ADDITIONAL_SETTINGS_TITLE_LABEL); + + if (main_config.hash_default_id==-1){ + int size; + config_str ret = yon_config_load(get_default_hash_command,&size); + if (size>0){ + char *hash = ret[0]; + if (hash[strlen(hash)-1]=='\n') hash[strlen(hash)-1]='\0'; + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->PasswordHashCombo),yon_char_unite(DEFAULT_USER_LABEL," (",hash,")",NULL)); + } + } int hash_size=0; config_str hash_algos = yon_file_open(hash_list_path,&hash_size); for (int i=1;iPasswordHashCombo),hash); } - g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_additional_settings_save),window); @@ -1596,6 +1609,7 @@ void config_init(){ main_config.lock_save_local=0; main_config.groups_size=0; main_config.load_mode=1; + main_config.hash_default_id=-1; main_config.groups = yon_file_open(groups_path,&main_config.groups_size); main_config.users = yon_file_open(users_path,&main_config.users_size); main_config.users_list=NULL; diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index 2369238..c2c8dbd 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -36,7 +36,7 @@ #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-usergroups" -#define clear_config_both_command "ubconfig remove TEMP_SECTION TEMP_PATAMETER" +#define get_default_hash_command "ubconfig --raw --source default get [users] HASHPASSWD" #define clear_config_global_command "ubconfig --target global remove TEMP_SECTION TEMP_PATAMETER" #define clear_config_local_command "ubconfig --target system remove TEMP_SECTION TEMP_PATAMETER" @@ -93,6 +93,7 @@ typedef struct { int password_min_length; + int hash_default_id; } config; typedef struct {