diff --git a/Makefile b/Makefile index ca6fee4..48fa69d 100644 --- a/Makefile +++ b/Makefile @@ -141,6 +141,7 @@ install: check uninstall @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "icons/com.ublinux.${PKGNAME}.profile-settings-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.save-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.lock-symbolic.svg" + @install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/actions/" "icons/com.ublinux.${PKGNAME}.user-add-symbolic.svg" @install -Dm644 -t "${DESTDIR}/usr/share/${PKGNAME}/csv" "csv/hash_list.csv" @install -Dm644 -t "${DESTDIR}/usr/share/${PKGNAME}/csv" "csv/shell_list.csv" @install -Dm644 -t "${DESTDIR}/usr/share/polkit-1/actions/" "${CMAKE_BUILD_DIR}/com.ublinux.${PKGNAME}${PKGIDENT}.policy" diff --git a/icons/com.ublinux.ubl-settings-usergroups.user-add-symbolic.svg b/icons/com.ublinux.ubl-settings-usergroups.user-add-symbolic.svg new file mode 100644 index 0000000..4f4cd53 --- /dev/null +++ b/icons/com.ublinux.ubl-settings-usergroups.user-add-symbolic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/ubl-settings-usergroups.c b/source/ubl-settings-usergroups.c index 3fb453c..8581ae9 100644 --- a/source/ubl-settings-usergroups.c +++ b/source/ubl-settings-usergroups.c @@ -1750,7 +1750,7 @@ ubl_settings_usergroups_password_window *yon_ubl_settings_usergroups_password_ne return window; } -void yon_system_load(ubl_settings_usergroups_system_window *window){ +void yon_system_load(main_window *window){ gtk_list_store_clear(window->liststore1); gtk_list_store_clear(window->liststore2); GtkTreeIter iter; @@ -1758,15 +1758,12 @@ void yon_system_load(ubl_settings_usergroups_system_window *window){ int parsed_size; if (main_config.groups[i][strlen(main_config.groups[i])-1]=='\n') main_config.groups[i][strlen(main_config.groups[i])-1]='\0'; config_str parsed = yon_char_parse(main_config.groups[i],&parsed_size,":"); - if (atoi(parsed[2])>=main_config.MINGID&&atoi(parsed[2])<=main_config.MAXGID||window->show_all==1){ gtk_list_store_append(window->liststore2,&iter); gtk_list_store_set(window->liststore2,&iter,0,atol(parsed[2]),1,parsed[0],2,parsed[3],-1); - } } for (int i=0;i=main_config.MINUID&&atoi(parsed[2])<=main_config.MAXUID)||window->show_all==1){ char *groups_string=""; char *main_group_name=""; for (int j=0;jliststore1,&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); - } yon_char_parsed_free(parsed,parsed_size); } int shadow_size; @@ -1808,18 +1804,18 @@ void yon_system_load(ubl_settings_usergroups_system_window *window){ } } -void on_mode_changed(GtkWidget *self, ubl_settings_usergroups_system_window *window){ - if (window->show_all==0){ - window->show_all=1; - gtk_style_context_add_class(gtk_widget_get_style_context(window->ToggleAllButton),"chosenOutline"); - } else { - window->show_all=0; - gtk_style_context_remove_class(gtk_widget_get_style_context(window->ToggleAllButton),"chosenOutline"); - } - yon_system_load(window); -} +// void on_mode_changed(GtkWidget *self, main_window *window){ +// if (window->show_all==0){ +// window->show_all=1; +// gtk_style_context_add_class(gtk_widget_get_style_context(window->ToggleAllButton),"chosenOutline"); +// } else { +// window->show_all=0; +// gtk_style_context_remove_class(gtk_widget_get_style_context(window->ToggleAllButton),"chosenOutline"); +// } +// yon_system_load(window); +// } -void on_system_update(GtkWidget *self, ubl_settings_usergroups_system_window *window){ +void on_system_update(GtkWidget *self, main_window *window){ main_config.groups = yon_file_open(groups_path,&main_config.groups_size); main_config.users = yon_file_open(users_path,&main_config.users_size); @@ -1870,10 +1866,8 @@ ubl_settings_usergroups_system_window *yon_ubl_settings_usergroups_system_new(){ g_list_free(list); gtk_window_set_title(GTK_WINDOW(window->MonitorWindow),INSPECTOR_TITLE_LABEL); - g_signal_connect(G_OBJECT(window->ToggleAllButton),"clicked",G_CALLBACK(on_mode_changed),window); + // g_signal_connect(G_OBJECT(window->ToggleAllButton),"clicked",G_CALLBACK(on_mode_changed),window); g_signal_connect(G_OBJECT(window->UpdateButton),"clicked",G_CALLBACK(on_system_update),window); - yon_system_load(window); - on_system_update(NULL,window); return window; } @@ -2809,6 +2803,37 @@ void on_config_update(GtkWidget *self, main_window *widgets){ } else { on_config_local_load(NULL,widgets); } + on_system_update(NULL,widgets); + +} + +void on_user_sync_with_config(GtkWidget *,main_window *widgets){ + int active = gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->MainNotebook)); + switch (active){ + 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); + int size; + config_str passwd_users = yon_config_load(user_shadow_path,&size); + int active_usr = yon_char_parsed_strstr(passwd_users,size,target); + int cur_size; + if (size>-1){ + config_str cur_user = yon_char_parse(passwd_users[active_usr],&cur_size,":"); + char *final_user = yon_char_unite(cur_user[4],":",cur_user[5],":",cur_size>1?cur_user[1]:"",":",cur_size>2?cur_user[2]:"",":",cur_user[0],":",":",NULL); + char *final_command = yon_config_parameter_prepare_command(dull_parameter_get_command,NULL,"users",USERADD_SYNC(target)); + yon_config_register(USERADD(target),final_command,final_user); + + int shadow_size; + config_str shadow = yon_config_load(shadow_path,&shadow_size); + } + } + break; + case 3: + break; + } } int *yon_element_chosen(GtkWidget *target){ @@ -2923,13 +2948,16 @@ void on_notebook_page_changed(GtkWidget *self, GtkWidget *page, int num, main_wi } else { gtk_widget_set_sensitive(widgets->EditButton,0); } - } else { + } else if (num==1){ GtkTreeModel *model = GTK_TREE_MODEL(widgets->GroupsList); if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->GroupsTree)),&model,&iter)){ gtk_widget_set_sensitive(widgets->EditButton,1); } else { gtk_widget_set_sensitive(widgets->EditButton,0); } + } else if (num==2){ + gtk_widget_hide(widgets->AddButton); + gtk_widget_hide(widgets->EditButton); } } @@ -2965,8 +2993,12 @@ main_window *yon_main_window_complete(main_window *widgets){ widgets->CacheAlgList=GTK_LIST_STORE(gtk_builder_get_object(builder,"CacheAlgList")); widgets->GroupsList=GTK_LIST_STORE(gtk_builder_get_object(builder,"GroupsList")); widgets->UsersList=GTK_LIST_STORE(gtk_builder_get_object(builder,"UsersList")); + widgets->liststore1=GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); + widgets->liststore2=GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore2")); widgets->PlugBox=yon_gtk_builder_get_widget(builder,"PlugBox"); - widgets->button1=yon_gtk_builder_get_widget(builder,"button1"); + widgets->UserAddToConfigButton=yon_gtk_builder_get_widget(builder,"UserAddToConfigButton"); + widgets->SystemTree=yon_gtk_builder_get_widget(builder,"SystemTree"); + widgets->SystemGroupsTree=yon_gtk_builder_get_widget(builder,"SystemGroupsTree"); widgets->button2=yon_gtk_builder_get_widget(builder,"button2"); widgets->button3=yon_gtk_builder_get_widget(builder,"button3"); widgets->AddButton=yon_gtk_builder_get_widget(builder,"AddButton"); @@ -2988,7 +3020,7 @@ main_window *yon_main_window_complete(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->DeleteButton),"clicked",G_CALLBACK(on_main_delete),widgets); g_signal_connect(G_OBJECT(widgets->button3),"clicked",G_CALLBACK(on_standard_groups_open),widgets); g_signal_connect(G_OBJECT(widgets->button2),"clicked",G_CALLBACK(on_ubl_settings_usergroups_additional_settings_open),widgets); - g_signal_connect(G_OBJECT(widgets->button1),"clicked",G_CALLBACK(on_settings_usergroups_system_open),widgets); + // g_signal_connect(G_OBJECT(widgets->UserAddToConfigButton),"clicked",G_CALLBACK(on_user_sync_with_config),widgets); g_signal_connect(G_OBJECT(widgets->UpdateButton),"clicked",G_CALLBACK(on_config_update),widgets); g_signal_connect(G_OBJECT(widgets->SavingSettingsButton),"clicked",G_CALLBACK(on_saving_settings_open),widgets); g_signal_connect(G_OBJECT(widgets->SaveMenuItem),"activate",G_CALLBACK(on_config_save),widgets); @@ -3010,6 +3042,9 @@ main_window *yon_main_window_complete(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->UsersTree),"button-press-event",G_CALLBACK(on_menu_open),widgets->UsersMenu); g_signal_connect(G_OBJECT(widgets->GroupsTree),"button-press-event",G_CALLBACK(on_menu_open),widgets->GroupsMenu); + yon_system_load(widgets); + on_system_update(NULL,widgets); + 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)); diff --git a/source/ubl-settings-usergroups.h b/source/ubl-settings-usergroups.h index 4959afc..a83a186 100644 --- a/source/ubl-settings-usergroups.h +++ b/source/ubl-settings-usergroups.h @@ -52,9 +52,11 @@ #define shadow_path "/etc/shadow" #define uid_path "/etc/login.defs" #define password_limits_path "/etc/security/pwquiality.conf" +#define get_user_info_command(target) yon_char_unite("getent passwd \"",target,"\"",NULL) #define get_home_command(target) yon_char_unite("getent passwd \"",target,"\" | cut -d: -f6",NULL) #define remove_home_dirs_command(users_string) yon_char_append("/usr/lib/ublinux/functions remove_userhome ", users_string) #define default_home_initiator_path "/etc/default/useradd" +#define user_shadow_path "/etc/shadow" #define hash_list_path "/usr/share/ubl-settings-usergroups/csv/hash_list.csv" #define shell_list_path "/usr/share/ubl-settings-usergroups/csv/shell_list.csv" @@ -168,7 +170,9 @@ typedef struct { GtkListStore *CacheAlgList; GtkListStore *GroupsList; GtkListStore *UsersList; - GtkWidget *button1; + GtkWidget *UserAddToConfigButton; + GtkWidget *SystemTree; + GtkWidget *SystemGroupsTree; GtkWidget *button2; GtkWidget *button3; GtkWidget *AddButton; @@ -182,6 +186,8 @@ typedef struct { rmb_menu_window *UsersMenu; rmb_menu_window *GroupsMenu; + GtkListStore *liststore1; + GtkListStore *liststore2; } main_window; diff --git a/ubl-settings-usergroups.glade b/ubl-settings-usergroups.glade index f201788..601c58c 100644 --- a/ubl-settings-usergroups.glade +++ b/ubl-settings-usergroups.glade @@ -80,11 +80,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False com.ublinux.ubl-settings-usergroups.profile-settings-symbolic - - True - False - com.ublinux.ubl-settings-usergroups.settings-symbolic - True False @@ -105,6 +100,53 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False com.ublinux.ubl-settings-usergroups.save-symbolic + + True + False + com.ublinux.ubl-settings-usergroups.user-add-symbolic + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True False @@ -118,23 +160,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 2 vertical 5 - - - True - True - True - Inspect users and groups in system - image12 - - - - False - True - 0 - - True @@ -191,6 +216,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 4 + + + True + True + Additional saving configuration + image5 + + + + False + True + 5 + + True @@ -205,7 +246,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True - 5 + 6 @@ -223,7 +264,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True - 6 + 7 @@ -240,7 +281,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True - 7 + 8 @@ -257,7 +298,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True - 8 + 9 @@ -268,7 +309,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True - 9 + 10 @@ -285,7 +326,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True - 10 + 11 @@ -477,7 +518,7 @@ status True False - Users + Configuration users False @@ -605,13 +646,337 @@ status True False - Groups + Configuration groups 1 False + + + True + True + + + True + True + liststore1 + 0 + both + + + + + + True + fixed + 50 + Locked + + + + 0 + + + + + + + True + fixed + 50 + UID + True + 1 + + + + 1 + + + + + + + True + fixed + 50 + Login + True + 2 + + + + 2 + + + + + + + True + fixed + 50 + Username + True + 3 + + + + 3 + + + + + + + True + fixed + 50 + Primary +group + True + 4 + + + + 4 + + + + + + + True + fixed + 50 + Additional +groups + True + 5 + + + 150 + + + 5 + + + + + + + 50 + Home +directory + True + 6 + + + + 6 + + + + + + + Shell +path + True + 7 + + + + 7 + + + + + + + Password has +been changed + True + 8 + + + + 8 + + + + + + + Expiration +date + True + 9 + + + + 9 + + + + + + + Password change +interval (min) + True + 10 + + + + 10 + + + + + + + Password change +interval (max) + True + 11 + + + + 11 + + + + + + + Days until +warning + True + 12 + + + + 12 + + + + + + + Days +without activity + True + 13 + + + + 13 + + + + + + + + + 2 + + + + + True + False + System users + + + 2 + False + + + + + True + True + + + True + True + liststore2 + 0 + both + + + + + + True + fixed + 50 + GID + True + 0 + + + + 0 + + + + + + + True + fixed + 50 + Group + True + 1 + + + 150 + + + 1 + + + + + + + 50 + Group +users + True + 2 + + + + 2 + + + + + + + + + 3 + + + + + True + False + System groups + + + 3 + False + + True