From c762b65ce42c18f026a16ee702cec5dc168a39be Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 2 Aug 2008 22:46:16 -0400 Subject: [PATCH] show unsafe options (RO) by default Small data leak, but only to admins, and I think it's worth it to see the stuff that cannot be configured. --- .IkiWiki.pm.swp | Bin 0 -> 16384 bytes IkiWiki.pm | 2 +- IkiWiki/Plugin/bzr.pm | 2 +- IkiWiki/Plugin/git.pm | 2 +- IkiWiki/Plugin/mercurial.pm | 2 +- IkiWiki/Plugin/monotone.pm | 2 +- IkiWiki/Plugin/svn.pm | 2 +- IkiWiki/Plugin/tla.pm | 2 +- IkiWiki/Plugin/websetup.pm | 38 ++++++++++++++++++++++++++++++------ websetup.pm | 1 + 10 files changed, 40 insertions(+), 13 deletions(-) create mode 100644 .IkiWiki.pm.swp create mode 120000 websetup.pm diff --git a/.IkiWiki.pm.swp b/.IkiWiki.pm.swp new file mode 100644 index 0000000000000000000000000000000000000000..adf830d94a5f4ed131610662776020c1c906d086 GIT binary patch literal 16384 zcmeI3Ym6jS6~~L0ILaz&h>s6=x2K2cafj(y*ae+&mLV{(1N&n3!Rj#EsqVTnQ%rYN zPgOO&W7|ti)K3U*;wHpMSh8Ua0Y3mH#wZ_%A;t%oXpF(cO%x+hK1d<~7XMw05}m#%xO>eQ+KJ@?*oZ_gC_4~*_q*Y|C<_*`yT8$NSv`>WQK)|Q(r>uz7q zN%dNv8Q-xh_F7k2))6t74}((PopI}sADwaU}zrFW+aqza@8qza@8qza@8qza@8qzb(66o{&qS?}WYh45{-AmLp;-{tsd zQhp~XZ{h;E=55L+`F<`b|0gNWU`WotMfnlFKXy@Eev|UUl%GnOW_wE zv8?-`1`*r^8{nA@meqh6*bEoLPcCC^4_jdiWZ{!=5&ZSTmi24+75oq$g`@CQxD#%J z0k{r&;0m|^{`?`Xg`@B_Xo3&pa4Yn{+Z~qmcX$zg56{7qa2x{AupjP#Vd#ZV!RZgO z*8tDLlkfvL0S~|tH~?3Jg3IADc=uAvdI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Wjf&Xf(nHpceWN+lhJXRv4NXvbJ`Csi&t zW#;W%Hkkb|<4;PqU|IeCveTq&9z{zh4avDN|2&ZArdu3>KC;oy%qi zhZoZCvwQst3)JcJ`TnuNvlL*95n!#ij~{VfUf;3V&^v#PFXqnj)vujc>$S!BIlOcx z8&Hj_g8bi`&Oi*e^*^`oI&p*W2oi}Xy(F&_=I#Ocz zj7FtLwd+a7r>5Gb+MaB^eN*~WhuF}EU6xksxZ3KFC1=aPkm;GICY2&Xt72J4WpNQ} z@_*cDMa_~%FTC6NX|?uN*J!pcuA?FTN6nV_ze>9$b4xrV%hD{DEsSrT=v936^EF(c zOD)8L?2wza@R`lc&kW0_s-#CaKKpah-;6C5;#oN`?Ik_d^jeW8c5ABa7jxMvKFL+R zvf2#nifkaX>D;S#L%G@fGGuytwi;V!b=P`2=2|o5f(zOCeE>bXFa@_Naf?2KXVtUz zCV6!pE-_Ws-V}4#{8LT;maw)<)5`Qwl^brDd&0Q$OJ&O)b{giTZ`I|plYw7J#1k*q zN+*&wO2$>ATBe76TYm0ie2G=O>MAwwMKXBACx#XUzNu-%1DWhpNVA&zhcd>eeEjN) z_inwmxGK#WUv?zyJakuIzO&O*$+;n_@;8hh%1>;{nrhPzaQkNloOVkEx;#iO3F+ZsOO&}y`P@ocIaWLT7NTU0lo*rto`PGWIr IxG-q_7i_y9oB#j- literal 0 HcmV?d00001 diff --git a/IkiWiki.pm b/IkiWiki.pm index 241a7c036..a2b4d8d80 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -92,7 +92,7 @@ sub getsetup () { #{{{ type => "string", default => '', example => "/var/www/wiki/ikiwiki.cgi", - description => "cgi executable to generate", + description => "cgi wrapper to generate", safe => 0, # file rebuild => 0, }, diff --git a/IkiWiki/Plugin/bzr.pm b/IkiWiki/Plugin/bzr.pm index 99025a973..0b5059292 100644 --- a/IkiWiki/Plugin/bzr.pm +++ b/IkiWiki/Plugin/bzr.pm @@ -36,7 +36,7 @@ sub getsetup () { #{{{ bzr_wrapper => { type => "string", #example => "", # FIXME add example - description => "bzr post-commit executable to generate", + description => "bzr post-commit hook to generate", safe => 0, # file rebuild => 0, }, diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index d1c1165e0..b6ad43167 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -45,7 +45,7 @@ sub getsetup () { #{{{ git_wrapper => { type => "string", example => "/git/wiki.git/hooks/post-update", - description => "git post-update executable to generate", + description => "git post-update hook to generate", safe => 0, # file rebuild => 0, }, diff --git a/IkiWiki/Plugin/mercurial.pm b/IkiWiki/Plugin/mercurial.pm index d2c34fa6a..23bebaaad 100644 --- a/IkiWiki/Plugin/mercurial.pm +++ b/IkiWiki/Plugin/mercurial.pm @@ -36,7 +36,7 @@ sub getsetup () { #{{{ mercurial_wrapper => { type => "string", #example => # FIXME add example - description => "mercurial post-commit executable to generate", + description => "mercurial post-commit hook to generate", safe => 0, # file rebuild => 0, }, diff --git a/IkiWiki/Plugin/monotone.pm b/IkiWiki/Plugin/monotone.pm index 4b9be316a..bdc6ee786 100644 --- a/IkiWiki/Plugin/monotone.pm +++ b/IkiWiki/Plugin/monotone.pm @@ -68,7 +68,7 @@ sub getsetup () { #{{{ mtn_wrapper => { type => "string", example => "/srv/mtn/wiki/_MTN/ikiwiki-netsync-hook", - description => "monotone netsync hook executable to generate", + description => "monotone netsync hook to generate", safe => 0, # file rebuild => 0, }, diff --git a/IkiWiki/Plugin/svn.pm b/IkiWiki/Plugin/svn.pm index 51683704c..c51b0f181 100644 --- a/IkiWiki/Plugin/svn.pm +++ b/IkiWiki/Plugin/svn.pm @@ -58,7 +58,7 @@ sub getsetup () { #{{{ svn_wrapper => { type => "string", example => "/svn/wikirepo/hooks/post-commit", - description => "svn post-commit executable to generate", + description => "svn post-commit hook to generate", safe => 0, # file rebuild => 0, }, diff --git a/IkiWiki/Plugin/tla.pm b/IkiWiki/Plugin/tla.pm index 6faaecccc..1c2763359 100644 --- a/IkiWiki/Plugin/tla.pm +++ b/IkiWiki/Plugin/tla.pm @@ -34,7 +34,7 @@ sub getsetup () { #{{{ tla_wrapper => { type => "string", #example => "", # TODO example - description => "tla post-commit executable to generate", + description => "tla post-commit hook to generate", safe => 0, # file rebuild => 0, }, diff --git a/IkiWiki/Plugin/websetup.pm b/IkiWiki/Plugin/websetup.pm index 6aab04e32..150c792a5 100644 --- a/IkiWiki/Plugin/websetup.pm +++ b/IkiWiki/Plugin/websetup.pm @@ -13,6 +13,7 @@ my @default_force_plugins=(qw{amazon_s3 external}); sub import { #{{{ hook(type => "getsetup", id => "websetup", call => \&getsetup); + hook(type => "checkconfig", id => "websetup", call => \&checkconfig); hook(type => "sessioncgi", id => "websetup", call => \&sessioncgi); hook(type => "formbuilder_setup", id => "websetup", call => \&formbuilder_setup); @@ -27,12 +28,29 @@ sub getsetup () { #{{{ safe => 0, rebuild => 0, }, + websetup_show_unsafe => { + type => "boolean", + example => 1, + description => "show unsafe settings, read-only, in web interface?", + safe => 0, + rebuild => 0, + }, +} #}}} + +sub checkconfig () { #{{{ + if (! exists $config{websetup_show_unsafe}) { + $config{websetup_show_unsafe}=1; + } } #}}} -sub formatexample ($) { #{{{ +sub formatexample ($$) { #{{{ my $example=shift; + my $value=shift; - if (defined $example && ! ref $example && length $example) { + if (defined $value && length $value) { + return ""; + } + elsif (defined $example && ! ref $example && length $example) { return "
Example: $example"; } else { @@ -50,8 +68,10 @@ sub showfields ($$$@) { #{{{ my $key=shift; my %info=%{shift()}; - # skip complex, unsafe, or internal settings - next if ref $config{$key} || ! $info{safe} || $info{type} eq "internal"; + # skip complex or internal settings + next if ref $config{$key} || ref $info{example} || $info{type} eq "internal"; + # maybe skip unsafe settings + next if ! $info{safe} && ! $config{websetup_show_unsafe}; # these are handled specially, so don't show next if $key eq 'add_plugins' || $key eq 'disable_plugins'; @@ -83,7 +103,7 @@ sub showfields ($$$@) { #{{{ $form->field( name => $name, label => $description, - comment => defined $value && length $value ? "" : formatexample($info{example}), + comment => formatexample($info{example}, $value), type => "text", value => $value, size => 60, @@ -94,7 +114,7 @@ sub showfields ($$$@) { #{{{ $form->field( name => $name, label => $description, - comment => formatexample($info{example}), + comment => formatexample($info{example}, $value), type => "text", value => $value, size => 60, @@ -106,6 +126,7 @@ sub showfields ($$$@) { #{{{ $form->field( name => $name, label => $description, + comment => formatexample($info{example}, $value), type => "text", value => $value, size => 5, @@ -123,6 +144,11 @@ sub showfields ($$$@) { #{{{ fieldset => $section, ); } + + if (! $info{safe}) { + $form->field(name => $name, disabled => 1); + $form->text(gettext("Note: Disabled options cannot be configured here, but only by editing the setup file.")); + } } return 1; diff --git a/websetup.pm b/websetup.pm new file mode 120000 index 000000000..8ca7a8a64 --- /dev/null +++ b/websetup.pm @@ -0,0 +1 @@ +/home/joey/src/ikiwiki/IkiWiki/Plugin/websetup.pm \ No newline at end of file -- 2.26.2