From 4e2a3ea9d0c161ff588a66dee50213b60712589d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 24 Jan 2024 18:15:54 +0600 Subject: [PATCH] Interface edits, localisation for chenged interface --- source/ubl-settings-usergroups.c | 114 ++++++++++++++---- source/ubl-settings-usergroups.h | 7 ++ source/ubl-strings.h | 3 + ...tings-usergroups-additional-settings.glade | 2 +- ubl-settings-usergroups-password.glade | 16 ++- ubl-settings-usergroups-user.glade | 71 +++++++++-- ubl-settings-usergroups.glade | 2 +- ubl-settings-usergroups.pot | 74 +++++++----- ubl-settings-usergroups_ru.po | 56 +++++---- 9 files changed, 254 insertions(+), 91 deletions(-) diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index 4e79a00..cf33de2 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -97,6 +97,19 @@ void on_config_global_load(GtkWidget *self, main_window *widgets){ yon_interface_update(widgets); } +void yon_samba_sync_proceed(){ +if (main_config.sync_users){ + for (int i=0;i-1){ + config_str temp = yon_char_parsed_rip(main_config.sync_users,&main_config.sync_size,sync_place); + free(main_config.sync_users); + main_config.sync_users = temp; + } + +} + +int yon_samba_sync_get(char *user){ + int sync_place = yon_char_parsed_check_exist(main_config.sync_users,main_config.sync_size,yon_char_append(user,":")); + if (sync_place>-1){ + if (!main_config.sync_users) + return 0; + int active = main_config.sync_users[sync_place][strlen(main_config.sync_users[sync_place])-1]==':'? 1:2; + return active; + } + return 0; +} + void on_delete_confirmation_delete_home_check(GtkCellRenderer *self, char *path, yon_confirmation_window *window){ GtkTreeIter iter; gboolean status; @@ -229,11 +270,12 @@ yon_savasettings_window *yon_saving_settings_new(){ window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); gtk_widget_show(window->Window); + yon_window_config_custom_window_setup(GTK_WINDOW(window->Window),"savingSettingsWindow"); char *string = yon_config_get_by_key("SAVE_ROOTCOPY_CHANGES"); if (!yon_char_is_empty(string)&&strstr(string,"/var/lib/samba")){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->SambaCheck),1); } - yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),SYSTEM_SAVEMODE_LABEL,BACKGROUND_IMAGE_INFO_TYPE); + yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savemode",SYSTEM_SAVEMODE_LABEL,BACKGROUND_IMAGE_INFO_TYPE); return window; } @@ -354,11 +396,6 @@ void on_password_change(GtkWidget *self, dictionary *entry_dict){ GtkComboBox *combo = yon_dictionary_get_data(entry_dict->first,GtkComboBox*); GtkEntry *output_target = yon_dictionary_get_data(entry_dict->first->next,GtkEntry*); ubl_settings_usergroups_password_window *window = yon_ubl_settings_usergroups_password_new(); - int active = gtk_combo_box_get_active(combo); - if (active == 2) - gtk_widget_hide(window->HashBox); - else if (active==3) - gtk_widget_hide(window->PasswordBox); dictionary *dict = NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); yon_dictionary_add_or_create_if_exists_with_data(dict,"target",output_target); @@ -796,7 +833,9 @@ void on_password_changed(GtkEntry *self, ubl_settings_usergroups_password_window char *self_text = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); char *pair_text = (char*)gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry)); if ((!yon_char_is_empty(self_text)&&!yon_char_is_empty(pair_text))&&strcmp(self_text,pair_text)){ - yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),PASSWORD_MISMATCH_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"password_mismatch",PASSWORD_MISMATCH_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + } else if (strlen(self_text)StatusBox),"password_short",PASSWORD_SHORT_LABEL(yon_char_from_int(main_config.password_min_length)),BACKGROUND_IMAGE_FAIL_TYPE); } else { yon_ubl_status_box_despawn_infinite(GTK_CONTAINER(window->StatusBox)); } @@ -805,18 +844,16 @@ void on_password_changed(GtkEntry *self, ubl_settings_usergroups_password_window void on_password_accept(GtkWidget *self, dictionary *dict){ ubl_settings_usergroups_password_window *window = yon_dictionary_get_data(dict->first,ubl_settings_usergroups_password_window*); GtkEntry *entry = yon_dictionary_get_data(dict->first->next,GtkEntry*); - if (gtk_widget_get_visible(window->HashBox)){ - char *pasted_hash = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordHashEntry)); - if (yon_char_is_empty(pasted_hash)){ - yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); - return; - } else { + char *pasted_hash = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordHashEntry)); + if (!yon_char_is_empty(pasted_hash)){ gtk_entry_set_text(entry,pasted_hash); - } } else { char *password = yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry))); if (yon_char_is_empty(password)){ - yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"password_empty",EMPTY_IMPORTANT_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + return; + } else if (password[0]=='%'&&password[1]=='%'){ + yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"password_wrong",EMPTY_IMPORTANT_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); return; } if (strlen(password)RepeatPasswordEntry)); if (!strcmp(password,password_check)){ - char *passwd_hash = g_malloc0(101); - FILE *fl = popen(password_hash_get_command(password),"r"); - fgets(passwd_hash,100,fl); - if (passwd_hash[strlen(passwd_hash)-1]=='\n') passwd_hash[strlen(passwd_hash)-1]='\0'; - gtk_entry_set_text(entry,passwd_hash); + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->NoEncriptionCheck))){ + char *pasw=yon_char_append("%%",password); + free(password); + password=pasw; + } + gtk_entry_set_text(GTK_ENTRY(entry),password); } else { - yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),PASSWORD_MISMATCH_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"password_mismatch",PASSWORD_MISMATCH_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); return; } } @@ -848,6 +886,7 @@ ubl_settings_usergroups_password_window *yon_ubl_settings_usergroups_password_ne window->PasswordHashEntry=yon_gtk_builder_get_widget(builder,"PasswordHashEntry"); window->HashBox=yon_gtk_builder_get_widget(builder,"HashBox"); window->PasswordBox=yon_gtk_builder_get_widget(builder,"PasswordBox"); + window->NoEncriptionCheck=yon_gtk_builder_get_widget(builder,"NoEncriptionCheck"); window->UserCancelButton=yon_gtk_builder_get_widget(builder,"UserCancelButton"); window->UserOkButton=yon_gtk_builder_get_widget(builder,"UserOkButton"); @@ -1010,7 +1049,7 @@ void on_UID_update(GtkWidget *self, ubl_settings_usergroups_user_window *window) if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userUIDAutoCheck))){ int config_size=0; int final_size=0; - config_str config_users = yon_config_get_all_by_key("USERADD",&config_size); + config_str config_users = yon_config_get_all_by_key("USERADD[",&config_size); yon_char_parsed_prepend_strings(config_users,config_size,":"); config_str final = yon_char_parsed_merge(main_config.users,main_config.users_size,config_users,config_size,&final_size); long prev_busy=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userCreateSystemCheck))?0:main_config.MINGID; @@ -1066,13 +1105,15 @@ void on_user_save(GtkWidget *self, dictionary *dict){ char *create_system_user = NULL; char *create_ununique = NULL; char *do_not_check = NULL; - char *samba_sync = NULL; + int samba_sync = 0; + int samba_password_sync = 0; char *deactivate = NULL; char *extra_options = NULL; char *useradd_boot = ""; char *useradd_shutdown = ""; char *usershadow_boot = ""; char *usershadow_shutdown = ""; + int uid_auto_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userUIDAutoCheck)); if (uid_auto_active){ @@ -1181,8 +1222,19 @@ void on_user_save(GtkWidget *self, dictionary *dict){ if (do_not_check_actve) do_not_check = " --badnames"; - int samba_sync_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userSyncSAMBACheck)); - if (samba_sync_active); + samba_sync = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userSyncSAMBACheck)); + samba_password_sync = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userSyncSAMBAPasswordCheck)); + if (samba_sync){ + if (yon_samba_sync_get(login)==2) + yon_samba_sync_remove(login); + yon_samba_sync_add(login,NULL); + } else if (samba_password_sync){ + if (yon_samba_sync_get(login)==1) + yon_samba_sync_remove(login); + yon_samba_sync_add(login,password); + } else { + yon_samba_sync_remove(login); + } int deactivate_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userDeactivatedCheck)); if (deactivate_active); @@ -1215,6 +1267,7 @@ void on_user_save(GtkWidget *self, dictionary *dict){ usershadow_shutdown = "shutdown"; } + char *useradd_sync_string = NULL; useradd_sync_string = yon_char_unite(useradd_boot,!yon_char_is_empty(useradd_boot)?",":"",useradd_shutdown,NULL); char *usershadow_sync_string = NULL; @@ -1306,6 +1359,7 @@ ubl_settings_usergroups_user_window *yon_ubl_settings_usergroups_user_new(){ window->userCreateUnuniqueCheck=yon_gtk_builder_get_widget(builder,"userCreateUnuniqueCheck"); window->userDontCheckCheck=yon_gtk_builder_get_widget(builder,"userDontCheckCheck"); window->userSyncSAMBACheck=yon_gtk_builder_get_widget(builder,"userSyncSAMBACheck"); + window->userSyncSAMBAPasswordCheck=yon_gtk_builder_get_widget(builder,"userSyncSAMBAPasswordCheck"); window->userDeactivatedCheck=yon_gtk_builder_get_widget(builder,"userDeactivatedCheck"); window->userExtraOptionsEntry=yon_gtk_builder_get_widget(builder,"userExtraOptionsEntry"); window->UserCancelButton=yon_gtk_builder_get_widget(builder,"UserCancelButton"); @@ -1480,6 +1534,12 @@ void on_main_edit(GtkWidget *self, main_window *widgets){ } } + int samba_sync = yon_samba_sync_get(name); + if (samba_sync==1){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->userSyncSAMBACheck),1); + } else if (samba_sync==2){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->userSyncSAMBAPasswordCheck),1); + } free(parameters); parameters=yon_char_parse(yon_config_get_by_key(USERSHADOW(name)),&parsed_size,":"); gtk_entry_set_text(GTK_ENTRY(window->userPasswordChangedEntry),parsed_size>0?parameters[0]:""); @@ -1637,6 +1697,8 @@ void config_init(){ main_config.users_list=NULL; main_config.groups_list=NULL; main_config.password_min_length=6; + main_config.sync_users = NULL; + main_config.sync_size=0; int login_size; config_str login_defs = yon_file_open(uid_path,&login_size); for (int i=0;iTrue True True - start + end image5 diff --git a/ubl-settings-usergroups-password.glade b/ubl-settings-usergroups-password.glade index 9ea91b3..e5dbfc0 100644 --- a/ubl-settings-usergroups-password.glade +++ b/ubl-settings-usergroups-password.glade @@ -163,6 +163,20 @@ 0 + + + Do not encrypt password + True + True + False + True + + + False + True + 1 + + True @@ -199,7 +213,7 @@ True True - 1 + 2 diff --git a/ubl-settings-usergroups-user.glade b/ubl-settings-usergroups-user.glade index 4c3cfd1..15e8121 100644 --- a/ubl-settings-usergroups-user.glade +++ b/ubl-settings-usergroups-user.glade @@ -323,7 +323,7 @@ False True - 3 + 4 @@ -392,7 +392,7 @@ False True - 4 + 5 @@ -443,7 +443,7 @@ False True - 5 + 6 @@ -469,14 +469,67 @@ True False vertical + 5 - - Sync with SAMBA user + True - True - False - start - True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + vertical + 5 + + + Sync user + True + True + False + start + True + + + False + True + 0 + + + + + Sync user with password + True + True + False + start + True + + + False + True + 1 + + + + + + + + + True + False + Samba + + False diff --git a/ubl-settings-usergroups.glade b/ubl-settings-usergroups.glade index 2ea5df0..88e0262 100644 --- a/ubl-settings-usergroups.glade +++ b/ubl-settings-usergroups.glade @@ -276,7 +276,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True True True - Update users and groups + Additional saving configuration image4