- import Faults
authorMark Huang <mlhuang@cs.princeton.edu>
Mon, 8 Jan 2007 18:19:07 +0000 (18:19 +0000)
committerMark Huang <mlhuang@cs.princeton.edu>
Mon, 8 Jan 2007 18:19:07 +0000 (18:19 +0000)
- add peer check

PLC/Methods/UpdatePeer.py

index 5a298d9..dd5f2c8 100644 (file)
@@ -1,3 +1,4 @@
+from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
 from PLC.Auth import Auth
@@ -34,8 +35,12 @@ class UpdatePeer(Method):
         peers = Peers(self.api, [peer_id_or_name])
         if not peers:
             raise PLCInvalidArgument, "No such peer"
-
         peer = peers[0]
+
+        if isinstance(self.caller, Peer):
+            if self.caller['peer_id'] != peer['peer_id']:
+                raise PLCPermissionDenied, "Not allowed to update specified peer"
+
         peer.update(peer_fields)
         peer.sync()