Password changes

pull/83/head
parent 9443a71ccd
commit 934629ddea

@ -32,44 +32,41 @@ void on_password_accept(GtkWidget *self, dictionary *dict){
yon_password_window *window = yon_dictionary_get_data(dict->first,yon_password_window*);
GtkEntry *entry = yon_dictionary_get_data(dict->first->next,GtkEntry*);
char *password = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry));
char *password_check = (char*)gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry));
if (yon_char_is_empty(password)){
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->NoEncriptionCheck))){
char *pasted_hash = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordHashEntry));
if (!yon_char_is_empty(pasted_hash)){
gtk_entry_set_text(entry,pasted_hash);
} else {
if (yon_char_is_empty(pasted_hash)){
yon_ubl_status_highlight_incorrect(window->PasswordEntry);
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),PASSWORD_SHORT_LABEL(yon_char_from_int(main_config.password_min_length)),5,BACKGROUND_IMAGE_FAIL_TYPE);
return;
}
gtk_entry_set_text(entry,pasted_hash);
} else {
char *password_check = (char*)gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry));
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);
return;
}
for (size_t i=0;i<strlen(password);i++){
if (password[i]=='!'||password[i]=='@'||password[i]=='#'||password[i]=='%'||password[i]=='^'||password[i]=='&'||password[i]=='*'||password[i]=='\"'||password[i]=='\''){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),RESTRICTED_SYMBOLS_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
return;
}
}
if (yon_char_is_empty(password)){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
return;
} else if (password[0]=='%'&&password[1]=='%'){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
return;
}
if ((glong)strlen(password)<main_config.password_min_length){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),PASSWORD_SHORT_LABEL(yon_char_from_int(main_config.password_min_length)),5,BACKGROUND_IMAGE_FAIL_TYPE);
yon_ubl_status_highlight_incorrect(window->PasswordEntry);
return;
}
if (!strcmp(password,password_check)){
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->NoEncriptionCheck))){
char *pasw=yon_char_append("%%",password);
password=pasw;
}
gtk_entry_set_text(GTK_ENTRY(entry),password);
} else {
if (strcmp(password,password_check)){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),PASSWORD_MISMATCH_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
yon_ubl_status_highlight_incorrect(window->PasswordEntry);
yon_ubl_status_highlight_incorrect(window->RepeatPasswordEntry);
return;
}
gtk_entry_set_text(GTK_ENTRY(entry),password);
}
on_subwindow_close(self);
}
@ -93,6 +90,8 @@ yon_password_window *yon_ubl_settings_usergroups_password_new(){
yon_window_config_custom_window_setup(GTK_WINDOW(window->Window),"PasswordWindow");
g_signal_connect(G_OBJECT(window->UserCancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
g_signal_connect(G_OBJECT(window->NoEncriptionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),window->PasswordHashEntry);
g_signal_connect(G_OBJECT(window->NoEncriptionCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),window->PasswordBox);
yon_gtk_entry_set_password_visibility_icon(GTK_ENTRY(window->PasswordEntry));
yon_gtk_entry_set_password_visibility_icon(GTK_ENTRY(window->RepeatPasswordEntry));
yon_gtk_entry_set_password_visibility_icon(GTK_ENTRY(window->PasswordHashEntry));

@ -27,27 +27,54 @@ void on_save_done(main_window *, config_str output, int size){
}
void yon_save_window_hide_passwords(template_saving_window *window){
GtkTreeIter iter;
for_iter(GTK_TREE_MODEL(window->list),&iter){
char *target, *old_val, *new_val;
gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,YON_SAVE_PARAMETER,&target,YON_SAVE_OLD,&old_val,YON_SAVE_NEW,&new_val,-1);
if (strstr(target,GRUB_PASSWORD_search)){
if (!yon_char_is_empty(old_val)) old_val="<s>******</s>"; else old_val="";
if (!yon_char_is_empty(new_val)) new_val="******"; else new_val="";
char *united = yon_char_unite(old_val,"\n",new_val,NULL);
gtk_list_store_set(window->list,&iter,YON_SAVE_COMPARE,united,-1);
free(united);
}
}
}
void on_config_global_local_save(GtkWidget *, main_window *){
main_config.save_config=3;
yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_global_command,NULL);
template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_global_command,NULL);
if (window){
yon_save_window_hide_passwords(window);
};
}
void on_config_local_save(GtkWidget *, main_window *){
main_config.save_config=1;
yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_local_command,NULL);
template_saving_window *window = yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_local_command,NULL);
if (window){
yon_save_window_hide_passwords(window);
};
}
void on_config_global_save(GtkWidget *, main_window *){
main_config.save_config=0;
yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_global_command,NULL);
template_saving_window *window = yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_global_command,NULL);
if (window){
yon_save_window_hide_passwords(window);
};
}
void on_config_custom_save(GtkWidget *, main_window *){
main_config.save_config=1;
template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,yon_config_get_custom_command("system"),NULL);
if (window){};
if (window){
yon_save_window_hide_passwords(window);
};
}
void on_config_local_load(GtkWidget *,main_window *widgets){

@ -272,3 +272,4 @@ void on_menu_chosen(GtkWidget *, yon_menu_item *item);
void on_submenu_open(GtkWidget *,yon_menu_item *item);
void on_children_clean(GtkWidget*, yon_menu_window *window);
gboolean yon_on_revealer_switched (yon_menu_window *window);
void yon_save_window_hide_passwords(template_saving_window *window);

@ -165,31 +165,25 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="NoEncriptionCheck">
<property name="label" translatable="yes">Do not encrypt password</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">5</property>
<child>
<object class="GtkLabel" id="label1">
<object class="GtkCheckButton" id="NoEncriptionCheck">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Password hash:</property>
<property name="xalign">0</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Password hash:</property>
<property name="xalign">0</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -200,6 +194,7 @@
<child>
<object class="GtkEntry" id="PasswordHashEntry">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">True</property>
<property name="visibility">False</property>
<property name="invisible-char">*</property>

Loading…
Cancel
Save