This file is indexed.

/usr/share/GNUstep/SOGo/WebServerResources/SOGoRootPage.js is in sogo-common 2.1.1b-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
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

var dialogs = {};

function initLogin() {
    var date = new Date();
    date.setTime(date.getTime() - 86400000);

    var href = $("connectForm").action.split("/");
    var appName = href[href.length-2];

    document.cookie = ("0xHIGHFLYxSOGo=discarded"
                       + "; expires=" + date.toGMTString()
                       + "; path=/" + appName + "/");

    var about = $("about");
    if (about) {
        about.observe("click", function(event) {
                jQuery('#aboutBox').slideToggle('fast');
                event.stop(); });
        var aboutClose = $("aboutClose");
        aboutClose.observe("click", function(event) {
                jQuery('#aboutBox').slideUp('fast');
                event.stop() });
    }

    var submit = $("submit");
    submit.observe("click", onLoginClick);

    var userName = $("userName");
    userName.observe("keydown", onFieldKeyDown);

    var passw = $("password");
    passw.observe("keydown", onFieldKeyDown);

    var image = $("preparedAnimation");
    image.parentNode.removeChild(image);

    var submitBtn = $("submit");
    submitBtn.disabled = false;

    if (userName.value.empty())
        userName.focus();
    else
        passw.focus();
}

function onFieldKeyDown(event) {
    if (event.keyCode == Event.KEY_RETURN) {
        if ($("password").value.length > 0
            && $("userName").value.length > 0)
            return onLoginClick(event);
        else
            Event.stop(event);
    } else if (IsCharacterKey(event.keyCode)
               || event.keyCode == Event.KEY_BACKSPACE) {
        SetLogMessage("errorMessage", null);
    }
}

function onLoginClick(event) {
    var userNameField = $("userName");
    var userName = userNameField.value;
    var password = $("password").value;
    var language = $("language");
    var domain = $("domain");

    SetLogMessage("errorMessage");

    if (userName.length > 0 && password.length > 0) {
        this.disabled = true;
        startAnimation($("animation"));

        if (typeof(loginSuffix) != "undefined"
            && loginSuffix.length > 0
            && !userName.endsWith(loginSuffix))
            userName += loginSuffix;

        var url = $("connectForm").getAttribute("action");
        var parameters = ("userName=" + encodeURIComponent(userName)
                          + "&password=" + encodeURIComponent(password));
        if (language)
            parameters += ((language.value == "WONoSelectionString")
                           ? ""
                           : ("&language=" + language.value));
        if (domain)
            parameters += "&domain=" + domain.value;
        var rememberLogin = $("rememberLogin");
        if (rememberLogin && rememberLogin.checked)
            parameters += "&rememberLogin=1";

        /// Discarded as it seems to create a cookie for nothing. To discard
        //  a cookie in JS, have a look here: http://www.quirksmode.org/js/cookies.html
        //document.cookie = "";\
        triggerAjaxRequest(url, onLoginCallback, null, (parameters),
                           { "Content-type": "application/x-www-form-urlencoded",
                                   "Content-length": parameters.length,
                                   "Connection": "close" });
    }
    else
        userNameField.focus();

    preventDefault(event);
}

function onLoginCallback(http) {
    if (http.readyState == 4) {
        var submitBtn = $("submit");

        if (http.status == 200) {
            // Make sure browser's cookies are enabled
            var loginCookie = readLoginCookie();

            if (!loginCookie) {
                SetLogMessage("errorMessage", _("cookiesNotEnabled"));
                submitBtn.disabled = false;
                return;
            }

            var jsonResponse = http.responseText.evalJSON(false);
            if (jsonResponse
                && typeof(jsonResponse["expire"]) != "undefined"
                && typeof(jsonResponse["grace"]) != "undefined") {

                if (jsonResponse["expire"] < 0 && jsonResponse["grace"] > 0)
                    showPasswordDialog("grace", createPasswordGraceDialog, jsonResponse["grace"]);
                else if (jsonResponse["expire"] > 0 && jsonResponse["grace"] == -1)
                    showPasswordDialog("expiration", createPasswordExpirationDialog, jsonResponse["expire"]);
                else {
                    redirectToUserPage();
                }
            }
            else
                redirectToUserPage();
        }
        else {
            if (http.status == 403
                && http.getResponseHeader("content-type")
                == "application/json") {
                var jsonResponse = http.responseText.evalJSON(false);
                handlePasswordError(jsonResponse);
            } else {
                SetLogMessage("errorMessage", _("An unhandled error occurred."));
            }
            submitBtn.disabled = false;
        }
    }
}

function redirectToUserPage() {
    // Redirect to proper page
    var userName = $("userName").value;
    var domain = $("domain");
    if (domain)
        userName += '@' + domain.value;
    else if (typeof(loginSuffix) != "undefined"
        && loginSuffix.length > 0
        && !userName.endsWith(loginSuffix))
        userName += loginSuffix;
    var address = "" + window.location.href;
    var baseAddress = ApplicationBaseURL + encodeURIComponent(userName);
    var altBaseAddress;
    if (baseAddress[0] == "/") {
        var parts = address.split("/");
        var hostpart = parts[2];
        var protocol = parts[0];
        baseAddress = protocol + "//" + hostpart + baseAddress;
    }
    var altBaseAddress;
    var parts = baseAddress.split("/");
    parts.splice(3, 0);
    altBaseAddress = parts.join("/");

    var newAddress;
    if ((address.startsWith(baseAddress)
         || address.startsWith(altBaseAddress))
        && !address.endsWith("/logoff"))
        newAddress = address;
    else
        newAddress = baseAddress;
    window.location.href = newAddress;
}

function handlePasswordError(jsonResponse) {
    var perr = jsonResponse["LDAPPasswordPolicyError"];
    if (perr == PolicyNoError) {
        SetLogMessage("errorMessage", _("Wrong username or password."));
    } else if (perr == PolicyAccountLocked) {
        SetLogMessage("errorMessage",
                      _("Your account was locked due to too many failed attempts."));
    } else if (perr == PolicyChangeAfterReset) {
        showPasswordDialog("change", createPasswordChangeDialog, 5);
    } else if (perr == PolicyPasswordExpired) {
         SetLogMessage("errorMessage",
                      _("Your account was locked due to an expired password."));
    }
    else
        SetLogMessage("errorMessage",
                      _("Login failed due to unhandled error case: " + perr));
}

function showPasswordDialog(dialogType, constructor, parameters) {
    var dialog = dialogs[dialogType];
    if (!dialog) {
        dialog = constructor(parameters);
        var form = $("connectForm");
        form.appendChild(dialog);
        dialogs[dialogType] = dialog;
    }
    var password = $("password");
    var offsets = password.positionedOffset();
    dialog.show();
    var top = offsets[1] - 2;
    var left = offsets[0] + 10 - dialog.clientWidth;
    dialog.setStyle({ "top": top + "px", "left": left + "px"});
}

function createPasswordChangeDialog() {
    var fields = createElement("p");
    createElement("span", "passwordError", null, null, null, fields);

    var fieldNames = [ "newPassword", "newPassword2" ];
    var fieldLabels = [ _("New password:"), _("Confirmation:") ];
    for (var i = 0; i < fieldNames.length; i++) {
        var label = createElement("label", null, null, null, null, fields);
        label.appendChild(document.createTextNode(fieldLabels[i]));
        createElement("input", fieldNames[i], "textField",
                      { "name": fieldNames[i], "type": "password" },
                      null, label);
        createElement("br", null, null, null, null, fields);
    }

    var button = createButton("passwordOKButton", _("OK"), passwordDialogOK);
    button.addClassName("actionButton");
    fields.appendChild(button);
    fields.appendChild(document.createTextNode(" "));
    button = createButton("passwordCancelButton",
                          _("Cancel"), passwordDialogCancel);
    fields.appendChild(button);

    var dialog = createDialog("passwordChangeDialog",
                              _("Change your Password"),
                              _("Your password has expired, please enter a new one below:"),
                              fields,
                              "right");

    return dialog;
}

function passwordDialogOK(event) {
    var field = $("newPassword");
    var confirmationField = $("newPassword2");
    if (field && confirmationField) {
        var newPassword = field.value;
        if (newPassword == confirmationField.value) {
            if (newPassword.length > 0) {
                var userName = $("userName");
                var password = $("password");
                var policy = new PasswordPolicy(userName.value,
                                                password.value);
                policy.setCallbacks(onPasswordChangeSuccess,
                                    onPasswordChangeFailure);
                policy.changePassword(newPassword);
            }
            else
                SetLogMessage("passwordError",
                              _("Password must not be empty."));
        }
        else {
            SetLogMessage("passwordError",
                          _("The passwords do not match. Please try again."));
            field.focus();
            field.select();
        }
    }
    event.stop();
}

function onPasswordChangeSuccess() {
    SetLogMessage("passwordError", _("Please wait..."));
    redirectToUserPage();
}

function onPasswordChangeFailure(code, message) {
    SetLogMessage("passwordError", message);
}

function passwordDialogCancel(event) {
    var dialog = $("passwordChangeDialog");
    dialog.hide();
    event.stop();
}

function createPasswordGraceDialog(tries) {
    var button = createButton("graceOKButton", _("OK"));
    button.observe("click", passwordGraceDialogOK);
    button.addClassName("actionButton");

    return createDialog("passwordGraceDialog",
                        _("Password Grace Period"),
                        _("You have %{0} logins remaining before your account is locked. Please change your password in the preference dialog.").formatted(tries),
                        button,
                        "right");
}

function passwordGraceDialogOK(event) {
    var dialog = $("passwordGraceDialog");
    dialog.hide();
    event.stop();
    redirectToUserPage();
}

function createPasswordExpirationDialog(expire) {
    var button = createButton("expirationOKButton", _("OK"));
    button.observe("click", passwordExpirationDialogOK);
    button.addClassName("actionButton");

    var value, string;

    if (expire > 86400) {
        value = Math.round(expire/86400);
        string = _("days");
    }
    else if (expire > 3600) {
        value = Math.round(expire/3600);
        string = _("hours");
    }
    else if (expire > 60) {
        value = Math.round(expire/60);
        string = _("minutes");
    }
    else {
        value = expire;
        string = _("seconds");
    }
    return createDialog("passwordExpirationDialog",
                        _("Password about to expire"),
                        _("Your password is going to expire in %{0} %{1}.").formatted(value, string),
                        button,
                        "right");
}

function passwordExpirationDialogOK(event) {
    var dialog = $("passwordExpirationDialog");
    dialog.hide();
    event.stop();
    redirectToUserPage();
}

document.observe("dom:loaded", initLogin);