Test fix for add . at password beginning

pull/160/head
parent 1a2e092588
commit 494c6feca4

@ -104,6 +104,8 @@ void yon_interface_update(main_window *widgets){
if (!check_is_password_hash(parameters[5])&&parameters[5][0]!='%'&&parameters[5][1]!='%'){ if (!check_is_password_hash(parameters[5])&&parameters[5][0]!='%'&&parameters[5][1]!='%'){
pars = ENCRYPTED_LABEL; pars = ENCRYPTED_LABEL;
} else if (!strcmp(parameters[5],"!*")){
pars = NO_PASSWORD_LABEL;
} else { } else {
pars = UNENCRYPTED_LABEL; pars = UNENCRYPTED_LABEL;
@ -113,7 +115,7 @@ void yon_interface_update(main_window *widgets){
} }
gtk_list_store_set(widgets->UsersList,&iter, gtk_list_store_set(widgets->UsersList,&iter,
0,parameters[5][0]=='!'||parameters[5][0]=='*', 0,(parameters[5][0]=='!'||parameters[5][0]=='*')||(parameters[5][0]=='!'&&parameters[5][1]=='*'),
2,login, 2,login,
3,parameters_size>0?parameters[0]:"", 3,parameters_size>0?parameters[0]:"",
1,parameters_size>1&&!yon_char_is_empty(parameters[1])?parameters[1]:"", 1,parameters_size>1&&!yon_char_is_empty(parameters[1])?parameters[1]:"",
@ -394,6 +396,19 @@ void on_save_done(main_window *widgets, config_str output, int size){
yon_accept_changes(); yon_accept_changes();
yon_samba_sync_proceed(); yon_samba_sync_proceed();
} }
textdomain(template_ui_LocaleName);
switch (main_config.save_config){
case 0:
yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
break;
case 1:
yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
break;
case 2:
yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
break;
}
textdomain(LocaleName);
} }
@ -401,6 +416,7 @@ void on_save_done(main_window *widgets, config_str output, int size){
void on_config_save(GtkWidget *self, main_window *widgets){ void on_config_save(GtkWidget *self, main_window *widgets){
yon_accept_changes(); yon_accept_changes();
yon_samba_sync_proceed(); yon_samba_sync_proceed();
main_config.save_config=2;
template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_command("global"),NULL); template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_command("global"),NULL);
if (window){ if (window){
if (main_config.load_mode==0){ if (main_config.load_mode==0){
@ -459,6 +475,7 @@ void on_config_save(GtkWidget *self, main_window *widgets){
} }
void on_config_global_save(GtkWidget *self, main_window *widgets){ void on_config_global_save(GtkWidget *self, main_window *widgets){
main_config.save_config=0;
template_saving_window *window = yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_command("global"),NULL); template_saving_window *window = yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_command("global"),NULL);
if (window){ if (window){
yon_hide_passwords(window); yon_hide_passwords(window);
@ -466,6 +483,7 @@ void on_config_global_save(GtkWidget *self, main_window *widgets){
} }
void on_config_local_save(GtkWidget *self, main_window *widgets){ void on_config_local_save(GtkWidget *self, main_window *widgets){
main_config.save_config=1;
int size; int size;
config_str keys = yon_config_get_all_by_key(USERADD_SEARCH_macro,&size); config_str keys = yon_config_get_all_by_key(USERADD_SEARCH_macro,&size);
int passw_size; int passw_size;
@ -489,8 +507,6 @@ void on_config_local_save(GtkWidget *self, main_window *widgets){
} }
yon_accept_changes(); yon_accept_changes();
yon_samba_sync_proceed(); yon_samba_sync_proceed();
// char *output = yon_config_save_simple(YON_CONFIG_LOCAL,"system");
// if (output) puts(output);
template_saving_window *window = yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_command("system"),NULL); template_saving_window *window = yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_command("system"),NULL);
if (window){ if (window){
yon_hide_passwords(window); yon_hide_passwords(window);
@ -503,6 +519,7 @@ void on_config_local_save(GtkWidget *self, main_window *widgets){
} }
void on_config_custom_save(GtkWidget *self, main_window *widgets){ void on_config_custom_save(GtkWidget *self, main_window *widgets){
main_config.save_config=1;
template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_command("system"),NULL); template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_command("system"),NULL);
if (window){ if (window){
yon_hide_passwords(window); yon_hide_passwords(window);
@ -659,6 +676,25 @@ void yon_group_delete_confirmation_save(GtkWidget *self, dictionary *dict){
on_subwindow_close(self); on_subwindow_close(self);
} }
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]=='*'){
char *copy = yon_char_new(password);
memcpy(copy,password+2,strlen(password+2));
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;
}
} else return 0;
}
yon_confirmation_window *yon_delete_confirmation_new(){ yon_confirmation_window *yon_delete_confirmation_new(){
yon_confirmation_window *window = malloc(sizeof(yon_confirmation_window)); yon_confirmation_window *window = malloc(sizeof(yon_confirmation_window));
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_ubl_settings_usergroups_confirmation); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_ubl_settings_usergroups_confirmation);
@ -1883,6 +1919,8 @@ void on_user_save(GtkWidget *self, dictionary *dict){
yon_ubl_status_highlight_incorrect(window->userPasswordEntry); yon_ubl_status_highlight_incorrect(window->userPasswordEntry);
return; return;
} }
} else if (password_active==1){
password = "!*";
} else { } else {
password=""; password="";
} }
@ -1890,7 +1928,7 @@ void on_user_save(GtkWidget *self, dictionary *dict){
char *old_password = NULL; char *old_password = NULL;
if (window->old_password){ if (window->old_password){
old_password = window->old_password; old_password = window->old_password;
if (old_password[0]=='!'||old_password[0]=='*') free(yon_char_divide(old_password,0)); yon_check_password_blocked(old_password);
} }
if (!old_password||old_password&&strcmp(old_password,password)){ if (!old_password||old_password&&strcmp(old_password,password)){
time_t t = time(NULL); time_t t = time(NULL);
@ -2494,21 +2532,20 @@ void on_main_edit(GtkWidget *self, main_window *widgets){
} }
if (parsed_size>5){ if (parsed_size>5){
window->old_password=yon_char_new(parameters[5]); window->old_password=yon_char_new(parameters[5]);
if (!yon_char_is_empty(window->old_password)&&strlen(window->old_password)&&window->old_password[0]=='!'&&window->old_password[1]=='*'){
free(yon_char_divide(window->old_password,1));
}
if (!strcmp(parameters[5],"!*")) parameters[5][1]='\0';
if (strcmp(parameters[5],"x")&&strcmp(parameters[5],"")){ if (strcmp(parameters[5],"x")&&strcmp(parameters[5],"")){
if (parameters[5][0]=='!'||parameters[5][0]=='*'){ 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);
} }
free(yon_char_divide(parameters[5],0));
if (!yon_char_is_empty(parameters[5])){ if (!yon_char_is_empty(parameters[5])){
if (!strcmp(parameters[5],"!*")){
gtk_combo_box_set_active(GTK_COMBO_BOX(window->userPasswordCombo),1);
} else {
gtk_entry_set_text(GTK_ENTRY(window->userPasswordEntry),parameters[5]); 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),2);
} }
} }
} }
}
int samba_sync = yon_samba_sync_get(name); int samba_sync = yon_samba_sync_get(name);
if (samba_sync==1){ if (samba_sync==1){
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->userSyncSAMBACheck),1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->userSyncSAMBACheck),1);
@ -2674,6 +2711,7 @@ void config_init(){
main_config.users_size=0; main_config.users_size=0;
main_config.load_mode=1; main_config.load_mode=1;
main_config.hash_default_id=-1; main_config.hash_default_id=-1;
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.users_list=NULL; main_config.users_list=NULL;

@ -130,6 +130,7 @@ typedef struct {
config_str remove_homes; config_str remove_homes;
int homes_size; int homes_size;
char *default_home; char *default_home;
int save_config;
} config; } config;
typedef struct { typedef struct {

Loading…
Cancel
Save