diff options
author | Thorvald Natvig <slicer@users.sourceforge.net> | 2010-02-15 20:18:06 +0300 |
---|---|---|
committer | Thorvald Natvig <slicer@users.sourceforge.net> | 2010-02-15 20:18:06 +0300 |
commit | 7ba42b7902d11bcedad825952481be4f90810a02 (patch) | |
tree | 61c86f8db4b46535181f383bd3852e6d2449d65e /scripts | |
parent | 9d3a304e0b2a6cb5b829a9fec317c193db4232a5 (diff) |
Split icesecret in icesecretread and icesecretwrite
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/mkwrapper.pl | 75 | ||||
-rw-r--r-- | scripts/murmur.ini | 9 | ||||
-rwxr-xr-x | scripts/testcallback.py | 4 |
3 files changed, 69 insertions, 19 deletions
diff --git a/scripts/mkwrapper.pl b/scripts/mkwrapper.pl index 39f5748e1..533887901 100644 --- a/scripts/mkwrapper.pl +++ b/scripts/mkwrapper.pl @@ -9,30 +9,65 @@ open(MI, "MurmurIce.cpp"); my @mi = <MI>; close(MI); +my $ice; +open(ICE, "Murmur.ice"); +my @ice=<ICE>; +close(ICE); +$ice = join("", @ice); + +$ice =~ s/\/\*.+?\*\///gms; +$ice =~ s/^\t+//gm; +$ice =~ s/\n+/\n/gs; +$ice =~ s/^\n+//s; + +$ice =~ s/"/\\"/g; +$ice =~ s/\n/\\n/g; + open(I, ">MurmurIceWrapper.cpp"); open(B, ">BasicImpl.cpp"); open(MH, "Murmur.h"); sub func($$\@\@\@) { my ($class, $func, $wrapargs, $callargs, $implargs) = @_; + - print I "void ::Murmur::${class}I::${func}_async(". join(", ", @{$wrapargs}).") {\n"; -# print I "\tqWarning(\"CALL ${func}\");\n"; - print I "\tif (! meta->mp.qsIceSecret.isEmpty()) {\n"; - print I "\t\t::Ice::Context::const_iterator i = current.ctx.find(\"secret\");\n"; - print I "\t\tif ((i == current.ctx.end()) || (u8((*i).second) != meta->mp.qsIceSecret)) {\n"; - print I "\t\t\tcb->ice_exception(InvalidSecretException());\n"; - print I "\t\t\treturn;\n"; - print I "\t\t}\n"; - print I "\t}\n"; - print I "\tExecEvent *ie = new ExecEvent(boost::bind(&impl_${class}_$func, " . join(", ", @${callargs})."));\n"; - print I "\tQCoreApplication::instance()->postEvent(mi, ie);\n"; - print I "};\n"; - - if( ! grep(/impl_${class}_$func/,@mi)) { - print B "static void impl_${class}_$func(".join(", ", @${implargs}). ") {}\n"; - } + print I qq' +void ::Murmur::${class}I::${func}_async('. join(", ", @{$wrapargs}).qq') { + // qWarning() << "${func}" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty(); +#ifndef ACCESS_${class}_${func}_ALL +#ifdef ACCESS_${class}_${func}_READ + if (! meta->mp.qsIceSecretRead.isNull()) { + bool ok = ! meta->mp.qsIceSecretRead.isEmpty(); +#else + if (! meta->mp.qsIceSecretRead.isNull() || ! meta->mp.qsIceSecretWrite.isNull()) { + bool ok = ! meta->mp.qsIceSecretWrite.isEmpty(); +#endif + ::Ice::Context::const_iterator i = current.ctx.find("secret"); + ok = ok && (i != current.ctx.end()); + if (ok) { + const QString &secret = u8((*i).second); +#ifdef ACCESS_${class}_${func}_READ + ok = ((secret == meta->mp.qsIceSecretRead) || (secret == meta->mp.qsIceSecretWrite)); +#else + ok = (secret == meta->mp.qsIceSecretWrite); +#endif + } + if (! ok) { + cb->ice_exception(InvalidSecretException()); + return; + } + } +#endif + ExecEvent *ie = new ExecEvent(boost::bind(&impl_${class}_$func, ' . join(", ", @${callargs}).qq')); + QCoreApplication::instance()->postEvent(mi, ie); } +'; + + if( ! grep(/impl_${class}_$func/,@mi)) { + print B "static void impl_${class}_$func(".join(", ", @${implargs}). ") {}\n"; + } +} + while(<MH>) { chomp(); @@ -46,6 +81,8 @@ while(<MH>) { my $func=$1; my $obj=$2; my $args=$3; + + next if ($func eq "getSlice"); my $class="Meta"; $class = "Server" if ($obj =~ /AMD_Server/); @@ -79,6 +116,12 @@ while(<MH>) { func($class,$func,@wrapargs,@callargs,@implargs); } } + +print I qq' +void ::Murmur::MetaI::getSlice_async(const ::Murmur::AMD_Meta_getSlicePtr& cb, const Ice::Current&) { + cb->ice_response(std::string("$ice")); +} +'; close(MH); close(I); diff --git a/scripts/murmur.ini b/scripts/murmur.ini index d454223f9..eefdf35b3 100644 --- a/scripts/murmur.ini +++ b/scripts/murmur.ini @@ -35,7 +35,14 @@ dbus=session # user account on your machine can connect to the Ice services. # You can set a plaintext "secret" on the Ice conntection, and # any script attempting to access must then have this secret. -#icesecret= +# Access is split in read (look only) and write (modify) +# operations. +# +# Note that if this is uncommented and with empty content, +# access will be denied. + +#icesecretread= +icesecretwrite= # How many login attempts do we tolerate from one IP # inside a given timeframe before we ban the connection? diff --git a/scripts/testcallback.py b/scripts/testcallback.py index 0939794be..fe07522e5 100755 --- a/scripts/testcallback.py +++ b/scripts/testcallback.py @@ -89,10 +89,10 @@ if __name__ == "__main__": meta = Murmur.MetaPrx.checkedCast(ice.stringToProxy('Meta:tcp -h 127.0.0.1 -p 6502')) adapter = ice.createObjectAdapterWithEndpoints("Callback.Client", "tcp -h 127.0.0.1") - + metaR=Murmur.MetaCallbackPrx.uncheckedCast(adapter.addWithUUID(MetaCallbackI())) adapter.activate() - + meta.addCallback(metaR) for server in meta.getBootedServers(): |