diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index 6b19b9e..0a14d11 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -6,7 +6,7 @@ config main_config; int yon_load_proceed(YON_CONFIG_TYPE type){ yon_config_load_register(YON_CONFIG_DEFAULT,"users","DEFAULTPASSWD DEFAULTROOTPASSWD USERGROUPS DEFAULTUSER HASHPASSWD ADDADM",NULL); - yon_config_load_register_no_cleaning(type,"users","DEFAULTPASSWD DEFAULTROOTPASSWD DEFAULTUSER HASHPASSWD USERGROUPS ADDADM USERADD[*] USERSHADOW[*] GROUPADD[*]","[system]","SYSTEMBOOT_STATEMODE","[save]","SAVE_ROOTCOPY_CHANGES",NULL); + yon_config_load_register_no_cleaning(type,"users","DEFAULTPASSWD DEFAULTROOTPASSWD DEFAULTUSER HASHPASSWD USERGROUPS ADDADM USERADD[*] USERADD_SYNC USERSHADOW[*] GROUPADD[*]","[system]","SYSTEMBOOT_STATEMODE","[save]","SAVE_ROOTCOPY_CHANGES",NULL); if (type!=YON_CONFIG_GLOBAL){ yon_config_load_register_no_cleaning(YON_CONFIG_GLOBAL,"users","DEFAULTPASSWD DEFAULTROOTPASSWD",NULL); } @@ -355,6 +355,11 @@ void yon_hide_passwords(template_saving_window *window){ } } +void on_save_done(main_window *widgets){ + on_config_update(NULL,widgets); +} + + void on_config_save(GtkWidget *self, main_window *widgets){ yon_accept_changes(); yon_samba_sync_proceed(); @@ -417,12 +422,13 @@ void on_config_save(GtkWidget *self, main_window *widgets){ } } -void on_config_global_save(){ +void on_config_global_save(GtkWidget *self, main_window *widgets){ yon_accept_changes(); yon_samba_sync_proceed(); template_saving_window *window = yon_save_proceed("global",YON_CONFIG_GLOBAL,"users", "DEFAULTPASSWD DEFAULTROOTPASSWD DEFAULTUSER HASHPASSWD USERGROUPS ADDADM USERADD[*] USERSHADOW[*] GROUPADD[*]",NULL); - if (window) yon_hide_passwords(window); - + if (window){ + yon_hide_passwords(window); + } } void on_config_local_save(GtkWidget *self, main_window *widgets){ @@ -960,6 +966,32 @@ void on_expiration_clicked(GtkWidget *self, ubl_settings_usergroups_user_window yon_char_parsed_free(hash_algos,hash_size); } + void on_users_boot_toggled(GtkToggleButton *self){ + if (gtk_toggle_button_get_active(self)){ + char *parameter = yon_config_get_by_key("USERADD_SYNC"); + if (!parameter){ + yon_config_register("USERADD_SYNC","users","boot"); + } else { + yon_config_append("USERADD_SYNC","boot",","); + } + } else { + yon_config_remove_element("USERADD_SYNC","boot",","); + } + } + + void on_users_shutdown_toggled(GtkToggleButton *self){ + if (gtk_toggle_button_get_active(self)){ + char *parameter = yon_config_get_by_key("USERADD_SYNC"); + if (!parameter){ + yon_config_register("USERADD_SYNC","users","shutdown"); + } else { + yon_config_append("USERADD_SYNC","shutdown",","); + } + } else { + yon_config_remove_element("USERADD_SYNC","shutdown",","); + } + } + ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_additional_settings_new(){ ubl_settings_usergroups_additional_settings_window *window = malloc(sizeof(ubl_settings_usergroups_additional_settings_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_ubl_settings_usergroups_additional_settings); @@ -977,9 +1009,20 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_ window->EncryptAllPasswordsButton=yon_gtk_builder_get_widget(builder,"EncryptAllPasswordsButton"); window->CancelButton=yon_gtk_builder_get_widget(builder,"CancelButton"); window->AcceptButton=yon_gtk_builder_get_widget(builder,"AcceptButton"); + window->UsersBootCheck=yon_gtk_builder_get_widget(builder,"UsersBootCheck"); + window->UsersShutdownCheck=yon_gtk_builder_get_widget(builder,"UsersShutdownCheck"); yon_window_config_custom_window_setup(GTK_WINDOW(window->Window),"AdditionalSettingsWindow"); gtk_window_set_title(GTK_WINDOW(window->Window),ADDITIONAL_SETTINGS_TITLE_LABEL); + char *sync_parameters = yon_config_get_by_key("USERADD_SYNC"); + if (sync_parameters){ + if (strstr(sync_parameters,"boot")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->UsersBootCheck),1); + } + if (strstr(sync_parameters,"shutdown")){ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->UsersShutdownCheck),1); + } + } int hash_size=0; config_str hash_algos = yon_file_open(hash_list_path,&hash_size); @@ -1063,6 +1106,9 @@ ubl_settings_usergroups_additional_settings_window *yon_ubl_settings_usergroups_ g_signal_connect(G_OBJECT(window->PasswordHashCombo),"changed",G_CALLBACK(on_hash_changed),window); + g_signal_connect(G_OBJECT(window->UsersBootCheck),"toggled",G_CALLBACK(on_users_boot_toggled),NULL); + g_signal_connect(G_OBJECT(window->UsersShutdownCheck),"toggled",G_CALLBACK(on_users_shutdown_toggled),NULL); + return window; } @@ -2694,6 +2740,7 @@ main_window *yon_main_window_complete(main_window *widgets){ yon_window_config_add_listener((GtkWidget*)g_list_nth_data(list,i),yon_char_append("GroupColumn",yon_char_from_int(i)),"fixed-width",YON_TYPE_INT); } g_list_free(list); + yon_save_window_set_postsave_function(on_save_done,widgets); return widgets; } diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index 19dde23..42b166f 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -189,6 +189,8 @@ typedef struct{ GtkWidget *CancelButton; GtkWidget *AcceptButton; GtkWidget *EncryptAllPasswordsButton; + GtkWidget *UsersBootCheck; + GtkWidget *UsersShutdownCheck; } ubl_settings_usergroups_additional_settings_window; typedef struct{ @@ -336,4 +338,6 @@ void on_settings_usergroups_system_open(GtkWidget *self, main_window *widgets); ubl_settings_usergroups_user_window *yon_ubl_settings_usergroups_user_new(); -void on_password_accept(GtkWidget *self, dictionary *dict); \ No newline at end of file +void on_password_accept(GtkWidget *self, dictionary *dict); + +void on_config_update(GtkWidget *self, main_window *widgets); \ No newline at end of file diff --git a/ubl-settings-usergroups-additional-settings.glade b/ubl-settings-usergroups-additional-settings.glade index 6042573..b513aa7 100644 --- a/ubl-settings-usergroups-additional-settings.glade +++ b/ubl-settings-usergroups-additional-settings.glade @@ -383,7 +383,7 @@ vertical 5 - + While booting the operating system, apply the settings of all users from the configuration True True @@ -397,7 +397,7 @@ - + While shutdown, save the settings of all users with UID>=1000 to the configuration True True