Changed user password saving and loading; default password and root password changes

pull/247/head
parent b84bc5812a
commit 5e13f75f1d

@ -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;

@ -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))

@ -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);
}

@ -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]=='!'&&parameters[5][1]=='*'):0,
0,parameters_size>5?(parameters[5][0]=='!'&&parameters[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);

@ -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"

@ -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)")," <b>\"",depends,"\"</b> ",_("is included into main group of users")," <b>\"",target,"\"</b>, ",_("which will be deleted"),".\n",_("After reboot users")," <b>",depends,"</b> ",_("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")

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<!-- Generated with glade 3.40.0 -->
<interface domain="ubl-settings-usergroups">
<requires lib="gtk+" version="3.24"/>
<!-- interface-css-provider-path ubl-settings-usergroups.css -->
@ -76,8 +76,8 @@
<row>
<col id="0">False</col>
<col id="1" translatable="yes">Group GID range</col>
<col id="2" translatable="yes"/>
<col id="3" translatable="yes"/>
<col id="2" translatable="yes"></col>
<col id="3" translatable="yes"></col>
<col id="4">True</col>
<col id="5">True</col>
<col id="6">False</col>
@ -90,8 +90,8 @@
<row>
<col id="0">False</col>
<col id="1" translatable="yes">Group GID in system</col>
<col id="2" translatable="yes"/>
<col id="3" translatable="yes"/>
<col id="2" translatable="yes"></col>
<col id="3" translatable="yes"></col>
<col id="4">True</col>
<col id="5">True</col>
<col id="6">False</col>
@ -176,8 +176,8 @@
<row>
<col id="0">False</col>
<col id="1" translatable="yes">Users UID range</col>
<col id="2" translatable="yes"/>
<col id="3" translatable="yes"/>
<col id="2" translatable="yes"></col>
<col id="3" translatable="yes"></col>
<col id="4">True</col>
<col id="5">True</col>
<col id="6">False</col>
@ -190,8 +190,8 @@
<row>
<col id="0">False</col>
<col id="1" translatable="yes">User UID in system</col>
<col id="2" translatable="yes"/>
<col id="3" translatable="yes"/>
<col id="2" translatable="yes"></col>
<col id="3" translatable="yes"></col>
<col id="4">True</col>
<col id="5">True</col>
<col id="6">False</col>
@ -461,6 +461,7 @@
<item translatable="yes">Default</item>
<item translatable="yes">No password required</item>
<item translatable="yes">Set a password</item>
<item translatable="yes">Deny login</item>
</items>
</object>
<packing>

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<!-- Generated with glade 3.40.0 -->
<interface domain="ubl-settings-usergroups">
<requires lib="gtk+" version="3.24"/>
<!-- interface-css-provider-path ubl-settings-usergroups.css -->
@ -237,6 +237,9 @@
<item translatable="yes">Default</item>
<item translatable="yes">No password required</item>
<item translatable="yes">Set a password</item>
<item translatable="yes">Deny login</item>
<item translatable="yes">Block login with password</item>
<item translatable="yes">Unblock login with password</item>
</items>
</object>
<packing>

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2
<!-- Generated with glade 3.40.0
ubl-settings-usergroups -
Copyright (C) UBGroup
@ -47,8 +47,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
</object>
<object class="GtkListStore" id="UsersList">
<columns>
<!-- column-name Block -->
<column type="gboolean"/>
<!-- column-name BlockStatusImage -->
<column type="gchararray"/>
<!-- column-name UID -->
<column type="gchararray"/>
<!-- column-name Login -->
@ -363,9 +363,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<property name="title" translatable="yes">Locked</property>
<property name="sort-column-id">0</property>
<child>
<object class="GtkCellRendererToggle"/>
<object class="GtkCellRendererPixbuf"/>
<attributes>
<attribute name="active">0</attribute>
<attribute name="icon-name">0</attribute>
</attributes>
</child>
</object>

@ -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 ""

@ -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 ""
"Часть пользователей выбранных на удаление используются как основные группы "
"других пользователей. После перезагрузки эти пользователи получат основную "
"группу по умолчанию"

Loading…
Cancel
Save