@ -74,8 +74,7 @@ int yon_load_proceed(YON_CONFIG_TYPE type){
}
}
void yon_interface_update ( main_window * widgets ) {
void yon_interface_update ( main_window * widgets ) {
gtk_list_store_clear ( widgets - > UsersList ) ;
on_system_update ( NULL , widgets ) ;
gtk_list_store_clear ( widgets - > GroupsList ) ;
int size ;
int size ;
GtkTreeIter iter ;
GtkTreeIter iter ;
char * def_groups = yon_config_get_by_key ( USERGROUPS_parameter ) ;
char * def_groups = yon_config_get_by_key ( USERGROUPS_parameter ) ;
@ -149,7 +148,6 @@ void yon_interface_update(main_window *widgets){
if ( parameters_size > 1 & & ! strcmp ( parameters [ 1 ] , " x " ) ) parameters [ 1 ] = " " ;
if ( parameters_size > 1 & & ! strcmp ( parameters [ 1 ] , " x " ) ) parameters [ 1 ] = " " ;
char * pars = " " ;
char * pars = " " ;
if ( parameters_size > 4 & & strcmp ( parameters [ 4 ] , " x " ) & & strcmp ( parameters [ 4 ] , " " ) ) {
if ( parameters_size > 4 & & strcmp ( parameters [ 4 ] , " x " ) & & strcmp ( parameters [ 4 ] , " " ) ) {
if ( ! check_is_password_hash ( parameters [ 4 ] ) & & parameters [ 4 ] [ 0 ] ! = ' % ' & & parameters [ 4 ] [ 1 ] ! = ' % ' ) {
if ( ! check_is_password_hash ( parameters [ 4 ] ) & & parameters [ 4 ] [ 0 ] ! = ' % ' & & parameters [ 4 ] [ 1 ] ! = ' % ' ) {
pars = ENCRYPTED_LABEL ;
pars = ENCRYPTED_LABEL ;
} else {
} else {
@ -162,9 +160,9 @@ void yon_interface_update(main_window *widgets){
}
}
gtk_list_store_set ( widgets - > GroupsList , & iter ,
gtk_list_store_set ( widgets - > GroupsList , & iter ,
1 , login ,
1 , login ,
0 , parameters_size > 1? parameters [ 1 ] : " " ,
0 , parameters_size > 2? parameters [ 2 ] : " " ,
2 , parameters_size > 0? parameters [ 0 ] : " " ,
2 , parameters_size > 1? parameters [ 1 ] : " " ,
3 , parameters_size > 2? parameters [ 2 ] : " " ,
3 , parameters_size > 3? parameters [ 3 ] : " " ,
4 , pars ,
4 , pars ,
- 1 ) ;
- 1 ) ;
if ( parameters )
if ( parameters )
@ -215,10 +213,10 @@ if (main_config.sync_users){
int size ;
int size ;
config_str parsed = yon_char_parse ( main_config . sync_users [ i ] , & size , " : " ) ;
config_str parsed = yon_char_parse ( main_config . sync_users [ i ] , & size , " : " ) ;
if ( ! yon_char_is_empty ( parsed [ 1 ] ) ) {
if ( ! yon_char_is_empty ( parsed [ 1 ] ) ) {
yon_launch ( yon_debug_output ( " %s \n " , samba_sync_password_command ( parsed [ 0 ] , parsed [ 1 ] ) ) ) ;
if ( system ( samba_sync_password_command ( parsed [ 0 ] , parsed [ 1 ] ) ) ) { } ;
} else {
} else {
if ( system ( samba_sync_command ( parsed [ 0 ] ) ) ) { } ;
yon_launch ( yon_debug_output ( " %s \n " , samba_sync_command ( parsed [ 0 ] ) ) ) ;
}
}
@ -412,6 +410,9 @@ void on_save_done(main_window *widgets, config_str output, int size){
textdomain ( LocaleName ) ;
textdomain ( LocaleName ) ;
}
}
void on_save_failed ( main_window * , config_str , int ) {
yon_samba_sync_proceed ( ) ;
}
void on_config_save ( GtkWidget * , main_window * ) {
void on_config_save ( GtkWidget * , main_window * ) {
@ -714,6 +715,20 @@ yon_confirmation_window *yon_delete_confirmation_new(){
return window ;
return window ;
}
}
void yon_system_delete_confirmation_open ( main_window * widgets ) {
yon_confirmation_window * window = yon_delete_confirmation_new ( ) ;
gtk_window_set_transient_for ( GTK_WINDOW ( window - > Window ) , GTK_WINDOW ( widgets - > Window ) ) ;
GtkTreeIter iter ;
dictionary * dict = NULL ;
yon_dictionary_add_or_create_if_exists_with_data ( dict , " widgets " , widgets ) ;
yon_dictionary_add_or_create_if_exists_with_data ( dict , " window " , window ) ;
g_signal_connect ( G_OBJECT ( window - > AcceptButton ) , " clicked " , G_CALLBACK ( yon_delete_confirmation_save ) , dict ) ;
GtkTreeModel * model = GTK_TREE_MODEL ( widgets - > liststore1 ) ;
if ( gtk_tree_selection_get_selected ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( widgets - > SystemTree ) ) , & model , & iter ) ) {
// gtk_tree_model_get(model,&iter,1,,2,,)
}
}
void yon_delete_confirmation_open ( main_window * widgets ) {
void yon_delete_confirmation_open ( main_window * widgets ) {
yon_confirmation_window * window = yon_delete_confirmation_new ( ) ;
yon_confirmation_window * window = yon_delete_confirmation_new ( ) ;
gtk_window_set_transient_for ( GTK_WINDOW ( window - > Window ) , GTK_WINDOW ( widgets - > Window ) ) ;
gtk_window_set_transient_for ( GTK_WINDOW ( window - > Window ) , GTK_WINDOW ( widgets - > Window ) ) ;
@ -850,8 +865,8 @@ void on_groups_save(GtkWidget *self, dictionary *dict){
void on_groups_clicked ( GtkWidget * , GtkEntry * output_target ) {
void on_groups_clicked ( GtkWidget * , GtkEntry * output_target ) {
ubl_settings_usergroups_group_window * window = yon_ubl_settings_usergroups_group_new ( 0 ) ;
ubl_settings_usergroups_group_window * window = yon_ubl_settings_usergroups_group_new ( 0 ) ;
gtk_window_set_title ( GTK_WINDOW ( window - > GroupsWindow ) , MAIN_GROUP_ LABEL) ;
gtk_window_set_title ( GTK_WINDOW ( window - > GroupsWindow ) , MAIN_GROUP_ TITLE_ LABEL) ;
gtk_label_set_text ( GTK_LABEL ( window - > HeaderLabel ) , MAIN_GROUP_ LABEL) ;
gtk_label_set_text ( GTK_LABEL ( window - > HeaderLabel ) , MAIN_GROUP_ TITLE_ LABEL) ;
GtkTreeIter iter , itar , itor ;
GtkTreeIter iter , itar , itor ;
int valid = gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( main_config . groups_list ) , & iter ) ;
int valid = gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( main_config . groups_list ) , & iter ) ;
for ( ; valid ; valid = gtk_tree_model_iter_next ( GTK_TREE_MODEL ( main_config . groups_list ) , & iter ) ) {
for ( ; valid ; valid = gtk_tree_model_iter_next ( GTK_TREE_MODEL ( main_config . groups_list ) , & iter ) ) {
@ -1003,8 +1018,10 @@ void on_password_change(GtkWidget *, dictionary *entry_dict){
if ( ! check_is_password_hash ( password ) ) {
if ( ! check_is_password_hash ( password ) ) {
gtk_entry_set_text ( GTK_ENTRY ( window - > PasswordHashEntry ) , password ) ;
gtk_entry_set_text ( GTK_ENTRY ( window - > PasswordHashEntry ) , password ) ;
} else {
} else {
if ( password [ 0 ] = = ' % ' & & password [ 1 ] = = ' % ' )
if ( password [ 0 ] = = ' % ' & & password [ 1 ] = = ' % ' ) {
free ( yon_char_divide ( password , 1 ) ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > NoEncriptionCheck ) , 1 ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > NoEncriptionCheck ) , 1 ) ;
}
gtk_entry_set_text ( GTK_ENTRY ( window - > PasswordEntry ) , password ) ;
gtk_entry_set_text ( GTK_ENTRY ( window - > PasswordEntry ) , password ) ;
}
}
}
}
@ -1320,18 +1337,15 @@ void on_GID_update(GtkWidget *, ubl_settings_usergroups_group_creation_window *w
yon_char_parsed_prepend_strings ( config_groups , config_size , " : " ) ;
yon_char_parsed_prepend_strings ( config_groups , config_size , " : " ) ;
config_str final = yon_char_parsed_merge ( main_config . groups , main_config . groups_size , config_groups , config_size , & final_size ) ;
config_str final = yon_char_parsed_merge ( main_config . groups , main_config . groups_size , config_groups , config_size , & final_size ) ;
long prev_busy = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > SystemGroupCheck ) ) ? 0 : main_config . MINGID ;
long prev_busy = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > SystemGroupCheck ) ) ? 0 : main_config . MINGID ;
int minimum = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > SystemGroupCheck ) ) ? 0 : main_config . MINGID ;
int maximum = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > SystemGroupCheck ) ) ? 68000 : main_config . MAXGID ;
for ( int i = 0 ; i < final_size ; i + + ) {
for ( int i = 0 ; i < final_size ; i + + ) {
int parsed_size ;
int parsed_size ;
config_str parsed = yon_char_parse ( final [ i ] , & parsed_size , " : " ) ;
config_str parsed = yon_char_parse ( final [ i ] , & parsed_size , " : " ) ;
if ( parsed_size > 2 & & minimum < atol ( parsed [ 2 ] ) & & atol ( parsed [ 2 ] ) < maximum ) {
if ( atol ( parsed [ 2 ] ) > = main_config . MINGID | | gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > SystemGroupCheck ) ) ) {
if ( atol ( parsed [ 2 ] ) > prev_busy ) {
if ( atol ( parsed [ 2 ] ) > main_config . MAXGID | | gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > SystemGroupCheck ) ) )
break ;
if ( atol ( parsed [ 2 ] ) = = prev_busy + 1 )
prev_busy = atol ( parsed [ 2 ] ) ;
prev_busy = atol ( parsed [ 2 ] ) ;
else {
yon_char_parsed_free ( parsed , parsed_size ) ;
break ;
}
}
}
}
yon_char_parsed_free ( parsed , parsed_size ) ;
yon_char_parsed_free ( parsed , parsed_size ) ;
@ -1364,28 +1378,35 @@ void on_group_save(GtkWidget *self, dictionary *dict){
yon_ubl_status_highlight_incorrect ( window - > userUIDEntry ) ;
yon_ubl_status_highlight_incorrect ( window - > userUIDEntry ) ;
return ;
return ;
}
}
}
int config_size = 0 ;
int final_size = 0 ;
if ( strcmp ( gid , window - > last_gid ) ) {
config_str config_users = yon_config_get_all_by_key ( USERADD_SEARCH_macro , & config_size ) ;
int config_size = 0 ;
yon_char_parsed_prepend_strings ( config_users , config_size , " : " ) ;
int final_size = 0 ;
config_str final = yon_char_parsed_merge ( main_config . groups , main_config . groups_size , config_users , config_size , & final_size ) ;
config_str config_users = yon_config_get_all_by_key ( GROUPADD_SEARCH_macro , & config_size ) ;
if ( ! gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > UnuniqueGIDCheck ) ) ) {
config_str final = yon_char_parsed_merge ( main_config . groups , main_config . groups_size , config_users , config_size , & final_size ) ;
int found = 0 ;
if ( ! gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > UnuniqueGIDCheck ) ) ) {
char * uid_string = ( char * ) gtk_entry_get_text ( GTK_ENTRY ( window - > userUIDEntry ) ) ;
int found = 0 ;
for ( int i = 0 ; i < final_size ; i + + ) {
char * uid_string = ( char * ) gtk_entry_get_text ( GTK_ENTRY ( window - > userUIDEntry ) ) ;
int parsed_size ;
for ( int i = 0 ; i < final_size ; i + + ) {
config_str parsed = yon_char_parse ( final [ i ] , & parsed_size , " : " ) ;
int parsed_size ;
if ( parsed_size > 1 & & ! strcmp ( parsed [ 2 ] , uid_string ) & & strcmp ( parsed [ 2 ] , window - > last_gid ) ) found = 1 ;
config_str parsed = yon_char_parse ( final [ i ] , & parsed_size , " : " ) ;
if ( parsed_size ) yon_char_parsed_free ( parsed , parsed_size ) ;
if ( parsed_size > 2 & & ! strcmp ( parsed [ 2 ] , uid_string ) ) {
}
if ( yon_char_is_empty ( window - > last_gid ) | | ( ! yon_char_is_empty ( window - > last_gid ) & & strcmp ( parsed [ 2 ] , window - > last_gid ) ) ) {
if ( found ) {
found = yon_char_parsed_check_exist ( config_users , config_size , final [ i ] ) > - 1 ? 1 : 2 ;
yon_ubl_status_box_spawn ( GTK_CONTAINER ( window - > StatusBox ) , GID_ALREADY_EXIST_LABEL , 5 , BACKGROUND_IMAGE_FAIL_TYPE ) ;
break ;
yon_ubl_status_highlight_incorrect ( window - > userUIDEntry ) ;
}
return ;
}
if ( parsed_size ) yon_char_parsed_free ( parsed , parsed_size ) ;
}
if ( found ) {
yon_ubl_status_box_spawn ( GTK_CONTAINER ( window - > StatusBox ) , found = = 1 ? GID_ALREADY_EXIST_CONFIG_LABEL : GID_ALREADY_EXIST_SYSTEM_LABEL , 5 , BACKGROUND_IMAGE_FAIL_TYPE ) ;
yon_ubl_status_highlight_incorrect ( window - > userUIDEntry ) ;
return ;
}
}
}
}
}
}
group_name = ( char * ) gtk_entry_get_text ( GTK_ENTRY ( window - > userLoginEntry ) ) ;
group_name = ( char * ) gtk_entry_get_text ( GTK_ENTRY ( window - > userLoginEntry ) ) ;
if ( group_name [ 0 ] > ' 0 ' & & group_name [ 0 ] < ' 9 ' ) {
if ( group_name [ 0 ] > ' 0 ' & & group_name [ 0 ] < ' 9 ' ) {
@ -1819,8 +1840,16 @@ void yon_system_load(main_window *window){
void on_system_update ( GtkWidget * , main_window * window ) {
void on_system_update ( GtkWidget * , main_window * window ) {
gtk_list_store_clear ( window - > UsersList ) ;
gtk_list_store_clear ( window - > GroupsList ) ;
if ( main_config . groups_size ) yon_char_parsed_free ( main_config . groups , main_config . groups_size ) ;
if ( main_config . users_size ) yon_char_parsed_free ( main_config . users , main_config . users_size ) ;
if ( main_config . shadow_size ) yon_char_parsed_free ( main_config . shadow , main_config . shadow_size ) ;
if ( main_config . group_shadow_size ) yon_char_parsed_free ( main_config . group_shadow , main_config . group_shadow_size ) ;
main_config . groups = yon_file_open ( groups_path , & main_config . groups_size ) ;
main_config . groups = yon_file_open ( groups_path , & main_config . groups_size ) ;
main_config . users = yon_file_open ( users_path , & main_config . users_size ) ;
main_config . users = yon_file_open ( users_path , & main_config . users_size ) ;
main_config . shadow = yon_file_open ( shadow_path , & main_config . shadow_size ) ;
main_config . group_shadow = yon_file_open ( group_shadow_path , & main_config . group_shadow_size ) ;
int login_size ;
int login_size ;
config_str login_defs = yon_file_open ( uid_path , & login_size ) ;
config_str login_defs = yon_file_open ( uid_path , & login_size ) ;
for ( int i = 0 ; i < login_size ; i + + ) {
for ( int i = 0 ; i < login_size ; i + + ) {
@ -1912,17 +1941,18 @@ void on_UID_update(GtkWidget *, ubl_settings_usergroups_user_window *window){
int parsed_size ;
int parsed_size ;
config_str parsed = yon_char_parse ( final [ i ] , & parsed_size , " : " ) ;
config_str parsed = yon_char_parse ( final [ i ] , & parsed_size , " : " ) ;
if ( atol ( parsed [ 2 ] ) > = main_config . MINUID | | gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > userCreateSystemCheck ) ) ) {
int minimum = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > userCreateUnuniqueCheck ) ) ? 0 : main_config . MINGID ;
if ( atol ( parsed [ 2 ] ) > main_config . MAXUID | | gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > userCreateSystemCheck ) ) )
int maximum = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > userCreateUnuniqueCheck ) ) ? 68000 : main_config . MAXGID ;
break ;
for ( int i = 0 ; i < final_size ; i + + ) {
if ( atol ( parsed [ 2 ] ) = = prev_busy + 1 )
int parsed_size ;
config_str parsed = yon_char_parse ( final [ i ] , & parsed_size , " : " ) ;
if ( minimum < atol ( parsed [ 2 ] ) & & atol ( parsed [ 2 ] ) < maximum ) {
if ( atol ( parsed [ 2 ] ) > prev_busy ) {
prev_busy = atol ( parsed [ 2 ] ) ;
prev_busy = atol ( parsed [ 2 ] ) ;
else {
yon_char_parsed_free ( parsed , parsed_size ) ;
break ;
}
}
}
}
yon_char_parsed_free ( parsed , parsed_size ) ;
}
yon_char_parsed_free ( parsed , parsed_size ) ;
}
}
gtk_entry_set_text ( GTK_ENTRY ( window - > userUIDEntry ) , yon_char_from_long ( prev_busy + 1 ) ) ;
gtk_entry_set_text ( GTK_ENTRY ( window - > userUIDEntry ) , yon_char_from_long ( prev_busy + 1 ) ) ;
}
}
@ -1982,18 +2012,26 @@ void on_user_save(GtkWidget *self, dictionary *dict){
config_str final = yon_char_parsed_merge ( main_config . users , main_config . users_size , config_users , config_size , & final_size ) ;
config_str final = yon_char_parsed_merge ( main_config . users , main_config . users_size , config_users , config_size , & final_size ) ;
uid_string = ( char * ) gtk_entry_get_text ( GTK_ENTRY ( window - > userUIDEntry ) ) ;
uid_string = ( char * ) gtk_entry_get_text ( GTK_ENTRY ( window - > userUIDEntry ) ) ;
if ( ! gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > userCreateUnuniqueCheck ) ) ) {
if ( strcmp ( uid_string , window - > last_uid ) ) {
int found = 0 ;
if ( ! gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( window - > userCreateUnuniqueCheck ) ) ) {
for ( int i = 0 ; i < final_size ; i + + ) {
int found = 0 ;
int parsed_size ;
for ( int i = 0 ; i < final_size ; i + + ) {
config_str parsed = yon_char_parse ( final [ i ] , & parsed_size , " : " ) ;
int parsed_size ;
if ( parsed_size > 1 & & ! strcmp ( parsed [ 2 ] , uid_string ) & & ( ! yon_char_is_empty ( window - > last_uid ) & & strcmp ( parsed [ 2 ] , window - > last_uid ) ) ) found = 1 ;
config_str parsed = yon_char_parse ( final [ i ] , & parsed_size , " : " ) ;
if ( parsed_size ) yon_char_parsed_free ( parsed , parsed_size ) ;
if ( parsed_size > 2 & & ! strcmp ( parsed [ 2 ] , uid_string ) ) {
}
if ( yon_char_is_empty ( window - > last_uid ) | | ( ! yon_char_is_empty ( window - > last_uid ) & & strcmp ( parsed [ 2 ] , window - > last_uid ) ) ) {
if ( found ) {
found = yon_char_parsed_check_exist ( config_users , config_size , final [ i ] ) > - 1 ? 1 : 2 ;
yon_ubl_status_box_spawn ( GTK_CONTAINER ( window - > StatusBox ) , UID_ALREADY_EXIST_LABEL , 5 , BACKGROUND_IMAGE_FAIL_TYPE ) ;
break ;
yon_ubl_status_highlight_incorrect ( window - > userUIDEntry ) ;
}
return ;
}
if ( parsed_size ) yon_char_parsed_free ( parsed , parsed_size ) ;
}
if ( found ) {
yon_ubl_status_box_spawn ( GTK_CONTAINER ( window - > StatusBox ) , found = = 1 ? UID_ALREADY_EXIST_CONFIG_LABEL : UID_ALREADY_EXIST_SYSTEM_LABEL , 5 , BACKGROUND_IMAGE_FAIL_TYPE ) ;
yon_ubl_status_highlight_incorrect ( window - > userUIDEntry ) ;
return ;
}
}
}
}
}
@ -2110,7 +2148,7 @@ void on_user_save(GtkWidget *self, dictionary *dict){
if ( user_shell_active > 0 ) {
if ( user_shell_active > 0 ) {
char * shell_string = ( char * ) gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( window - > userShellCombo ) ) ;
char * shell_string = ( char * ) gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( window - > userShellCombo ) ) ;
if ( strcmp ( shell_string , SET_LABEL ) ) {
if ( strcmp ( shell_string , SET_LABEL ) ) {
user_shell = yon_char_unite ( " --shell " , shell_string , NULL ) ;
user_shell = yon_char_unite ( " --shell " , shell_string , " " , NULL ) ;
} else {
} else {
user_shell = yon_char_unite ( " --shell " , ( char * ) gtk_entry_get_text ( GTK_ENTRY ( window - > userShellEntry ) ) , NULL ) ;
user_shell = yon_char_unite ( " --shell " , ( char * ) gtk_entry_get_text ( GTK_ENTRY ( window - > userShellEntry ) ) , NULL ) ;
}
}
@ -2590,6 +2628,8 @@ void on_main_edit(GtkWidget *, main_window *widgets){
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > userUIDAutoCheck ) , 0 ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > userUIDAutoCheck ) , 0 ) ;
gtk_entry_set_text ( GTK_ENTRY ( window - > userUIDEntry ) , parsed_size > 1 ? parameters [ 1 ] : " " ) ;
gtk_entry_set_text ( GTK_ENTRY ( window - > userUIDEntry ) , parsed_size > 1 ? parameters [ 1 ] : " " ) ;
}
}
if ( ! yon_char_is_empty ( parameters [ 1 ] ) )
window - > last_uid = yon_char_new ( parameters [ 1 ] ) ;
}
}
if ( parsed_size > 2 ) {
if ( parsed_size > 2 ) {
if ( ! strcmp ( parameters [ 2 ] , " x " ) )
if ( ! strcmp ( parameters [ 2 ] , " x " ) )
@ -2597,8 +2637,6 @@ void on_main_edit(GtkWidget *, main_window *widgets){
else {
else {
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > userGroupsCheck ) , 0 ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > userGroupsCheck ) , 0 ) ;
gtk_entry_set_text ( GTK_ENTRY ( window - > userGroupsEntry ) , parsed_size > 2 ? parameters [ 2 ] : " " ) ;
gtk_entry_set_text ( GTK_ENTRY ( window - > userGroupsEntry ) , parsed_size > 2 ? parameters [ 2 ] : " " ) ;
if ( ! yon_char_is_empty ( parameters [ 2 ] ) )
window - > last_uid = yon_char_new ( parameters [ 2 ] ) ;
}
}
}
}
if ( parsed_size > 3 ) {
if ( parsed_size > 3 ) {
@ -2640,12 +2678,28 @@ void on_main_edit(GtkWidget *, main_window *widgets){
}
}
}
}
if ( parsed_size > 5 ) {
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 ;
}
}
window - > old_password = yon_char_new ( parameters [ 5 ] ) ;
window - > old_password = yon_char_new ( parameters [ 5 ] ) ;
if ( strcmp ( parameters [ 5 ] , " x " ) & & strcmp ( parameters [ 5 ] , " " ) ) {
if ( strcmp ( parameters [ 5 ] , " x " ) & & strcmp ( parameters [ 5 ] , " " ) ) {
if ( yon_check_password_blocked ( parameters [ 5 ] ) ) {
if ( yon_check_password_blocked ( parameters [ 5 ] ) ) {
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > userDeactivatedCheck ) , 1 ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( window - > userDeactivatedCheck ) , 1 ) ;
}
}
if ( ! yon_char_is_empty ( parameters [ 5 ] ) ) {
if ( ! yon_char_is_empty ( parameters [ 5 ] ) ) {
if ( check_is_password_hash ( parameters [ 5 ] ) ) {
if ( yon_char_check_begins_with ( parameters [ 5 ] , " %% " ) = = - 1 ) {
char * temp = yon_char_append ( " %% " , parameters [ 5 ] ) ;
free ( parameters [ 5 ] ) ;
parameters [ 5 ] = temp ;
}
gtk_widget_set_sensitive ( window - > userSyncSAMBAPasswordCheck , 0 ) ;
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 ] , " !* " ) ) {
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 ) , 1 ) ;
} else {
} else {
@ -2780,10 +2834,46 @@ void on_main_delete(GtkWidget *, main_window *widgets){
dialog_confirmation_data * data = malloc ( sizeof ( dialog_confirmation_data ) ) ;
dialog_confirmation_data * data = malloc ( sizeof ( dialog_confirmation_data ) ) ;
data - > function = NULL ;
data - > function = NULL ;
data - > data = NULL ;
data - > data = NULL ;
if ( gtk_notebook_get_current_page ( GTK_NOTEBOOK ( widgets - > MainNotebook ) ) = = 0 ) {
int active = gtk_notebook_get_current_page ( GTK_NOTEBOOK ( widgets - > MainNotebook ) ) ;
switch ( active ) {
case 0 :
yon_delete_confirmation_open ( widgets ) ;
yon_delete_confirmation_open ( widgets ) ;
} else {
break ;
case 1 :
yon_group_delete_confirmation_open ( widgets ) ;
yon_group_delete_confirmation_open ( widgets ) ;
break ;
case 2 : {
GtkTreeModel * model = GTK_TREE_MODEL ( widgets - > liststore1 ) ;
GtkTreeIter iter ;
if ( gtk_tree_selection_get_selected ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( widgets - > SystemTree ) ) , & model , & iter ) ) {
char * target ;
gtk_tree_model_get ( model , & iter , 2 , & target , - 1 ) ;
dialog_confirmation_data data ;
int found = ! ! config ( USERADD ( target ) ) ;
if ( found ) {
data . action_text = SYSTEM_USER_CONFIG_REMOVE_CONFIRMATION_LABEL ( target ) ;
data . function = NULL ;
data . data = NULL ;
} else {
data . action_text = SYSTEM_USER_SYSTEM_REMOVE_CONFIRMATION_LABEL ( target ) ;
data . function = NULL ;
data . data = NULL ;
}
if ( yon_confirmation_dialog_call ( widgets - > Window , & data ) ! = GTK_RESPONSE_ACCEPT ) {
return ;
}
if ( found ) {
yon_delete_confirmation_open ( widgets ) ;
} else {
yon_system_delete_confirmation_open ( widgets ) ;
}
}
} break ;
case 3 : {
} break ;
}
}
}
}
@ -2793,14 +2883,14 @@ void on_config_update(GtkWidget *, main_window *widgets){
} else {
} else {
on_config_local_load ( NULL , widgets ) ;
on_config_local_load ( NULL , widgets ) ;
}
}
on_system_update ( NULL , widgets ) ;
// on_system_update(NULL,widgets);
}
}
void on_user_sync_with_config ( GtkWidget * , main_window * widgets ) {
void on_user_sync_with_config ( GtkWidget * , main_window * widgets ) {
int active = gtk_notebook_get_current_page ( GTK_NOTEBOOK ( widgets - > MainNotebook ) ) ;
int active = gtk_notebook_get_current_page ( GTK_NOTEBOOK ( widgets - > MainNotebook ) ) ;
switch ( active ) {
switch ( active ) {
case 2 :
case 2 : {
GtkTreeModel * model = GTK_TREE_MODEL ( widgets - > liststore1 ) ;
GtkTreeModel * model = GTK_TREE_MODEL ( widgets - > liststore1 ) ;
GtkTreeIter iter ;
GtkTreeIter iter ;
if ( gtk_tree_selection_get_selected ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( widgets - > SystemTree ) ) , & model , & iter ) ) {
if ( gtk_tree_selection_get_selected ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( widgets - > SystemTree ) ) , & model , & iter ) ) {
@ -2819,40 +2909,79 @@ void on_user_sync_with_config(GtkWidget *,main_window *widgets){
if ( yon_confirmation_dialog_call ( widgets - > Window , & data ) ! = GTK_RESPONSE_ACCEPT ) {
if ( yon_confirmation_dialog_call ( widgets - > Window , & data ) ! = GTK_RESPONSE_ACCEPT ) {
return ;
return ;
}
}
int size ;
config_str passwd_users = yon_file_open ( users_path , & size ) ;
char * user = yon_char_parsed_check_exist_begins_with ( main_config . groups , main_config . groups_size , target ) ;
int active_usr = yon_char_parsed_strstr ( passwd_users , size , target ) ;
char * shadow = yon_char_parsed_check_exist_begins_with ( main_config . group_shadow , main_config . group_shadow_size , target ) ;
int cur_size ;
yon_char_remove_last_symbol ( user , ' \n ' ) ;
if ( size ) {
yon_char_remove_last_symbol ( shadow , ' \n ' ) ;
yon_char_remove_last_symbol ( passwd_users [ active_usr ] , ' \n ' ) ;
int user_size = 0 ;
config_str cur_user = yon_char_parse ( passwd_users [ active_usr ] , & cur_size , " : " ) ;
int shadow_size = 0 ;
int final_size = 0 ;
config_str parsed = yon_char_parse ( user , & user_size , " : " ) ;
config_str final_user_parsed = NULL ;
config_str parsed_shadow = yon_char_parse ( shadow , & shadow_size , " : " ) ;
yon_char_parsed_add_or_create_if_exists ( final_user_parsed , & final_size , cur_user [ 4 ] ) ;
yon_char_parsed_add_or_create_if_exists ( final_user_parsed , & final_size , cur_user [ 3 ] ) ;
char * optionals = yon_char_unite ( user_size > 5 ? parsed [ 5 ] : " " , user_size > 5 ? " " : " " , user_size > 6 ? parsed [ 6 ] : " " , NULL ) ;
yon_char_parsed_add_or_create_if_exists ( final_user_parsed , & final_size , " x " ) ;
char * config_user = yon_char_unite ( parsed [ 0 ] , " : " ,
char * extra_groups = yon_char_unite ( ! yon_char_is_empty ( cur_user [ 6 ] ) ? " --shell " : " " , ! yon_char_is_empty ( cur_user [ 6 ] ) ? cur_user [ 6 ] : " " , ! yon_char_is_empty ( cur_user [ 6 ] ) ? " " : " " , ! yon_char_is_empty ( cur_user [ 5 ] ) ? " --home-dir " : " " , ! yon_char_is_empty ( cur_user [ 5 ] ) ? cur_user [ 5 ] : " " , NULL ) ;
user_size > 4 ? parsed [ 4 ] : " " , " : " ,
yon_char_parsed_add_or_create_if_exists ( final_user_parsed , & final_size , extra_groups ) ;
user_size > 2 ? parsed [ 2 ] : " " , " : " ,
yon_char_parsed_add_or_create_if_exists ( final_user_parsed , & final_size , cur_user [ 1 ] ) ;
user_size > 3 ? parsed [ 3 ] : " " , " : " ,
char * final_user = yon_char_parsed_to_string ( final_user_parsed , final_size , " : " ) ;
! yon_char_is_empty ( optionals ) ? optionals : " " , " : " ,
if ( config ( USERADD ( target ) ) ) {
user_size > 1 & & strcmp ( parsed [ 1 ] , " x " ) ? yon_char_return_if_exist ( parsed [ 1 ] , " " ) : yon_char_return_if_exist ( parsed_shadow [ 1 ] , " " ) , NULL ) ;
char * final_command = yon_config_parameter_prepare_command ( dull_parameter_get_command , NULL , " users " , USERADD_SYNC ( target ) ) ;
char * config_shadow = yon_char_unite ( yon_char_return_if_exist ( parsed [ 2 ] , " " ) , " : " ,
yon_config_register ( USERADD_SYNC ( target ) , final_command , final_user ) ;
user_size > 3 ? parsed [ 3 ] : " " , " : " ,
user_size > 4 ? parsed [ 4 ] : " " , " : " ,
} else {
user_size > 5 ? parsed [ 5 ] : " " , " : " ,
char * final_command = yon_config_parameter_prepare_command ( dull_parameter_get_command , NULL , " users " , USERADD ( target ) ) ;
user_size > 6 ? parsed [ 6 ] : " " , " : " ,
yon_config_register ( USERADD ( target ) , final_command , final_user ) ;
user_size > 7 ? parsed [ 7 ] : " " , " : " , NULL ) ;
}
if ( ! yon_char_is_empty ( config_user ) ) {
char * user_command = yon_config_parameter_prepare_command ( dull_parameter_get_command , NULL , " users " , USERADD ( target ) ) ;
// int shadow_size;
yon_config_register ( USERADD ( target ) , user_command , config_user ) ;
// config_str shadow = yon_file_open(shadow_path,&shadow_size);
}
}
if ( ! yon_char_is_empty ( config_shadow ) ) {
char * shadow_command = yon_config_parameter_prepare_command ( dull_parameter_get_command , NULL , " users " , USERSHADOW ( target ) ) ;
yon_config_register ( USERSHADOW ( target ) , shadow_command , config_shadow ) ;
}
yon_interface_update ( widgets ) ;
}
}
yon_interface_update ( ( main_window * ) widgets ) ;
yon_interface_update ( ( main_window * ) widgets ) ;
break ;
} break ;
case 3 :
case 3 : {
break ;
GtkTreeModel * model = GTK_TREE_MODEL ( widgets - > liststore1 ) ;
GtkTreeIter iter ;
if ( gtk_tree_selection_get_selected ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( widgets - > SystemGroupsTree ) ) , & model , & iter ) ) {
char * target ;
gtk_tree_model_get ( model , & iter , 1 , & target , - 1 ) ;
dialog_confirmation_data data ;
if ( config ( GROUPADD ( target ) ) ) {
data . action_text = SYSTEM_GROUP_ADD_CONFIRMATION_LABEL ( target ) ;
data . data = NULL ;
data . function = NULL ;
} else {
data . action_text = SYSTEM_GROUP_SYNC_CONFIRMATION_LABEL ( target ) ;
data . data = NULL ;
data . function = NULL ;
}
if ( yon_confirmation_dialog_call ( widgets - > Window , & data ) ! = GTK_RESPONSE_ACCEPT ) {
return ;
}
char * group = yon_char_parsed_check_exist_begins_with ( main_config . groups , main_config . groups_size , target ) ;
char * group_shadow = yon_char_parsed_check_exist_begins_with ( main_config . group_shadow , main_config . group_shadow_size , target ) ;
yon_char_remove_last_symbol ( group , ' \n ' ) ;
yon_char_remove_last_symbol ( group_shadow , ' \n ' ) ;
int group_size = 0 ;
int group_shadow_size = 0 ;
config_str parsed = yon_char_parse ( group , & group_size , " : " ) ;
config_str parsed_shadow = yon_char_parse ( group_shadow , & group_shadow_size , " : " ) ;
char * config_group = yon_char_unite ( parsed [ 0 ] , " : " , parsed [ 3 ] , " : " , parsed [ 2 ] , " :: " , parsed_shadow [ 2 ] , " : " , strcmp ( parsed [ 1 ] , " x " ) ? parsed [ 1 ] : parsed_shadow [ 1 ] , NULL ) ;
if ( ! yon_char_is_empty ( config_group ) ) {
char * group_command = yon_config_parameter_prepare_command ( dull_parameter_get_command , NULL , " users " , GROUPADD ( target ) ) ;
yon_config_register ( GROUPADD ( target ) , group_command , config_group ) ;
yon_interface_update ( widgets ) ;
}
}
} break ;
}
}
}
}
@ -2882,6 +3011,8 @@ void config_init(){
main_config . save_config = 0 ;
main_config . save_config = 0 ;
main_config . groups = yon_file_open ( groups_path , & main_config . groups_size ) ;
main_config . groups = yon_file_open ( groups_path , & main_config . groups_size ) ;
main_config . users = yon_file_open ( users_path , & main_config . users_size ) ;
main_config . users = yon_file_open ( users_path , & main_config . users_size ) ;
main_config . shadow = yon_file_open ( shadow_path , & main_config . shadow_size ) ;
main_config . group_shadow = yon_file_open ( group_shadow_path , & main_config . group_shadow_size ) ;
main_config . users_list = NULL ;
main_config . users_list = NULL ;
main_config . groups_list = NULL ;
main_config . groups_list = NULL ;
main_config . password_min_length = 6 ;
main_config . password_min_length = 6 ;
@ -3076,25 +3207,32 @@ main_window *yon_main_window_complete(main_window *widgets){
yon_root_button_setup ( ( template_main_window * ) widgets , main_config . launch_arguments , main_config . launch_size ) ;
yon_root_button_setup ( ( template_main_window * ) widgets , main_config . launch_arguments , main_config . launch_size ) ;
yon_gtk_tree_view_minimal_fixed_size_set_full ( GTK_TREE_VIEW ( widgets - > UsersTree ) ) ;
yon_gtk_tree_view_minimal_fixed_size_set_full ( GTK_TREE_VIEW ( widgets - > GroupsTree ) ) ;
yon_load_proceed ( YON_CONFIG_LOCAL ) ;
yon_load_proceed ( YON_CONFIG_LOCAL ) ;
yon_interface_update ( ( main_window * ) widgets ) ;
yon_interface_update ( ( main_window * ) widgets ) ;
gtk_widget_realize ( GTK_WIDGET ( widgets - > UsersTree ) ) ;
gtk_widget_realize ( GTK_WIDGET ( widgets - > UsersTree ) ) ;
yon_gtk_tree_view_minimal_fixed_size_set_full ( GTK_TREE_VIEW ( widgets - > UsersTree ) ) ;
gtk_widget_realize ( GTK_WIDGET ( widgets - > GroupsTree ) ) ;
gtk_widget_realize ( GTK_WIDGET ( widgets - > GroupsTree ) ) ;
yon_gtk_tree_view_minimal_fixed_size_set_full ( GTK_TREE_VIEW ( widgets - > GroupsTree ) ) ;
GList * list = gtk_tree_view_get_columns ( GTK_TREE_VIEW ( widgets - > UsersTree ) ) ;
GList * list = gtk_tree_view_get_columns ( GTK_TREE_VIEW ( widgets - > UsersTree ) ) ;
gtk_tree_view_column_set_min_width ( GTK_TREE_VIEW_COLUMN ( g_list_nth_data ( list , 1 ) ) , 50 ) ;
gtk_tree_view_column_set_min_width ( GTK_TREE_VIEW_COLUMN ( g_list_nth_data ( list , 2 ) ) , 175 ) ;
gtk_tree_view_column_set_min_width ( GTK_TREE_VIEW_COLUMN ( g_list_nth_data ( list , 3 ) ) , 175 ) ;
for ( guint i = 0 ; i < g_list_length ( list ) ; i + + ) {
for ( guint i = 0 ; i < g_list_length ( list ) ; i + + ) {
if ( i ! = 1 & & i ! = 2 & & i ! = 3 )
yon_gtk_tree_view_column_minimal_fixed_size_set ( GTK_TREE_VIEW_COLUMN ( g_list_nth_data ( list , i ) ) ) ;
yon_window_config_add_listener ( ( GtkWidget * ) g_list_nth_data ( list , i ) , yon_char_append ( " UserColumn " , yon_char_from_int ( i ) ) , " fixed-width " , YON_TYPE_INT ) ;
yon_window_config_add_listener ( ( GtkWidget * ) g_list_nth_data ( list , i ) , yon_char_append ( " UserColumn " , yon_char_from_int ( i ) ) , " fixed-width " , YON_TYPE_INT ) ;
}
}
g_list_free ( list ) ;
g_list_free ( list ) ;
list = gtk_tree_view_get_columns ( GTK_TREE_VIEW ( widgets - > GroupsTree ) ) ;
list = gtk_tree_view_get_columns ( GTK_TREE_VIEW ( widgets - > GroupsTree ) ) ;
gtk_tree_view_column_set_min_width ( GTK_TREE_VIEW_COLUMN ( g_list_nth_data ( list , 0 ) ) , 50 ) ;
gtk_tree_view_column_set_min_width ( GTK_TREE_VIEW_COLUMN ( g_list_nth_data ( list , 1 ) ) , 175 ) ;
for ( guint i = 0 ; i < g_list_length ( list ) ; i + + ) {
for ( guint i = 0 ; i < g_list_length ( list ) ; i + + ) {
if ( i ! = 0 & & i ! = 1 )
yon_gtk_tree_view_column_minimal_fixed_size_set ( GTK_TREE_VIEW_COLUMN ( g_list_nth_data ( list , i ) ) ) ;
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 ) ;
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 ) ;
g_list_free ( list ) ;
yon_save_window_set_postsave_function ( on_save_done , widgets ) ;
yon_save_window_set_postsave_function ( on_save_done , widgets ) ;
yon_save_window_set_postsave_failure_function ( on_save_failed , widgets ) ;
return widgets ;
return widgets ;
}
}