From 1dae1c72eed79d89fe3563a6e6d48eaa7752a21f Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 16 May 2025 15:05:34 +0600 Subject: [PATCH 01/12] Password encrypt button changes --- ...bl-settings-usergroups-additional-config.c | 27 ++- source/ubl-settings-usergroups-password.c | 17 +- source/ubl-settings-usergroups-settings.c | 15 +- source/ubl-settings-usergroups.c | 221 +++++++++++++----- source/ubl-settings-usergroups.h | 5 + source/ubl-strings.h | 3 + ubl-settings-usergroups-confirmation.glade | 14 +- ubl-settings-usergroups-password.glade | 48 ++-- 8 files changed, 249 insertions(+), 101 deletions(-) diff --git a/source/ubl-settings-usergroups-additional-config.c b/source/ubl-settings-usergroups-additional-config.c index e99741d..b600f19 100644 --- a/source/ubl-settings-usergroups-additional-config.c +++ b/source/ubl-settings-usergroups-additional-config.c @@ -23,9 +23,28 @@ void on_additional_settings_clicked(GtkWidget *, GtkEntry *){ } -void on_passwords_encrypt(){ - int pid = fork(); - if (!pid){ - exit(system(encrypt_passwords_command)); +gboolean on_encrypt_update(dictionary *dict){ + main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + ubl_settings_usergroups_additional_settings_window *window = yon_dictionary_get_data(dict->first->next,ubl_settings_usergroups_additional_settings_window*); + gtk_widget_destroy(window->Window); + yon_load_proceed((YON_CONFIG_TYPE)main_config.load_mode); + yon_interface_update(widgets); + return G_SOURCE_REMOVE; +} + +void *yon_passwords_encrypt(dictionary *dict){ + int exitstatus = system(encrypt_passwords_command); + if (!exitstatus){ + yon_ubl_status_box_render_thread(yon_char_get_localised_from_lib(SUCCESS_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE); + g_idle_add((GSourceFunc)on_encrypt_update,dict); + + } else { + yon_ubl_status_box_render_thread(yon_char_get_localised_from_lib(FAIL_LABEL),BACKGROUND_IMAGE_SUCCESS_TYPE); + } + g_thread_exit(NULL); +} + +void on_passwords_encrypt(GtkWidget*,dictionary *dict){ + g_thread_new("encrypt_all_passwords_thread",(GThreadFunc)yon_passwords_encrypt,dict); } \ No newline at end of file diff --git a/source/ubl-settings-usergroups-password.c b/source/ubl-settings-usergroups-password.c index 8eef247..e56c390 100644 --- a/source/ubl-settings-usergroups-password.c +++ b/source/ubl-settings-usergroups-password.c @@ -105,6 +105,19 @@ void on_password_accept(GtkWidget *self, dictionary *dict){ on_subwindow_close(self); } +void on_password_hash_sensitiveness(GtkWidget *,ubl_settings_usergroups_password_window *window){ + if (!yon_char_is_empty(gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)))||!yon_char_is_empty(gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry)))){ + gtk_widget_set_sensitive(window->HashBox,0); + gtk_widget_set_sensitive(window->PasswordBox,1); + } else if (!yon_char_is_empty(gtk_entry_get_text(GTK_ENTRY(window->PasswordHashEntry)))) { + gtk_widget_set_sensitive(window->HashBox,1); + gtk_widget_set_sensitive(window->PasswordBox,0); + } else { + gtk_widget_set_sensitive(window->HashBox,1); + gtk_widget_set_sensitive(window->PasswordBox,1); + } +} + ubl_settings_usergroups_password_window *yon_ubl_settings_usergroups_password_new(){ ubl_settings_usergroups_password_window *window = malloc(sizeof(ubl_settings_usergroups_password_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_ubl_settings_usergroups_password); @@ -123,6 +136,9 @@ ubl_settings_usergroups_password_window *yon_ubl_settings_usergroups_password_ne yon_window_config_custom_window_setup(GTK_WINDOW(window->CreateGroupWindow),"PasswordWindow"); g_signal_connect(G_OBJECT(window->UserCancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->PasswordEntry),"icon-press",G_CALLBACK(on_password_show_hide),NULL); + g_signal_connect(G_OBJECT(window->PasswordEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window); + g_signal_connect(G_OBJECT(window->RepeatPasswordEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window); + g_signal_connect(G_OBJECT(window->PasswordHashEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window); g_signal_connect(G_OBJECT(window->RepeatPasswordEntry),"icon-press",G_CALLBACK(on_password_show_hide),NULL); g_signal_connect(G_OBJECT(window->PasswordHashEntry),"icon-press",G_CALLBACK(on_password_show_hide),NULL); gtk_window_set_title(GTK_WINDOW(window->CreateGroupWindow),PASSWORD_TITLE_LABEL); @@ -130,7 +146,6 @@ ubl_settings_usergroups_password_window *yon_ubl_settings_usergroups_password_ne return window; } - int yon_check_password_blocked(char *password){ if (!yon_char_is_empty(password)){ if (!strcmp(password,"!*")){ diff --git a/source/ubl-settings-usergroups-settings.c b/source/ubl-settings-usergroups-settings.c index af0fe5d..f922cd8 100644 --- a/source/ubl-settings-usergroups-settings.c +++ b/source/ubl-settings-usergroups-settings.c @@ -717,12 +717,7 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_ yon_dictionary_add_or_create_if_exists_with_data(root_dict,"entry",window->RootPasswordEntry); g_signal_connect(G_OBJECT(window->DefaultPasswordButton),"clicked",G_CALLBACK(on_password_change),default_dict); g_signal_connect(G_OBJECT(window->RootPasswordButton),"clicked",G_CALLBACK(on_password_change),root_dict); - dialog_confirmation_data *data=malloc(sizeof(dialog_confirmation_data)); - data->function=on_passwords_encrypt; - data->action_text = ENCRYPT_SURE_LABEL; - data->data=NULL; - g_signal_connect(G_OBJECT(window->EncryptAllPasswordsButton),"clicked",G_CALLBACK(yon_confirmation_dialog_call),data); g_signal_connect(G_OBJECT(window->PasswordHashCombo),"changed",G_CALLBACK(on_hash_changed),window); g_signal_connect(G_OBJECT(window->DefaultUserNameEntry),"changed",G_CALLBACK(on_additional_settings_changed),window); @@ -741,6 +736,16 @@ return window; void on_ubl_settings_usergroups_additional_settings_open(GtkWidget *, main_window *widgets){ ubl_settings_usergroups_additional_settings_window *window = yon_ubl_settings_usergroups_additional_settings_new(); + + dictionary *encrypt_data = NULL; + yon_dictionary_add_or_create_if_exists_with_data(encrypt_data,"widgets",widgets); + yon_dictionary_add_or_create_if_exists_with_data(encrypt_data,"window",window); + dialog_confirmation_data *data=yon_confirmation_dialog_data_new(); + data->function=on_passwords_encrypt; + data->action_text = ENCRYPT_SURE_LABEL; + data->data=encrypt_data; + + g_signal_connect(G_OBJECT(window->EncryptAllPasswordsButton),"clicked",G_CALLBACK(yon_confirmation_dialog_call),data); gtk_window_set_transient_for(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window)); gtk_widget_show(window->Window); diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index 0c4a3d4..7d900d1 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -226,7 +226,7 @@ void on_config_local_load(GtkWidget *, main_window *widgets){ textdomain(template_ui_LocaleName); yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); textdomain(LocaleName); - main_config.load_mode=1; + main_config.load_mode=YON_CONFIG_LOCAL; yon_interface_update(widgets); } @@ -235,7 +235,7 @@ void on_config_global_load(GtkWidget *, main_window *widgets){ textdomain(template_ui_LocaleName); yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); textdomain(LocaleName); - main_config.load_mode=0; + main_config.load_mode=YON_CONFIG_GLOBAL; yon_interface_update(widgets); } @@ -244,7 +244,7 @@ void on_config_custom_load(GtkWidget *,main_window *widgets){ textdomain(template_ui_LocaleName); yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); textdomain(LocaleName); - main_config.load_mode=3; + main_config.load_mode=YON_CONFIG_CUSTOM; yon_interface_update(widgets); } @@ -395,7 +395,7 @@ void yon_hide_passwords(template_saving_window *window){ free(yon_char_divide(new_value,1)); newv=new_value; } else if (!yon_char_is_empty(new_value)&&new_value[0]=='$') { - if (main_config.load_mode==1){ + if (main_config.load_mode==YON_CONFIG_LOCAL){ newv=new_value; } else { newv="*******"; @@ -404,7 +404,7 @@ void yon_hide_passwords(template_saving_window *window){ newv="*******"; } if (!yon_char_is_empty(old_value)){ - if (main_config.load_mode==1){ + if (main_config.load_mode==YON_CONFIG_LOCAL){ old = yon_char_new("*******"); } else { @@ -421,7 +421,7 @@ void yon_hide_passwords(template_saving_window *window){ free(yon_char_divide(new_value,1)); newv=new_value; } else if (!yon_char_is_empty(new_value)&&new_value[0]=='$') { - if (main_config.load_mode==1){ + if (main_config.load_mode==YON_CONFIG_LOCAL){ newv=new_value; } else { newv="*******"; @@ -430,7 +430,7 @@ void yon_hide_passwords(template_saving_window *window){ newv="*******"; } if (!yon_char_is_empty(old_value)){ - if (main_config.load_mode==1){ + if (main_config.load_mode==YON_CONFIG_LOCAL){ old = yon_char_new("*******"); } else { old = yon_char_unite("",old_value,"",NULL); @@ -451,7 +451,7 @@ void on_save_done(main_window *widgets, config_str output, int size){ } yon_char_parsed_free(output,size); on_config_update(NULL,widgets); - if (main_config.load_mode==1){ + if (main_config.load_mode==YON_CONFIG_LOCAL){ yon_accept_changes(); yon_samba_sync_proceed(); } @@ -593,62 +593,159 @@ void on_delete_confirmation_delete_check(GtkCellRenderer *, char *path, yon_conf } -void yon_delete_confirmation_save(GtkWidget *self, dictionary *dict){ - GtkTreeIter iter,itar; - main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); - yon_confirmation_window *window = yon_dictionary_get_data(dict->first->next,yon_confirmation_window*); - int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->UsersList),&iter); - for (;valid;valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->UsersList),&iter)){ - char *name; - gtk_tree_model_get(GTK_TREE_MODEL(widgets->UsersList),&iter,2,&name,-1); - int valid2 = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&itar); - for (;valid2;valid2 = gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&itar)){ - char *name_check; - int status,delete; - gtk_tree_model_get(GTK_TREE_MODEL(window->list),&itar,0,&delete,1,&name_check,3,&status,-1); - if (!strcmp(name,name_check)&&delete){ - // char *user = config(USERADD(name)); - // int size; - // config_str parsed = yon_char_parse(user,&size,":"); - // if (size>3&&(strcmp(parsed[3],name)&&strcmp(parsed[2],parsed[3]))){ - // yon_ubl_status_box_spawn_infinite(window->) - // } - gtk_list_store_remove(widgets->UsersList,&iter); - yon_config_remove_by_key(USERADD(name)); - yon_config_remove_by_key(USERSHADOW(name)); - yon_config_register(USERADD_SYNC(name),USERADD_SYNC_command(name),""); - yon_config_remove_by_key(USERADD_SYNC(name)); - yon_config_remove_by_key(USERSHADOW_SYNC(name)); - gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->UsersList),&iter); - if (status){ - if (yon_char_parsed_check_exist(main_config.remove_homes,main_config.homes_size,name)==-1){ - yon_char_parsed_add_or_create_if_exists(main_config.remove_homes,&main_config.homes_size,name); - } +char *yon_user_get_group_string(char *user){ + char *cur_user = config(USERADD(user)); + + int size; + config_str parsed = yon_char_parse(cur_user,&size,":"); + if (size>2&&!yon_char_is_empty(parsed[2])){ + char *current_group = parsed[2]; + size_t digits=0; + for (guint k=0;k2&&!strcmp(groups_parsed[2],current_group)){ + final_group_name=yon_char_new(groups_parsed[0]); + if (group_size) yon_char_parsed_free(groups_parsed,group_size); + break; } + if (group_size) yon_char_parsed_free(groups_parsed,group_size); } + } else { + final_group_name=yon_char_new(current_group); } + return final_group_name; + } else { + return user; } + return NULL; +} + +char *yon_user_check_groups(GtkListStore *list, char *target){ + char *final=""; + GtkTreeIter iter; + GtkTreeModel *model = GTK_TREE_MODEL(list); + for_iter(model,&iter){ char *name; - if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->UsersList),&iter)){ - gtk_tree_model_get(GTK_TREE_MODEL(widgets->UsersList),&iter,2,&name,-1); - int valid2 = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&itar); - for (;valid2;valid2 = gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&itar)){ - char *name_check; - int status,delete; - gtk_tree_model_get(GTK_TREE_MODEL(window->list),&itar,0,&delete,1,&name_check,3,&status,-1); - if (!strcmp(name,name_check)&&delete){ - gtk_list_store_remove(widgets->UsersList,&iter); - yon_config_remove_by_key(USERADD(name)); - yon_config_remove_by_key(USERSHADOW(name)); - gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->UsersList),&iter); - if (status){ - if (yon_char_parsed_check_exist(main_config.remove_homes,main_config.homes_size,name)==-1){ - yon_char_parsed_add_or_create_if_exists(main_config.remove_homes,&main_config.homes_size,name); - } - } + char *group; + gtk_tree_model_get(model,&iter,1,&name,6,&group,-1); + if (!strcmp(group,target)&&strcmp(name,target)){ + char *temp = yon_char_unite(final,!yon_char_is_empty(final)?",":"",name,NULL); + if (!yon_char_is_empty(final)) free(final); + final = temp; + } + } + return !yon_char_is_empty(final)?final:NULL; +} + +void yon_delete_confirmation_save(GtkWidget *self, dictionary *dict){ + // GtkTreeIter iter,itar; + main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); + yon_confirmation_window *window = yon_dictionary_get_data(dict->first->next,yon_confirmation_window*); + // int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->UsersList),&iter); + // for (;valid;valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->UsersList),&iter)){ + // char *name; + // gtk_tree_model_get(GTK_TREE_MODEL(widgets->UsersList),&iter,2,&name,-1); + // int valid2 = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&itar); + // for (;valid2;valid2 = gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&itar)){ + // char *name_check; + // int status,delete; + // gtk_tree_model_get(GTK_TREE_MODEL(window->list),&itar,0,&delete,1,&name_check,3,&status,-1); + // if (!strcmp(name,name_check)&&delete){ + // gtk_list_store_remove(widgets->UsersList,&iter); + // yon_config_remove_by_key(USERADD(name)); + // yon_config_remove_by_key(USERSHADOW(name)); + // yon_config_register(USERADD_SYNC(name),USERADD_SYNC_command(name),""); + // yon_config_remove_by_key(USERADD_SYNC(name)); + // yon_config_remove_by_key(USERSHADOW_SYNC(name)); + // gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->UsersList),&iter); + // if (status){ + // if (yon_char_parsed_check_exist(main_config.remove_homes,main_config.homes_size,name)==-1){ + // yon_char_parsed_add_or_create_if_exists(main_config.remove_homes,&main_config.homes_size,name); + // } + // } + // } + // } + // } + + GtkTreeIter iter; + GtkTreeModel *model = GTK_TREE_MODEL(window->list); + char *single_target = NULL; + int founds = 0; + char *depends = NULL; + for_iter(model,&iter){ + int selected; + char *target; + char *group; + gtk_tree_model_get(model,&iter,0,&selected,1,&target,6,&group,-1); + if (selected){ + if ((!strcmp(target,group))){ + depends = yon_user_check_groups(window->list,target); + if (!yon_char_is_empty(depends)) { + single_target = target; + founds++; } } } + } + if (founds==1){ + dialog_confirmation_data *data = yon_confirmation_dialog_data_new(); + data->action_text = CONFIRMATION_GROUP_DEPENDS_SINGLE_LABEL(single_target,depends); + if(yon_confirmation_dialog_call(window->Window,data)!=GTK_RESPONSE_ACCEPT){ + return; + } + } else if (founds >1){ + dialog_confirmation_data *data = yon_confirmation_dialog_data_new(); + data->action_text = CONFIRMATION_GROUP_DEPENDS_MULTIPLE_LABEL; + if (yon_confirmation_dialog_call(window->Window,data)!=GTK_RESPONSE_ACCEPT){ + return; + } + } + + for_iter(model,&iter){ + int selected; + char *target; + gtk_tree_model_get(model,&iter,0,&selected,1,&target,-1); + if (selected){ + yon_config_remove_by_key(USERADD(target)); + yon_config_remove_by_key(USERSHADOW(target)); + yon_config_remove_by_key(USERADD_SYNC(target)); + yon_config_remove_by_key(USERSHADOW_SYNC(target)); + } + } + + yon_interface_update(widgets); + + // char *name; + // if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->UsersList),&iter)){ + // gtk_tree_model_get(GTK_TREE_MODEL(widgets->UsersList),&iter,2,&name,-1); + // int valid2 = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&itar); + // for (;valid2;valid2 = gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&itar)){ + // char *name_check; + // int status,delete; + // gtk_tree_model_get(GTK_TREE_MODEL(window->list),&itar,0,&delete,1,&name_check,3,&status,-1); + // if (!strcmp(name,name_check)&&delete){ + // gtk_list_store_remove(widgets->UsersList,&iter); + // yon_config_remove_by_key(USERADD(name)); + // yon_config_remove_by_key(USERSHADOW(name)); + // gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->UsersList),&iter); + // if (status){ + // if (yon_char_parsed_check_exist(main_config.remove_homes,main_config.homes_size,name)==-1){ + // yon_char_parsed_add_or_create_if_exists(main_config.remove_homes,&main_config.homes_size,name); + // } + // } + // } + // } + // } on_subwindow_close(self); } @@ -737,8 +834,8 @@ void yon_delete_confirmation_open(main_window *widgets){ } int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->UsersList),&iter); for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->UsersList),&iter)){ - char *name,*username,*parameters,*homedir=NULL; - gtk_tree_model_get(GTK_TREE_MODEL(widgets->UsersList),&iter,2,&name,3,&username,6,¶meters,-1); + char *name,*username,*parameters,*homedir=NULL, *group=NULL; + gtk_tree_model_get(GTK_TREE_MODEL(widgets->UsersList),&iter,2,&name,3,&username,4,&group,6,¶meters,-1); int size; config_str home = yon_config_load(get_home_command(name),&size); if (size>0&&!yon_char_is_empty(home[0])){ @@ -751,7 +848,9 @@ void yon_delete_confirmation_open(main_window *widgets){ int status=0; if (homedir) status=1; gtk_list_store_append(window->list,&itar); - gtk_list_store_set(window->list,&itar,0,yon_char_parsed_check_exist(chosen,chosen_size,name)>-1?1:0,1,name,2,homedir,3,0,4,yon_char_parsed_check_exist(chosen,chosen_size,name)>-1&&status?1:0,5,username,-1); + group = yon_user_get_group_string(name); + + gtk_list_store_set(window->list,&itar,0,yon_char_parsed_check_exist(chosen,chosen_size,name)>-1?1:0,1,name,2,homedir,3,0,4,yon_char_parsed_check_exist(chosen,chosen_size,name)>-1&&status?1:0,5,username,6,group,-1); free(name); free(username); free(parameters); @@ -1736,7 +1835,7 @@ void on_main_delete(GtkWidget *, main_window *widgets){ } void on_config_update(GtkWidget *, main_window *widgets){ - if (main_config.load_mode==0){ + if (main_config.load_mode==YON_CONFIG_GLOBAL){ on_config_global_load(NULL,widgets); } else { on_config_local_load(NULL,widgets); @@ -1767,7 +1866,7 @@ void config_init(){ main_config.lock_save_local=0; main_config.groups_size=0; main_config.users_size=0; - main_config.load_mode=1; + main_config.load_mode=YON_CONFIG_LOCAL; main_config.hash_default_id=-1; main_config.save_config=0; main_config.groups = yon_file_open(groups_path,&main_config.groups_size); diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index f58c439..1deb992 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -566,4 +566,9 @@ void on_useradd_sync_changed(ubl_settings_usergroups_additional_settings_window void yon_gtk_login_block_symbols(GtkEntry *target); void on_login_insert_custom_restricted_check(GtkEditable *editable, const gchar *text, gint length, gint *position); void on_group_delete_toggled(GtkWidget *,gchar* path,yon_confirmation_window *window); +char *yon_user_check_groups(GtkListStore *list, char *target); +char *yon_user_get_group_string(char *user); +void on_password_hash_sensitiveness(GtkWidget *,ubl_settings_usergroups_password_window *window); +gboolean on_encrypt_update(dictionary *dict); +void *yon_passwords_encrypt(dictionary *dict); #endif \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index c6bed22..3c77764 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -270,3 +270,6 @@ #define SHUTDOWN_MAXIMUM_UID_LABEL _("Maximum UID") #define SHUTDOWN_MINIMUM_GID_LABEL _("Minimum GID") #define SHUTDOWN_MAXIMUM_GID_LABEL _("Maximum GID") + +#define CONFIRMATION_GROUP_DEPENDS_SINGLE_LABEL(target,depends) yon_char_unite(_("User")," \"",target,"\" ",_("is included into main group of users")," \"",depends,"\", ",_("which will be deleted"),".\n",_("After reboot users")," ",depends," ",_("main group will be set to default group"),".",NULL) +#define CONFIRMATION_GROUP_DEPENDS_MULTIPLE_LABEL _("Some of users, chosen for deletion, are included as main group for other users. This users will get default main group after reboot") diff --git a/ubl-settings-usergroups-confirmation.glade b/ubl-settings-usergroups-confirmation.glade index 30a228a..2c654b0 100644 --- a/ubl-settings-usergroups-confirmation.glade +++ b/ubl-settings-usergroups-confirmation.glade @@ -15,17 +15,19 @@ - + - + - + - + - + - + + + diff --git a/ubl-settings-usergroups-password.glade b/ubl-settings-usergroups-password.glade index e5dbfc0..60ac200 100644 --- a/ubl-settings-usergroups-password.glade +++ b/ubl-settings-usergroups-password.glade @@ -94,7 +94,7 @@ True True - 1 + 0 @@ -136,47 +136,47 @@ True True - 2 + 1 - - - False - True - 1 - - - - - True - False - vertical - 5 - + + Do not encrypt password True - False + True + False + True False True - 0 + 2 - - Do not encrypt password + True - True - False - True + False False True - 1 + 3 + + + False + True + 1 + + + + + True + False + vertical + 5 True From 339a28c5edcea84d9dacad652ac5ec483f39af23 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 19 May 2025 14:57:15 +0600 Subject: [PATCH 02/12] Check for removing of users with main group used by another users --- source/ubl-settings-usergroups-password.c | 2 +- source/ubl-strings.h | 2 +- ubl-settings-usergroups.pot | 24 ++++++++++++++ ubl-settings-usergroups_ru.po | 40 +++++++++++++++++++---- 4 files changed, 60 insertions(+), 8 deletions(-) diff --git a/source/ubl-settings-usergroups-password.c b/source/ubl-settings-usergroups-password.c index e56c390..8805f47 100644 --- a/source/ubl-settings-usergroups-password.c +++ b/source/ubl-settings-usergroups-password.c @@ -25,7 +25,7 @@ void on_password_change(GtkWidget *, dictionary *entry_dict){ dictionary *dict = NULL; char *password = (char*)gtk_entry_get_text(output_target); if (!yon_char_is_empty(password)){ - if (main_config.load_mode==0){ + if (main_config.load_mode==YON_CONFIG_GLOBAL){ password = yon_char_new(password); if (!check_is_password_hash(password)){ gtk_entry_set_text(GTK_ENTRY(window->PasswordHashEntry),password); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 3c77764..830943c 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -271,5 +271,5 @@ #define SHUTDOWN_MINIMUM_GID_LABEL _("Minimum GID") #define SHUTDOWN_MAXIMUM_GID_LABEL _("Maximum GID") -#define CONFIRMATION_GROUP_DEPENDS_SINGLE_LABEL(target,depends) yon_char_unite(_("User")," \"",target,"\" ",_("is included into main group of users")," \"",depends,"\", ",_("which will be deleted"),".\n",_("After reboot users")," ",depends," ",_("main group will be set to default group"),".",NULL) +#define CONFIRMATION_GROUP_DEPENDS_SINGLE_LABEL(target,depends) yon_char_unite(_("User(-s)")," \"",depends,"\" ",_("is included into main group of users")," \"",target,"\", ",_("which will be deleted"),".\n",_("After reboot users")," ",depends," ",_("main group will be set to default group"),".",NULL) #define CONFIRMATION_GROUP_DEPENDS_MULTIPLE_LABEL _("Some of users, chosen for deletion, are included as main group for other users. This users will get default main group after reboot") diff --git a/ubl-settings-usergroups.pot b/ubl-settings-usergroups.pot index 0222b4d..6d0f778 100644 --- a/ubl-settings-usergroups.pot +++ b/ubl-settings-usergroups.pot @@ -912,3 +912,27 @@ msgstr "" #: source/ubl-strings.h:272 msgid "Maximum GID" msgstr "" + +#: source/ubl-strings.h:272 +msgid "User(-s)" +msgstr "" + +#: source/ubl-strings.h:272 +msgid "is included into main group of users" +msgstr "" + +#: source/ubl-strings.h:272 +msgid "which will be deleted" +msgstr "" + +#: source/ubl-strings.h:272 +msgid "After reboot users" +msgstr "" + +#: source/ubl-strings.h:272 +msgid "main group will be set to default group" +msgstr "" + +#: source/ubl-strings.h:272 +msgid "Some of users, chosen for deletion, are included as main group for other users. This users will get default main group after reboot" +msgstr "" diff --git a/ubl-settings-usergroups_ru.po b/ubl-settings-usergroups_ru.po index 1999d5c..ef19cba 100644 --- a/ubl-settings-usergroups_ru.po +++ b/ubl-settings-usergroups_ru.po @@ -425,8 +425,10 @@ msgid "" "- The name can consist of: lowercase Latin letters, numbers, underscores and " "hyphens;\n" "- Max name length: 32 symbols;" -msgstr "- Первым символом должна быть буква или подчёркивание\n" -"- Имя может состоять из: строчных латинских букв, цифр, подчеркивания и дефиса\n" +msgstr "" +"- Первым символом должна быть буква или подчёркивание\n" +"- Имя может состоять из: строчных латинских букв, цифр, подчеркивания и " +"дефиса\n" "- Максимальная длина имени: 32 символа" #: source/ubl-strings.h:114 @@ -924,19 +926,19 @@ msgid "All system users" msgstr "Все пользователи в системе" #: source/ubl-strings.h:253 source/ubl-strings.h:266 -msgid "Users UID range" +msgid "Users GID range" msgstr "Диапазон UID пользователей в системе" #: source/ubl-strings.h:254 source/ubl-strings.h:267 -msgid "User UID in system" +msgid "User GID in system" msgstr "Пользователь в системе с UID" #: source/ubl-strings.h:255 -msgid "Users GID range" +msgid "Users UID range" msgstr "Диапазон UID пользователей в системе" #: source/ubl-strings.h:256 -msgid "User GID in system" +msgid "User UID in system" msgstr "Пользователь в системе с UID" #: source/ubl-strings.h:258 @@ -978,3 +980,29 @@ msgstr "Минимальный GID" #: source/ubl-strings.h:272 msgid "Maximum GID" msgstr "Максимальный GID" + +#: source/ubl-strings.h:272 +msgid "User(-s)" +msgstr "Пользователь(-ли)" + +#: source/ubl-strings.h:272 +msgid "is included into main group of users" +msgstr "включен в основную группу" + +#: source/ubl-strings.h:272 +msgid "which will be deleted" +msgstr "которая будет удалена" + +#: source/ubl-strings.h:272 +msgid "After reboot users" +msgstr "После перезагрузки пользователь(-ли)" + +#: source/ubl-strings.h:272 +msgid "main group will be set to default group" +msgstr "получит(-ат) основную группу по умолчанию" + +#: source/ubl-strings.h:272 +msgid "" +"Some of users, chosen for deletion, are included as main group for other " +"users. This users will get default main group after reboot" +msgstr "Часть пользователей выбранных на удаление используются как основные группы других пользователей. После перезагрузки эти пользователи получат основную группу по умолчанию" From b84bc5812ab3ff03e5ee515258d501eb97e4c62e Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 19 May 2025 15:00:13 +0600 Subject: [PATCH 03/12] Localisation fixes --- ubl-settings-usergroups_ru.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubl-settings-usergroups_ru.po b/ubl-settings-usergroups_ru.po index ef19cba..5d9930b 100644 --- a/ubl-settings-usergroups_ru.po +++ b/ubl-settings-usergroups_ru.po @@ -987,7 +987,7 @@ msgstr "Пользователь(-ли)" #: source/ubl-strings.h:272 msgid "is included into main group of users" -msgstr "включен в основную группу" +msgstr "включен(-ы) в основную группу" #: source/ubl-strings.h:272 msgid "which will be deleted" From 5e13f75f1dee317a127a6b823d77be765d6b9f4e Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Mon, 19 May 2025 17:18:49 +0600 Subject: [PATCH 04/12] Changed user password saving and loading; default password and root password changes --- source/ubl-settings-usergroups-password.c | 12 ++---- source/ubl-settings-usergroups-settings.c | 34 ++++++++++++++--- source/ubl-settings-usergroups-user.c | 34 +++++++++++++++-- source/ubl-settings-usergroups.c | 25 +++++++++--- source/ubl-settings-usergroups.h | 3 ++ source/ubl-strings.h | 4 ++ ...tings-usergroups-additional-settings.glade | 19 +++++----- ubl-settings-usergroups-user.glade | 5 ++- ubl-settings-usergroups.glade | 10 ++--- ubl-settings-usergroups.pot | 36 ++++++++++++------ ubl-settings-usergroups_ru.po | 38 +++++++++++++------ 11 files changed, 159 insertions(+), 61 deletions(-) diff --git a/source/ubl-settings-usergroups-password.c b/source/ubl-settings-usergroups-password.c index 8805f47..ebe7fb8 100644 --- a/source/ubl-settings-usergroups-password.c +++ b/source/ubl-settings-usergroups-password.c @@ -147,20 +147,14 @@ return window; } int yon_check_password_blocked(char *password){ - if (!yon_char_is_empty(password)){ - if (!strcmp(password,"!*")){ - memset(password,0,strlen(password)); - return 1; - } else if (password[0]=='!'&&password[1]=='*'){ + if (!yon_char_is_empty(password)&&strlen(password)>0){ + if (password[0]=='!'&&password[1]!='*'){ char *copy = yon_char_new(password); - memcpy(copy,password+2,strlen(password+2)); + memcpy(copy,password+1,strlen(password+1)); memset(password,0,strlen(password)); memcpy(password,copy,strlen(copy)); free(copy); return 1; - } else if (password[0]=='!'||password[0]=='*'){ - free(yon_char_divide(password,0)); - return 1; } } return 0; diff --git a/source/ubl-settings-usergroups-settings.c b/source/ubl-settings-usergroups-settings.c index f922cd8..2ffac0c 100644 --- a/source/ubl-settings-usergroups-settings.c +++ b/source/ubl-settings-usergroups-settings.c @@ -33,7 +33,15 @@ void on_additional_settings_changed(GtkWidget *self, ubl_settings_usergroups_add if (window->default_user_name) yon_config_remove_by_key(DEFAULTUSER_parameter); } - char *default_password = gtk_combo_box_get_active(GTK_COMBO_BOX(window->DefaultPasswordCombo))>1? (char*)gtk_entry_get_text(GTK_ENTRY(window->DefaultPasswordEntry)):NULL; + char *default_password = NULL; + int user_password_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->DefaultPasswordCombo)); + if (user_password_active==2) + default_password=(char*)gtk_entry_get_text(GTK_ENTRY(window->DefaultPasswordEntry)); + else if (user_password_active==1) + default_password=" "; + else if (user_password_active==3){ + default_password="!*"; + } if (!yon_char_is_empty(default_password)){ if (window->default_password) yon_config_register(DEFAULTPASSWD_parameter,DEFAULTPASSWD_parameter_command,default_password); @@ -41,7 +49,12 @@ void on_additional_settings_changed(GtkWidget *self, ubl_settings_usergroups_add if (window->default_password) yon_config_remove_by_key(DEFAULTPASSWD_parameter); } - char *root_password = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RootPasswordCombo)) > 1 ? (char*)gtk_entry_get_text(GTK_ENTRY(window->RootPasswordEntry)) : NULL; + char *root_password = NULL; + int root_password_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RootPasswordCombo)); + if (root_password_active==2) + root_password=(char*)gtk_entry_get_text(GTK_ENTRY(window->RootPasswordCombo)); + else if (root_password_active==1) + root_password=" "; if (!yon_char_is_empty(root_password)){ if (window->default_root_password) yon_config_register(DEFAULTROOTPASSWD_parameter,DEFAULTROOTPASSWD_parameter_command,root_password); @@ -660,15 +673,24 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_ g_signal_connect(G_OBJECT(window->DefaultPasswordCombo),"changed",G_CALLBACK(on_password_combo_changed),window->DefaultPasswordButton); char *default_password = yon_config_get_by_key(DEFAULTPASSWD_parameter); if (!yon_char_is_empty(default_password)){ - gtk_entry_set_text(GTK_ENTRY(window->DefaultPasswordEntry),default_password); - if(!yon_config_check_ignore(DEFAULTPASSWD_parameter)) + if (!strcmp(default_password," ")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->DefaultPasswordCombo),1); + } else if (!strcmp(default_password,"!*")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->DefaultPasswordCombo),3); + + } else { gtk_combo_box_set_active(GTK_COMBO_BOX(window->DefaultPasswordCombo),2); + gtk_entry_set_text(GTK_ENTRY(window->DefaultPasswordEntry),default_password); + } } char *root_password = yon_config_get_by_key(DEFAULTROOTPASSWD_parameter); if (!yon_char_is_empty(root_password)){ - gtk_entry_set_text(GTK_ENTRY(window->RootPasswordEntry),root_password); - if(!yon_config_check_ignore(DEFAULTROOTPASSWD_parameter)) + if (!strcmp(root_password," ")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RootPasswordCombo),1); + } else { gtk_combo_box_set_active(GTK_COMBO_BOX(window->RootPasswordCombo),2); + gtk_entry_set_text(GTK_ENTRY(window->DefaultPasswordEntry),root_password); + } } char *is_k_admin = yon_config_get_by_key(ADDADM_parameter); if (!yon_char_is_empty(is_k_admin)) diff --git a/source/ubl-settings-usergroups-user.c b/source/ubl-settings-usergroups-user.c index fdaa763..6757bd8 100644 --- a/source/ubl-settings-usergroups-user.c +++ b/source/ubl-settings-usergroups-user.c @@ -392,7 +392,11 @@ void on_user_save(GtkWidget *self, dictionary *dict){ } int password_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->userPasswordCombo)); - if (password_active > 1){ + if (password_active == 0){ + password = NULL; + } else if (password_active ==1){ + password = " "; + } else if (password_active ==2){ password = (char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordEntry)); if (yon_char_is_empty(password)){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); @@ -400,10 +404,31 @@ void on_user_save(GtkWidget *self, dictionary *dict){ gtk_notebook_set_current_page(GTK_NOTEBOOK(window->MainNotebook),0); return; } - } else if (password_active==1){ + } else if (password_active==3){ password = "!*"; - } else { - password=""; + } else if (password_active ==4){ + password = (char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordEntry)); + if (yon_char_is_empty(password)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->userPasswordEntry); + gtk_notebook_set_current_page(GTK_NOTEBOOK(window->MainNotebook),0); + return; + } + if (password[0]!='!') { + char *temp = yon_char_append("!",password); + password=temp; + } + } else if (password_active == 5){ + password = yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordEntry))); + if (yon_char_is_empty(password)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->userPasswordEntry); + gtk_notebook_set_current_page(GTK_NOTEBOOK(window->MainNotebook),0); + return; + } + if (password[0]=='!'){ + free(yon_char_divide(password,0)); + } } char *old_password = NULL; @@ -432,6 +457,7 @@ void on_user_save(GtkWidget *self, dictionary *dict){ if (strlen(password)>1&&password[0]=='%'&&password[1]=='%'){ char *temp = yon_char_replace(password,"%%","!!"); password = yon_char_replace(temp,"!!","%%!"); + } else if (!yon_char_is_empty(password)&&password[0]=='!'){ } else { password = yon_char_append("!",password); } diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index 7d900d1..0c35df4 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -121,7 +121,7 @@ void yon_interface_update(main_window *widgets){ } gtk_list_store_set(widgets->UsersList,&iter, - 0,parameters_size>5?(parameters[5][0]=='!'||parameters[5][0]=='*')||(parameters[5][0]=='!'&¶meters[5][1]=='*'):0, + 0,parameters_size>5?(parameters[5][0]=='!'&¶meters[5][1]=='*')?check_checked_icon_name:(parameters[5][0]=='!'||parameters[5][0]=='*')?check_attention_icon_name:NULL:NULL, 2,login, 3,parameters_size>0?parameters[0]:"", 1,parameters_size>1&&!yon_char_is_empty(parameters[1])?parameters[1]:"", @@ -886,7 +886,20 @@ void on_saving_settings_open(GtkWidget *, main_window *widgets){ } void on_password_combo_changed(GtkComboBox *self, GtkWidget *target){ - gtk_widget_set_sensitive(target,gtk_combo_box_get_active(self)>1); + int active = gtk_combo_box_get_active(self); + switch(active){ + case 0: + case 1: + case 3: + case 4: + gtk_widget_set_sensitive(target,0); + break; + case 2: + case 5: + gtk_widget_set_sensitive(target,1); + break; + } + } @@ -1614,9 +1627,6 @@ void on_main_edit(GtkWidget *, main_window *widgets){ } window->old_password=yon_char_new(parameters[5]); if (strcmp(parameters[5],"x")&&strcmp(parameters[5],"")){ - if (yon_check_password_blocked(parameters[5])){ - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->userDeactivatedCheck),1); - } if (!yon_char_is_empty(parameters[5])){ if (check_is_password_hash(parameters[5])){ if (yon_char_check_begins_with(parameters[5],"%%")==-1){ @@ -1628,7 +1638,12 @@ void on_main_edit(GtkWidget *, main_window *widgets){ g_signal_handlers_block_by_func(G_OBJECT(window->userSyncSAMBACheck),G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),window->userSyncSAMBAPasswordCheck); } if (!strcmp(parameters[5],"!*")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),3); + } else if (!strcmp(parameters[5]," ")) { gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),1); + } else if (parameters[5][0]=='!'){ + gtk_entry_set_text(GTK_ENTRY(window->userPasswordEntry),parameters[5]); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),4); } else { gtk_entry_set_text(GTK_ENTRY(window->userPasswordEntry),parameters[5]); gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),2); diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index 1deb992..f3820bf 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -87,6 +87,9 @@ #define GROUPADD_SYNC_parameter "GROUPADD_SYNC" #define GROUPADD_SYNC_parameter_command "ubconfig --source system get users USERADD_SYNC" +#define check_box_icon_name "com.ublinux.libublsettingsui-gtk3.checkbox-symbolic" +#define check_checked_icon_name "com.ublinux.libublsettingsui-gtk3.checkbox-checked-symbolic" +#define check_attention_icon_name "com.ublinux.libublsettingsui-gtk3.checkbox-attention-symbolic" #define add_icon_name "com.ublinux.ubl-settings-usergroups.increase-symbolic" #define edit_icon_name "com.ublinux.ubl-settings-usergroups.edit-symbolic" #define delete_icon_name "com.ublinux.ubl-settings-usergroups.trash-symbolic" diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 830943c..b9a2c3d 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -271,5 +271,9 @@ #define SHUTDOWN_MINIMUM_GID_LABEL _("Minimum GID") #define SHUTDOWN_MAXIMUM_GID_LABEL _("Maximum GID") +#define DENY_LOGIN_LABEL _("Deny login") +#define BLOCK_LOGIN_LABEL _("Block login with password") +#define UNBOCK_LOGIN_LABEL _("Unblock login with password") + #define CONFIRMATION_GROUP_DEPENDS_SINGLE_LABEL(target,depends) yon_char_unite(_("User(-s)")," \"",depends,"\" ",_("is included into main group of users")," \"",target,"\", ",_("which will be deleted"),".\n",_("After reboot users")," ",depends," ",_("main group will be set to default group"),".",NULL) #define CONFIRMATION_GROUP_DEPENDS_MULTIPLE_LABEL _("Some of users, chosen for deletion, are included as main group for other users. This users will get default main group after reboot") diff --git a/ubl-settings-usergroups-additional-settings.glade b/ubl-settings-usergroups-additional-settings.glade index e2a11e8..8921f94 100644 --- a/ubl-settings-usergroups-additional-settings.glade +++ b/ubl-settings-usergroups-additional-settings.glade @@ -1,5 +1,5 @@ - + @@ -76,8 +76,8 @@ False Group GID range - - + + True True False @@ -90,8 +90,8 @@ False Group GID in system - - + + True True False @@ -176,8 +176,8 @@ False Users UID range - - + + True True False @@ -190,8 +190,8 @@ False User UID in system - - + + True True False @@ -461,6 +461,7 @@ Default No password required Set a password + Deny login diff --git a/ubl-settings-usergroups-user.glade b/ubl-settings-usergroups-user.glade index dc453a6..59c758c 100644 --- a/ubl-settings-usergroups-user.glade +++ b/ubl-settings-usergroups-user.glade @@ -1,5 +1,5 @@ - + @@ -237,6 +237,9 @@ Default No password required Set a password + Deny login + Block login with password + Unblock login with password diff --git a/ubl-settings-usergroups.glade b/ubl-settings-usergroups.glade index 4ec95c8..8077571 100644 --- a/ubl-settings-usergroups.glade +++ b/ubl-settings-usergroups.glade @@ -1,5 +1,5 @@ - - + + @@ -363,9 +363,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Locked 0 - + - 0 + 0 diff --git a/ubl-settings-usergroups.pot b/ubl-settings-usergroups.pot index 6d0f778..8312117 100644 --- a/ubl-settings-usergroups.pot +++ b/ubl-settings-usergroups.pot @@ -858,19 +858,19 @@ msgid "All system users" msgstr "" #: source/ubl-strings.h:253 source/ubl-strings.h:266 -msgid "Users GID range" +msgid "Users UID range" msgstr "" #: source/ubl-strings.h:254 source/ubl-strings.h:267 -msgid "User GID in system" +msgid "User UID in system" msgstr "" #: source/ubl-strings.h:255 -msgid "Users UID range" +msgid "Users GID range" msgstr "" #: source/ubl-strings.h:256 -msgid "User UID in system" +msgid "User GID in system" msgstr "" #: source/ubl-strings.h:258 @@ -913,26 +913,40 @@ msgstr "" msgid "Maximum GID" msgstr "" -#: source/ubl-strings.h:272 +#: source/ubl-strings.h:274 +msgid "Deny login" +msgstr "" + +#: source/ubl-strings.h:275 +msgid "Block login with password" +msgstr "" + +#: source/ubl-strings.h:276 +msgid "Unblock login with password" +msgstr "" + +#: source/ubl-strings.h:278 msgid "User(-s)" msgstr "" -#: source/ubl-strings.h:272 +#: source/ubl-strings.h:278 msgid "is included into main group of users" msgstr "" -#: source/ubl-strings.h:272 +#: source/ubl-strings.h:278 msgid "which will be deleted" msgstr "" -#: source/ubl-strings.h:272 +#: source/ubl-strings.h:278 msgid "After reboot users" msgstr "" -#: source/ubl-strings.h:272 +#: source/ubl-strings.h:278 msgid "main group will be set to default group" msgstr "" -#: source/ubl-strings.h:272 -msgid "Some of users, chosen for deletion, are included as main group for other users. This users will get default main group after reboot" +#: source/ubl-strings.h:279 +msgid "" +"Some of users, chosen for deletion, are included as main group for other " +"users. This users will get default main group after reboot" msgstr "" diff --git a/ubl-settings-usergroups_ru.po b/ubl-settings-usergroups_ru.po index 5d9930b..a6ccde3 100644 --- a/ubl-settings-usergroups_ru.po +++ b/ubl-settings-usergroups_ru.po @@ -926,19 +926,19 @@ msgid "All system users" msgstr "Все пользователи в системе" #: source/ubl-strings.h:253 source/ubl-strings.h:266 -msgid "Users GID range" +msgid "Users UID range" msgstr "Диапазон UID пользователей в системе" #: source/ubl-strings.h:254 source/ubl-strings.h:267 -msgid "User GID in system" +msgid "User UID in system" msgstr "Пользователь в системе с UID" #: source/ubl-strings.h:255 -msgid "Users UID range" +msgid "Users GID range" msgstr "Диапазон UID пользователей в системе" #: source/ubl-strings.h:256 -msgid "User UID in system" +msgid "User GID in system" msgstr "Пользователь в системе с UID" #: source/ubl-strings.h:258 @@ -981,28 +981,44 @@ msgstr "Минимальный GID" msgid "Maximum GID" msgstr "Максимальный GID" -#: source/ubl-strings.h:272 +#: source/ubl-strings.h:274 +msgid "Deny login" +msgstr "Запретить вход" + +#: source/ubl-strings.h:275 +msgid "Block login with password" +msgstr "Заблокировать вход по паролю" + +#: source/ubl-strings.h:276 +#, fuzzy +msgid "Unblock login with password" +msgstr "Разблокировать вход по паролю" + +#: source/ubl-strings.h:278 msgid "User(-s)" msgstr "Пользователь(-ли)" -#: source/ubl-strings.h:272 +#: source/ubl-strings.h:278 msgid "is included into main group of users" msgstr "включен(-ы) в основную группу" -#: source/ubl-strings.h:272 +#: source/ubl-strings.h:278 msgid "which will be deleted" msgstr "которая будет удалена" -#: source/ubl-strings.h:272 +#: source/ubl-strings.h:278 msgid "After reboot users" msgstr "После перезагрузки пользователь(-ли)" -#: source/ubl-strings.h:272 +#: source/ubl-strings.h:278 msgid "main group will be set to default group" msgstr "получит(-ат) основную группу по умолчанию" -#: source/ubl-strings.h:272 +#: source/ubl-strings.h:279 msgid "" "Some of users, chosen for deletion, are included as main group for other " "users. This users will get default main group after reboot" -msgstr "Часть пользователей выбранных на удаление используются как основные группы других пользователей. После перезагрузки эти пользователи получат основную группу по умолчанию" +msgstr "" +"Часть пользователей выбранных на удаление используются как основные группы " +"других пользователей. После перезагрузки эти пользователи получат основную " +"группу по умолчанию" From ea87c713bbc7b4e10a3291bc549cc94a339d8906 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 21 May 2025 10:17:28 +0600 Subject: [PATCH 05/12] Crash fix --- source/ubl-settings-usergroups-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ubl-settings-usergroups-user.c b/source/ubl-settings-usergroups-user.c index 6757bd8..9e95b00 100644 --- a/source/ubl-settings-usergroups-user.c +++ b/source/ubl-settings-usergroups-user.c @@ -393,7 +393,7 @@ void on_user_save(GtkWidget *self, dictionary *dict){ int password_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->userPasswordCombo)); if (password_active == 0){ - password = NULL; + password = ""; } else if (password_active ==1){ password = " "; } else if (password_active ==2){ From 4c9b727061ac347574672e8c8c03bdcf84df68a2 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 21 May 2025 11:47:07 +0600 Subject: [PATCH 06/12] Test fix for rare crash --- source/ubl-settings-usergroups.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index 0c35df4..77e7fb2 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -687,7 +687,7 @@ void yon_delete_confirmation_save(GtkWidget *self, dictionary *dict){ char *target; char *group; gtk_tree_model_get(model,&iter,0,&selected,1,&target,6,&group,-1); - if (selected){ + if (selected&&!yon_char_is_empty(target)&&!yon_char_is_empty(group)){ if ((!strcmp(target,group))){ depends = yon_user_check_groups(window->list,target); if (!yon_char_is_empty(depends)) { From a618ca9398b382941e7a9d731d74e2166a1135f2 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 21 May 2025 14:36:04 +0600 Subject: [PATCH 07/12] Fixed user password --- source/ubl-settings-usergroups-user.c | 6 --- source/ubl-settings-usergroups.c | 63 ++++----------------------- 2 files changed, 9 insertions(+), 60 deletions(-) diff --git a/source/ubl-settings-usergroups-user.c b/source/ubl-settings-usergroups-user.c index 9e95b00..f6e63d2 100644 --- a/source/ubl-settings-usergroups-user.c +++ b/source/ubl-settings-usergroups-user.c @@ -408,12 +408,6 @@ void on_user_save(GtkWidget *self, dictionary *dict){ password = "!*"; } else if (password_active ==4){ password = (char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordEntry)); - if (yon_char_is_empty(password)){ - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); - yon_ubl_status_highlight_incorrect(window->userPasswordEntry); - gtk_notebook_set_current_page(GTK_NOTEBOOK(window->MainNotebook),0); - return; - } if (password[0]!='!') { char *temp = yon_char_append("!",password); password=temp; diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index 77e7fb2..2327c2a 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -648,35 +648,8 @@ char *yon_user_check_groups(GtkListStore *list, char *target){ } void yon_delete_confirmation_save(GtkWidget *self, dictionary *dict){ - // GtkTreeIter iter,itar; main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); yon_confirmation_window *window = yon_dictionary_get_data(dict->first->next,yon_confirmation_window*); - // int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->UsersList),&iter); - // for (;valid;valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->UsersList),&iter)){ - // char *name; - // gtk_tree_model_get(GTK_TREE_MODEL(widgets->UsersList),&iter,2,&name,-1); - // int valid2 = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&itar); - // for (;valid2;valid2 = gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&itar)){ - // char *name_check; - // int status,delete; - // gtk_tree_model_get(GTK_TREE_MODEL(window->list),&itar,0,&delete,1,&name_check,3,&status,-1); - // if (!strcmp(name,name_check)&&delete){ - // gtk_list_store_remove(widgets->UsersList,&iter); - // yon_config_remove_by_key(USERADD(name)); - // yon_config_remove_by_key(USERSHADOW(name)); - // yon_config_register(USERADD_SYNC(name),USERADD_SYNC_command(name),""); - // yon_config_remove_by_key(USERADD_SYNC(name)); - // yon_config_remove_by_key(USERSHADOW_SYNC(name)); - // gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->UsersList),&iter); - // if (status){ - // if (yon_char_parsed_check_exist(main_config.remove_homes,main_config.homes_size,name)==-1){ - // yon_char_parsed_add_or_create_if_exists(main_config.remove_homes,&main_config.homes_size,name); - // } - // } - // } - // } - // } - GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL(window->list); char *single_target = NULL; @@ -725,27 +698,6 @@ void yon_delete_confirmation_save(GtkWidget *self, dictionary *dict){ yon_interface_update(widgets); - // char *name; - // if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->UsersList),&iter)){ - // gtk_tree_model_get(GTK_TREE_MODEL(widgets->UsersList),&iter,2,&name,-1); - // int valid2 = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&itar); - // for (;valid2;valid2 = gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&itar)){ - // char *name_check; - // int status,delete; - // gtk_tree_model_get(GTK_TREE_MODEL(window->list),&itar,0,&delete,1,&name_check,3,&status,-1); - // if (!strcmp(name,name_check)&&delete){ - // gtk_list_store_remove(widgets->UsersList,&iter); - // yon_config_remove_by_key(USERADD(name)); - // yon_config_remove_by_key(USERSHADOW(name)); - // gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->UsersList),&iter); - // if (status){ - // if (yon_char_parsed_check_exist(main_config.remove_homes,main_config.homes_size,name)==-1){ - // yon_char_parsed_add_or_create_if_exists(main_config.remove_homes,&main_config.homes_size,name); - // } - // } - // } - // } - // } on_subwindow_close(self); } @@ -1618,11 +1570,11 @@ void on_main_edit(GtkWidget *, main_window *widgets){ } } if (parsed_size>5){ - if (check_is_password_hash(parameters[5])){ - if (strcmp(parameters[5],"!*")&&!yon_char_check_begins_with(parameters[5],"%%")){ - char *temp = yon_char_append("%%",parameters[5]); - free(parameters[5]); - parameters[5]=temp; + if (strcmp(parameters[5]," ")&&!yon_char_check_begins_with(parameters[5],"!")&&!yon_char_check_begins_with(parameters[5],"*")&&!yon_char_check_begins_with(parameters[5],"%%")){ + if (check_is_password_hash(parameters[5])){ + char *temp = yon_char_append("%%",parameters[5]); + free(parameters[5]); + parameters[5]=temp; } } window->old_password=yon_char_new(parameters[5]); @@ -1642,8 +1594,11 @@ void on_main_edit(GtkWidget *, main_window *widgets){ } else if (!strcmp(parameters[5]," ")) { gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),1); } else if (parameters[5][0]=='!'){ - gtk_entry_set_text(GTK_ENTRY(window->userPasswordEntry),parameters[5]); + char *password_or = yon_char_new(parameters[5]); + free(yon_char_divide(password_or,0)); + gtk_entry_set_text(GTK_ENTRY(window->userPasswordEntry),password_or); gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),4); + free(password_or); } else { gtk_entry_set_text(GTK_ENTRY(window->userPasswordEntry),parameters[5]); gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),2); From adf3b045a4fbd5e54ee4210f16bdb46f5f4aa46a Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 21 May 2025 14:46:32 +0600 Subject: [PATCH 08/12] Localisation changes --- source/ubl-settings-usergroups-settings.c | 1 + source/ubl-strings.h | 3 ++- ubl-settings-usergroups.pot | 12 ++++++++++-- ubl-settings-usergroups_ru.po | 17 ++++++++++++----- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/source/ubl-settings-usergroups-settings.c b/source/ubl-settings-usergroups-settings.c index 2ffac0c..75aa645 100644 --- a/source/ubl-settings-usergroups-settings.c +++ b/source/ubl-settings-usergroups-settings.c @@ -766,6 +766,7 @@ void on_ubl_settings_usergroups_additional_settings_open(GtkWidget *, main_windo data->function=on_passwords_encrypt; data->action_text = ENCRYPT_SURE_LABEL; data->data=encrypt_data; + data->title = ENCRYPT_TITLE_LABEL; g_signal_connect(G_OBJECT(window->EncryptAllPasswordsButton),"clicked",G_CALLBACK(yon_confirmation_dialog_call),data); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index b9a2c3d..8a2518a 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -85,7 +85,8 @@ #define DESCTRYPT_LABEL "desctrypt" #define NT_LABEL "nt" #define ACCEPT_LABEL _("Accept") -#define ENCRYPT_SURE_LABEL _("Are you sure want to encrypt all passwords?\nThis action can't be undone.") +#define ENCRYPT_SURE_LABEL yon_char_unite("",_("Attention!")," ",_("All unencrypted password in configuration will be encrypted.\nAre you sure want to encrypt all passwords? This action can't be undone."),NULL) +#define ENCRYPT_TITLE_LABEL _("Encrypt all unencrypted passwords") #define ENCRYPT_TOOLTIP_LABEL _("Encrypt all unencrypted passwords at global configuration") #define DES_DESCRIPTION_LABEL _("DES (Algorithm for Symmetric Encryption)") #define MD5_DESCRIPTION_LABEL _("MD5 (128-bit hashing algorithm)") diff --git a/ubl-settings-usergroups.pot b/ubl-settings-usergroups.pot index 8312117..46c57e8 100644 --- a/ubl-settings-usergroups.pot +++ b/ubl-settings-usergroups.pot @@ -286,10 +286,18 @@ msgstr "" msgid "Accept" msgstr "" +#: source/ubl-strings.h:87 +msgid "Attention!" +msgstr "" + #: source/ubl-strings.h:88 msgid "" -"Are you sure want to encrypt all passwords?\n" -"This action can't be undone." +"All unencrypted password in configuration will be encrypted.\n" +"Are you sure want to encrypt all passwords? This action can't be undone." +msgstr "" + +#: source/ubl-strings.h:89 +msgid "Encrypt all unencrypted passwords" msgstr "" #: source/ubl-strings.h:89 diff --git a/ubl-settings-usergroups_ru.po b/ubl-settings-usergroups_ru.po index a6ccde3..9cb1694 100644 --- a/ubl-settings-usergroups_ru.po +++ b/ubl-settings-usergroups_ru.po @@ -314,13 +314,20 @@ msgstr "Не зашифрован" msgid "Accept" msgstr "Принять" +#: source/ubl-strings.h:87 +msgid "Attention!" +msgstr "Внимание!" + #: source/ubl-strings.h:88 msgid "" -"Are you sure want to encrypt all passwords?\n" -"This action can't be undone." -msgstr "" -"Вы уверены что хотите зашифровать все пароли?\n" -"Это действие нельзя отменить." +"All unencrypted password in configuration will be encrypted.\n" +"Are you sure want to encrypt all passwords? This action can't be undone." +msgstr "Все незашифрованные пароли, хранящиеся в конфигурации, будут зашифрованы.\n" +"Вы уверены, что хотите зашифровать все пароли? Это действие нельзя отменить." + +#: source/ubl-strings.h:89 +msgid "Encrypt all unencrypted passwords" +msgstr "Зашифровать все пароли" #: source/ubl-strings.h:89 msgid "Encrypt all unencrypted passwords at global configuration" From 0ed982a46986fa5ef1d8fc94bf3adae2b95c71f0 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 21 May 2025 14:58:36 +0600 Subject: [PATCH 09/12] Password combo boxes fixes and reorder --- source/ubl-settings-usergroups-settings.c | 16 ++++++------- source/ubl-settings-usergroups-user.c | 10 ++++---- source/ubl-settings-usergroups.c | 18 +++++++------- ...tings-usergroups-additional-settings.glade | 24 +++++++++---------- ubl-settings-usergroups-user.glade | 4 ++-- 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/source/ubl-settings-usergroups-settings.c b/source/ubl-settings-usergroups-settings.c index 75aa645..d7992e7 100644 --- a/source/ubl-settings-usergroups-settings.c +++ b/source/ubl-settings-usergroups-settings.c @@ -35,9 +35,9 @@ void on_additional_settings_changed(GtkWidget *self, ubl_settings_usergroups_add } char *default_password = NULL; int user_password_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->DefaultPasswordCombo)); - if (user_password_active==2) + if (user_password_active==1) default_password=(char*)gtk_entry_get_text(GTK_ENTRY(window->DefaultPasswordEntry)); - else if (user_password_active==1) + else if (user_password_active==2) default_password=" "; else if (user_password_active==3){ default_password="!*"; @@ -51,9 +51,9 @@ void on_additional_settings_changed(GtkWidget *self, ubl_settings_usergroups_add } char *root_password = NULL; int root_password_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RootPasswordCombo)); - if (root_password_active==2) + if (root_password_active==1) root_password=(char*)gtk_entry_get_text(GTK_ENTRY(window->RootPasswordCombo)); - else if (root_password_active==1) + else if (root_password_active==2) root_password=" "; if (!yon_char_is_empty(root_password)){ if (window->default_root_password) @@ -674,21 +674,21 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_ char *default_password = yon_config_get_by_key(DEFAULTPASSWD_parameter); if (!yon_char_is_empty(default_password)){ if (!strcmp(default_password," ")){ - gtk_combo_box_set_active(GTK_COMBO_BOX(window->DefaultPasswordCombo),1); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->DefaultPasswordCombo),2); } else if (!strcmp(default_password,"!*")){ gtk_combo_box_set_active(GTK_COMBO_BOX(window->DefaultPasswordCombo),3); } else { - gtk_combo_box_set_active(GTK_COMBO_BOX(window->DefaultPasswordCombo),2); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->DefaultPasswordCombo),1); gtk_entry_set_text(GTK_ENTRY(window->DefaultPasswordEntry),default_password); } } char *root_password = yon_config_get_by_key(DEFAULTROOTPASSWD_parameter); if (!yon_char_is_empty(root_password)){ if (!strcmp(root_password," ")){ - gtk_combo_box_set_active(GTK_COMBO_BOX(window->RootPasswordCombo),1); - } else { gtk_combo_box_set_active(GTK_COMBO_BOX(window->RootPasswordCombo),2); + } else { + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RootPasswordCombo),1); gtk_entry_set_text(GTK_ENTRY(window->DefaultPasswordEntry),root_password); } } diff --git a/source/ubl-settings-usergroups-user.c b/source/ubl-settings-usergroups-user.c index f6e63d2..3cd23fd 100644 --- a/source/ubl-settings-usergroups-user.c +++ b/source/ubl-settings-usergroups-user.c @@ -394,9 +394,9 @@ void on_user_save(GtkWidget *self, dictionary *dict){ int password_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->userPasswordCombo)); if (password_active == 0){ password = ""; - } else if (password_active ==1){ + } else if (password_active ==5){ password = " "; - } else if (password_active ==2){ + } else if (password_active ==1){ password = (char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordEntry)); if (yon_char_is_empty(password)){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); @@ -404,15 +404,15 @@ void on_user_save(GtkWidget *self, dictionary *dict){ gtk_notebook_set_current_page(GTK_NOTEBOOK(window->MainNotebook),0); return; } - } else if (password_active==3){ + } else if (password_active==2){ password = "!*"; - } else if (password_active ==4){ + } else if (password_active ==3){ password = (char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordEntry)); if (password[0]!='!') { char *temp = yon_char_append("!",password); password=temp; } - } else if (password_active == 5){ + } else if (password_active == 4){ password = yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordEntry))); if (yon_char_is_empty(password)){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index 2327c2a..3875555 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -841,13 +841,13 @@ void on_password_combo_changed(GtkComboBox *self, GtkWidget *target){ int active = gtk_combo_box_get_active(self); switch(active){ case 0: - case 1: + case 2: case 3: - case 4: + case 5: gtk_widget_set_sensitive(target,0); break; - case 2: - case 5: + case 1: + case 4: gtk_widget_set_sensitive(target,1); break; } @@ -1399,7 +1399,7 @@ void on_toggle_button_set_active_from_combo_box(GtkComboBox *self,ubl_settings_u void on_toggle_button_set_active_from_toggle_button_inversed(GtkToggleButton *, ubl_settings_usergroups_user_window *window){ char *passw = (char*)gtk_entry_get_text(GTK_ENTRY(window->userPasswordEntry)); - if ((passw[0]!='$')&>k_combo_box_get_active(GTK_COMBO_BOX(window->userPasswordCombo))>1){ + if ((passw[0]!='$')&>k_combo_box_get_active(GTK_COMBO_BOX(window->userPasswordCombo))==1){ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userSyncSAMBACheck))){ gtk_widget_set_sensitive(GTK_WIDGET(window->userSyncSAMBAPasswordCheck),0); } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->userSyncSAMBAPasswordCheck))){ @@ -1590,18 +1590,18 @@ void on_main_edit(GtkWidget *, main_window *widgets){ g_signal_handlers_block_by_func(G_OBJECT(window->userSyncSAMBACheck),G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),window->userSyncSAMBAPasswordCheck); } if (!strcmp(parameters[5],"!*")){ - gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),3); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),2); } else if (!strcmp(parameters[5]," ")) { - gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),1); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),5); } else if (parameters[5][0]=='!'){ char *password_or = yon_char_new(parameters[5]); free(yon_char_divide(password_or,0)); gtk_entry_set_text(GTK_ENTRY(window->userPasswordEntry),password_or); - gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),4); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),3); free(password_or); } else { gtk_entry_set_text(GTK_ENTRY(window->userPasswordEntry),parameters[5]); - gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),2); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),1); } } } diff --git a/ubl-settings-usergroups-additional-settings.glade b/ubl-settings-usergroups-additional-settings.glade index 8921f94..f475bcc 100644 --- a/ubl-settings-usergroups-additional-settings.glade +++ b/ubl-settings-usergroups-additional-settings.glade @@ -1,5 +1,5 @@ - + @@ -76,8 +76,8 @@ False Group GID range - - + + True True False @@ -90,8 +90,8 @@ False Group GID in system - - + + True True False @@ -176,8 +176,8 @@ False Users UID range - - + + True True False @@ -190,8 +190,8 @@ False User UID in system - - + + True True False @@ -383,8 +383,9 @@ 0 Default - No password required Set a password + No password required + Deny login @@ -459,9 +460,8 @@ 0 Default - No password required Set a password - Deny login + No password required diff --git a/ubl-settings-usergroups-user.glade b/ubl-settings-usergroups-user.glade index 59c758c..a25b015 100644 --- a/ubl-settings-usergroups-user.glade +++ b/ubl-settings-usergroups-user.glade @@ -1,5 +1,5 @@ - + @@ -235,11 +235,11 @@ 0 Default - No password required Set a password Deny login Block login with password Unblock login with password + No password required From 51fb99f6c578ca257b7f259c0388a16155b2bdf3 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 22 May 2025 11:03:37 +0600 Subject: [PATCH 10/12] Default password and default root password saving fix --- source/ubl-settings-usergroups-settings.c | 12 ++++++------ ubl-settings-usergroups_ru.po | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/ubl-settings-usergroups-settings.c b/source/ubl-settings-usergroups-settings.c index d7992e7..e6d44c2 100644 --- a/source/ubl-settings-usergroups-settings.c +++ b/source/ubl-settings-usergroups-settings.c @@ -43,23 +43,23 @@ void on_additional_settings_changed(GtkWidget *self, ubl_settings_usergroups_add default_password="!*"; } if (!yon_char_is_empty(default_password)){ - if (window->default_password) + // if (window->default_password) yon_config_register(DEFAULTPASSWD_parameter,DEFAULTPASSWD_parameter_command,default_password); } else { - if (window->default_password) + // if (window->default_password) yon_config_remove_by_key(DEFAULTPASSWD_parameter); } char *root_password = NULL; int root_password_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->RootPasswordCombo)); if (root_password_active==1) - root_password=(char*)gtk_entry_get_text(GTK_ENTRY(window->RootPasswordCombo)); + root_password=(char*)gtk_entry_get_text(GTK_ENTRY(window->RootPasswordEntry)); else if (root_password_active==2) root_password=" "; if (!yon_char_is_empty(root_password)){ - if (window->default_root_password) + // if (window->default_root_password) yon_config_register(DEFAULTROOTPASSWD_parameter,DEFAULTROOTPASSWD_parameter_command,root_password); } else { - if (window->default_root_password) + // if (window->default_root_password) yon_config_remove_by_key(DEFAULTROOTPASSWD_parameter); } int user_k_admin = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DefaultUserAdministratorCheck)); @@ -689,7 +689,7 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_ gtk_combo_box_set_active(GTK_COMBO_BOX(window->RootPasswordCombo),2); } else { gtk_combo_box_set_active(GTK_COMBO_BOX(window->RootPasswordCombo),1); - gtk_entry_set_text(GTK_ENTRY(window->DefaultPasswordEntry),root_password); + gtk_entry_set_text(GTK_ENTRY(window->RootPasswordEntry),root_password); } } char *is_k_admin = yon_config_get_by_key(ADDADM_parameter); diff --git a/ubl-settings-usergroups_ru.po b/ubl-settings-usergroups_ru.po index 9cb1694..cdd3e2b 100644 --- a/ubl-settings-usergroups_ru.po +++ b/ubl-settings-usergroups_ru.po @@ -300,7 +300,7 @@ msgstr "Пароль не требуется" #: source/ubl-strings.h:72 msgid "Set a password" -msgstr "Задать пароль" +msgstr "Установить пароль" #: source/ubl-strings.h:73 source/ubl-strings.h:124 msgid "Encrypted" From 74d0ffc91c4d9f73d1f8f826cb904818a595a09e Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 22 May 2025 12:05:19 +0600 Subject: [PATCH 11/12] Changed group password --- source/ubl-settings-usergroups-group.c | 29 +++++++++-- source/ubl-settings-usergroups.c | 51 ++++++++++++++++---- source/ubl-settings-usergroups.h | 1 + ubl-settings-usergroups-group-creation.glade | 7 ++- 4 files changed, 71 insertions(+), 17 deletions(-) diff --git a/source/ubl-settings-usergroups-group.c b/source/ubl-settings-usergroups-group.c index 5f6a2da..182d78b 100644 --- a/source/ubl-settings-usergroups-group.c +++ b/source/ubl-settings-usergroups-group.c @@ -193,9 +193,11 @@ void on_group_save(GtkWidget *self, dictionary *dict){ int password_active = gtk_combo_box_get_active(GTK_COMBO_BOX(window->PasswordCombo)); - if (password_active == 1) { - password = "!*"; - } else if (password_active == 2){ + if (password_active == 0){ + password = ""; + } else if (password_active ==5){ + password = " "; + } else if (password_active == 1){ password = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); if (yon_char_is_empty(password)){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); @@ -203,8 +205,25 @@ void on_group_save(GtkWidget *self, dictionary *dict){ yon_ubl_status_highlight_incorrect(window->PasswordEntry); return; } - } else { - password=""; + } else if (password_active==2){ + password = "!*"; + } else if (password_active ==3){ + password = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); + if (password[0]!='!') { + char *temp = yon_char_append("!",password); + password=temp; + } + } else if (password_active == 4){ + password = yon_char_new((char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry))); + if (yon_char_is_empty(password)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->PasswordEntry); + gtk_notebook_set_current_page(GTK_NOTEBOOK(window->MainNotebook),0); + return; + } + if (password[0]=='!'){ + free(yon_char_divide(password,0)); + } } final_string = yon_char_unite(yon_char_return_if_exist(group_users,""), ":",yon_char_return_if_exist(gid,"x"), diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index 3875555..ed7e20c 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -110,8 +110,12 @@ void yon_interface_update(main_window *widgets){ if (!check_is_password_hash(parameters[5])&¶meters[5][0]!='%'&¶meters[5][1]!='%'){ pars = ENCRYPTED_LABEL; - } else if (!strcmp(parameters[5],"!*")){ + } else if (!strcmp(parameters[5]," ")){ pars = NO_PASSWORD_LABEL; + } else if (!strcmp(parameters[5],"!*")){ + pars = DENY_LOGIN_LABEL; + } else if (parameters[5][0]=='!'){ + pars = BLOCK_LOGIN_LABEL; } else { pars = UNENCRYPTED_LABEL; @@ -158,8 +162,12 @@ void yon_interface_update(main_window *widgets){ if (parameters_size>4&&strcmp(parameters[4],"x")&&strcmp(parameters[4],"")){ if (!check_is_password_hash(parameters[4])&¶meters[4][0]!='%'&¶meters[4][1]!='%'){ pars = ENCRYPTED_LABEL; - } else if (!strcmp(parameters[4],"!*")||!strcmp(parameters[4],"*")||!strcmp(parameters[4],"!")){ + } else if (!strcmp(parameters[4]," ")){ pars = NO_PASSWORD_LABEL; + } else if (!strcmp(parameters[4],"!*")){ + pars = DENY_LOGIN_LABEL; + } else if (parameters[4][0]=='!'){ + pars = BLOCK_LOGIN_LABEL; } else { pars = UNENCRYPTED_LABEL; @@ -1702,14 +1710,37 @@ void on_main_edit(GtkWidget *, main_window *widgets){ } } if (size>4){ - if (!yon_char_is_empty(parsed[4])){ - if (!strcmp(parsed[4],"!*")||!strcmp(parsed[4],"!")||!strcmp(parsed[4],"*")){ - gtk_combo_box_set_active(GTK_COMBO_BOX(window->PasswordCombo),1); - gtk_entry_set_text(GTK_ENTRY(window->PasswordEntry),""); - } else if (strcmp(parsed[4],"x")){ - gtk_entry_set_text(GTK_ENTRY(window->PasswordEntry),parsed[4]); - gtk_combo_box_set_active(GTK_COMBO_BOX(window->PasswordCombo),2); - + if (strcmp(parsed[4]," ")&&!yon_char_check_begins_with(parsed[4],"!")&&!yon_char_check_begins_with(parsed[4],"*")&&!yon_char_check_begins_with(parsed[4],"%%")){ + if (check_is_password_hash(parsed[4])){ + char *temp = yon_char_append("%%",parsed[4]); + free(parsed[4]); + parsed[4]=temp; + } + } + window->old_password=yon_char_new(parsed[4]); + if (strcmp(parsed[4],"x")&&strcmp(parsed[4],"")){ + if (!yon_char_is_empty(parsed[4])){ + if (check_is_password_hash(parsed[4])){ + if (yon_char_check_begins_with(parsed[4],"%%")==-1){ + char *temp = yon_char_append("%%",parsed[4]); + free(parsed[4]); + parsed[4]=temp; + } + } + if (!strcmp(parsed[4],"!*")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->PasswordCombo),2); + } else if (!strcmp(parsed[4]," ")) { + gtk_combo_box_set_active(GTK_COMBO_BOX(window->PasswordCombo),5); + } else if (parsed[4][0]=='!'){ + char *password_or = yon_char_new(parsed[4]); + free(yon_char_divide(password_or,0)); + gtk_entry_set_text(GTK_ENTRY(window->PasswordEntry),password_or); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->PasswordCombo),3); + free(password_or); + } else { + gtk_entry_set_text(GTK_ENTRY(window->PasswordEntry),parsed[4]); + gtk_combo_box_set_active(GTK_COMBO_BOX(window->PasswordCombo),1); + } } } } else { diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index f3820bf..c8fbb7c 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -307,6 +307,7 @@ typedef struct{ GtkWidget *MainNotebook; char *last_gid; + char *old_password; } ubl_settings_usergroups_group_creation_window; typedef struct{ diff --git a/ubl-settings-usergroups-group-creation.glade b/ubl-settings-usergroups-group-creation.glade index d50bf79..e4b169b 100644 --- a/ubl-settings-usergroups-group-creation.glade +++ b/ubl-settings-usergroups-group-creation.glade @@ -1,5 +1,5 @@ - + @@ -353,8 +353,11 @@ 0 Default - No password required Set a password + Deny login + Block login with password + Unblock login with password + No password required From 0f0c750efd59e449843085a6cb2be1d2faaacd5d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 22 May 2025 18:34:42 +0600 Subject: [PATCH 12/12] Test fix for default passwords --- source/ubl-settings-usergroups-settings.c | 34 +++++++++++++---------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/source/ubl-settings-usergroups-settings.c b/source/ubl-settings-usergroups-settings.c index e6d44c2..e7d7d33 100644 --- a/source/ubl-settings-usergroups-settings.c +++ b/source/ubl-settings-usergroups-settings.c @@ -671,25 +671,29 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_ g_signal_connect(G_OBJECT(window->RootPasswordCombo),"changed",G_CALLBACK(on_password_combo_changed),window->RootPasswordButton); g_signal_connect(G_OBJECT(window->DefaultPasswordCombo),"changed",G_CALLBACK(on_password_combo_changed),window->DefaultPasswordButton); - char *default_password = yon_config_get_by_key(DEFAULTPASSWD_parameter); - if (!yon_char_is_empty(default_password)){ - if (!strcmp(default_password," ")){ - gtk_combo_box_set_active(GTK_COMBO_BOX(window->DefaultPasswordCombo),2); - } else if (!strcmp(default_password,"!*")){ - gtk_combo_box_set_active(GTK_COMBO_BOX(window->DefaultPasswordCombo),3); + if (!yon_config_check_default(DEFAULTPASSWD_parameter)){ + char *default_password = yon_config_get_by_key(DEFAULTPASSWD_parameter); + if (!yon_char_is_empty(default_password)){ + if (!strcmp(default_password," ")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->DefaultPasswordCombo),2); + } else if (!strcmp(default_password,"!*")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->DefaultPasswordCombo),3); - } else { - gtk_combo_box_set_active(GTK_COMBO_BOX(window->DefaultPasswordCombo),1); - gtk_entry_set_text(GTK_ENTRY(window->DefaultPasswordEntry),default_password); + } else { + gtk_combo_box_set_active(GTK_COMBO_BOX(window->DefaultPasswordCombo),1); + gtk_entry_set_text(GTK_ENTRY(window->DefaultPasswordEntry),default_password); + } } } + if (!yon_config_check_default(DEFAULTROOTPASSWD_parameter)){ char *root_password = yon_config_get_by_key(DEFAULTROOTPASSWD_parameter); - if (!yon_char_is_empty(root_password)){ - if (!strcmp(root_password," ")){ - gtk_combo_box_set_active(GTK_COMBO_BOX(window->RootPasswordCombo),2); - } else { - gtk_combo_box_set_active(GTK_COMBO_BOX(window->RootPasswordCombo),1); - gtk_entry_set_text(GTK_ENTRY(window->RootPasswordEntry),root_password); + if (!yon_char_is_empty(root_password)){ + if (!strcmp(root_password," ")){ + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RootPasswordCombo),2); + } else { + gtk_combo_box_set_active(GTK_COMBO_BOX(window->RootPasswordCombo),1); + gtk_entry_set_text(GTK_ENTRY(window->RootPasswordEntry),root_password); + } } } char *is_k_admin = yon_config_get_by_key(ADDADM_parameter);