~ubuntu-branches/ubuntu/oneiric/mcollective/oneiric-proposed

« back to all changes in this revision

Viewing changes to plugins/mcollective/security/psk.rb

  • Committer: Bazaar Package Importer
  • Author(s): Marc Cluet, Marc Cluet, Chuck Short
  • Date: 2011-05-05 07:37:54 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110505073754-klk1jkz8afi4fomx
Tags: 1.2.0-0ubuntu1
[Marc Cluet]
* Update to 1.2.0
* Build for Oneiric.

[Chuck Short]
* Drop ruby from mcollective, mcollective-middleware, mcollective-client
  since its a dependency of mcollective-common.
* Bump standards to 3.9.2.
* Fix up lintian warnings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
            end
31
31
 
32
32
            # Encodes a reply
33
 
            def encodereply(sender, target, msg, requestid, filter={})
 
33
            def encodereply(sender, target, msg, requestid, requestcallerid=nil)
34
34
                serialized  = Marshal.dump(msg)
35
35
                digest = makehash(serialized)
36
36
 
37
 
                @log.debug("Encoded a message with hash #{digest} for request #{requestid}")
 
37
                req = create_reply(requestid, sender, target, serialized)
 
38
                req[:hash] = digest
38
39
 
39
 
                Marshal.dump({:senderid => @config.identity,
40
 
                              :requestid => requestid,
41
 
                              :senderagent => sender,
42
 
                              :msgtarget => target,
43
 
                              :msgtime => Time.now.to_i,
44
 
                              :hash => digest,
45
 
                              :body => serialized})
 
40
                Marshal.dump(req)
46
41
            end
47
42
 
48
43
            # Encodes a request msg
49
 
            def encoderequest(sender, target, msg, requestid, filter={})
 
44
            def encoderequest(sender, target, msg, requestid, filter={}, target_agent=nil, target_collective=nil)
50
45
                serialized = Marshal.dump(msg)
51
46
                digest = makehash(serialized)
52
47
 
53
 
                @log.debug("Encoding a request for '#{target}' with request id #{requestid}")
54
 
                request = {:body => serialized,
55
 
                           :hash => digest,
56
 
                           :senderid => @config.identity,
57
 
                           :requestid => requestid,
58
 
                           :msgtarget => target,
59
 
                           :filter => filter,
60
 
                           :msgtime => Time.now.to_i}
61
 
 
62
 
                # if we're in use by a client add the callerid to the main client hashes
63
 
                request[:callerid] = callerid if @initiated_by == :client
64
 
 
65
 
                Marshal.dump(request)
 
48
                req = create_request(requestid, target, filter, serialized, @initiated_by, target_agent, target_collective)
 
49
                req[:hash] = digest
 
50
 
 
51
                Marshal.dump(req)
66
52
            end
67
53
 
68
54
            # Checks the md5 hash in the request body against our psk, the request sent for validation
105
91
                        id ="uid=#{Process.uid}"
106
92
                end
107
93
 
108
 
                @log.debug("Setting callerid to #{id} based on callertype=#{callertype}")
 
94
                Log.debug("Setting callerid to #{id} based on callertype=#{callertype}")
109
95
 
110
96
                id
111
97
            end