From 5f70327ea71ce1cdad65dd93966ccdd0c7895983 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 2 Aug 2023 18:03:52 +0600 Subject: [PATCH] Fixed user key getting --- source/ubl-settings-repomanager.c | 17 +++++++++++------ source/ubl-settings-repomanager.h | 3 ++- source/ubl-strings.h | 6 +++++- ubl-settings-repomanager.pot | 4 ++++ ubl-settings-repomanager_ru.po | 6 +++++- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/source/ubl-settings-repomanager.c b/source/ubl-settings-repomanager.c index f30b3e1..c5f681e 100644 --- a/source/ubl-settings-repomanager.c +++ b/source/ubl-settings-repomanager.c @@ -116,7 +116,6 @@ void on_load(){ config_str packs = yon_char_parse(parameter_string,&packsize," "); GtkTreeIter packIter; if (!packs){ - printf("%s\n",get_saved_package_info_command(path,parameter_string)); FILE *file = popen(get_saved_package_info_command(path,parameter_string),"r"); char *cur_string=g_malloc0(sizeof(char)*4096); char *packname=NULL, *packver=NULL, *packarch=NULL, *packdepends=NULL; @@ -133,7 +132,6 @@ void on_load(){ } else for (int j=0;jkey, " -p ", signed_packs,NULL); - printf("%s\n",sign_command); system(sign_command); } @@ -330,7 +327,7 @@ void on_tree_selection_changed(GtkWidget *self,main_window *widgets){ gtk_label_set_text(GTK_LABEL(widgets->VersionInfoLabel),version ? version : ""); gtk_label_set_text(GTK_LABEL(widgets->ArchitectureInfoLabel),architecture ? architecture : ""); gtk_label_set_text(GTK_LABEL(widgets->DependencesInfoLabel),dependeces ? dependeces : ""); - gtk_label_set_text(GTK_LABEL(widgets->SignatureInfoLabel),signature ? signature : ""); + gtk_label_set_text(GTK_LABEL(widgets->SignatureInfoLabel),signature ? signature : ABSENT_LABEL); int depth = gtk_tree_store_iter_depth(main_config.tree_store,&iter); if (depth == 0){ gtk_widget_set_sensitive(widgets->CreateButton,1); @@ -338,7 +335,10 @@ void on_tree_selection_changed(GtkWidget *self,main_window *widgets){ gtk_widget_set_sensitive(widgets->ConfigureButton,1); gtk_widget_set_sensitive(widgets->DeleteButton,1); gtk_widget_set_sensitive(widgets->AddPackageButton,1); - gtk_widget_set_sensitive(widgets->RemovePackageButton,1); + gtk_widget_set_sensitive(widgets->RemovePackageButton,0); + // if (main_config.lock_root==1){ + // gtk_widget_set_sensitive(widgets->SignButton,0); + // } } else if (depth == 1){ gtk_widget_set_sensitive(widgets->CreateButton,1); gtk_widget_set_sensitive(widgets->LoadFromLocalButton,1); @@ -346,6 +346,9 @@ void on_tree_selection_changed(GtkWidget *self,main_window *widgets){ gtk_widget_set_sensitive(widgets->DeleteButton,0); gtk_widget_set_sensitive(widgets->AddPackageButton,1); gtk_widget_set_sensitive(widgets->RemovePackageButton,1); + // if (main_config.lock_root==1){ + // gtk_widget_set_sensitive(widgets->SignButton,0); + // } } } } @@ -621,7 +624,6 @@ void yon_add_file(main_window *widgets){ char *cur_string=g_malloc0(sizeof(char)*4096); char *packname=NULL, *packver=NULL, *packarch=NULL, *packdepends=NULL; while (fgets(cur_string,4096,file)){ - printf("%s\n",cur_string); char *stringe = yon_char_divide_search(cur_string,"\n",-1); char *p = yon_char_divide_search(stringe,":",-1); if (strstr(p,"Name")) packname = yon_char_new(stringe); @@ -855,6 +857,7 @@ int main(int argc, char *argv[]){ main_config.lock_load_global=1; main_config.lock_save_global=1; main_config.lock_save_local=1; + main_config.lock_root=1; } gtk_init(&argc,&argv); @@ -875,6 +878,8 @@ int main(int argc, char *argv[]){ gtk_paned_set_position(GTK_PANED(widgets->MovePaned),400); on_load(); + // if (getuid()!=0) + // yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); GtkCssProvider *css=gtk_css_provider_new(); gtk_css_provider_load_from_resource(css,CssPath); gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), diff --git a/source/ubl-settings-repomanager.h b/source/ubl-settings-repomanager.h index 604fa88..9c51b90 100644 --- a/source/ubl-settings-repomanager.h +++ b/source/ubl-settings-repomanager.h @@ -42,7 +42,7 @@ typedef char* string; #define get_package_info_command(filename) yon_char_unite("LC_ALL=EN pacman -Q --info --file ",filename," |sed -e 's/ */ /g' -e 's/ : /:/g' -e 's/:/:/;s/\\n/ /g' -e 's/ *//g'",NULL) #define get_saved_package_info_command(path,filename) yon_char_unite("LC_ALL=EN pacman -Q --info --file $(find \"",path,"\" -name *",filename,"* -not -name *.sig |head -n 1)|sed -e 's/ */ /g' -e 's/ : /:/g'",NULL) -#define get_gpg_keys_command yon_char_unite("su - ",yon_ubl_root_user_get()," -c \"gpg --list-signatures\" | grep '^sig 3' | cut -d' ' -f10,11,13- | sort -u |sed -e 's/[0-9]*-[0-9]*-[0-9]* //g'",NULL) +#define get_gpg_keys_command yon_char_unite(yon_ubl_check_root()==1 ? yon_char_unite("su - ",yon_ubl_root_user_get()," -c \"gpg --list-signatures\"",NULL):"","gpg --list-signatures | grep '^sig 3' | cut -d' ' -f10,11,13- | sort -u |sed -e 's/[0-9]*-[0-9]*-[0-9]* //g'",NULL) string version_application; @@ -64,6 +64,7 @@ typedef struct { int lock_save_local; int lock_save_global; int lock_load_global; + int lock_root; } config; typedef struct { diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 99d462c..bcc4d0d 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -1,6 +1,8 @@ #define VERSION_LABEL yon_char_unite(_("Version:")," ",version_application,"\n",NULL) #define HELP_LABEL yon_char_unite(_("ubl-settings-repomanager version:")," ", version_application,"\n",TITLE_LABEL,"\n",_("Usage:"), " ubl-settings-repomanager ",_("[OPTIONS]"),"\n",_("Options:"),"\n\t--help, -h\t\t\t",_("Show this help"),"\n\t--version, -V\t\t\t",_("Show package version"),"\n\t--lock-help\t\t\t",_("Lock this help menu"),"\n\t--lock-save\t\t\t",_("Lock configuration saving"),"\n\t--lock-save-local\t\t",_("Lock local configration saving"),"\n\t--lock-save-global\t\t",_("Lock global configration saving"),"\n\t--lock-load-global\t\t",_("Lock global configration loading"),"\n",NULL) +#define ROOT_WARNING_LABEL _("Warning! Application was launched without root - root-dependent actions are locked") + #define TITLE_LABEL _("Repository manager") #define TITLE_INFO_LABEL _("Repository management and configuring") #define SUCCESS_LABEL _("Operation succeeded") @@ -80,4 +82,6 @@ #define CHOOSE_PATH_LABEL _("Choose path for new repository") #define ADD_REPO_LABEL _("Choose repository folder") -#define LOAD_REPO_LABEL _("Choose repository") \ No newline at end of file +#define LOAD_REPO_LABEL _("Choose repository") + +#define ABSENT_LABEL _("Absent") \ No newline at end of file diff --git a/ubl-settings-repomanager.pot b/ubl-settings-repomanager.pot index 25ce2df..58b3ac3 100644 --- a/ubl-settings-repomanager.pot +++ b/ubl-settings-repomanager.pot @@ -308,3 +308,7 @@ msgstr "" #: source/ubl-strings.h:83 msgid "Choose repository" msgstr "" + +#: source/ubl-strings.h:85 +msgid "Absent" +msgstr "" diff --git a/ubl-settings-repomanager_ru.po b/ubl-settings-repomanager_ru.po index 917b2c8..4260706 100644 --- a/ubl-settings-repomanager_ru.po +++ b/ubl-settings-repomanager_ru.po @@ -217,7 +217,7 @@ msgstr "Компоненты" #: source/ubl-strings.h:55 msgid "Signature:" -msgstr "Подпись" +msgstr "Подпись:" #: source/ubl-strings.h:57 msgid "Create repository" @@ -318,3 +318,7 @@ msgstr "Выбрать директорию для репозитория" #, fuzzy msgid "Choose repository" msgstr "Выбрать репозиторий" + +#: source/ubl-strings.h:85 +msgid "Absent" +msgstr "Отсутствует"