This file is indexed.

/usr/share/php/OpenCloud/DNS/Service.php is in php-opencloud 1.10.0-2.

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
<?php
/**
 * Copyright 2012-2014 Rackspace US, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace OpenCloud\DNS;

use OpenCloud\Common\Http\Message\Formatter;
use OpenCloud\Common\Service\CatalogService;
use OpenCloud\Compute\Resource\Server;
use OpenCloud\DNS\Collection\DnsIterator;
use OpenCloud\DNS\Resource\HasPtrRecordsInterface;

/**
 * DNS Service.
 */
class Service extends CatalogService
{
    const DEFAULT_TYPE = 'rax:dns';
    const DEFAULT_NAME = 'cloudDNS';

    protected $regionless = true;

    public function collection($class, $url = null, $parent = null, $data = null)
    {
        $options = $this->makeResourceIteratorOptions($this->resolveResourceClass($class));
        $options['baseUrl'] = $url;

        $parent = $parent ? : $this;

        return DnsIterator::factory($parent, $options, $data);
    }

    /**
     * Returns a domain
     *
     * @param mixed $info either the ID, an object, or array of parameters
     * @return Resource\Domain
     */
    public function domain($info = null)
    {
        return $this->resource('Domain', $info);
    }

    /**
     * Returns a collection of domains
     *
     * @param array $filter key/value pairs to use as query strings
     * @return \OpenCloud\Common\Collection
     */
    public function domainList($filter = array())
    {
        $url = $this->getUrl(Resource\Domain::resourceName());
        $url->setQuery($filter);

        return $this->resourceList('Domain', $url);
    }

    /**
     * returns a PtrRecord object for a server
     *
     * @param mixed $info ID, array, or object containing record data
     * @return Resource\Record
     */
    public function ptrRecord($info = null)
    {
        return $this->resource('PtrRecord', $info);
    }

    /**
     * returns a Collection of PTR records for a given Server
     *
     * @param \OpenCloud\Compute\Resource\Server $server the server for which to
     *                                                   retrieve the PTR records
     * @return \OpenCloud\Common\Collection
     */
    public function ptrRecordList(HasPtrRecordsInterface $parent)
    {
        $url = $this->getUrl()
            ->addPath('rdns')
            ->addPath($parent->getService()->getName())
            ->setQuery(array('href' => (string) $parent->getUrl()));

        return $this->resourceList('PtrRecord', $url);
    }

    /**
     * retrieves an asynchronous response
     *
     * This method calls the provided `$url` and expects an asynchronous
     * response. It checks for various HTTP error codes and returns
     * an `AsyncResponse` object. This object can then be used to poll
     * for the status or to retrieve the final data as needed.
     *
     * @param string $url     the URL of the request
     * @param string $method  the HTTP method to use
     * @param array  $headers key/value pairs for headers to include
     * @param string $body    the body of the request (for PUT and POST)
     * @return Resource\AsyncResponse
     */
    public function asyncRequest($url, $method = 'GET', $headers = array(), $body = null)
    {
        $response = $this->getClient()->createRequest($method, $url, $headers, $body)->send();

        return new Resource\AsyncResponse($this, Formatter::decode($response));
    }

    /**
     * Imports domain records
     *
     * Note that this function is called from the service (DNS) level, and
     * not (as you might suspect) from the Domain object. Because the function
     * return an AsyncResponse, the domain object will not actually exist
     * until some point after the import has occurred.
     *
     * @param string $data the BIND_9 formatted data to import
     * @return Resource\AsyncResponse
     */
    public function import($data)
    {
        $url = clone $this->getUrl();
        $url->addPath('domains');
        $url->addPath('import');

        $object = (object) array(
            'domains' => array(
                (object) array(
                    'contents'    => $data,
                    'contentType' => 'BIND_9'
                )
            )
        );

        // encode it
        $json = json_encode($object);

        // perform the request
        return $this->asyncRequest($url, 'POST', self::getJsonHeader(), $json);
    }

    /**
     * returns a list of limits
     */
    public function limits($type = null)
    {
        $url = $this->getUrl('limits');

        if ($type) {
            $url->addPath($type);
        }

        $response = $this->getClient()->get($url)->send();
        $body = Formatter::decode($response);

        return isset($body->limits) ? $body->limits : $body;
    }

    /**
     * returns an array of limit types
     *
     * @return array
     */
    public function limitTypes()
    {
        $response = $this->getClient()->get($this->getUrl('limits/types'))->send();
        $body = Formatter::decode($response);

        return $body->limitTypes;
    }
}