This file is indexed.

/usr/share/php/irods/prods/src/RODSMessage.class.php is in php-irods-prods 3.3.0~beta1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php

require_once("autoload.inc.php");

$GLOBALS['RODSMessage_types'] = array(
    "RODS_CONNECT_T" => "RODS_CONNECT",
    "RODS_VERSION_T" => "RODS_VERSION",
    "RODS_API_REQ_T" => "RODS_API_REQ",
    "RODS_DISCONNECT_T" => "RODS_DISCONNECT",
    "RODS_REAUTH_T" => "RODS_REAUTH",
    "RODS_API_REPLY_T" => "RODS_API_REPLY"
);

class RODSMessage
{
    private $type; // (String) message type, such as "RODS_CONNECT_T"
    private $typestr; // (String) str representation of the type that RODS server understand
    private $msg; // (RODSPacket) main message body
    private $header; // (RODSPacket) a special packet, header for other packets
    private $header_xml; // (string) packet header in XML
    private $msg_xml; // (string) message in XML
    private $binstr; // (string) binary string
    private $errstr; // (string) error string
    private $intinfo; // an additional integer info, for API, it is the
    // apiReqNum
    private $serialized;

    public function __construct($type = NULL, $_msg = NULL, $intinfo = 0, $binstr = "", $errstr = "")
    {
        if (!isset($type)) {
            return;
        }

        $this->type = $type;
        $RODSMessage_types = $GLOBALS['RODSMessage_types'];
        if (!isset($RODSMessage_types[$type])) {
            throw new RODSException("RODSMessage::__construct failed.1! Unknown type '$type'",
                "PERR_INTERNAL_ERR");
        }
        $this->typestr = $RODSMessage_types[$type];

        if (isset($_msg)) {
            if (!($_msg instanceof RODSPacket)) {
                throw new RODSException("RODSMessage::__construct failed.2!",
                    "PERR_INTERNAL_ERR");
            }
        }
        $this->msg = $_msg;
        $this->intinfo = $intinfo;
        $this->binstr = $binstr;
        $this->errstr = $errstr;
    }

    public function pack()
    {
        if (isset($this->msg))
            $this->msg_xml = $this->msg->toXML();

        $this->header = new RP_MsgHeader($this->typestr, strlen($this->msg_xml),
            strlen($this->errstr), strlen($this->binstr), $this->intinfo);
        $header_xml = $this->header->toXML();
        $this->serialized = pack("N", strlen($header_xml)) . $header_xml .
            $this->msg_xml;
        return $this->serialized;
    }


    public function unpack($conn, &$bslen = NULL)
    {
        if (FALSE === ($chunk = stream_get_contents($conn, 4))) {
            throw new RODSException("RODSMessage::unpack failed.0! ",
                "SYS_PACK_INSTRUCT_FORMAT_ERR");
        }


        $arr = unpack("Nlen", $chunk);
        $header_len = $arr['len'];
        if ((!is_int($header_len)) || ($header_len < 1) || ($header_len > 8192 - 4)) {
            throw new RODSException("RODSMessage::unpack failed.1! The header length is unexpected: '$header_len'",
                "SYS_PACK_INSTRUCT_FORMAT_ERR");
        }

        $this->header_xml = stream_get_contents($conn, $header_len);
        $this->parseHeaderXML($this->header_xml);
        $intInfo = $this->header->intInfo;

        // get main msg string
        $msg_len = $this->header->msgLen;
        $this->msg_xml = stream_get_contents($conn, $msg_len);
        if ($msg_len != strlen($this->msg_xml)) {
            throw new RODSException("RODSMessage::unpack failed.2! " .
                    "The body length is unexpected: " . strlen($this->msg_xml) .
                    " expecting: $msg_len",
                "SYS_PACK_INSTRUCT_FORMAT_ERR");
        }
        if ($msg_len > 0) {
            $this->parseBodyXML($this->msg_xml);
        }

        // get err string
        $errlen = $this->header->errorLen;
        $this->errstr = stream_get_contents($conn, $errlen);
        if ($errlen != strlen($this->errstr)) {
            throw new RODSException("RODSMessage::unpack failed.3! " .
                    "The err length is unexpected: " . strlen($this->errstr) .
                    " expecting: $errlen",
                "SYS_PACK_INSTRUCT_FORMAT_ERR");
        }

        // get bin string
        $bslen = $this->header->bsLen;
        $this->binstr = stream_get_contents($conn, $bslen);
        if ($bslen != strlen($this->binstr)) {
            throw new RODSException("RODSMessage::unpack failed.4! " .
                    "The bin str length is unexpected: " . strlen($this->binstr) .
                    " expecting: $bslen",
                "SYS_PACK_INSTRUCT_FORMAT_ERR");
        }

        return $this->header->intInfo;
    }

    private function parseHeaderXML($xmlstr)
    {
        $xml = new SimpleXMLElement($xmlstr);
        $name = $xml->getName();
        if ($name != "MsgHeader_PI") {
            throw new RODSException("RODSMessage::parseHeaderXML failed! " .
                    "The XML header name is unexpected:$name " .
                    " expecting: MsgHeader_PI",
                "SYS_PACK_INSTRUCT_FORMAT_ERR");
        }
        $this->header = new RP_MsgHeader();
        $this->header->fromSXE($xml);
    }

    private function parseBodyXML($xmlstr)
    {
        //try {
        $xml = new SimpleXMLElement($xmlstr);
        $name = $xml->getName();
        if (substr($name, -3, 3) != "_PI") {
            throw new RODSException("RODSMessage::parseMainBodyXML failed! " .
                    "The XML node's name is unexpected:$name " .
                    " expecting some thing like xxx_PI",
                "SYS_PACK_INSTRUCT_FORMAT_ERR");
        }
        $rp_classname = "RP_" . substr($name, 0, strlen($name) - 3);
        $this->msg = new $rp_classname();
        $this->msg->fromSXE($xml);

        /*} catch (Exception $e) {
          throw new RODSException("RODSMessage::parseMainBodyXML failed! ".
              "Mal formated XML in RODS message :".
              $xmlstr,
              "SYS_PACK_INSTRUCT_FORMAT_ERR",$e);
        }
        */
    }

    public function getBody()
    {
        return $this->msg;
    }

    public function getBinstr()
    {
        return $this->binstr;
    }

    public function getXML()
    {
        return $this->header_xml . "\n" . $this->msg_xml;
    }

    public static function packConnectMsg($user, $zone, $relVersion = RODS_REL_VERSION,
                                          $apiVersion = RODS_API_VERSION, $option = NULL)
    {
        $msgbody = new RP_StartupPack($user, $zone, $relVersion, $apiVersion . $option);
        $rods_msg = new RODSMessage("RODS_CONNECT_T", $msgbody);
        return $rods_msg->pack();
    }
}

?>