From 698cf77eda026c6cc0540845727bca67b813ff82 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Thu, 18 Apr 2024 19:06:15 +0600 Subject: [PATCH] Domain window added, 50%~ is unconfigured --- auth_profile.csv | 25 ++ gresource.xml | 3 + source/CMakeLists.txt | 3 + source/ubl-settings-system.c | 110 +++++ source/ubl-settings-system.h | 61 ++- source/ubl-strings.h | 4 +- ubl-settings-system-connection.glade | 555 ++++++++++++++++++++++++++ ubl-settings-system-domain-view.glade | 72 ++++ ubl-settings-system-domain.glade | 255 ++++++++++++ ubl-settings-system.glade | 59 ++- 10 files changed, 1144 insertions(+), 3 deletions(-) create mode 100644 auth_profile.csv create mode 100644 ubl-settings-system-connection.glade create mode 100644 ubl-settings-system-domain-view.glade create mode 100644 ubl-settings-system-domain.glade diff --git a/auth_profile.csv b/auth_profile.csv new file mode 100644 index 0000000..a306bf0 --- /dev/null +++ b/auth_profile.csv @@ -0,0 +1,25 @@ +AUTH_NAME +wth-altfiles +with-ecryptfs +with-faillock +with-files-access-provider +with-files-domain +with-pamaccess +with-silent-lastlog +with-sudo +with-systemd-homed +with-time +without-nullok +with-fingerprint +with-pam-u2f +with-pam-u2f-2fa +without-nullok +without-pam-u2f-nouserok +with-smartcard +with-smartcard-lock-on-removal +with-smartcard-required +with-mdns4 +with-mdns6 +with-mkhomedir +with-mkhomedir-simple +with-nispwquality diff --git a/gresource.xml b/gresource.xml index a172326..4038613 100644 --- a/gresource.xml +++ b/gresource.xml @@ -3,6 +3,9 @@ ubl-settings-system.glade ubl-settings-system-layouts.glade + ubl-settings-system-domain.glade + ubl-settings-system-connection.glade + ubl-settings-system-domain-view.glade ubl-settings-system.css diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index f969a33..ed45a17 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -30,6 +30,9 @@ add_custom_target(GLADE ubl-settings-system.glade) set(DEPENDFILES ../ubl-settings-system.glade + ../ubl-settings-system-domain.glade + ../ubl-settings-system-connection.glade + ../ubl-settings-system-domain-view.glade ../ubl-settings-system-layouts.glade ../gresource.xml ../ubl-settings-system-banner.png diff --git a/source/ubl-settings-system.c b/source/ubl-settings-system.c index d3811a6..78fb3ab 100644 --- a/source/ubl-settings-system.c +++ b/source/ubl-settings-system.c @@ -438,6 +438,110 @@ void on_language_changed(GtkComboBox *self, main_window *widgets){ } } +domain_info_window *yon_information_window_new(){ + GtkBuilder *builder = gtk_builder_new_from_resource(glade_domain_view_path); + + domain_info_window *window = malloc(sizeof(domain_info_window)); + window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->DomainOutputLabel = yon_gtk_builder_get_widget(builder,"DomainOutputLabel"); + + return window; +} + +void on_domain_connect(GtkWidget *self, connection_window *window){ + char *adress = (char*)gtk_entry_get_text(GTK_ENTRY(window->AdressEntry)); + if (yon_char_is_empty(adress)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->AdressEntry); + return; + } + char *login = (char*)gtk_entry_get_text(GTK_ENTRY(window->LoginEntry)); + char *password = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); + char *kerberos = (char*)gtk_entry_get_text(GTK_ENTRY(window->KerberosServerEntry)); + char *dns = (char*)gtk_entry_get_text(GTK_ENTRY(window->DNSEntry)); + char *client = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(window->ClientCombo)); + char *final = yon_char_unite(!yon_char_is_empty(kerberos)?kerberos_addition_command(kerberos):"",!yon_char_is_empty(kerberos)?" ":"",!yon_char_is_empty(dns)?dns_addition_command(dns):"",!yon_char_is_empty(dns)?" ":"",!yon_char_is_empty(client)?client_addition_command(client):"",!yon_char_is_empty(client)?" ":"",NULL); + + int size; + config_str parsed = yon_config_load(domain_connect_command(adress,login,password,final),&size); + domain_info_window *dialog = yon_information_window_new(); + gtk_widget_show(dialog->Window); + gtk_label_set_text(GTK_LABEL(dialog->DomainOutputLabel),yon_char_parsed_to_string(parsed,size,"\n")); + on_subwindow_close(window->Window); +} + +connection_window *yon_connection_window_new(){ + GtkBuilder *builder = gtk_builder_new_from_resource(glade_connection_path); + connection_window *window = malloc(sizeof(connection_window)); + window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->AdressEntry = yon_gtk_builder_get_widget(builder,"AdressEntry"); + window->StatusEntry = yon_gtk_builder_get_widget(builder,"StatusEntry"); + window->FindEntry = yon_gtk_builder_get_widget(builder,"FindEntry"); + window->LoginEntry = yon_gtk_builder_get_widget(builder,"LoginEntry"); + window->PasswordEntry = yon_gtk_builder_get_widget(builder,"PasswordEntry"); + window->KerberosServerEntry = yon_gtk_builder_get_widget(builder,"KerberosServerEntry"); + window->DNSEntry = yon_gtk_builder_get_widget(builder,"DNSEntry"); + window->ClientCombo = yon_gtk_builder_get_widget(builder,"ClientCombo"); + window->AdditionalCombo = yon_gtk_builder_get_widget(builder,"AdditionalCombo"); + window->EditButton = yon_gtk_builder_get_widget(builder,"EditButton"); + window->SettingsTree = yon_gtk_builder_get_widget(builder,"SettingsTree"); + window->SaveButton = yon_gtk_builder_get_widget(builder,"SaveButton"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->list = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_domain_connect),window); + return window; +} + +void on_domain_disconnect(GtkWidget *self, domain_window *window){ + char *adress = (char*)gtk_entry_get_text(GTK_ENTRY(window->AdressEntry)); + char *login = (char*)gtk_entry_get_text(GTK_ENTRY(window->LoginEntry)); + char *password = (char*)gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); + if (yon_char_is_empty(adress)){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),EMPTY_IMPORTANT_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(window->AdressEntry); + return; + } + int size; + config_str parsed = yon_config_load(domain_disconnect_command(adress,login,password),&size); + domain_info_window *dialog = yon_information_window_new(); + gtk_widget_show(dialog->Window); + gtk_label_set_text(GTK_LABEL(dialog->DomainOutputLabel),yon_char_parsed_to_string(parsed,size,"\n")); + on_subwindow_close(window->Window); +} + +domain_window *yon_domain_window_new(){ + GtkBuilder *builder = gtk_builder_new_from_resource(glade_domain_path); + + domain_window *window = malloc(sizeof(domain_window)); + window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); + window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); + window->SaveButton = yon_gtk_builder_get_widget(builder,"SaveButton"); + window->AdressEntry = yon_gtk_builder_get_widget(builder,"AdressEntry"); + window->LoginEntry = yon_gtk_builder_get_widget(builder,"LoginEntry"); + window->PasswordEntry = yon_gtk_builder_get_widget(builder,"PasswordEntry"); + window->DNSEntry = yon_gtk_builder_get_widget(builder,"DNSEntry"); + g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); + g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_domain_disconnect),window); + + return window; +} + +void on_domain_opened(GtkWidget *self, main_window *widgets){ + if (main_config.domain_connected){ + domain_window *window = yon_domain_window_new(); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),TITLE_LABEL,"com.ublinux.ubl-settings-system","DomainWindow"); + + gtk_widget_show(window->Window); + } else { + connection_window *window = yon_connection_window_new(); + yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),TITLE_LABEL,"com.ublinux.ubl-settings-system","ConnectWindow"); + gtk_widget_show(window->Window); + } + +} + // standard functions void config_init(){ @@ -450,6 +554,7 @@ void config_init(){ main_config.lock_load_global=0; main_config.lock_save_global=0; main_config.lock_save_local=0; + main_config.domain_connected=0; } main_window *yon_main_window_complete(main_window *widgets){ @@ -468,6 +573,9 @@ main_window *yon_main_window_complete(main_window *widgets){ widgets->LocaleButton = yon_gtk_builder_get_widget(builder,"getLocalesButton"); widgets->LocaleEntry = yon_gtk_builder_get_widget(builder,"localeEntry"); + widgets->DomainButton = yon_gtk_builder_get_widget(builder,"DomainButton"); + widgets->DomainEntry = yon_gtk_builder_get_widget(builder,"DomainEntry"); + widgets->fontlist = GTK_LIST_STORE(gtk_builder_get_object(builder,"fontlist")); widgets->languagelist = GTK_LIST_STORE(gtk_builder_get_object(builder,"languagelist")); @@ -504,6 +612,8 @@ main_window *yon_main_window_complete(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->LocaleButton),"clicked",G_CALLBACK(on_locale_open),widgets); g_signal_connect(G_OBJECT(widgets->ConsoleFontCombo),"changed",G_CALLBACK(on_console_font_changed),widgets); g_signal_connect(G_OBJECT(widgets->LanguageCombo),"changed",G_CALLBACK(on_language_changed),widgets); + + g_signal_connect(G_OBJECT(widgets->DomainButton),"clicked",G_CALLBACK(on_domain_opened),widgets); gtk_widget_set_size_request(widgets->Window,800,-1); diff --git a/source/ubl-settings-system.h b/source/ubl-settings-system.h index 27e86ef..133bc9b 100644 --- a/source/ubl-settings-system.h +++ b/source/ubl-settings-system.h @@ -20,6 +20,9 @@ #define _(String) gettext(String) #define glade_path "/com/ublinux/ui/ubl-settings-system.glade" +#define glade_domain_path "/com/ublinux/ui/ubl-settings-system-domain.glade" +#define glade_connection_path "/com/ublinux/ui/ubl-settings-system-connection.glade" +#define glade_domain_view_path "/com/ublinux/ui/ubl-settings-system-domain-view.glade" #define glade_locales_path "/com/ublinux/ui/ubl-settings-system-layouts.glade" #define banner_path "/com/ublinux/images/ubl-settings-system-banner.png" #define CssPath "/com/ublinux/css/ubl-settings-system.css" @@ -37,7 +40,7 @@ #define get_id_command "grep '' /etc/machine-id" // #define get_fonts_command "ls /usr/share/kbd/consolefonts/ |grep -v \"README\"|grep -oE \"^[-a-zA-Z0-9_]{3,}.psf\"|sed -e 's/\\.psf//g'" -#define config_get_command(source) yon_char_unite("ubconfig --source ", source, " get system HOSTNAME MACHINEID",NULL), yon_char_unite("ubconfig --source ", source, " get locale CONSOLE_FONT LOCALE LANG",NULL) +#define config_get_command(source) yon_char_unite("ubconfig --source ", source, " get system HOSTNAME MACHINEID",NULL), yon_char_unite("ubconfig --source ", source, " get locale CONSOLE_FONT LOCALE LANG",NULL), yon_char_unite("ubconfig --source ", source, " get [network] DOMAIN",NULL) #define config_get_default_command "" #define config_get_global_only_parameters "" @@ -57,6 +60,18 @@ #define CONSOLE_FONT_get_command "ubconfig --source global get [locale] CONSOLE_FONT" // #define NUMLOCK_get_command "ubconfig --source global get [locale] NUMLOCK" #define LANG_get_command "ubconfig --source global get [locale] LANG" +#define DOMAIN_get_command "ubconfig --source global get [network] DOMAIN" + +#define check_domain_access_command(targeet) yon_char_append("adcli info --domain ",target) +#define get_domain_info_command(target) yon_char_append("ubdomain-client list ",target) +#define domains_seek_command "ubdomain-client discover" +#define domain_connect_command(target,user,password, addition) yon_char_unite("ubdomain-client join",yon_char_is_empty(user)?" --user \"":"",yon_char_is_empty(user)?user:"",yon_char_is_empty(user)?"\"":"",yon_char_is_empty(password)?" --password \"":"",yon_char_is_empty(password)?password:"",yon_char_is_empty(password)?"\"":""," --domain \"",target,"\"", addition,NULL) +#define domain_disconnect_command(target,user,password) yon_char_unite("ubdomain-client join",yon_char_is_empty(user)?" --user \"":"",yon_char_is_empty(user)?user:"",yon_char_is_empty(user)?"\"":"",yon_char_is_empty(password)?" --password \"":"",yon_char_is_empty(password)?password:"",yon_char_is_empty(password)?"\"":""," --domain \"",target,"\"",NULL) +#define kerberos_addition_command(target) yon_char_unite("--domain_server \"",target,"\"",NULL) +#define dns_addition_command(target) yon_char_unite("--dns \"",target,"\"",NULL) +#define client_addition_command(target) yon_char_unite("--domain_client \"",target,"\"",NULL) + +#define domain_info(target) yon_char_append("ubdomain-client discover --domain ",target) typedef char* string; string version_application; @@ -66,6 +81,7 @@ char *local; typedef struct { template_config_fields GtkListStore *localeslist; + int domain_connected; } config; typedef struct { @@ -81,6 +97,9 @@ typedef struct { GtkWidget *LocaleButton; GtkWidget *LocaleEntry; + GtkWidget *DomainEntry; + GtkWidget *DomainButton; + GtkListStore *fontlist; GtkListStore *languagelist; @@ -109,5 +128,45 @@ typedef struct { GtkCellRenderer *ToggleCell; } locals_window; +typedef struct { + GtkWidget *Window; + + GtkWidget *StatusBox; + + GtkWidget *CancelButton; + GtkWidget *SaveButton; + GtkWidget *AdressEntry; + GtkWidget *LoginEntry; + GtkWidget *PasswordEntry; + GtkWidget *DNSEntry; +} domain_window; + +typedef struct { + GtkWidget *Window; + + GtkWidget *StatusBox; + + GtkWidget *CancelButton; + GtkWidget *SaveButton; + GtkWidget *AdressEntry; + GtkWidget *LoginEntry; + GtkWidget *PasswordEntry; + GtkWidget *DNSEntry; + GtkWidget *StatusEntry; + GtkWidget *FindEntry; + GtkWidget *KerberosServerEntry; + GtkWidget *ClientCombo; + GtkWidget *AdditionalCombo; + GtkWidget *EditButton; + GtkWidget *SettingsTree; + GtkListStore *list; +} connection_window; + +typedef struct { + GtkWidget *Window; + + GtkWidget *DomainOutputLabel; +} domain_info_window; + main_window *setup_window(); void on_id_changed(GtkEntry *self, main_window *widgets); \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index bf53924..319011f 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -26,4 +26,6 @@ #define INSERT_LABEL _("Insert data") -#define ACCEPT_LABEL _("Accept") \ No newline at end of file +#define ACCEPT_LABEL _("Accept") + +#define EMPTY_IMPORTANT_LABEL _("Important field is empty") \ No newline at end of file diff --git a/ubl-settings-system-connection.glade b/ubl-settings-system-connection.glade new file mode 100644 index 0000000..2b47159 --- /dev/null +++ b/ubl-settings-system-connection.glade @@ -0,0 +1,555 @@ + + + + + + + True + False + gtk-missing-image + + + True + False + gtk-missing-image + + + True + False + document-edit-symbolic + + + + False + True + com.ublinux.ubl-settings-repomanager + + + True + False + vertical + 5 + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + vertical + + + True + True + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + 5 + + + True + False + Domain address: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + True + True + True + image1 + + + False + True + 2 + + + + + True + True + True + image2 + + + False + True + 3 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Domain administrator name: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 1 + + + + + True + False + 5 + + + True + False + Domain administrator password: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 2 + + + + + + + True + False + Main + + + False + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + 5 + + + True + False + Kerberos/AD domain server: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + DNS server: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 1 + + + + + True + False + 5 + + + True + False + Domain connection client + + + False + True + 0 + + + + + True + False + + Default + Sssd client + Winbind client + Samba client + Switch client off or autometically + + + + True + True + 1 + + + + + False + True + 2 + + + + + True + False + 0 + in + + + True + False + 5 + 5 + 5 + + + True + False + vertical + 5 + + + True + False + + Default + Set + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + vertical + 5 + + + True + True + True + image3 + + + + False + True + 0 + + + + + False + True + 0 + + + + + True + False + 0 + in + + + True + True + liststore1 + + + + + + + + True + False + + + + + True + True + 1 + + + + + True + True + 1 + + + + + + + + + True + False + Additional options for autentification profile + + + + + True + True + 4 + + + + + 1 + + + + + True + False + Additional + + + 1 + False + + + + + True + True + 0 + + + + + True + True + 0 + + + + + True + True + 1 + + + + + + + True + False + + + True + False + System configuration + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-system + + + + + Cancel + True + True + True + + + 1 + + + + + Connect + True + True + True + + + end + 2 + + + + + + diff --git a/ubl-settings-system-domain-view.glade b/ubl-settings-system-domain-view.glade new file mode 100644 index 0000000..9e1f1fd --- /dev/null +++ b/ubl-settings-system-domain-view.glade @@ -0,0 +1,72 @@ + + + + + + + False + True + com.ublinux.ubl-settings-repomanager + + + True + False + vertical + 5 + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + True + 0 + + + False + True + 1 + + + + + + + True + False + True + + + True + False + Domain information + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-system + + + + + + diff --git a/ubl-settings-system-domain.glade b/ubl-settings-system-domain.glade new file mode 100644 index 0000000..9aa15cb --- /dev/null +++ b/ubl-settings-system-domain.glade @@ -0,0 +1,255 @@ + + + + + + + False + True + com.ublinux.ubl-settings-repomanager + + + True + False + vertical + 5 + + + True + False + vertical + + + + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + vertical + 5 + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + Domain adress: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Domain administrator password: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 1 + + + + + True + False + 5 + + + True + False + Domain administrator name: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 2 + + + + + True + False + 5 + + + True + False + DNS server: + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 3 + + + + + False + True + 4 + + + + + True + True + 1 + + + + + + + True + False + + + True + False + System configuration + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-system + + + + + Cancel + True + True + True + + + 1 + + + + + Disconnect + True + True + True + + + end + 2 + + + + + + + diff --git a/ubl-settings-system.glade b/ubl-settings-system.glade index bd5680b..9ee8fda 100644 --- a/ubl-settings-system.glade +++ b/ubl-settings-system.glade @@ -49,6 +49,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False document-edit-symbolic + + True + False + com.ublinux.libublsettingsui-gtk3.arrows-left-right-symbolic + @@ -120,6 +125,58 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0 + + + True + False + 5 + + + True + False + Domain adress: + + + False + True + 0 + + + + + True + False + com.ublinux.libublsettingsui-gtk3.cloud-arrow-up-symbolic + + + True + True + 1 + + + + + True + True + True + image3 + + + + False + True + 2 + + + + + False + True + 1 + + True @@ -201,7 +258,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True - 1 + 2