Merge pull request 'master' (#288) from YanTheKaller/ubl-settings-usergroups:master into master

Reviewed-on: #288
master v2.40
Dmitry Razumov 3 weeks ago
commit 3d548d9d3e

@ -34,7 +34,7 @@ msgid "Default user name (if there's no another):"
msgstr ""
#: source/ubl-strings.h:8
msgid "User with ID 1000 is administrator"
msgid "A user ID of 1000 is an administrator included in the wheel group"
msgstr ""
#: source/ubl-strings.h:9
@ -1039,3 +1039,7 @@ msgstr ""
#: source/ubl-strings.h:302
msgid "MM-DD-YYYY"
msgstr ""
#: source/ubl-strings.h:302
msgid "The selected home directory is used by another user"
msgstr ""

@ -34,8 +34,8 @@ msgid "Default user name (if there's no another):"
msgstr "Имя пользователя по умолчанию (если нет других):"
#: source/ubl-strings.h:8
msgid "User with ID 1000 is administrator"
msgstr "Пользователь с ID 1000 является администратором"
msgid "A user ID of 1000 is an administrator included in the wheel group"
msgstr "Пользователь с ID 1000 является администратором включённым в группу wheel"
#: source/ubl-strings.h:9
msgid "Default user password:"
@ -1119,6 +1119,10 @@ msgstr "ДД/ММ/ГГГГ"
msgid "MM-DD-YYYY"
msgstr "ММ-ДД-ГГГГ"
#: source/ubl-strings.h:302
msgid "The selected home directory is used by another user"
msgstr "Указанный домашний каталог используется другим пользователем"
#~ msgid "User(-s)"
#~ msgstr "Пользователь(-ли)"

@ -31,8 +31,7 @@ ubl_settings_usergroups_group_creation_window *yon_ubl_settings_usergroups_group
gtk_window_set_title(GTK_WINDOW(window->CreateGroupWindow),GROUPS_TITLE_LABEL);
// yon_on_entry_set_allowed_symbols(GTK_ENTRY(window->userGroupsEntry),"abcdefghijklmnopqrstuvwxyz1234567890");
yon_on_entry_set_allowed_symbols(GTK_ENTRY(window->userLoginEntry),"abcdefghijklmnopqrstuvwxyz1234567890");
yon_gtk_entry_block_symbols(GTK_ENTRY(window->userLoginEntry),":\n");
on_GID_update(NULL,window);
dictionary *entry_dict=NULL;
yon_dictionary_add_or_create_if_exists_with_data(entry_dict,"combo",window->PasswordCombo);

@ -133,8 +133,6 @@ ubl_settings_usergroups_password_window *yon_ubl_settings_usergroups_password_ne
window->UserCancelButton=yon_gtk_builder_get_widget(builder,"UserCancelButton");
window->UserOkButton=yon_gtk_builder_get_widget(builder,"UserOkButton");
yon_gtk_entry_allow_password_symbols(GTK_ENTRY(window->PasswordEntry));
yon_gtk_entry_allow_password_symbols(GTK_ENTRY(window->RepeatPasswordEntry));
yon_window_config_custom_window_setup(GTK_WINDOW(window->CreateGroupWindow),"PasswordWindow");
g_signal_connect(G_OBJECT(window->UserCancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
g_signal_connect(G_OBJECT(window->PasswordEntry),"icon-press",G_CALLBACK(on_password_show_hide),NULL);

@ -149,6 +149,37 @@ void on_homedir_changed(GtkComboBox *self, GtkWidget *target){
}
void on_home_changed(GtkWidget *self,ubl_settings_usergroups_user_window *window){
const char *homepath = gtk_entry_get_text(GTK_ENTRY(self));
if (yon_char_is_empty(homepath)) return;
char *home_parameter = yon_char_unite("--home-dir ",homepath,NULL);
int size;
config_str parameters = yon_config_get_all_by_key(USERADD_SEARCH_macro,&size);
for (int i=0;i<size;i++){
int parsed_size;
config_str parsed = yon_char_parse(parameters[i],&parsed_size,":");
if (strstr(parsed[4],home_parameter)){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),HOMEDIR_USED_LABEL,5,BACKGROUND_IMAGE_INFO_TYPE);
yon_ubl_status_highlight_incorrect(window->userHomeEntry);
break;
}
yon_char_parsed_free(parsed,parsed_size);
}
yon_char_parsed_free(parameters,size);
for (int i=0;i<main_config.users_size; i++){
int parsed_size;
config_str parsed = yon_char_parse(main_config.users[i],&parsed_size,":");
if (strstr(parsed[5],homepath)){
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),HOMEDIR_USED_LABEL,5,BACKGROUND_IMAGE_INFO_TYPE);
yon_ubl_status_highlight_incorrect(window->userHomeEntry);
break;
}
yon_char_parsed_free(parsed,parsed_size);
}
free(home_parameter);
}
ubl_settings_usergroups_user_window *yon_ubl_settings_usergroups_user_new(){
ubl_settings_usergroups_user_window *window = malloc(sizeof(ubl_settings_usergroups_user_window));
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_ubl_settings_usergroups_user);
@ -198,8 +229,8 @@ ubl_settings_usergroups_user_window *yon_ubl_settings_usergroups_user_new(){
window->MainNotebook=yon_gtk_builder_get_widget(builder,"MainNotebook");
window->expiration_unix=NULL;
window->last_uid=NULL;
yon_gtk_entry_block_symbols(GTK_ENTRY(window->userUserNameEntry),"\"'[]");
yon_on_entry_set_allowed_symbols(GTK_ENTRY(window->userLoginEntry),"abcdefghijklmnopqrstuvwxyz1234567890");
yon_gtk_entry_block_symbols(GTK_ENTRY(window->userUserNameEntry),":\n");
yon_gtk_entry_block_symbols(GTK_ENTRY(window->userLoginEntry),":\n");
time_t t = time(NULL);
struct tm tm = *localtime(&t);
@ -263,6 +294,7 @@ ubl_settings_usergroups_user_window *yon_ubl_settings_usergroups_user_new(){
g_signal_connect(G_OBJECT(window->userPasswordCombo),"changed",G_CALLBACK(on_toggle_button_set_active_from_combo_box),window);
g_signal_connect(G_OBJECT(window->userPasswordEntry),"changed",G_CALLBACK(on_password_user_changed),window);
g_signal_connect(G_OBJECT(window->userHomeEntry),"changed",G_CALLBACK(on_parameter_changed),window);
g_signal_connect(G_OBJECT(window->userHomeEntry),"changed",G_CALLBACK(on_home_changed),window);
g_signal_connect(G_OBJECT(window->userHomeCombo),"changed",G_CALLBACK(on_parameter_changed),window);
g_signal_connect(G_OBJECT(window->userShellCombo),"changed",G_CALLBACK(on_parameter_changed),window);
g_signal_connect(G_OBJECT(window->userShellEntry),"changed",G_CALLBACK(on_parameter_changed),window);
@ -335,6 +367,7 @@ void on_user_login_update(GtkWidget *, ubl_settings_usergroups_user_window *wind
void on_user_save(GtkWidget *self, dictionary *dict){
main_window *widgets = yon_dictionary_get_data(dict->first,main_window*);
ubl_settings_usergroups_user_window *window = yon_dictionary_get_data(dict->first->next,ubl_settings_usergroups_user_window*);
yon_ubl_status_box_despawn(GTK_CONTAINER(window->StatusBox));
char *final_user="";
char *uid_string = NULL;
char *password = NULL;

@ -89,7 +89,29 @@ void yon_gtk_tree_view_select_first(GtkTreeView *target){
}
}
int yon_config_check_valid(){
int size;
config_str parameters = yon_config_get_all_keys(&size);
int invalid_found = 0;
for (int i=0;i<size;i++){
int open_brackets = yon_char_count(parameters[i],"[");
int close_brackets = yon_char_count(parameters[i],"]");
if (open_brackets!=close_brackets||strstr(parameters[i],"\n")){
yon_config_remove_by_key(parameters[i]);
invalid_found = 1;
}
}
if (invalid_found){
yon_ubl_status_box_render(CONFIG_INVALID_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
return 0;
}
return 1;
}
void yon_interface_update(main_window *widgets){
if (!yon_config_check_valid()) return;
on_system_update(NULL,widgets);
int size;
GtkTreeIter iter;
@ -134,6 +156,17 @@ void yon_interface_update(main_window *widgets){
pars = DEFAULT_USER_LABEL;
}
GdkRGBA rgba = {0};
char *wheel = yon_char_parsed_check_exist_begins_with(main_config.shadow,main_config.shadow_size,"wheel");
int wheel_size;
config_str wheel_parsed = yon_char_parse(wheel,&wheel_size,":");
char *param = config(ADDADM_parameter);
if ((atoi(parameters[1])==1000&&!yon_char_is_empty(param)&&!strcmp(param,"yes"))||yon_char_parsed_check_exist(wheel_parsed,wheel_size,login)>-1){
rgba.red=253.0/255.0;
rgba.green=251.0/255.0;
rgba.blue=216.0/255.0;
rgba.alpha=1;
}
gtk_list_store_set(widgets->UsersList,&iter,
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,
@ -144,6 +177,7 @@ void yon_interface_update(main_window *widgets){
6,parameters_size>4?!strcmp(parameters[4],"x")?"":parameters[4]:"",
7,!yon_char_is_empty(pars)?pars:"",
8,!yon_char_is_empty(tooltip)?tooltip:"",
9,rgba.alpha==1?&rgba:NULL,
-1);
if(parameters)
free(parameters);
@ -582,7 +616,7 @@ void on_config_custom_save(GtkWidget *, main_window *){
void on_saving_settings_save(GtkWidget *self, yon_savasettings_window *window){
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->SambaCheck))){
if (!yon_config_append(SAVE_ROOTCOPY_CHANGES_parameter,"/var/lib/samba",",")){
if (!yon_config_append_element(SAVE_ROOTCOPY_CHANGES_parameter,"/var/lib/samba",",")){
yon_config_register(SAVE_ROOTCOPY_CHANGES_parameter,SAVE_ROOTCOPY_CHANGES_get_command,"/var/lib/samba");
}
} else {
@ -1350,8 +1384,20 @@ void yon_system_load(main_window *window){
}
yon_char_parsed_free(parsed_group,parsed_gr_size);
}
GdkRGBA rgba = {0};
char *wheel = yon_char_parsed_check_exist_begins_with(main_config.shadow,main_config.shadow_size,"wheel");
int wheel_size;
config_str wheel_parsed = yon_char_parse(wheel,&wheel_size,":");
char *param = config(ADDADM_parameter);
if ((atoi(parsed[2])==1000&&!yon_char_is_empty(param)&&!strcmp(param,"yes"))||yon_char_parsed_check_exist(wheel_parsed,wheel_size,parsed[0])>-1){
rgba.red=253.0/255.0;
rgba.green=251.0/255.0;
rgba.blue=216.0/255.0;
rgba.alpha=1;
}
gtk_list_store_append(window->liststore1,&iter);
gtk_list_store_set(window->liststore1,&iter,1,atol(parsed[2]),2,parsed[0],3,parsed[4],4,main_group_name,5,groups_string,6,parsed[5],-1);
gtk_list_store_set(window->liststore1,&iter,1,atol(parsed[2]),2,parsed[0],3,parsed[4],4,main_group_name,5,groups_string,6,parsed[5],14,&rgba,-1);
yon_char_parsed_free(wheel_parsed,wheel_size);
yon_char_parsed_free(parsed,parsed_size);
}
int shadow_size;

@ -625,4 +625,6 @@ char *yon_user_get_system_groups(char *target_login);
int yon_system_group_sync(char *group);
int yon_system_user_sync(char *user);
void on_homedir_changed(GtkComboBox *self, GtkWidget *target);
int yon_config_check_valid();
void on_home_changed(GtkWidget *self,ubl_settings_usergroups_user_window *window);
#endif

@ -5,7 +5,7 @@
#define DEFAULT_USER_GROUPS_LABEL _("Default user groups:")
#define DEFAULT_USER_NAME_LABEL _("Default user name (if there's no another):")
#define USER_1000_IS_ADMIN_LABEL _("User with ID 1000 is administrator")
#define USER_1000_IS_ADMIN_LABEL _("A user ID of 1000 is an administrator included in the wheel group")
#define DEFAULT_USER_PASSWORD_LABEL _("Default user password:")
#define ROOT_USER_PASSWORD_LABEL _("Root user password:")
#define PASSWORD_HASH_ALGORYTHM_LABEL _("Password hash algorythm:")
@ -300,3 +300,5 @@
#define DMY_MINUS_FORMAT_LABEL _("DD-MM-YYYY")
#define DMY_SLASH_FORMAT_LABEL _("DD/MM/YYYY")
#define MDY_FORMAT_LABEL _("MM-DD-YYYY")
#define HOMEDIR_USED_LABEL _("The selected home directory is used by another user")

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<!-- Generated with glade 3.38.2 -->
<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>
<col id="3" translatable="yes"></col>
<col id="2" translatable="yes"/>
<col id="3" translatable="yes"/>
<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>
<col id="3" translatable="yes"></col>
<col id="2" translatable="yes"/>
<col id="3" translatable="yes"/>
<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>
<col id="3" translatable="yes"></col>
<col id="2" translatable="yes"/>
<col id="3" translatable="yes"/>
<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>
<col id="3" translatable="yes"></col>
<col id="2" translatable="yes"/>
<col id="3" translatable="yes"/>
<col id="4">True</col>
<col id="5">True</col>
<col id="6">False</col>
@ -339,7 +339,7 @@
</child>
<child>
<object class="GtkCheckButton" id="DefaultUserAdministratorCheck">
<property name="label" translatable="yes">User with ID 1000 is administrator</property>
<property name="label" translatable="yes"> user ID of 1000 is an administrator included in the wheel group</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>

@ -73,6 +73,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<column type="gchararray"/>
<!-- column-name Tooltip -->
<column type="gchararray"/>
<!-- column-name Color -->
<column type="GdkRGBA"/>
</columns>
</object>
<object class="GtkTreeModelFilter" id="ConfigUsersFilter">
@ -156,6 +158,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<column type="gchararray"/>
<!-- column-name ActivityDays -->
<column type="gchararray"/>
<!-- column-name Color -->
<column type="GdkRGBA"/>
</columns>
</object>
<object class="GtkTreeModelFilter" id="SystemUsersFilter">
@ -472,6 +476,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<child>
<object class="GtkCellRendererPixbuf"/>
<attributes>
<attribute name="cell-background-rgba">9</attribute>
<attribute name="icon-name">0</attribute>
</attributes>
</child>
@ -489,6 +494,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">9</attribute>
<attribute name="text">1</attribute>
</attributes>
</child>
@ -505,6 +511,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">9</attribute>
<attribute name="text">2</attribute>
</attributes>
</child>
@ -522,6 +529,7 @@ name</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">9</attribute>
<attribute name="text">3</attribute>
</attributes>
</child>
@ -539,6 +547,7 @@ group</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">9</attribute>
<attribute name="text">4</attribute>
</attributes>
</child>
@ -559,6 +568,7 @@ groups</property>
<property name="wrap-width">150</property>
</object>
<attributes>
<attribute name="cell-background-rgba">9</attribute>
<attribute name="text">5</attribute>
</attributes>
</child>
@ -579,6 +589,7 @@ parameters</property>
<property name="wrap-width">150</property>
</object>
<attributes>
<attribute name="cell-background-rgba">9</attribute>
<attribute name="text">6</attribute>
</attributes>
</child>
@ -595,6 +606,7 @@ status</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">9</attribute>
<attribute name="text">7</attribute>
</attributes>
</child>
@ -869,6 +881,7 @@ status</property>
<child>
<object class="GtkCellRendererToggle"/>
<attributes>
<attribute name="cell-background-rgba">14</attribute>
<attribute name="active">0</attribute>
</attributes>
</child>
@ -886,6 +899,7 @@ status</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">14</attribute>
<attribute name="text">1</attribute>
</attributes>
</child>
@ -902,6 +916,7 @@ status</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">14</attribute>
<attribute name="text">2</attribute>
</attributes>
</child>
@ -918,6 +933,7 @@ status</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">14</attribute>
<attribute name="text">3</attribute>
</attributes>
</child>
@ -935,6 +951,7 @@ group</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">14</attribute>
<attribute name="text">4</attribute>
</attributes>
</child>
@ -954,6 +971,7 @@ groups</property>
<property name="wrap-width">150</property>
</object>
<attributes>
<attribute name="cell-background-rgba">14</attribute>
<attribute name="text">5</attribute>
</attributes>
</child>
@ -969,6 +987,7 @@ directory</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">14</attribute>
<attribute name="text">6</attribute>
</attributes>
</child>
@ -983,6 +1002,7 @@ path</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">14</attribute>
<attribute name="text">7</attribute>
</attributes>
</child>
@ -997,6 +1017,7 @@ been changed</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">14</attribute>
<attribute name="text">8</attribute>
</attributes>
</child>
@ -1011,6 +1032,7 @@ date</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">14</attribute>
<attribute name="text">9</attribute>
</attributes>
</child>
@ -1025,6 +1047,7 @@ interval (min)</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">14</attribute>
<attribute name="text">10</attribute>
</attributes>
</child>
@ -1039,6 +1062,7 @@ interval (max)</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">14</attribute>
<attribute name="text">11</attribute>
</attributes>
</child>
@ -1053,6 +1077,7 @@ warning</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">14</attribute>
<attribute name="text">12</attribute>
</attributes>
</child>
@ -1067,6 +1092,7 @@ without activity</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="cell-background-rgba">14</attribute>
<attribute name="text">13</attribute>
</attributes>
</child>

Loading…
Cancel
Save