This file is indexed.

/usr/share/mediatomb/web/js/auth.js is in mediatomb-common 0.12.1-0ubuntu4.

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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/*MT*
    
    MediaTomb - http://www.mediatomb.cc/
    
    auth.js - this file is part of MediaTomb.
    
    Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>,
                       Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
    
    Copyright (C) 2006-2010 Gena Batyan <bgeradz@mediatomb.cc>,
                            Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
                            Leonhard Wimmer <leo@mediatomb.cc>
    
    MediaTomb is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License version 2
    as published by the Free Software Foundation.
    
    MediaTomb is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    version 2 along with MediaTomb; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
    
    $Id: auth.js 2081 2010-03-23 20:18:00Z lww $
*/

function authenticate()
{
    
    // fetch authentication token
    var url = link('auth', {action: 'get_token'});
    
    var myAjax = new Ajax.Request(
        url,
        {
            method: 'get',
            onComplete: gotToken
        });
}

function gotToken(ajaxRequest)
{
    var xml = ajaxRequest.responseXML;
    if (!errorCheck(xml)) return;
    
    var rootEl = xmlGetElement(xml, "root");
    
    var token = xmlGetElementText(rootEl, "token");
    
    var username = frames["rightF"].document.login_form.username.value;
    var password = frames["rightF"].document.login_form.password.value;
    
    // create authentication password
    password = hex_md5(token + password);
    // try to login
    var url = link('auth', {action: 'login', username: username, password: password});
    var myAjax = new Ajax.Request(
        url,
        {
            method: 'get',
            onComplete: checkLogin
        });
}

function checkLogin(ajaxRequest)
{
    var xml = ajaxRequest.responseXML;
    if (!errorCheck(xml)) return;
    
    var topDocument = frames["topF"].document;
    var rightDocument = frames["rightF"].document;
    var leftDocument = frames["leftF"].document;
    Element.hide(rightDocument.getElementById("loginDiv"));
    Element.hide(leftDocument.getElementById("leftLoginDiv"));
    //Element.show(topDocument.getElementById("topDiv"));
    Element.show(topDocument.getElementById("statusDiv"));
    Element.show(frames["leftF"].document.getElementById("treeDiv"));
    Element.show(frames["topleftF"].document.getElementById("db_fs_selector"));
    if (ACCOUNTS)
        Element.show(topDocument.getElementById("logout_link"));
    loggedIn = true;
    initLoggedIn();
    updateTreeAfterLogin();
}

function checkSID()
{
    var url = link('auth', {action: 'get_sid'});
    var myAjax = new Ajax.Request(
        url,
        {
            method: 'get',
            asynchronous: false,
            onComplete: checkSIDcallback
        });
}

function checkSIDcallback(ajaxRequest)
{
    var xml = ajaxRequest.responseXML;
    errorCheck(xml, true);
    var rootEl = xmlGetElement(xml, "root");
    var sidWasValid = xmlGetAttribute(rootEl, "sid_was_valid") == "1";
    if (! sidWasValid)
    {
        var newSID = xmlGetAttribute(rootEl, "sid");
        if (newSID)
        {
            SID = newSID;
            setCookie("SID", SID);
        }
    }
    LOGGED_IN = xmlGetAttribute(rootEl, "logged_in") == "1";
}

function logout()
{
    var url = link('auth', {action: 'logout'});
    var myAjax = new Ajax.Request(
        url,
        {
            method: 'get',
            asynchronous: false,
            onComplete: handleLogout
        });
}

function handleLogout(ajaxRequest)
{
    errorCheck(ajaxRequest.responseXML);
    var now = new Date();
    var expire = new Date();
    expire.setTime(now.getTime() - 3600000 * 24 * 360);
    setCookie('SID', null, expire);
    SID = null;
    window.location = '/';
}

function getConfig()
{
    var url = link('auth', {action: 'get_config'});
    var myAjax = new Ajax.Request(
        url,
        {
            method: 'get',
            asynchronous: false,
            onComplete: getConfigCallback
        });
}

function getConfigCallback(ajaxRequest)
{
    var xml = ajaxRequest.responseXML;
    errorCheck(xml, true);
    var rootEl = xmlGetElement(xml, "root");
    var configEl = xmlGetElement(rootEl, "config");
    if (configEl)
    {
        accountsStr = xmlGetAttribute(configEl, "accounts");
        ACCOUNTS = (accountsStr && accountsStr == "1");
        pollIntervalTime = xmlGetAttribute(configEl, "poll-interval") * 1000;
        pollWhenIdle = (xmlGetAttribute(configEl, "poll-when-idle") == 1);
        showTooltips = (xmlGetAttribute(configEl, "show-tooltips") == 1);
        if (pollWhenIdle)
            startPollInterval();
        var itemsPerPageOptionsEl = xmlGetElement(configEl, "items-per-page");
        if (itemsPerPageOptionsEl)
        {
            var newDefaultViewItems = xmlGetAttribute(itemsPerPageOptionsEl, "default");
            var options = itemsPerPageOptionsEl.getElementsByTagName("option");
            var newItemOptions = new Array();
            var newViewItemsMin = -1;
            var defaultViewItemsFound = false;
            var currentViewItemsFound = false;
            for (var i = 0; i < options.length; i++)
            {
                var itemOption = options[i].firstChild.nodeValue;
                newItemOptions[i] = itemOption;
                if (itemOption == newDefaultViewItems)
                    defaultViewItemsFound = true;
                if (viewItems != -1 && itemOption == viewItems)
                    currentViewItemsFound = true;
                if (newViewItemsMin == -1 || itemOption < newViewItemsMin)
                    newViewItemsMin = itemOption;
            }
            if (defaultViewItemsFound)
            {
                itemOptions = newItemOptions;
                viewItemsMin = newViewItemsMin;
                if (! currentViewItemsFound)
                    viewItems = newDefaultViewItems;
            }
        }
        var haveInotify = (xmlGetAttribute(configEl, "have-inotify") == "1");
        if (haveInotify)
        {
            Element.show(frames["rightF"].document.getElementById("scan_mode_inotify"));
            Element.show(frames["rightF"].document.getElementById("scan_mode_inotify_label"));
        }
        var actionsEl = xmlGetElement(configEl, "actions");
        if (actionsEl)
        {
            var actions = actionsEl.getElementsByTagName("action");
            for (var i = 0; i < actions.length; i++)
            {
                var action = actions[i].firstChild.nodeValue;
                var actionEl = frames["topF"].document.getElementById("action_"+action);
                if (actionEl)
                {
                    Element.show(actionEl);
                }
            }
        }
    }
}