From 11bae7c906964e0b95c2836ff9eebd1f5acc0972 Mon Sep 17 00:00:00 2001 From: lars Date: Fri, 31 Mar 2006 02:21:52 +0000 Subject: [PATCH] improved gnupg support --- ezmlm-web.cgi | 53 ++++++++++++---- lang/de.hdf | 12 +++- lang/en.hdf | 10 ++++ .../config_options/gpg_allow_key_submission | 0 template/config_options/gpg_encrypt_to_all | 0 template/config_options/gpg_nokey_nocrypt | 0 .../config_options/gpg_require_subscriber | 0 template/config_options/gpg_sign_messages | 0 .../config_options/gpg_verified_key_required | 0 template/config_options/webusers.cs | 2 +- template/gnupg_public.cs | 32 ++++++++++ template/nav.cs | 27 +++++++++ template/ui/gnupg/normal.hdf | 60 +++++++++++++++++++ 13 files changed, 183 insertions(+), 13 deletions(-) create mode 100644 template/config_options/gpg_allow_key_submission create mode 100644 template/config_options/gpg_encrypt_to_all create mode 100644 template/config_options/gpg_nokey_nocrypt create mode 100644 template/config_options/gpg_require_subscriber create mode 100644 template/config_options/gpg_sign_messages create mode 100644 template/config_options/gpg_verified_key_required create mode 100644 template/gnupg_public.cs create mode 100644 template/ui/gnupg/normal.hdf diff --git a/ezmlm-web.cgi b/ezmlm-web.cgi index bebdb4f..fb19f45 100755 --- a/ezmlm-web.cgi +++ b/ezmlm-web.cgi @@ -54,7 +54,7 @@ use vars qw[$TEXT_ENCODE]; $TEXT_ENCODE='us-ascii'; # by ooyama for multibyte co # "pagedata" contains the hdf tree for clearsilver # "pagename" refers to the template file that should be used -# "ui_set" is the selected kind of interface ("normal", "gnupg", ...) +# "ui_set" is the selected kind of interface ("default", "gnupg", ...) # "ui_template" is one of "basic", "normal" and "expert" use vars qw[$pagedata $pagename $error $customError $warning $customWarning $success]; use vars qw[$ui_set $ui_template]; @@ -214,6 +214,26 @@ elsif ($action eq '' || $action eq 'list_select') { $error = 'ParameterMissing'; $pagename = 'list_select'; } +} elsif (($action eq 'gnupg_ask') || ($action eq 'gnupg_do')) { + # User wants to manage keys (only for encrypted mailing lists) + my $subset = $q->param('gnupg_subset'); + if (defined($q->param('list')) && ($subset ne '')) { + if (($subset =~ /^[\w]*$/) && (-e "$TEMPLATE_DIR/gnupg_$subset" . ".cs")) { + $pagename = 'gnupg_' . $subset; + } else { + $pagename = ''; + } + if ($pagename ne '') { + $success = 'UpdateGnupg' if (($action eq 'gnupg_do') && &update_gnupg()); + } else { + $error = 'UnknownGnupgPage'; + warn "missing gnupg page: $subset"; + $pagename = 'list_select'; + } + } else { + $error = 'ParameterMissing'; + $pagename = 'list_select'; + } } elsif ($action eq 'textfiles') { # Edit DIR/text ... if (defined($q->param('list'))) { @@ -309,17 +329,17 @@ sub load_hdf { # initialize the data for clearsilver my $hdf = ClearSilver::HDF->new(); - $hdf->readFile($LANGUAGE_DIR . '/' . $HTML_LANGUAGE . '.hdf'); - - &fatal_error("Template dir ($TEMPLATE_DIR) not found!") unless (-e $TEMPLATE_DIR); - $hdf->setValue("TemplateDir", "$TEMPLATE_DIR/"); &fatal_error("Language data dir ($LANGUAGE_DIR) not found!") unless (-e $LANGUAGE_DIR); $hdf->setValue("LanguageDir", "$LANGUAGE_DIR/"); - # the "ui_set" may be changed later according to the type of list, that we encounter - $ui_set = 'default'; + &fatal_error("Template dir ($TEMPLATE_DIR) not found!") unless (-e $TEMPLATE_DIR); + $hdf->setValue("TemplateDir", "$TEMPLATE_DIR/"); + + # TODO: put some language detection and "web_lang" handling here + $hdf->readFile($LANGUAGE_DIR . '/' . $HTML_LANGUAGE . '.hdf'); # "normal", "basic" and "expert" should be supported + # TODO: should be selected via web interface $ui_template = "normal"; $hdf->setValue("Config.UI.LinkAttrs.web_lang", $HTML_LANGUAGE); $hdf->setValue("Config.UI.LinkAttrs.template", $ui_template); @@ -469,12 +489,14 @@ sub set_pagedata4list &set_pagedata4list_common($listname, $part_type); # is this list encrypted? - if (&is_list_encrypted($listname)) { + if (&is_list_gnupg($listname)) { # some encryption specific stuff - &set_pagedata4list_encrypted($listname); + &set_pagedata4list_gnupg($listname); + $ui_set = "gnupg"; } else { # do the non-encryption configuration &set_pagedata4list_normal($listname, $part_type); + $ui_set = "default"; } return (0==0); @@ -484,7 +506,7 @@ sub set_pagedata4list # extract hdf-data for encrypted lists # non-encrypted lists should not use this function -sub set_pagedata4list_encrypted() { +sub set_pagedata4list_gnupg() { my ($listname) = @_; my ($gpg_list, %config, $item, @gpg_keys, $gpg_key, %hash); @@ -502,13 +524,16 @@ sub set_pagedata4list_encrypted() { foreach $gpg_key (@gpg_keys) { %hash = $gpg_key; $pagedata->setValue("Data.List.gnupg_keys.public." . $hash{id}, $hash{uid}); + warn "pubkey: $hash{uid}"; } # retrieve the currently available secret keys @gpg_keys = $gpg_list->get_secret_keys(); foreach $gpg_key (@gpg_keys) { + # TODO: %hash is broken! %hash = $gpg_key; $pagedata->setValue("Data.List.gnupg_keys.secret." . $hash{id}, $hash{uid}); + warn "seckey: " . $hash{uid}; } } @@ -715,7 +740,7 @@ sub get_list_part # --------------------------------------------------------------------------- -sub is_list_encrypted { +sub is_list_gnupg { my ($listname) = @_; return (1==0) unless ($GPG_SUPPORT); @@ -1174,6 +1199,12 @@ sub extract_options_from_params() # ------------------------------------------------------------------------ +sub update_gnupg { + return (0==0); +} + +# ------------------------------------------------------------------------ + sub update_config { # Save the new user entered config ... diff --git a/lang/de.hdf b/lang/de.hdf index 38499c3..faffae0 100644 --- a/lang/de.hdf +++ b/lang/de.hdf @@ -19,6 +19,10 @@ Lang { ConfigArchive = Archivierung ConfigProcess = Verarbeitung ConfigAll = Übersicht + KeyManagement = Schlüsselverwaltung + KeysPublic = öffentliche Schlüssel + KeysSecret = private Schlüssel + KeysGenerate = Schlüssel anlegen TextFiles = Texte ListSelect = Auswahl einer Liste Properties = Eigenschaften von @@ -44,6 +48,9 @@ Lang { ListDelete = Löschung von FileSelect = Auswählen eines Textbausteins FileEdit = Bearbeitung des Textbausteins + GnupgPublic = Öffentliche Schlüssel + GnupgSecret = Private Schlüssel + GnupgGenerate = Erzeugen eines Schlüssels } @@ -53,6 +60,7 @@ Lang { DeleteAddress = Adresse(n) entfernen AddAddress = Adresse(n) hinzufügen UpdateConfiguration = Einstellungen speichern + UpdateGnupg = Schlüsselring aktualisieren EditFile = Datei bearbeiten SaveFile = Datei speichern ResetFile = Angepassten Textbaustein verwerfen @@ -64,7 +72,8 @@ Lang { ParameterMissing = Diese Aktion benätigt weitere Parameter! Forbidden = Fehler: dir fehlen die notwendigen Rechte für diese Aktion InvalidFileName = Der Dateiname ist nicht zulässig. - UnknownConfigPage = Die gähle Konfigurations-Seite existiert nicht! + UnknownConfigPage = Diese Konfigurations-Seite existiert nicht! + UnknownGnupgPage = Diese GnuPG-Seite existiert nicht! } @@ -104,6 +113,7 @@ Lang { CreateList = Die neue Liste wurde erfolgreich angelegt. DeleteList = Die Mailingliste wurde gelöscht. UpdateConfig = Die neuen Einstellungen wurden erfolgreich gespeichert. + UpdateGnupg = Der Schlüsselring wurde erfolgreich geändert. SaveFile = Die Datei wurde gespeichert. ResetFile = Der angepasste Textbaustein wurde entfernt. Zukünftig wird stattdessen der systemweite Standard-Baustein verwendet. } diff --git a/lang/en.hdf b/lang/en.hdf index b6e95e7..0325a54 100644 --- a/lang/en.hdf +++ b/lang/en.hdf @@ -19,6 +19,10 @@ Lang { ConfigArchive = archive ConfigProcess = processing ConfigAll = overview + KeyManagement = Key management + KeysPublic = public keys + KeysSecret = secret keys + KeysGenerate = generate key TextFiles = Text files ListSelect = Choose a list Properties = Properties of @@ -44,6 +48,9 @@ Lang { ListDelete = Delete list FileSelect = Choose a file for editing FileEdit = Editing file + GnupgPublic = Public keys + GnupgSecret = Secret keys + GnupgGenerate = Generate a new keypair } @@ -53,6 +60,7 @@ Lang { DeleteAddress = Delete address(es) AddAddress = Add address(es) UpdateConfiguration = Update configuration + UpdateGnupg = Update keyring EditFile = Edit file SaveFile = Save file ResetFile = Remove customized file @@ -65,6 +73,7 @@ Lang { Forbidden = Error: you are not allowed to do this! InvalidFileName = The name of the file is invalid! UnknownConfigPage = The chosen config page is invalid! + UnknownGnupgPage = The chosen gnupg page is invalid! } @@ -104,6 +113,7 @@ Lang { CreateList = The new mailing list was successfully created. DeleteList = The mailing list was successfully removed. UpdateConfig = The mailing list's configuration was successfully changed. + UpdateGnupg = The keyring was successfully changed. SaveFile = The file was saved. ResetFile = The customized text file was successfully removed. From now on, the system-wide default text file will be used instead of it. } diff --git a/template/config_options/gpg_allow_key_submission b/template/config_options/gpg_allow_key_submission new file mode 100644 index 0000000..e69de29 diff --git a/template/config_options/gpg_encrypt_to_all b/template/config_options/gpg_encrypt_to_all new file mode 100644 index 0000000..e69de29 diff --git a/template/config_options/gpg_nokey_nocrypt b/template/config_options/gpg_nokey_nocrypt new file mode 100644 index 0000000..e69de29 diff --git a/template/config_options/gpg_require_subscriber b/template/config_options/gpg_require_subscriber new file mode 100644 index 0000000..e69de29 diff --git a/template/config_options/gpg_sign_messages b/template/config_options/gpg_sign_messages new file mode 100644 index 0000000..e69de29 diff --git a/template/config_options/gpg_verified_key_required b/template/config_options/gpg_verified_key_required new file mode 100644 index 0000000..e69de29 diff --git a/template/config_options/webusers.cs b/template/config_options/webusers.cs index 073cda3..38ebdb6 100644 --- a/template/config_options/webusers.cs +++ b/template/config_options/webusers.cs @@ -3,7 +3,7 @@ + 0 + ?>
  • +
  • +
  • class="nav_active" diff --git a/template/ui/gnupg/normal.hdf b/template/ui/gnupg/normal.hdf new file mode 100644 index 0000000..00bad31 --- /dev/null +++ b/template/ui/gnupg/normal.hdf @@ -0,0 +1,60 @@ +UI { + + Navigation { + ListSelect = 1 + ListCreate = 1 + Subscribers { + Subscribers = 1 + } + + Config { + Main = 1 + } + + Keymanagement { + PublicKeys = 1 + SecretKeys = 1 + GenerateKey = 1 + } + + TextEdit = 1 + ListDelete = 1 + + Help = 1 + } + + + Options { + + Create { + # TODO: was soll hier ein? + Listname = create_listname + Listaddress = create_listaddress + Listlanguage = lang_select + Mysql = mysql + Webuser = webusers + } + + + Config { + Main { + #Language = lang_select + #Charset = charset_select + SignMessages = gpg_sign_messages + EncryptToAll = gpg_encrypt_to_all + AllowKeySubmission = gpg_allow_key_submission + NokeyNocrypt = gpg_nokey_nocrypt + VerifiedKeyReq = gpg_verified_key_required + RequireSub = gpg_require_subscriber + WebUsers = webusers + } + + Keymanagement { + } + + } + + } + + } +