diff options
author | RaindropsSys <contact@minteck.org> | 2023-06-18 13:01:49 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-06-18 13:01:49 +0200 |
commit | 4480e889a967e571e89eb312b7ead883b827ed28 (patch) | |
tree | 7da95d791b6c56e514edef7cccc75f6c88929d7c /core | |
parent | 391ed3d1afa0334390df24af3f1ab13cf7066a84 (diff) | |
download | kirinos-4480e889a967e571e89eb312b7ead883b827ed28.tar.gz kirinos-4480e889a967e571e89eb312b7ead883b827ed28.tar.bz2 kirinos-4480e889a967e571e89eb312b7ead883b827ed28.zip |
Updated 3 files and added 11 files (automated)
Diffstat (limited to 'core')
-rw-r--r-- | core/login/back.svg | 1 | ||||
-rw-r--r-- | core/login/decrypt.sh | 9 | ||||
-rw-r--r-- | core/login/index.html | 260 | ||||
-rw-r--r-- | core/login/restart.svg | 1 | ||||
-rw-r--r-- | core/login/shutdown.svg | 1 | ||||
-rw-r--r-- | core/login/sleep.svg | 1 | ||||
-rw-r--r-- | core/login/unwrap.js | 1 | ||||
-rw-r--r-- | core/startup/encryption.sh | 1 | ||||
-rw-r--r-- | core/startup/index.html | 7 |
9 files changed, 282 insertions, 0 deletions
diff --git a/core/login/back.svg b/core/login/back.svg new file mode 100644 index 0000000..5811847 --- /dev/null +++ b/core/login/back.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M480-160 160-480l320-320 42 42-248 248h526v60H274l248 248-42 42Z"/></svg>
\ No newline at end of file diff --git a/core/login/decrypt.sh b/core/login/decrypt.sh new file mode 100644 index 0000000..b18f84e --- /dev/null +++ b/core/login/decrypt.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +ID=$1 +PASSWORD=$2 + +B64=$(echo "$PASSWORD" | base64 -w0) +KEY=$(cat /mango/users/$ID/key) +PASSPHRASE=$(node unwrap.js $ID $B64) +mount -t ecryptfs /mango/users/$ID/lock /mango/users/$ID/home -o verbosity=0,key=passphrase:passphrase_passwd=$PASSPHRASE,ecryptfs_sig=$KEY,ecryptfs_fnek_sig=$KEY,ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_unlink_sigs
\ No newline at end of file diff --git a/core/login/index.html b/core/login/index.html new file mode 100644 index 0000000..3d647d1 --- /dev/null +++ b/core/login/index.html @@ -0,0 +1,260 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>mangoos</title> + <style> + * { + font-family: "Inter", sans-serif; + user-select: none; + -webkit-user-drag: none; + outline: none; + } + + html, body { + background-color: cornflowerblue; + color: black; + margin: 0; + } + + ::-webkit-scrollbar { + width: 7px; + } + + ::-webkit-scrollbar-track { + background: transparent; + } + + ::-webkit-scrollbar-thumb { + background: rgba(0, 0, 0, .25); + border-radius: 999px; + } + + ::-webkit-scrollbar-thumb:hover { + background: rgba(0, 0, 0, .35); + } + + ::-webkit-scrollbar-thumb:active { + background: rgba(0, 0, 0, .5); + } + + .user-card-avatar { + display: block; + margin-left: auto; + margin-right: auto; + width: 64px; + height: 64px; + border-radius: 999px; + } + + #login-card-avatar { + width: 64px; + height: 64px; + border-radius: 999px; + } + + .login-card { + display: grid; + grid-template-columns: max-content max-content; + width: 256px; + grid-gap: 10px; + margin-left: auto; + margin-right: auto; + } + + .user-card-name { + display: block; + width: max-content; + margin-left: auto; + margin-right: auto; + } + + #users { + display: grid; + grid-template-columns: repeat(5, 1fr); + margin: 20px 50px 0; + } + + .user-card:hover, .login-action:hover { + background: rgba(0, 0, 0, .05); + } + + .user-card { + padding: 10px; + border-radius: 10px; + } + + .user-card:active, .login-action:active { + background: rgba(0, 0, 0, .075); + } + + .login-action { + border-radius: 5px; + width: 32px; + height: 32px; + display: inline-flex; + align-items: center; + justify-content: center; + } + + #login-card-password { + width: 182px; + border: 0; + height: 24px; + padding: 5px 20px; + border-radius: 999px; + background: rgba(0, 0, 0, .025); + } + </style> +</head> +<body style="opacity: 0; pointer-events: none;"> + <div style="display: flex; align-items: center; justify-content: center; position: fixed; inset: 0;"> + <div style="background: rgba(255, 255, 255, .75); backdrop-filter: blur(10px); padding: 50px; width: 512px; height: 256px; border-radius: 10px;"> + <div style="background: rgba(0, 0, 0, .1); margin: -50px -50px 0; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom: 1px solid rgba(0, 0, 0, .1); height: 80px;"> + <div style="display: inline-flex; align-items: center;margin: 0 10px; height: 100%; width: max-content;"> + <img src="../../logo.svg" style="width: 64px;"> + <h2 style="margin-left: 5px;" id="clock">--:--</h2> + <script> + document.getElementById("clock").innerText = (new Intl.DateTimeFormat('en-IE', { + hour: 'numeric', + minute: '2-digit' + })).format(new Date()); + </script> + </div> + <div style="float: right; display: flex; align-items: center; height: 100%; margin: 0 25px;" id="power-actions"> + <a class="login-action" onclick="shutdown();"> + <img src="shutdown.svg" style="width: 24px;"> + </a> + <a class="login-action" onclick="restart();"> + <img src="restart.svg" style="width: 24px;"> + </a> + <a class="login-action" onclick="sleep();"> + <img src="sleep.svg" style="width: 24px;"> + </a> + </div> + </div> + <div style="height: calc(100% + 19px); margin: 0 -50px -50px;overflow-y: scroll;"> + <div id="users"></div> + <div id="login" style="display: none; padding: 10px; height: calc(100% - 20px);"> + <a id="login-back" class="login-action" onclick="cancelLogin();"> + <img src="back.svg" style="width: 24px;"> + </a> + + <div class="login-card" style="height: calc(100% - 64px);"> + <div style="display: flex; align-items: center;"> + <img src="" alt="" id="login-card-avatar"> + </div> + <div style="display: flex; align-items: center;"> + <div> + <h3 id="login-card-name" style="margin: 0 0 5px;"></h3> + <input type="password" id="login-card-password" placeholder="Enter password"> + <img src="../startup/loader.svg" style="height: 30px; display: none;" id="login-card-loader"> + </div> + </div> + </div> + </div> + </div> + </div> + </div> + + <script> + for (let user of require('fs').readdirSync("/mango/users")) { + document.getElementById("users").innerHTML += `<a onclick="loginAs('${user}')"> + <div class="user-card"> + <img src="${require('fs').existsSync("/mango/users/" + user + "/avatar") ? "file:///mango/users/" + user + "/avatar" : "../../defaultuser.svg"}" alt="" class="user-card-avatar"> + <span class="user-card-name">${require('fs').existsSync("/mango/users/" + user + "/name") ? require('fs').readFileSync("/mango/users/" + user + "/name").toString().trim() : user}</span> + </div> + </a>`; + } + + function sleep() { + require('child_process').execSync("suspend"); + } + + function shutdown() { + document.body.style.opacity = "0"; + document.body.style.pointerEvents = "none"; + require('child_process').execSync("poweroff"); + } + + function restart() { + document.body.style.opacity = "0"; + document.body.style.pointerEvents = "none"; + require('child_process').execSync("reboot"); + } + + window.onload = () => { + document.body.style.opacity = ""; + document.body.style.pointerEvents = ""; + } + + window.currentUser = null; + + function loginAs(id) { + window.currentUser = id; + + document.getElementById("login-card-avatar").src = require('fs').existsSync("/mango/users/" + id + "/avatar") ? "file:///mango/users/" + id + "/avatar" : "../../defaultuser.svg"; + document.getElementById("login-card-name").innerText = require('fs').existsSync("/mango/users/" + id + "/name") ? require('fs').readFileSync("/mango/users/" + id + "/name").toString().trim() : id; + document.getElementById("login-card-password").innerText = ""; + + document.getElementById("users").style.display = "none"; + document.getElementById("login").style.display = ""; + document.getElementById("login-card-password").focus(); + } + + document.getElementById("login-card-password").onkeydown = (e) => { + if (e.code === "Enter" && document.getElementById("login-card-password").value.length > 0 && document.getElementById("login-card-password").value.length < 64) { + confirmLogin(); + } + } + + function confirmLogin() { + document.getElementById("login-back").style.opacity = "0"; + document.getElementById("login-back").style.pointerEvents = "none"; + document.getElementById("login-card-password").style.display = "none"; + document.getElementById("login-card-loader").style.display = ""; + document.getElementById("power-actions").style.opacity = ".5"; + document.getElementById("power-actions").style.pointerEvents = "none"; + document.body.style.cursor = "none"; + + let p = require('child_process').execFile("./decrypt.sh", [ window.currentUser, document.getElementById("login-card-password").value.replaceAll('"', "\\\"") ], { stdio: "pipe", shell: true, cwd: "/mango/core/login" }); + + p.stdout.on('data', (data) => { + console.info(data.toString()); + }); + + p.stderr.on('data', (data) => { + console.error(data.toString()); + }); + + p.on('close', (code, signal) => { + console.log(code, signal); + + if (code === 0) { + try { require('child_process').execSync("rm -rf /mango/session"); } catch (e) {} + require('child_process').execSync("ln -s /mango/users/" + currentUser + "/home /mango/session"); + + document.body.style.opacity = "0"; + document.body.style.pointerEvents = "none"; + location.href = "../desktop/index.html"; + } else { + document.getElementById("login-back").style.opacity = "1"; + document.getElementById("login-back").style.pointerEvents = ""; + document.getElementById("login-card-password").style.display = ""; + document.getElementById("login-card-password").value = ""; + document.getElementById("login-card-loader").style.display = "none"; + document.getElementById("power-actions").style.opacity = "1"; + document.getElementById("power-actions").style.pointerEvents = ""; + document.getElementById("login-card-password").focus(); + } + }) + } + + function cancelLogin() { + window.currentUser = null; + document.getElementById("users").style.display = ""; + document.getElementById("login").style.display = "none"; + } + </script> +</body> +</html>
\ No newline at end of file diff --git a/core/login/restart.svg b/core/login/restart.svg new file mode 100644 index 0000000..f82b97f --- /dev/null +++ b/core/login/restart.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M451-122q-123-10-207-101t-84-216q0-77 35.5-145T295-695l43 43q-56 33-87 90.5T220-439q0 100 66 173t165 84v60Zm60 0v-60q100-12 165-84.5T741-439q0-109-75.5-184.5T481-699h-20l60 60-43 43-133-133 133-133 43 43-60 60h20q134 0 227 93.5T801-439q0 125-83.5 216T511-122Z"/></svg>
\ No newline at end of file diff --git a/core/login/shutdown.svg b/core/login/shutdown.svg new file mode 100644 index 0000000..e12cf33 --- /dev/null +++ b/core/login/shutdown.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M450-438v-406h60v406h-60Zm30 320q-74 0-139.5-28.5T226-224q-49-49-77.5-114.5T120-478q0-80 34-149.5T250-751l42 42q-53 43-82.5 102.5T180-478.022Q180-353 267.5-265.5 355-178 480-178q125.357 0 212.679-87.5Q780-353 780-478.022 780-547 750.5-607.5 721-668 670-709l43-42q60 51 93.5 122T840-478q0 74-28.5 139.5t-77 114.5q-48.5 49-114 77.5T480-118Z"/></svg>
\ No newline at end of file diff --git a/core/login/sleep.svg b/core/login/sleep.svg new file mode 100644 index 0000000..b8f052b --- /dev/null +++ b/core/login/sleep.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M480.235-380Q522-380 551-409.235q29-29.236 29-71Q580-522 550.765-551q-29.236-29-71-29Q438-580 409-550.765q-29 29.236-29 71Q380-438 409.235-409q29.236 29 71 29Zm.031 300q-82.734 0-155.5-31.5t-127.266-86q-54.5-54.5-86-127.341Q80-397.681 80-480.5q0-82.819 31.5-155.659Q143-709 197.5-763t127.341-85.5Q397.681-880 480.5-880q82.819 0 155.659 31.5Q709-817 763-763t85.5 127Q880-563 880-480.266q0 82.734-31.5 155.5T763-197.684q-54 54.316-127 86Q563-80 480.266-80Zm.234-60Q622-140 721-239.5t99-241Q820-622 721.188-721 622.375-820 480-820q-141 0-240.5 98.812Q140-622.375 140-480q0 141 99.5 240.5t241 99.5Zm-.5-340Z"/></svg>
\ No newline at end of file diff --git a/core/login/unwrap.js b/core/login/unwrap.js new file mode 100644 index 0000000..50ac419 --- /dev/null +++ b/core/login/unwrap.js @@ -0,0 +1 @@ +console.log(require('child_process').execSync('echo "' + Buffer.from(process.argv[3], "base64").toString().trim().replaceAll('"', "\\\"") + '" | ecryptfs-unwrap-passphrase /mango/users/' + process.argv[2] + '/crypt/wrapped-passphrase').toString().trim().split("\n")[1]);
\ No newline at end of file diff --git a/core/startup/encryption.sh b/core/startup/encryption.sh new file mode 100644 index 0000000..cc1f786 --- /dev/null +++ b/core/startup/encryption.sh @@ -0,0 +1 @@ +#!/bin/bash
\ No newline at end of file diff --git a/core/startup/index.html b/core/startup/index.html index edd1c63..50f65ac 100644 --- a/core/startup/index.html +++ b/core/startup/index.html @@ -10,6 +10,7 @@ user-select: none; user-focus: none; cursor: none; + outline: none; } html, body { @@ -82,6 +83,10 @@ { title: "Starting UNIX policy manager...", command: "systemctl start polkit.service" + }, + { + title: "Configuring encryption...", + command: "modprobe ecryptfs && /mango/core/startup/encryption.sh" } ]; @@ -121,6 +126,8 @@ } document.getElementById("loading-message").innerText = "Initialising login screen..."; + document.body.style.opacity = "0"; + document.body.style.pointerEvents = "none"; location.href = "../login/index.html"; }, 3000); </script> |