Commit 2100384b authored by Tristan A Spakes's avatar Tristan A Spakes

ver. 1.1.5 Logging complete for User & Group Management, Badge Management, and...

ver. 1.1.5 Logging complete for User & Group Management, Badge Management, and File System Management
parent b32b4a43
Pipeline #24424 failed with stages
in 3 seconds
......@@ -8,6 +8,8 @@ const ipcRenderer = require('electron').ipcRenderer
const fs = require('fs')
function badgeConfig() {
ipcRenderer.send('log', `ORNL Toolbox: Submitted Badge Minder apply settings request`, 'info')
//For checking if the user chose beep, phone, both, or neither reminders
var enableBeeps = document.getElementById('badgeMinderBeepCheckBox').checked
var enableTxtmsg = document.getElementById('badgeMinderTextCheckBox').checked
......@@ -24,6 +26,7 @@ function badgeConfig() {
var regex = /^\d*(?:\.\d+)?$/ //Checks for 0 or more nums, a decimal, then 1 or more nums
if(! regex.test(beepTime)) {
alert('Invalid beepTime duration')
ipcRenderer.send('log', `ORNL Toolbox: Invalid Beep Reminder duration - request aborted`, 'err')
return
} else if(beepTime == "") {
/* Since there are 2.5 seconds between each beep, time is measured
......@@ -33,7 +36,17 @@ function badgeConfig() {
beepTime = beepTime * 24.0
}
beepTime = beepTime.toPrecision(7)
var logBeepTime = beepTime / 24.0
logBeepTime = logBeepTime.toPrecision(7)
ipcRenderer.send('log', `ORNL Toolbox: Beep Reminder is enabled`, 'info')
if(logBeepTime == 1.0) {
ipcRenderer.send('log', `ORNL Toolbox: Duration of Beeps is set to 1 minute`, 'info')
} else {
ipcRenderer.send('log', `ORNL Toolbox: Duration of Beeps is set to ${logBeepTime} minutes`, 'info')
}
} else {
ipcRenderer.send('log', `ORNL Toolbox: Beep Reminder is disabled`, 'info')
beepTime = 0
}
var beepTimeRounded = Math.round(beepTime)
......@@ -50,14 +63,17 @@ function badgeConfig() {
//Check if any of the phone number fields are invalid
if(parseInt(phoneNum1) == NaN || parseInt(phoneNum1) < 0 || /^[0-9]+$/.test(phoneNum1) == false || phoneNum1.length < 3) {
alert('Invalid 1st phone number field')
ipcRenderer.send('log', `ORNL Toolbox: Invalid 1st phone number field - request aborted`, 'err')
return
}
if(parseInt(phoneNum2) == NaN || parseInt(phoneNum2) < 0 || /^[0-9]+$/.test(phoneNum2) == false || phoneNum2.length < 3) {
alert('Invalid 2nd phone number field')
ipcRenderer.send('log', `ORNL Toolbox: Invalid 2nd phone number field - request aborted`, 'err')
return
}
if(parseInt(phoneNum3) == NaN || parseInt(phoneNum3) < 0 || /^[0-9]+$/.test(phoneNum3) == false || phoneNum3.length < 4) {
alert('Invalid 3rd phone number field')
ipcRenderer.send('log', `ORNL Toolbox: Invalid 3rd phone number field - request aborted`, 'err')
return
}
......@@ -65,6 +81,7 @@ function badgeConfig() {
switch(parseInt(carrier)) {
case 0:
alert('Invalid carrier') //No carrier is selected
ipcRenderer.send('log', `ORNL Toolbox: Invalid carrier - request aborted`, 'err')
return
break
case 1:
......@@ -118,7 +135,11 @@ function badgeConfig() {
//Combining the three phone number entries into one string
phone = `${phoneNum1}${phoneNum2}${phoneNum3}`
ipcRenderer.send('log', `ORNL Toolbox: Text Message Reminder is enabled`, 'info')
ipcRenderer.send('log', `ORNL Toolbox: Phone number is set to ${phone}`, 'info')
ipcRenderer.send('log', `ORNL Toolbox: Carrier is set to ${carrier}`, 'info')
} else {
ipcRenderer.send('log', `ORNL Toolbox: Text Message Reminder is disabled`, 'info')
//Text reminder is not enabled
phone = "none"
carrier = "none"
......@@ -140,6 +161,9 @@ function badgeConfig() {
fs.writeFile(path, `beepTime=${beepTime}\nbeepTimeRounded=${beepTimeRounded}\nphone=\"${phone}\"\ncarrier=\"${carrier}\"\n`, (error) => {
if(error) {
console.log(error)
ipcRenderer.send('log', `ORNL Toolbox: Error saving Badge Minder config file`, 'err')
} else {
ipcRenderer.send('log', `ORNL Toolbox: Badge Minder config file saved`, 'info')
}
//Block for killing old script and starting new one
......@@ -147,6 +171,7 @@ function badgeConfig() {
scriptStart = 'bash ' + scriptStart.substring(0, scriptStart.length - 11) + 'resources/app/badgeManagement/badgeMinder/badgeMinder.bash &'
try { //Kill the old reminder script if it exists
execSync('pkill -f badgeMinder.bash', () => {})
ipcRenderer.send('log', `ORNL Toolbox: Previous Badge Minder script killed`, 'info')
} catch(err) {
//Ignore that a process that doesn't exist can't be killed
}
......@@ -161,7 +186,9 @@ function badgeConfig() {
} catch(err) {
console.log(err)
console.log("Cannot start badgeMinder.bash")
ipcRenderer.send('log', `ORNL Toolbox: Failed to start Badge Minder script`, 'err')
}
ipcRenderer.send('log', `ORNL Toolbox: Badge Minder script started`, 'info')
//Block for writing in .xprofile startup script
try {
......
......@@ -2,4 +2,5 @@
function badgeMinderClose() {
console.log('close')
ipcRenderer.send('close minor window')
ipcRenderer.send('log', `ORNL Toolbox: Clicked 'Close' - Badge Minder closed`, 'info')
}
......@@ -9,4 +9,5 @@ function badgeMinderTest() {
console.log(err)
console.log("Error with badgeMinderTest.bash")
}
ipcRenderer.send('log', `ORNL Toolbox: Badge Minder tested`, 'info')
}
const execSync = require('child_process').execSync
function yubiBadgeCheckpoint(whichPage) {
ipcRenderer.send('log', 'ORNL Toolbox: Submitted Yubikey/Badge Checkpoint request', 'info')
if(whichPage == 0) {
addWinMain('./badgeManagement/yubiBadgeCheckpoint/yubiBadgeCheckpoint.html', 'Yubikey/Badge Checkpoint', 225, 180)
} else if(whichPage == 1) {
......@@ -12,6 +14,7 @@ function yubiBadgeCheckpoint(whichPage) {
if(checkBadge) { //Badge inserted
alert('Please remove your badge')
ipcRenderer.send('close minor window')
ipcRenderer.send('log', `ORNL Toolbox: Badge inserted - request aborted`, 'err')
return
}
} catch(err) {
......@@ -23,10 +26,13 @@ function yubiBadgeCheckpoint(whichPage) {
if(! checkYubi) { //No Yubikey inserted
alert('Please insert a Yubikey')
ipcRenderer.send('close minor window')
ipcRenderer.send('log', `ORNL Toolbox: No Yubikey inserted - request aborted`, 'err')
return
}
}
ipcRenderer.send('log', 'ORNL Toolbox: Yubikey/Badge Checkpoint passed - request completed', 'info')
//Load either yubiChecker or yubiChanger
if(whichPage == 0) {
addWinMain('./badgeManagement/yubiChecker/yubiChecker.html', 'Yubikey Lock Checker', 225, 180)
......
const electron = require('electron')
const exec = require('child_process').exec
const execSync = require('child_process').execSync
const ipcRenderer = require('electron').ipcRenderer
//If the entered current PIN matches the registed current PIN, allow the user to create a new PIN that is 6 to 8 digits
function yubiChanger() {
ipcRenderer.send('log', 'ORNL Toolbox: Submitted Yubikey PIN change request', 'info')
var currentPIN = document.getElementById("yubikeyChangeEnterPIN1").value
var newPIN = document.getElementById("yubikeyChangeEnterPIN2").value
var confirmNewPIN = document.getElementById("yubikeyChangeEnterPIN3").value
......@@ -12,9 +15,11 @@ function yubiChanger() {
//Throw error if either PIN doesn't match the requirements
if((! numeric.test(currentPIN)) || (! numeric.test(newPIN)) || (! numeric.test(confirmNewPIN))) {
alert('Each PIN must consist of 6 to 8 digits')
ipcRenderer.send('log', `ORNL Toolbox: Invalid PIN entered - request aborted`, 'err')
return
} else if(newPIN != confirmNewPIN) {
alert('New PIN and confirmation of new PIN must match')
ipcRenderer.send('log', `ORNL Toolbox: New PIN and confirmation PIN do not match - request aborted`, 'err')
return
} else {
try { //PINs meet requirements - check with registered PIN and try to change
......@@ -23,20 +28,25 @@ function yubiChanger() {
error = error.toString()
if(error.includes('Failed verifying pin code')) {
alert('The current PIN entered does not match the registered PIN')
ipcRenderer.send('log', `ORNL Toolbox: Entered PIN does not match the registered PIN - request aborted`, 'err')
return
} else if(error.includes('The pin code is blocked')) {
alert('The current Yubikey is blocked. Please go to the Solution Center to unblock it')
ipcRenderer.send('log', `ORNL Toolbox: Yubikey is locked - request aborted`, 'err')
return
} else if(error.includes('Failed to connect')) {
alert('No Yubikey inserted')
ipcRenderer.send('log', `ORNL Toolbox: No Yubikey inserted - request aborted`, 'err')
return
} else { //For uncaught/unconsidered errors
alert('Error changing PIN')
ipcRenderer.send('log', `ORNL Toolbox: Error with PIN change - request aborted`, 'err')
return
}
}
//Pin should be changed if this is reached
alert("PIN changed successfully.")
ipcRenderer.send('log', `ORNL Toolbox: Yubikey PIN changed successfully`, 'info')
}
}
const electron = require('electron')
const execSync = require('child_process').execSync
const ipcRenderer = require('electron').ipcRenderer
//Checks if the Yubikey is locked and alerts the user accordingly
function yubiChecker() {
ipcRenderer.send('log', 'ORNL Toolbox: Submitted Yubikey check request', 'info')
var checkLock = execSync('pkcs11-tool -I -l | grep \"\"', (error, stdout, stderr) => {})
checkLock = checkLock.toString()
if(checkLock.includes("WARNING:")) {
alert('Yubikey is locked')
ipcRenderer.send('log', `ORNL Toolbox: Inserted Yubikey is locked`, 'info')
} else if(checkLock.includes("Logging")) {
alert('Yubikey is not locked')
ipcRenderer.send('log', `ORNL Toolbox: Inserted Yubikey is not locked`, 'info')
} else {
alert('No Yubikey inserted') //If Yubikey is unplugged, will get this
ipcRenderer.send('log', `ORNL Toolbox: No Yubikey inserted - request aborted`, 'err')
}
}
......@@ -6,7 +6,7 @@ if [[ ${CI_COMMIT_REF_NAME} == 'master' ]]; then
else
BRANCH="-${CI_COMMIT_REF_NAME}"
fi
VERSION_NUMBER='1.1.4'
VERSION_NUMBER='1.1.5'
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -ivh epel-release-latest-7.noarch.rpm
sudo yum -y install nodejs npm ruby-devel gcc make rpm-build rubygems
......
function addPassphrase() {
if(!execSync) var execSync = require('child_process').execSync
if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer
ipcRenderer.send('log', 'ORNL Toolbox: Submitted Add Passphrase request', 'info')
//Check for encrypted partitions
var encrypted = execSync('lsblk --fs -l | grep "crypto_LUKS" | cut -f 1 -d " " || true', () => {})
encrypted = (encrypted.toString()).trim()
if(encrypted == "") {
alert("This device has no encrypted partitions")
ipcRenderer.send('log', 'ORNL Toolbox: No encrypted partitions detected - request aborted', 'err')
return
}
......@@ -14,6 +18,7 @@ function addPassphrase() {
partition = partition.toString()
if(partition == "") { //Exiting if an encrypted partition is not found
alert('No encrypted partition found')
ipcRenderer.send('log', 'ORNL Toolbox: No encrypted partitions detected - request aborted', 'err')
return
}
......@@ -24,10 +29,12 @@ function addPassphrase() {
//Each field must have something in it
if(pass1 == "" || pass2 == "" || pass3 == "") {
alert('Please fill in all fields')
ipcRenderer.send('log', 'ORNL Toolbox: All fields not filled in - request aborted', 'err')
return
}
if(pass2 != pass3) {
alert('The new passphrase and its confirmation do not match')
ipcRenderer.send('log', 'ORNL Toolbox: New passphrase and its confirmation do not match - request aborted', 'err')
return
}
......@@ -37,16 +44,21 @@ function addPassphrase() {
error = error.toString()
if(error.includes("No key available with this passphrase")) { //Entered passphrase does not exist
alert('The entered passphrase does not exist')
ipcRenderer.send('log', 'ORNL Toolbox: Entered passphrase does not exist - request aborted', 'err')
} else if(error.includes("Request dismissed")) { //pkexec canceled
//Do nothing
ipcRenderer.send('log', 'ORNL Toolbox: Request canceled by user', 'info')
} else if(error.includes("All key slots full")) { //8 passphrases already exist, can't add more
alert('Maximum number of passphrases reached - please delete a passphrase first')
ipcRenderer.send('log', 'ORNL Toolbox: 8 passphrases already exist (maximum) - request aborted', 'err')
} else { //Catch any unconsidered errors
alert(error)
ipcRenderer.send('log', 'ORNL Toolbox: Failed to complete Add Passphrase request', 'err')
}
return
}
ipcRenderer.send('log', 'ORNL Toolbox: Completed Add Passphrase request', 'info')
alert('Passphrase added')
//Load a fresh Add Passphrase page
addWinMain('./fileSystemManagement/addPassphrase/addPassphrase.html', 'Add Passphrase Reset', 300, 300)
......
function driveHealthCheck() {
if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer
ipcRenderer.send('log', 'ORNL Toolbox: Submitted Drive Health Check request', 'info')
//Get SCSI drives excluding read-only memory drives
var drives = execSync(`lsblk -S | grep -v 'rom' | grep -v 'NAME HCTL'`, (error, stdout, stderr) => {
if(error) {
alert(error)
ipcRenderer.send('log', 'ORNL Toolbox: Error detecting drives - request aborted', 'err')
}
return
})
......@@ -33,6 +38,7 @@ function driveHealthCheck() {
})
output = output.toString()
if(output == "") { //Request dismissed
ipcRenderer.send('log', 'ORNL Toolbox: Request canceled by user', 'info')
return
}
......@@ -47,8 +53,11 @@ function driveHealthCheck() {
error = error.toString()
if(error.includes("Error executing command as another")) {
console.log("Request dismissed")
ipcRenderer.send('log', 'ORNL Toolbox: Request canceled by user', 'info')
} else {
console.error(error)
ipcRenderer.send('log', 'ORNL Toolbox: Failed to complete Drive Health Check request', 'err')
}
}
ipcRenderer.send('log', 'ORNL Toolbox: Completed Drive Health Check request', 'info')
}
function openDiskUsageAnalyzer() { //Open Disk Usage Analyzer application
if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer
ipcRenderer.send('log', 'ORNL Toolbox: Submitted Local Drive Usage request', 'info')
if(! installedCheck("baobab")) {
alert('This feature is not installed on this system - click the help button or contact the Solution Center for assistance')
ipcRenderer.send('log', 'ORNL Toolbox: baobab not installed - request aborted', 'err')
return
}
exec('pkexec baobab', (error, stdout, stderr) => {
if(error) {
console.error(`exec error: ${error}`)
ipcRenderer.send('log', 'ORNL Toolbox: Failed to launch Disk Usage Analyzer', 'err')
return
}
})
ipcRenderer.send('log', 'ORNL Toolbox: Completed Local Drive Usage request', 'info')
}
//This code was an attempt to give a loading gif for the wait times when doing
//passphrase activities
/*
function addKey(partition, pass1, pass2) {
if(!execSync) var execSync = require('child_process').execSync
......
function registerRecoveryKey() {
if(!execSync) var execSync = require('child_process').execSync
if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer
var pass = document.getElementById('registerRecoveryKeyEnterPass').value
ipcRenderer.send('log', 'ORNL Toolbox: Submitted Register Recovery Key request', 'info')
//Check for encrypted partitions
var encrypted = execSync('lsblk | grep crypt || true', () => {})
encrypted = (encrypted.toString()).trim()
if(encrypted == "") {
alert("This device has no encrypted partitions")
ipcRenderer.send('log', 'ORNL Toolbox: No encrypted partitions detected - request aborted', 'err')
return
}
if(pass == "") {
alert('Please enter an existing passphrase to register')
ipcRenderer.send('log', 'ORNL Toolbox: No existing passphrase entered - request aborted', 'err')
return
}
......@@ -21,6 +25,7 @@ function registerRecoveryKey() {
var out = execSync(`echo ${pass} | pkexec bash /var/wscfengine3/modules/common/luks/register`, () => {})
out = out.toString()
if(out.includes("Request dismissed")) { //pkexec canceled
ipcRenderer.send('log', 'ORNL Toolbox: Request canceled by user', 'info')
return
}
if(out.includes("Provided passphrase does not unlock")) { //Entered passphrase does not exist for a specific partition
......@@ -31,13 +36,16 @@ function registerRecoveryKey() {
}
if(out.includes("Failed to write new passphrase")) { //Fail when creating passphrase file
alert('Error creating a passphrase for registration')
return
ipcRenderer.send('log', 'ORNL Toolbox: Error creating passphrase for registration - request aborted', 'err')
return ipcRenderer.send('log', 'ORNL Toolbox: Error creating passphrase for registration - request aborted', 'err')
}
if(out.includes("Failed to add new passphrase")) { //Couldn't add the passphrase to the LUKS header
if(out.includes("Failed to add new passphrase")) { //Couldn't ad}d the passphrase to the LUKS header
finalOut = finalOut + 'Failed to register a passphrase\n'
}
if(out == "") { //No encrypted drives found
alert('No encrypted drives found')
ipcRenderer.send('log', 'ORNL Toolbox: No encrypted drives detected - request aborted', 'err')
return
}
if(out.includes("Recovery passphrase already registered")) { //Already registered
......@@ -46,13 +54,28 @@ function registerRecoveryKey() {
if(out.includes("Passphrase added to LUKS")) { //Success for an encrypted partition
finalOut = finalOut + 'Recovery passphrase registered\n'
}
alert(finalOut)
outList = finalOut.split("\n")
ipcRenderer.send('log', `ORNL Toolbox: Register Recovery Key request encountered the following:`, 'info')
for(i = 0; i < outList.length; i++) { //Logging the messages from finalOut
if(outList[i] == "") continue //Ignore blanks
ipcRenderer.send('log', `ORNL Toolbox: ${outList[i]}`, 'info')
}
ipcRenderer.send('log', 'ORNL Toolbox: End of encounter list', 'info')
} catch(error) { //Catch any unconsidered errors
error = error.toString()
alert(error)
if(error.includes("Request dismissed")) {
//Do nothing
ipcRenderer.send('log', 'ORNL Toolbox: Request canceled by user', 'info')
} else {
alert(error)
ipcRenderer.send('log', 'ORNL Toolbox: Unexpected Register Recovery Key error - request aborted', 'err')
}
return
}
ipcRenderer.send('log', 'ORNL Toolbox: Completed Register Recovery Key request', 'info')
//Load a fresh Register Recovery Key page
addWinMain('./fileSystemManagement/registerRecoveryKey/registerRecoveryKey.html', 'Register Recovery Key Reset', 325, 180)
}
function removePassphrase() {
if(!execSync) var execSync = require('child_process').execSync
if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer
ipcRenderer.send('log', 'ORNL Toolbox: Submitted Remove Passphrase request', 'info')
//Check for encrypted partitions
var encrypted = execSync('lsblk --fs -l | grep "crypto_LUKS" | cut -f 1 -d " " || true', () => {})
encrypted = (encrypted.toString()).trim()
if(encrypted == "") {
alert("This device has no encrypted partitions")
ipcRenderer.send('log', 'ORNL Toolbox: No encrypted partitions detected - request aborted', 'err')
return
}
......@@ -14,6 +18,7 @@ function removePassphrase() {
partition = partition.toString()
if(partition == "") { //Exiting if an encrypted partition is not found
alert('No encrypted partition found')
ipcRenderer.send('log', 'ORNL Toolbox: No encrypted partitions detected - request aborted', 'err')
return
}
......@@ -22,6 +27,7 @@ function removePassphrase() {
//The field must have something in it
if(pass == "") {
alert('Please enter a passphrase to remove')
ipcRenderer.send('log', 'ORNL Toolbox: No passphrase entered - request aborted', 'err')
return
}
......@@ -31,14 +37,18 @@ function removePassphrase() {
error = error.toString()
if(error.includes("No key available with this passphrase")) { //Entered passphrase does not exist
alert('The entered passphrase does not exist')
ipcRenderer.send('log', 'ORNL Toolbox: Invalid passphrase entered - request aborted', 'err')
} else if(error.includes("Request dismissed")) { //pkexec canceled
//Do nothing
ipcRenderer.send('log', 'ORNL Toolbox: Request canceled by user', 'info')
} else { //Catch any unconsidered errors
alert(error)
ipcRenderer.send('log', 'ORNL Toolbox: Failed to complete Remove Passphrase request', 'err')
}
return
}
ipcRenderer.send('log', 'ORNL Toolbox: Completed Remove Passphrase request', 'info')
alert('Passphrase removed')
//Load a fresh Add Passphrase page
addWinMain('./fileSystemManagement/removePassphrase/removePassphrase.html', 'Remove Passphrase Reset', 300, 180)
......
......@@ -259,7 +259,7 @@ function createWindow() {
var menu = Menu.buildFromTemplate(menuTemplate);
Menu.setApplicationMenu(menu); //Sets the template as the app menu
//mainWindow.openDevTools() //Opens dev tools on start
mainWindow.openDevTools() //Opens dev tools on start
}
function addWin(file, title, width, height) {
......@@ -310,7 +310,7 @@ function addWin(file, title, width, height) {
})
addWindow.setMenu(null)
//addWindow.openDevTools()
addWindow.openDevTools()
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment