Commit 680c60d1 authored by Tristan A Spakes's avatar Tristan A Spakes

ver. 1.1.3 Added logging for Sync Passwords. Toolbox closed and Toolbox opened being logged as well

parent 2ff97710
Pipeline #23410 failed with stages
in 2 seconds
......@@ -6,7 +6,7 @@ if [[ ${CI_COMMIT_REF_NAME} == 'master' ]]; then
else
BRANCH="-${CI_COMMIT_REF_NAME}"
fi
VERSION_NUMBER='1.1.2'
VERSION_NUMBER='1.1.3'
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
......
......@@ -310,7 +310,7 @@ function addWin(file, title, width, height) {
})
addWindow.setMenu(null)
//addWindow.openDevTools()
addWindow.openDevTools()
}
}
......@@ -381,7 +381,15 @@ ipcMain.on('close app', () => {
app.quit()
})
app.on('ready', createWindow)
app.on('ready', () => {
try {
execSync(`echo 'ORNL Toolbox: Toolbox opened' | logger -p local0.info`)
} catch(error) {
console.error(error)
return
}
createWindow()
})
app.on('window-all-closed', () => {
app.quit()
......
......@@ -8,7 +8,7 @@ function addUser() {
ipcRenderer.send('log', 'ORNL Toolbox: Submitted Add User request', 'info')
if(uid.length != 3 || /^[a-z0-9]+$/.test(uid) == false) {
ipcRenderer.send('log', `ORNL Toolbox: Invalid UID submitted for Add User - ${uid}`, 'err')
ipcRenderer.send('log', `ORNL Toolbox: ${uid} is an invalid UID for Add User - request aborted`, 'err')
alert('Please enter a valid 3 character UID')
return
}
......@@ -57,7 +57,7 @@ function addUser() {
} catch(error) {
error = error.toString()
if(error.includes('already exists')) {
ipcRenderer.send('log', `ORNL Toolbox: Add User reuest failed - ${uid} already exists as a user`, 'err')
ipcRenderer.send('log', `ORNL Toolbox: Add User request failed - ${uid} already exists as a user`, 'err')
alert('User already exists')
return
} else if(error.includes('Request dismissed')) {
......
......@@ -10,7 +10,7 @@ function removeUser() {
ipcRenderer.send('log', 'ORNL Toolbox: Submitted Remove User request', 'info')
if(uid.length != 3 || /^[a-z0-9]+$/.test(uid) == false) { //Test for valid UID
ipcRenderer.send('log', `ORNL Toolbox: Invalid UID submitted for Remove User - ${uid}`, 'err')
ipcRenderer.send('log', `ORNL Toolbox: ${uid} is an invalid UID for Remove User - request aborted`, 'err')
alert('Please enter a valid 3 character UID')
return
}
......
const electron = require('electron')
const exec = require('child_process').exec
const execSync = require('child_process').execSync
const ipcRenderer = require('electron').ipcRenderer
function syncPasswords(all) {
if(all == false) {
ipcRenderer.send('log', 'ORNL Toolbox: Submitted Sync Passwords request', 'info')
if(all == false) { //User pressed "Sync"
ipcRenderer.send('log', 'ORNL Toolbox: Sync clicked', 'info')
var uid = document.getElementById("syncForUID").value //Retrieve UID
if(uid == "") { //No entry, so sync current user's password
ipcRenderer.send('log', `ORNL Toolbox: Current user UID set to be synced for password`, 'info')
exec('wspasswd', (error, stdout, stderr) => {
if (error) {
alert(`${error}`)
......@@ -15,9 +19,10 @@ function syncPasswords(all) {
} else {
alert(`${stdout}`)
}
return
ipcRenderer.send('log', 'ORNL Toolbox: Password sync completed', 'info')
});
} else if(uid.length > 0 && uid.length < 3) { //For entry of invalid length
ipcRenderer.send('log', `ORNL Toolbox: ${uid} is an invalid UID for Sync Passwords - request aborted`, 'err')
alert("Invalid length for UID")
return
} else {
......@@ -30,36 +35,46 @@ function syncPasswords(all) {
valid = false
}
if(valid == false) { //UID does not exist on the system
ipcRenderer.send('log', `ORNL Toolbox: ${uid} does not exist on this system - request aborted`, 'err')
alert(`User \'${uid}\' does not exist`)
return
}
ipcRenderer.send('log', `ORNL Toolbox: ${uid} set to be synced for password`, 'info')
exec(`pkexec wspasswd ${uid}`, (error, stdout, stderr) => {
if(stderr) {
if(stderr.includes("Request dismissed")) return
if(stderr.includes("Request dismissed")) {
ipcRenderer.send('log', 'ORNL Toolbox: Sync Passwords request canceled', 'info')
alert('Operation canceled')
return
}
alert(`${stderr}`)
} else {
alert(`${stdout}`)
}
return
ipcRenderer.send('log', 'ORNL Toolbox: Password sync completed', 'info')
});
}
} else { //User pressed "Sync All"
ipcRenderer.send('log', 'ORNL Toolbox: Sync All clicked', 'info')
exec('pkexec wspasswd -a 2>&1 | grep -P \"Account .{3} :\"', (error, stdout, stderr) => {
if(stderr) {
alert(`${stderr}`)
if(stdout == "") { //Assuming request dismissed due to grep finding nothing
ipcRenderer.send('log', 'ORNL Toolbox: Sync Passwords request canceled', 'info')
alert('Operation canceled')
return
} else {
if(stdout == "") return
alert(`${stdout}`) //Need to test for a large number of system users
}
ipcRenderer.send('log', 'ORNL Toolbox: Password sync completed', 'info')
})
}
}
//Find out who the current user is and set it as the UID placeholder
function findUID() {
ipcRenderer.send('log', 'ORNL Toolbox: Determining current user UID', 'info')
var currentUser = execSync('whoami', (error, stdout, stderr) => {
if(stderr) {
alert(`${stderr}`)
......@@ -70,5 +85,6 @@ function findUID() {
})
currentUser = currentUser.toString()
document.getElementById("syncForUID").placeholder = currentUser
ipcRenderer.send('log', `ORNL Toolbox: Current user UID is ${currentUser}`, 'info')
return currentUser
}
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