diff --git a/badgeManagement/MFAVerification/MFAVerification.css b/badgeManagement/MFAVerification/MFAVerification.css new file mode 100644 index 0000000000000000000000000000000000000000..c42dd43a23fa5b9dae0c0a0be5586fe57a596675 --- /dev/null +++ b/badgeManagement/MFAVerification/MFAVerification.css @@ -0,0 +1,60 @@ +/* Prevents highlighting of text, dragging of images, etc. */ +*, *::after, *::before { + margin: 0; + padding: 0; + -webkit-user-select: none; + -webkit-user-drag: none; + -webkit-app-region: no-drag; + font-family: 'Montserrat', sans-serif; +} + +div { + -webkit-user-select: none; + -webkit-user-drag: none; + -webkit-app-region: no-drag; + font-family: 'Montserrat', sans-serif; +} + +/* Horizontal line formatting */ +hr { + display: block; + margin-top: 0.15em; + margin-bottom: 0.15em; +} + +/* For submission buttons */ +input[type=submit] { + padding: 0; + border: none; + background: none; + font-size: 21px; +} + +#MFAVerificationPage { + display: flex; + flex-direction: column; + height: 100vh; + justify-content: center; + align-items: center; +} +#MFAVerificationText { + text-align: center; + font-size: 15px; + margin-bottom: 15px; + margin-left: 12px; + margin-right: 12px; +} +#MFAVerificationButton { + align-self: center; + background-color: #007833; + border-radius: 8px; + width: 50vw; + height: 30vh; + text-align: center; + font-size: 30px; + box-shadow: 0 3px 6px 0 rgba(0,0,0,0.2), 0 4px 8px 0 rgba(0,0,0,0.19); +} +#MFAVerificationButton:hover { + background-color: Gray; + cursor: pointer; +} diff --git a/badgeManagement/MFAVerification/MFAVerification.html b/badgeManagement/MFAVerification/MFAVerification.html new file mode 100644 index 0000000000000000000000000000000000000000..ddf5d3b0bf0bb96d1ec573c2052ec460ae389dc0 --- /dev/null +++ b/badgeManagement/MFAVerification/MFAVerification.html @@ -0,0 +1,20 @@ + + + + + Smart Card Verification + + + + + +
+
+ Please ensure that there is one smart card inserted before clicking 'Verify' +
+ + + +
+ + diff --git a/badgeManagement/MFAVerification/MFAVerification.js b/badgeManagement/MFAVerification/MFAVerification.js new file mode 100644 index 0000000000000000000000000000000000000000..7ce4ceeedce0150f0e90cad8ac49493e283f02e1 --- /dev/null +++ b/badgeManagement/MFAVerification/MFAVerification.js @@ -0,0 +1,62 @@ +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 MFAVerification() { + ipcRenderer.send('log', 'ORNL Toolbox: Submitted MFA verification request', 'info') + + try { //Scan for active smart card slots for inserted smart cards + var cardCheck = execSync(`pkcs11-tool -T | grep "Slot"`, (error, stdout, stderr) => {}) + cardCheck = cardCheck.toString() + } catch(error) { + error = error.toString() + if(error.includes("No slots")) { + alert('No smart card inserted') + ipcRenderer.send('log', 'ORNL Toolbox: No smart card inserted - request aborted', 'err') + return + } else { + alert(error) + ipcRenderer.send('log', 'ORNL Toolbox: Error checking for smart card - request aborted', 'err') + return + } + } + + //Check for the number of smart card slots + var count = (cardCheck.match(/Slot/g) || []).length; + if(count > 1) { //More than one slot found + alert('Please ensure only one smart card is inserted') + ipcRenderer.send('log', 'ORNL Toolbox: More than one smart card inserted - request aborted', 'err') + return + } else if(count < 1) { //No slots found + alert('No smart card inserted') + ipcRenderer.send('log', 'ORNL Toolbox: No smart card inserted - request aborted', 'err') + return + } else { + ipcRenderer.send('log', 'ORNL Toolbox: 1 smart card found inserted', 'info') + } + + try { //Check for entry in digest mapping file + var inDigest = execSync(`grep $(pkcs15-tool -r 1 --rfc4716 2>/dev/null | openssl x509 -noout -fingerprint -sha1 -inform pem | grep -Po '(?<==).*(?=$)') /etc/pam_pkcs11/digest_mapping`, (error, stdout, stderr) => {}) + } catch(error) { + error = error.toString() + if(error.includes('unable to load certificate')) { //Extra safety for no smartcard inserted scenario + alert('No smart card inserted') + ipcRenderer.send('log', 'ORNL Toolbox: No smart card inserted - request aborted', 'err') + return + } else { + inDigest = "" + } + } + + if(inDigest == "") { //Tell user the if the smart card has an entry or not + //Not in digest mapping + alert('Inserted smart card absent from diggest mapping and will not function') + ipcRenderer.send('log', 'ORNL Toolbox: Inserted smart card was not found in /etc/pam_pkcs11/digest_mapping', 'info') + } else { + //In digest mapping + alert('Inserted smart card present in digest mapping and should function unless locked') + ipcRenderer.send('log', 'ORNL Toolbox: Inserted smart card has an entry in /etc/pam_pkcs11/digest_mapping', 'info') + } + ipcRenderer.send('log', 'ORNL Toolbox: Completed MFA verification request', 'info') +} diff --git a/badgeManagement/badgeManagement.css b/badgeManagement/badgeManagement.css index 4bfc947acd532c36ed7126cadcda3e6c495d2081..57850e3f393de9250f5d1abccea3f02571f7674d 100644 --- a/badgeManagement/badgeManagement.css +++ b/badgeManagement/badgeManagement.css @@ -88,6 +88,12 @@ input[type=submit] { background-color: White; } +#badgeManagementHiddenbuttons { + width: 32vh; + height: 20vh; + padding: 4px 4px; + margin: 30px 30px; +} .backContent { display: flex; diff --git a/badgeManagement/badgeManagement.html b/badgeManagement/badgeManagement.html index 957bfbb0c76081beb20452ec5c6856177e11bfd6..e7b687b90bcd1d38f8d1ca0a987285e24bc77379 100644 --- a/badgeManagement/badgeManagement.html +++ b/badgeManagement/badgeManagement.html @@ -10,12 +10,15 @@ + + + @@ -36,7 +39,7 @@
-
Badge Minder
+
Badge Minder
Yubikey Lock Checker
@@ -44,9 +47,16 @@
Yubikey PIN Changer
+ +
Smart Card Verification
+
+ +
Temporary Smart Card Registration
+
+
-
+
White Chat Bubble
@@ -54,12 +64,13 @@
-
+
Question Mark
Help
+ diff --git a/badgeManagement/badgeManagement.js b/badgeManagement/badgeManagement.js index 7334b95601d09be756d0eaa42ddd9aa245c83d0f..8ff34992040777f68fff2ce7be526ce65a476647 100644 --- a/badgeManagement/badgeManagement.js +++ b/badgeManagement/badgeManagement.js @@ -1,5 +1,6 @@ //Loads the badgeManagement major page and closes minor windows function badgeManWin() { + ipcRenderer.send('log', 'ORNL Toolbox: Opened Badge Management', 'info') //Destroying any minor windows that were opened from the main window ipcRenderer.send('close minor window') // Change main window to badge management window diff --git a/badgeManagement/badgeMinder/badgeInstallCheckpoint/badgeInstallCheckpoint.css b/badgeManagement/badgeMinder/badgeInstallCheckpoint/badgeInstallCheckpoint.css new file mode 100644 index 0000000000000000000000000000000000000000..114d926bb2dc8bed9a64601a59117e462cc8606b --- /dev/null +++ b/badgeManagement/badgeMinder/badgeInstallCheckpoint/badgeInstallCheckpoint.css @@ -0,0 +1,72 @@ +/* Prevents highlighting of text, dragging of images, etc. */ +*, *::after, *::before { + margin: 0; + padding: 0; + -webkit-user-select: none; + -webkit-user-drag: none; + -webkit-app-region: no-drag; + font-family: 'Montserrat', sans-serif; +} + +div { + -webkit-user-select: none; + -webkit-user-drag: none; + -webkit-app-region: no-drag; + font-family: 'Montserrat', sans-serif; +} + +/* Horizontal line formatting */ +hr { + display: block; + margin-top: 0.15em; + margin-bottom: 0.15em; +} + +/* For submission buttons */ +input[type=submit] { + padding: 0; + border: none; + background: none; + font-size: 21px; +} + +#badgeInstallCheckpointPage { + display: flex; + height: 100vh; + flex-direction: column; + justify-content: center; + align-items: center; +} + +#badgeInstallCheckpointText { + font-size: 16px; + text-align: center; + margin-bottom: 25px; + margin-left: 12px; + margin-right: 12px; +} + +.badgeInstallCheckpointButtonsContent { + width: 100vw; + height: 10vh; + display: flex; + flex-direction: row; + justify-content: center; +} + +.badgeInstallCheckpointButtons { + text-align: center; + align-items: center; + width: 22vw; + height: 18vh; + margin-right: 12.5px; + margin-left: 12.5px; + background-color: #007833 !important; + border-radius: 8px; + box-shadow: 0 2px 4px 0 rgba(0,0,0,0.2), 0 4px 8px 0 rgba(0,0,0,0.19); + color: White; +} +.badgeInstallCheckpointButtons:hover { + background-color: Gray !important; + cursor: pointer; +} diff --git a/badgeManagement/badgeMinder/badgeInstallCheckpoint/badgeInstallCheckpoint.html b/badgeManagement/badgeMinder/badgeInstallCheckpoint/badgeInstallCheckpoint.html new file mode 100644 index 0000000000000000000000000000000000000000..31d0a8f53cc9e41ad3d100b2bfcad9d1f94b78f3 --- /dev/null +++ b/badgeManagement/badgeMinder/badgeInstallCheckpoint/badgeInstallCheckpoint.html @@ -0,0 +1,28 @@ + + + + + Badge Minder Checkpoint + + + + + + + +
+
+ Gnome-Screensaver is not currently installed. Badge Minder requires + Gnome-Screensaver to function. Would you like to install it? +
+
+ + + + + + +
+
+ + diff --git a/badgeManagement/badgeMinder/badgeInstallCheckpoint/badgeInstallCheckpoint.js b/badgeManagement/badgeMinder/badgeInstallCheckpoint/badgeInstallCheckpoint.js new file mode 100644 index 0000000000000000000000000000000000000000..2da17364b9930d5dc5e2fd9fcb49b14d84106788 --- /dev/null +++ b/badgeManagement/badgeMinder/badgeInstallCheckpoint/badgeInstallCheckpoint.js @@ -0,0 +1,42 @@ +function badgeInstallCheckpoint() { + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer + if(!execSync) var execSync = require('child_process').execSync + + ipcRenderer.send('log', 'ORNL Toolbox: Submitted Badge Install Checkpoint request', 'info') + + var os + try { //Detect OS + execSync('grep Ubuntu /etc/os-release') + os = "Ubuntu" + ipcRenderer.send('log', 'ORNL Toolbox: OS determined to be Ubuntu', 'info') + } catch(error) { + //"Ubuntu" not found in file + os = "RHEL" + ipcRenderer.send('log', 'ORNL Toolbox: OS determined to be RHEL', 'info') + } + + try { + if(os == "Ubuntu") { + package = execSync(`apt -qq list --installed gnome-screensaver`) + } else { + package = execSync(`yum list installed gnome-screensaver | grep gnome-screensaver`) + } + } catch(error) { + error = error.toString() + if(os != "Ubuntu" && error.includes("No matching Packages to list")) { + package = "" + } else { + alert(error) + ipcRenderer.send('log', 'ORNL Toolbox: Failed while checking for gnome-screensaver - request aborted', 'err') + return + } + } + + ipcRenderer.send('log', 'ORNL Toolbox: Completed Badge Install Checkpoint request', 'info') + + if(package == "") { + addWinMain('./badgeManagement/badgeMinder/badgeInstallCheckpoint/badgeInstallCheckpoint.html', 'Badge Minder Checkpoint', 400, 175) + } else { + addWinMain('./badgeManagement/badgeMinder/badgeMinder.html', 'Badge Minder', 450, 360) + } +} diff --git a/badgeManagement/badgeMinder/badgeInstallCheckpoint/badgeInstallCheckpointConfirm.js b/badgeManagement/badgeMinder/badgeInstallCheckpoint/badgeInstallCheckpointConfirm.js new file mode 100644 index 0000000000000000000000000000000000000000..d50b03da599e6ede53dd53f420ea3c0ebea677de --- /dev/null +++ b/badgeManagement/badgeMinder/badgeInstallCheckpoint/badgeInstallCheckpointConfirm.js @@ -0,0 +1,43 @@ +function badgeInstallCheckpointConfirm() { + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer + if(!execSync) var execSync = require('child_process').execSync + + ipcRenderer.send('log', 'ORNL Toolbox: Submitted install request for gnome-screensaver', 'info') + + var os + try { //Detect OS + execSync('grep Ubuntu /etc/os-release') + os = "Ubuntu" + ipcRenderer.send('log', 'ORNL Toolbox: OS determined to be Ubuntu', 'info') + } catch(error) { + //"Ubuntu" not found in file + os = "RHEL" + ipcRenderer.send('log', 'ORNL Toolbox: OS determined to be RHEL', 'info') + } + + try { //Install gnome-screensaver + if(os == "Ubuntu") { + execSync(`pkexec apt install gnome-screensaver`) + } else { + execSync(`pkexec yum -y install gnome-screensaver`) + } + } catch(error) { + error = error.toString() + if(error.includes("Request dismissed")) { + ipcRenderer.send('log', 'ORNL Toolbox: Request canceled by user', 'err') + badgeMinderClose() + return + } else { + ipcRenderer.send('log', 'ORNL Toolbox: Failed to install gnome-screensaver - request aborted', 'err') + console.error(error) + alert(error) + badgeMinderClose() + } + } + + alert('Gnome Screensaver successfully installed') + ipcRenderer.send('log', 'ORNL Toolbox: Completed install request for gnome-screensaver', 'info') + + //Open Badge Minder window + addWinMain('./badgeManagement/badgeMinder/badgeMinder.html', 'Badge Minder', 450, 360) +} diff --git a/badgeManagement/badgeMinder/badgeMinder.html b/badgeManagement/badgeMinder/badgeMinder.html index c4061899a8368426509bdd902c2af17075b9d7c7..2ec3e8bc0629e490e0b160205c2f324da2ec83bf 100644 --- a/badgeManagement/badgeMinder/badgeMinder.html +++ b/badgeManagement/badgeMinder/badgeMinder.html @@ -61,22 +61,6 @@
diff --git a/badgeManagement/badgeMinder/badgeMinder.js b/badgeManagement/badgeMinder/badgeMinder.js index cddaabc31d802610c3848080e9736d2bf95031c6..9147103b9ea0c17ea0ddb990b13de5333d44c86d 100644 --- a/badgeManagement/badgeMinder/badgeMinder.js +++ b/badgeManagement/badgeMinder/badgeMinder.js @@ -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,75 +63,48 @@ 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 } - //Assigning a domain string to the carrier - switch(parseInt(carrier)) { - case 0: - alert('Invalid carrier') //No carrier is selected - return - break - case 1: - carrier = "@txt.att.net" //AT&T - break - case 2: - carrier = "@vtext.com" //Verizon - break - case 3: - carrier = "@email.uscc.net" //U.S. Cellular - break - case 4: - carrier = "@messaging.sprintpcs.com" //Sprint - break - case 5: - carrier = "@vmobl.com" //Virgin Mobile - break - case 6: - carrier = "@tmomail.net" //T-Mobile - break - case 7: - carrier = "@mmst5.tracfone.co" //Tracfone - break - case 8: - carrier = "@mymetropcs.com" //Metro PCS - break - case 9: - carrier = "@myboostmobile.com" //Boost Mobile - break - case 10: - carrier = "@sms.mycricket.com" //Cricket - break - case 11: - carrier = "@messaging.nextel.com" //Nextel - break - case 12: - carrier = "@message.alltel.com" //Alltel - break - case 13: - carrier = "@ptel.com" //Ptel - break - case 14: - carrier = "@tms.suncom.com" //Suncom - break - case 15: - carrier = "@qwestmp.com" //Qwest + carrier = parseInt(carrier) + //Grabs carriers.csv for list of carriers + var carriersPath = remote.app.getPath('exe') //Grabs the path to the executable + carriersPath = carriersPath.substring(0, carriersPath.length - 11) + 'resources/app/badgeManagement/badgeMinder/carriers.csv' + var carriers = fs.readFileSync(carriersPath, 'utf-8', () => {}) + carriers = carriers.split(/,|\n/) + + if(carrier == 0) { //No carrier is selected + alert('Invalid carrier') + ipcRenderer.send('log', `ORNL Toolbox: Invalid carrier - request aborted`, 'err') + return + } + + for(i = 1; i < carriers.length; i+=2) { + if(i == carrier) { + carrier = carriers[parseInt(i / 2) + 1] break - case 16: - carrier = "@mailmymobile.net" //Ting + } } + //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 +126,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 +136,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 +151,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 { diff --git a/badgeManagement/badgeMinder/badgeMinderClose.js b/badgeManagement/badgeMinder/badgeMinderClose.js index 322ff3623d01b69632dbd1381c7516ca411fa135..2161ad17af4bc52f0cd84da708fb6d9466ee85f6 100644 --- a/badgeManagement/badgeMinder/badgeMinderClose.js +++ b/badgeManagement/badgeMinder/badgeMinderClose.js @@ -1,5 +1,5 @@ - function badgeMinderClose() { - console.log('close') + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer ipcRenderer.send('close minor window') + ipcRenderer.send('log', `ORNL Toolbox: Badge Minder closed`, 'info') } diff --git a/badgeManagement/badgeMinder/badgeMinderConfigLoad.js b/badgeManagement/badgeMinder/badgeMinderConfigLoad.js index 4e7a6f01fd4214aa11247fd7758e0dedc6de00a0..bd49a6d974b17bda101e10896335578021fbe376 100644 --- a/badgeManagement/badgeMinder/badgeMinderConfigLoad.js +++ b/badgeManagement/badgeMinder/badgeMinderConfigLoad.js @@ -22,6 +22,7 @@ function configLoad() { var phone3 var carrier + //Grabs saved settings for Badge Minder var contents = fs.readFileSync(remote.app.getPath('home') + '/.config/ornltoolbox/badgeMinder.config', 'utf-8', () => {}) contents = contents.split('\n') @@ -54,56 +55,26 @@ function configLoad() { document.getElementById('badgeMinderPhoneTextBox2').value = phone2 document.getElementById('badgeMinderPhoneTextBox3').value = phone3 - //Assigning a carrier number to the domain string - switch(carrier) { - case "@txt.att.net": - carrier = 1 //AT&T - break - case "@vtext.com": - carrier = 2 //Verizon - break - case "@email.uscc.net": - carrier = 3 //U.S. Cellular - break - case "@messaging.sprintpcs.com": - carrier = 4 //Sprint - break - case "@vmobl.com": - carrier = 5 //Virgin Mobile - break - case "@tmomail.net": - carrier = 6 //T-Mobile - break - case "@mmst5.tracfone.co": - carrier = 7 //Tracfone - break - case "@mymetropcs.com": - carrier = 8 //Metro PCS - break - case "@myboostmobile.com": - carrier = 9 //Boost Mobile - break - case "@sms.mycricket.com": - carrier = 10 //Cricket - break - case "@messaging.nextel.com": - carrier = 11 //Nextel - break - case "@message.alltel.com": - carrier = 12 //Alltel - break - case "@ptel.com": - carrier = 13 //Ptel - break - case "@tms.suncom.com": - carrier = 14 //Suncom - break - case "@qwestmp.com": - carrier = 15 //Qwest - break - case "@mailmymobile.net": - carrier = 16 //Ting + //Grabs carriers.csv for list of carriers + var carriersPath = remote.app.getPath('exe') //Grabs the path to the executable + carriersPath = carriersPath.substring(0, carriersPath.length - 11) + 'resources/app/badgeManagement/badgeMinder/carriers.csv' + var carriers = fs.readFileSync(carriersPath, 'utf-8', () => {}) + carriers = carriers.split(/,|\n/) + + //Retrieve the dropdown for carriers in Badge Minder + var carrierDropdown = document.getElementById('badgeMinderCarrier') + //Loop for assigning a carrier number to the domain string + for(i = 1; i < carriers.length; i+=2) { + if(carriers[i] == carrier) { //Correct carrier found, assign number + carrier = parseInt(i / 2) + 1 + } + var option = document.createElement('option') //Create new dropdown option + option.text = carriers[i - 1] //Assign correct carrier name to option + option.value = parseInt(i / 2) + 1 //Assign correct number to option + carrierDropdown.add(option) //Add dropdown option } + + //Assign previously selected value onto the initial page document.getElementById('badgeMinderCarrier').value = carrier } catch(error) { //No config file diff --git a/badgeManagement/badgeMinder/badgeMinderTest.js b/badgeManagement/badgeMinder/badgeMinderTest.js index 5ff445249224f60f22bd1c43c8d2e30a0a20b89b..bb1291b42f7e9737fe35353639d0ef13a69f2f8c 100644 --- a/badgeManagement/badgeMinder/badgeMinderTest.js +++ b/badgeManagement/badgeMinder/badgeMinderTest.js @@ -9,4 +9,5 @@ function badgeMinderTest() { console.log(err) console.log("Error with badgeMinderTest.bash") } + ipcRenderer.send('log', `ORNL Toolbox: Badge Minder tested`, 'info') } diff --git a/badgeManagement/badgeMinder/carriers.csv b/badgeManagement/badgeMinder/carriers.csv new file mode 100644 index 0000000000000000000000000000000000000000..d27cb63adfde07b4e12ee8b8b16b9ff4b97d5d56 --- /dev/null +++ b/badgeManagement/badgeMinder/carriers.csv @@ -0,0 +1,16 @@ +AT&T,@txt.att.net +Verizon,@vtext.com +U.S. Cellular,@email.uscc.net +Sprint,@messaging.sprintpcs.com +Virgin Mobile,@vmobl.com +T-Mobile,@tmomail.net +Tracfone,@mmst5.tracfone.com +Metro PCS,@mymetropcs.com +Boost Mobile,@myboostmobile.com +Cricket,@sms.mycricket.com +Nextel,@messaging.nextel.com +Alltel,@message.alltel.com +Ptel,@ptel.com +Suncom,@tms.suncom.com +Qwest,@qwestmp.com +Ting,@mailmymobile.net diff --git a/badgeManagement/tempMFARegistration/tempMFARegistration.css b/badgeManagement/tempMFARegistration/tempMFARegistration.css new file mode 100644 index 0000000000000000000000000000000000000000..da61f2b26dc2d33c75ab6409d4001ec18e70151a --- /dev/null +++ b/badgeManagement/tempMFARegistration/tempMFARegistration.css @@ -0,0 +1,70 @@ +/* Prevents highlighting of text, dragging of images, etc. */ +*, *::after, *::before { + margin: 0; + padding: 0; + -webkit-user-select: none; + -webkit-user-drag: none; + -webkit-app-region: no-drag; + font-family: 'Montserrat', sans-serif; +} + +div { + -webkit-user-select: none; + -webkit-user-drag: none; + -webkit-app-region: no-drag; + font-family: 'Montserrat', sans-serif; +} + +/* Horizontal line formatting */ +hr { + display: block; + margin-top: 0.15em; + margin-bottom: 0.15em; +} + +/* For submission buttons */ +input[type=submit] { + padding: 0; + border: none; + background: none; + font-size: 21px; +} + +#tempMFARegistrationPage { + display: flex; + flex-direction: column; + height: 100vh; + justify-content: center; + align-items: center; +} +#tempMFARegistrationText { + text-align: center; + font-size: 15px; + margin-bottom: 15px; + margin-left: 12px; + margin-right: 12px; +} +#tempMFARegistrationButton { + align-self: center; + background-color: #007833; + border-radius: 8px; + width: 68vw; + height: 30vh; + text-align: center; + font-size: 30px; + box-shadow: 0 3px 6px 0 rgba(0,0,0,0.2), 0 4px 8px 0 rgba(0,0,0,0.19); +} +#tempMFARegistrationButton:hover { + background-color: Gray; + cursor: pointer; +} +#tempMFARegistrationUserSelect { + margin-bottom: 4.5vh; + width: 25vw; +} + +.tempMFARegistrationLine { + display: flex; + flex-direction: row; + height: 15vh; +} diff --git a/badgeManagement/tempMFARegistration/tempMFARegistration.html b/badgeManagement/tempMFARegistration/tempMFARegistration.html new file mode 100644 index 0000000000000000000000000000000000000000..58eb6b3f6d2497efa66c22cbf73a59e7d4573f51 --- /dev/null +++ b/badgeManagement/tempMFARegistration/tempMFARegistration.html @@ -0,0 +1,27 @@ + + + + + Temporary SC Registration + + + + + +
+
+
+ Select a user: +
+ +
+
+ Please ensure that there is one smart card inserted before clicking 'Register' +
+ + + +
+ + diff --git a/badgeManagement/tempMFARegistration/tempMFARegistration.js b/badgeManagement/tempMFARegistration/tempMFARegistration.js new file mode 100644 index 0000000000000000000000000000000000000000..4f4c55660cb17bb26f2860f02a0d9401e49348d3 --- /dev/null +++ b/badgeManagement/tempMFARegistration/tempMFARegistration.js @@ -0,0 +1,89 @@ +const electron = require('electron') +const execSync = require('child_process').execSync +const ipcRenderer = require('electron').ipcRenderer +const remote = require('electron').remote + +//Checks if the Yubikey is locked and alerts the user accordingly +function tempMFARegistration() { + ipcRenderer.send('log', 'ORNL Toolbox: Submitted MFA temporary registration request', 'info') + + dropdown = document.getElementById('tempMFARegistrationUserSelect') + uid = dropdown.options[dropdown.selectedIndex].text + if(uid == "User") { + alert('Please select a user') + ipcRenderer.send('log', 'ORNL Toolbox: No user selected - request aborted', 'err') + return + } + + try { //Check for entry in digest mapping file + alert('Please insert an unregistered smart card before proceeding. Ensure it is the only smart card plugged in.') + if(!checkSmartCard()) return + //Grab the unregistered smart card mapping to be added + var entry = execSync(`echo "$(pkcs15-tool -r 1 --rfc4716 2>/dev/null | openssl x509 -noout -fingerprint -sha1 -inform pem | grep -Po '(?<==).*(?=$)') -> ${uid}"`, (error, stdout, stderr) => {}) + alert('Please remove the unregistered smart card and then insert a registered smart card. Ensure it is the only smart card plugged in.') + if(!checkSmartCard()) return + execSync(`pkexec bash -c 'echo "${entry}" >> /etc/pam_pkcs11/digest_mapping'`, () => {}) + } catch(error) { + error = error.toString() + console.log(error) + alert('An error occured during the registration process') + ipcRenderer.send('log', 'ORNL Toolbox: An error occured during the registration process - request aborted', 'err') + return + } + + alert('Initally inserted smart card is now temporarily registered') + ipcRenderer.send('log', 'ORNL Toolbox: Completed MFA temporary registration request', 'info') +} + +function checkSmartCard() { + try { //Scan for active smart card slots for inserted smart cards + var cardCheck = execSync(`pkcs11-tool -T | grep "Slot"`, (error, stdout, stderr) => {}) + cardCheck = cardCheck.toString() + } catch(error) { + error = error.toString() + if(error.includes("No slots")) { + alert('No smart card inserted') + ipcRenderer.send('log', 'ORNL Toolbox: No smart card inserted - request aborted', 'err') + return + } else { + alert(error) + ipcRenderer.send('log', 'ORNL Toolbox: Error checking for smart card - request aborted', 'err') + return + } + } + + //Check for the number of smart card slots + var count = (cardCheck.match(/Slot/g) || []).length; + if(count > 1) { //More than one slot found + alert('Please ensure only one smart card is inserted') + ipcRenderer.send('log', 'ORNL Toolbox: More than one smart card inserted - request aborted', 'err') + return false + } else if(count < 1) { //No slots found + alert('No smart card inserted') + ipcRenderer.send('log', 'ORNL Toolbox: No smart card inserted - request aborted', 'err') + return false + } else { + ipcRenderer.send('log', 'ORNL Toolbox: 1 smart card found inserted', 'info') + return true + } +} + +function tempMFARegistrationLoad() { //Loading the users + if(!execSync) var execSync = require('child_process').execSync + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer + + //Adding the options of the dropdown menu + var optionValue = 1 + var dropdownString = '' + var users = execSync('ls /home', () => {}) + users = users.toString() + userArray = users.split('\n') + for(i = 0; i < userArray.length; i++) { + //Skip blanks and users that are not UIDs + if(userArray[i].trim() == "" || (userArray[i].trim()).length != 3) continue + dropdownString = dropdownString + '\n' + `` + optionValue++ + } + document.getElementById('tempMFARegistrationUserSelect').innerHTML = dropdownString; + ipcRenderer.send('log', `ORNL Toolbox: List of users loaded`, 'info') +} diff --git a/badgeManagement/yubiBadgeCheckpoint/yubiBadgeCheckpoint.js b/badgeManagement/yubiBadgeCheckpoint/yubiBadgeCheckpoint.js index 3f47fd8440bbbb5ead181e9d5d330cdd153982b1..407d348cfbaf38f229d913b025420f92bde87360 100644 --- a/badgeManagement/yubiBadgeCheckpoint/yubiBadgeCheckpoint.js +++ b/badgeManagement/yubiBadgeCheckpoint/yubiBadgeCheckpoint.js @@ -1,6 +1,8 @@ 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) diff --git a/badgeManagement/yubiChanger/yubiChanger.js b/badgeManagement/yubiChanger/yubiChanger.js index 0d1580207f3b695a8e68c3723fe2324410922b31..b5b142d211d3b5a7c9213763a67d6733fb3d1668 100644 --- a/badgeManagement/yubiChanger/yubiChanger.js +++ b/badgeManagement/yubiChanger/yubiChanger.js @@ -1,9 +1,12 @@ 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') } } diff --git a/badgeManagement/yubiChecker/yubiChecker.js b/badgeManagement/yubiChecker/yubiChecker.js index 2555f047953eb5428f28c63848c8d3575bc26f7d..3ca3e4fd2ffa13b5c14cb8a7df9073837879331d 100644 --- a/badgeManagement/yubiChecker/yubiChecker.js +++ b/badgeManagement/yubiChecker/yubiChecker.js @@ -1,15 +1,21 @@ 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`, 'info') } + ipcRenderer.send('log', 'ORNL Toolbox: Completed Yubikey check request', 'info') } diff --git a/build.bash b/build.bash index 48ec0c8df407055773e594f67723eae71614d818..08f3d611d162551b67ece99253008477d48264be 100644 --- a/build.bash +++ b/build.bash @@ -6,7 +6,7 @@ if [[ ${CI_COMMIT_REF_NAME} == 'master' ]]; then else BRANCH="-${CI_COMMIT_REF_NAME}" fi -VERSION_NUMBER='1.0.11' +VERSION_NUMBER='1.3.7' 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 @@ -16,6 +16,6 @@ npm install electron-packager sed -i "s/VERSION_NUMBER/$VERSION_NUMBER/" ./about/about.html npm run build mv ./Releases/ornltoolbox-linux-x64 ./ornltoolbox -sudo /usr/local/bin/fpm -s dir -f -n ornltoolbox${BRANCH} --provides ornltoolbox --deb-no-default-config-files -v $VERSION_NUMBER --description "A collection of ORNL Linux tools" -t deb -p /opt/ornltoolbox${BRANCH}-${VERSION_NUMBER}.deb --prefix /opt --after-install ./packages/packagePostInstall.bash --after-remove ./packages/packagePostRemove.bash --before-upgrade ./packages/packagePostRemove.bash --after-upgrade ./packages/packagePostInstall.bash -d 'libgconf-2-4' -d 'gnome-screensaver' -d 'yubico-piv-tool' -d 'sox' -d 'smartmontools' -d 'policykit-1-gnome' -d 'desktop-file-utils' ./ornltoolbox -sudo /usr/local/bin/fpm -s dir -f -n ornltoolbox${BRANCH} --provides ornltoolbox --deb-no-default-config-files -v $VERSION_NUMBER --description "A collection of ORNL Linux tools" -t rpm -p /opt/ornltoolbox${BRANCH}-${VERSION_NUMBER}.rpm --prefix /opt --after-install ./packages/packagePostInstall.bash --after-remove ./packages/packagePostRemove.bash --before-upgrade ./packages/packagePostRemove.bash --after-upgrade ./packages/packagePostInstall.bash -d 'libXScrnSaver' -d 'gnome-screensaver' -d 'yubico-piv-tool' -d 'sox' -d 'smartmontools' -d 'polkit-gnome' ./ornltoolbox +sudo /usr/local/bin/fpm -s dir -f -n ornltoolbox${BRANCH} --provides ornltoolbox --deb-no-default-config-files -v $VERSION_NUMBER --description "A collection of ORNL Linux tools" -t deb -p /opt/ornltoolbox${BRANCH}-${VERSION_NUMBER}.deb --prefix /opt --after-install ./packages/packagePostInstall.bash --after-remove ./packages/packagePostRemove.bash --before-upgrade ./packages/packagePostRemove.bash --after-upgrade ./packages/packagePostInstall.bash -d 'libgconf-2-4' -d 'yubico-piv-tool' -d 'sox' -d 'smartmontools' -d 'policykit-1-gnome' -d 'desktop-file-utils' ./ornltoolbox +sudo /usr/local/bin/fpm -s dir -f -n ornltoolbox${BRANCH} --provides ornltoolbox --deb-no-default-config-files -v $VERSION_NUMBER --description "A collection of ORNL Linux tools" -t rpm -p /opt/ornltoolbox${BRANCH}-${VERSION_NUMBER}.rpm --prefix /opt --after-install ./packages/packagePostInstall.bash --after-remove ./packages/packagePostRemove.bash --before-upgrade ./packages/packagePostRemove.bash --after-upgrade ./packages/packagePostInstall.bash -d 'libXScrnSaver' -d 'yubico-piv-tool' -d 'sox' -d 'smartmontools' -d 'polkit-gnome' ./ornltoolbox cp /opt/ornltoolbox${BRANCH}-${VERSION_NUMBER}* . diff --git a/feedback/feedback.js b/feedback/feedback.js index 28a3e2003a4ee440bf4e152a76e1ea7f265ae07a..b78b96aff3282584aba0b44c0643dbbe3add603b 100644 --- a/feedback/feedback.js +++ b/feedback/feedback.js @@ -6,6 +6,9 @@ const ipc = require('electron').ipcRenderer //Send feedback email function sendFeedback() { + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer + ipcRenderer.send('log', 'ORNL Toolbox: Submitted request to send feedback email', 'info') + var cat = document.getElementById('feedbackCategory').value var body = document.getElementById('feedbackTextBox').value var subject @@ -18,6 +21,7 @@ function sendFeedback() { case 0: subject = "" alert('Please choose a category') + ipcRenderer.send('log', 'ORNL Toolbox: No feedback email category selected - request aborted', 'err') return case 1: subject = "Bug Report" @@ -38,19 +42,27 @@ function sendFeedback() { if(body == "") { alert('Please explain the issue') + ipcRenderer.send('log', 'ORNL Toolbox: Email body is blank - request aborted', 'err') return } command = `bash /opt/ornltoolbox/resources/app/feedback/feedback-emailer.sh "ORNL Toolbox Feedback: ${subject}" "${body}"` //Send the feedback email - execSync(command, (error, stdout, stderr) => { + var result = execSync(command, (error, stdout, stderr) => { if(stderr) { alert(`${stderr}`) + return 1 } }) + if(result == 1) { + ipcRenderer.send('log', 'ORNL Toolbox: Failed to send the feedback email - request aborted', 'err') + return + } + alert('Feedback sent') + ipcRenderer.send('log', 'ORNL Toolbox: Completed feedback email request', 'info') let feedWin = remote.getGlobal('addWindow') feedWin.destroy() if(feedWin) { diff --git a/fileSystemManagement/addPassphrase/addPassphrase.js b/fileSystemManagement/addPassphrase/addPassphrase.js index 839c916492969eb286aa8e6fd139a1e6db3bab1e..79b3d8be212edcbb2d6b8e2c6d5952e53979d39a 100644 --- a/fileSystemManagement/addPassphrase/addPassphrase.js +++ b/fileSystemManagement/addPassphrase/addPassphrase.js @@ -1,11 +1,15 @@ 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) diff --git a/fileSystemManagement/baobabCheckpoint/baobabCheckpoint.css b/fileSystemManagement/baobabCheckpoint/baobabCheckpoint.css new file mode 100644 index 0000000000000000000000000000000000000000..4227d09593fcd442e1465de1241c745c78b550b8 --- /dev/null +++ b/fileSystemManagement/baobabCheckpoint/baobabCheckpoint.css @@ -0,0 +1,72 @@ +/* Prevents highlighting of text, dragging of images, etc. */ +*, *::after, *::before { + margin: 0; + padding: 0; + -webkit-user-select: none; + -webkit-user-drag: none; + -webkit-app-region: no-drag; + font-family: 'Montserrat', sans-serif; +} + +div { + -webkit-user-select: none; + -webkit-user-drag: none; + -webkit-app-region: no-drag; + font-family: 'Montserrat', sans-serif; +} + +/* Horizontal line formatting */ +hr { + display: block; + margin-top: 0.15em; + margin-bottom: 0.15em; +} + +/* For submission buttons */ +input[type=submit] { + padding: 0; + border: none; + background: none; + font-size: 21px; +} + +#baobabCheckpointPage { + display: flex; + height: 100vh; + flex-direction: column; + justify-content: center; + align-items: center; +} + +#baobabCheckpointText { + font-size: 16px; + text-align: center; + margin-bottom: 25px; + margin-left: 12px; + margin-right: 12px; +} + +.baobabCheckpointButtonsContent { + width: 100vw; + height: 10vh; + display: flex; + flex-direction: row; + justify-content: center; +} + +.baobabCheckpointButtons { + text-align: center; + align-items: center; + width: 22vw; + height: 18vh; + margin-right: 12.5px; + margin-left: 12.5px; + background-color: #007833 !important; + border-radius: 8px; + box-shadow: 0 2px 4px 0 rgba(0,0,0,0.2), 0 4px 8px 0 rgba(0,0,0,0.19); + color: White; +} +.baobabCheckpointButtons:hover { + background-color: Gray !important; + cursor: pointer; +} diff --git a/fileSystemManagement/baobabCheckpoint/baobabCheckpoint.html b/fileSystemManagement/baobabCheckpoint/baobabCheckpoint.html new file mode 100644 index 0000000000000000000000000000000000000000..420ac767d2a7377d641d8af42574715bd8ee4b4b --- /dev/null +++ b/fileSystemManagement/baobabCheckpoint/baobabCheckpoint.html @@ -0,0 +1,30 @@ + + + + + Baobab Checkpoint + + + + + + + + +
+
+ Baobab is not currently installed. 'Local Drive Usage' opens + the Disk Usage Analyzer which requires baobab. Would you like to + install it? +
+
+ + + + + + +
+
+ + diff --git a/fileSystemManagement/baobabCheckpoint/baobabCheckpoint.js b/fileSystemManagement/baobabCheckpoint/baobabCheckpoint.js new file mode 100644 index 0000000000000000000000000000000000000000..c8e48d0e5ff2e15c5fc7251fd504012fdd8ebb37 --- /dev/null +++ b/fileSystemManagement/baobabCheckpoint/baobabCheckpoint.js @@ -0,0 +1,42 @@ +function baobabCheckpoint() { + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer + if(!execSync) var execSync = require('child_process').execSync + + ipcRenderer.send('log', 'ORNL Toolbox: Submitted baobab checkpoint request', 'info') + + var os + try { //Detect OS + execSync('grep Ubuntu /etc/os-release') + os = "Ubuntu" + ipcRenderer.send('log', 'ORNL Toolbox: OS determined to be Ubuntu', 'info') + } catch(error) { + //"Ubuntu" not found in file + os = "RHEL" + ipcRenderer.send('log', 'ORNL Toolbox: OS determined to be RHEL', 'info') + } + + try { + if(os == "Ubuntu") { + package = execSync(`apt -qq list --installed baobab`) + } else { + package = execSync(`yum list installed baobab | grep baobab`) + } + } catch(error) { + error = error.toString() + if(os != "Ubuntu" && error.includes("No matching Packages to list")) { + package = "" + } else { + alert(error) + ipcRenderer.send('log', 'ORNL Toolbox: Failed while checking for baobab - request aborted', 'err') + return + } + } + + ipcRenderer.send('log', 'ORNL Toolbox: Completed baobab checkpoint request', 'info') + + if(package == "") { + addWinMain('./fileSystemManagement/baobabCheckpoint/baobabCheckpoint.html', 'Baobab Checkpoint', 400, 175) + } else { + openDiskUsageAnalyzer() + } +} diff --git a/fileSystemManagement/baobabCheckpoint/baobabCheckpointConfirm.js b/fileSystemManagement/baobabCheckpoint/baobabCheckpointConfirm.js new file mode 100644 index 0000000000000000000000000000000000000000..769089a6563a1fb220acdc2d81582f2b97f05c46 --- /dev/null +++ b/fileSystemManagement/baobabCheckpoint/baobabCheckpointConfirm.js @@ -0,0 +1,50 @@ +function baobabCheckpointConfirm() { + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer + if(!execSync) var execSync = require('child_process').execSync + + ipcRenderer.send('log', 'ORNL Toolbox: Submitted install request for baobab', 'info') + + var os + try { //Detect OS + execSync('grep Ubuntu /etc/os-release') + os = "Ubuntu" + ipcRenderer.send('log', 'ORNL Toolbox: OS determined to be Ubuntu', 'info') + } catch(error) { + //"Ubuntu" not found in file + os = "RHEL" + ipcRenderer.send('log', 'ORNL Toolbox: OS determined to be RHEL', 'info') + } + + try { //Install baobab + if(os == "Ubuntu") { + execSync(`pkexec apt install baobab`) + } else { + execSync(`pkexec yum -y install baobab`) + } + } catch(error) { + error = error.toString() + if(error.includes("Request dismissed")) { + ipcRenderer.send('log', 'ORNL Toolbox: Request canceled by user', 'err') + baobabClose() + return + } else { + ipcRenderer.send('log', 'ORNL Toolbox: Failed to install baobab - request aborted', 'err') + console.error(error) + alert(error) + baobabClose() + } + } + + alert('Baobab successfully installed') + ipcRenderer.send('log', 'ORNL Toolbox: Completed install request for baobab', 'info') + + //Open baobab + openDiskUsageAnalyzer() + baobabClose() +} + +function baobabClose() { + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer + ipcRenderer.send('close minor window') + ipcRenderer.send('log', `ORNL Toolbox: Baobab checkpoint closed`, 'info') +} diff --git a/fileSystemManagement/driveHealthCheck/driveHealthCheck.js b/fileSystemManagement/driveHealthCheck/driveHealthCheck.js index e655c598362a598410d54eaebe583f01f0008846..99e3b68877c24b507aafe56b04fa32a1e0b1185d 100644 --- a/fileSystemManagement/driveHealthCheck/driveHealthCheck.js +++ b/fileSystemManagement/driveHealthCheck/driveHealthCheck.js @@ -1,8 +1,13 @@ 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,12 @@ 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') + return } } + ipcRenderer.send('log', 'ORNL Toolbox: Completed Drive Health Check request', 'info') } diff --git a/fileSystemManagement/fileSystemManagement.html b/fileSystemManagement/fileSystemManagement.html index 38ee7b187208339668a010e052473cf05ef365c4..2e745af6556e0f1027c2ec5d0b6e68fabf3a4cbd 100644 --- a/fileSystemManagement/fileSystemManagement.html +++ b/fileSystemManagement/fileSystemManagement.html @@ -10,9 +10,12 @@ + + + @@ -46,7 +49,7 @@
Register Recovery Key
-
Local Drive Usage
+
Local Drive Usage
Drive Health Check
@@ -54,7 +57,7 @@
-
+
White Chat Bubble
@@ -62,7 +65,7 @@
-
+
Question Mark
diff --git a/fileSystemManagement/fileSystemManagement.js b/fileSystemManagement/fileSystemManagement.js index 4456125532fe2ca40a10f873f1bd7218b00ccde1..7bf4649ba36540595fcb2f42542a5c7f7b82e767 100644 --- a/fileSystemManagement/fileSystemManagement.js +++ b/fileSystemManagement/fileSystemManagement.js @@ -1,5 +1,6 @@ //Change to file system management page after closing the minor window function fileSysWin() { + ipcRenderer.send('log', 'ORNL Toolbox: Opened File System Management', 'info') //Destroying any minor windows that were opened from the main window ipcRenderer.send('close minor window') // Change main window to file system management window diff --git a/fileSystemManagement/localDriveUsage/localDriveUsage.js b/fileSystemManagement/localDriveUsage/localDriveUsage.js index 243e46d2eb5eeb1e9dc15e572a3e49d5aa23ef4f..119a7cb10b7615d340d6fbf8b27153678eba6c5c 100644 --- a/fileSystemManagement/localDriveUsage/localDriveUsage.js +++ b/fileSystemManagement/localDriveUsage/localDriveUsage.js @@ -1,14 +1,21 @@ - function openDiskUsageAnalyzer() { //Open Disk Usage Analyzer application + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer + if(!exec) var exec = require('child_process').exec + + 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') } diff --git a/fileSystemManagement/passphraseCheckpoint/passphraseCheckpoint.js b/fileSystemManagement/passphraseCheckpoint/passphraseCheckpoint.js index 4b0c9dac6010d70fb46153b5d72dfa70159d7ac7..48c79b356d870858460bcf58116272cb3407fa71 100644 --- a/fileSystemManagement/passphraseCheckpoint/passphraseCheckpoint.js +++ b/fileSystemManagement/passphraseCheckpoint/passphraseCheckpoint.js @@ -1,3 +1,5 @@ +//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 diff --git a/fileSystemManagement/registerRecoveryKey/registerRecoveryKey.js b/fileSystemManagement/registerRecoveryKey/registerRecoveryKey.js index b7a2e8085a11a0d4cecc772063b4fa880e338d7b..41da7a1fd7d59a50a876ff5a80e49dadba8b656c 100644 --- a/fileSystemManagement/registerRecoveryKey/registerRecoveryKey.js +++ b/fileSystemManagement/registerRecoveryKey/registerRecoveryKey.js @@ -1,18 +1,22 @@ - 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) } diff --git a/fileSystemManagement/removePassphrase/removePassphrase.js b/fileSystemManagement/removePassphrase/removePassphrase.js index 7388eb6310300e486352922f528fdcd1946c203c..fc472f566ac43484e1f54c6632c824a5fcc0af8c 100644 --- a/fileSystemManagement/removePassphrase/removePassphrase.js +++ b/fileSystemManagement/removePassphrase/removePassphrase.js @@ -1,11 +1,15 @@ 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) diff --git a/help/help.js b/help/help.js index d559c3548bc0e30714767f5200096a6d1be2c03f..3efa33baa6bebb3903450e32d178fd2a81494618 100644 --- a/help/help.js +++ b/help/help.js @@ -2,6 +2,8 @@ const execSync = require('child_process').execSync const remote = require('electron').remote function getHostName() { + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer + try { var hostname = execSync('hostname', () => {}) hostname = (hostname.toString()).trim() @@ -11,12 +13,18 @@ function getHostName() { document.getElementById("helpDevice").value = hostname } catch(error) { console.error(error) + ipcRenderer.send('log', 'ORNL Toolbox: Failed to retrieve host name', 'err') + return } + ipcRenderer.send('log', 'ORNL Toolbox: Sucessfully retrieved host name', 'info') } function help() { + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer if(!fs) var fs = require('fs') + ipcRenderer.send('log', 'ORNL Toolbox: Submitted request to send help email', 'info') + var short = document.getElementById('helpShort').value var long = document.getElementById('helpLong').value var replyTo = execSync('whoami', () => {}) @@ -27,8 +35,8 @@ function help() { var subject = "Help Request from ORNL Toolbox" //William Key's email receiver requires two newlines to process a ticket correctly - //This strangeness is to allow users to type ' " and ` freely - fs.writeFileSync("/tmp/ToolboxEmail.txt", String.raw`uid="${replyTo}" + //This strangeness is to allow users to type ', ", and ` freely + var result = fs.writeFileSync("/tmp/ToolboxEmail.txt", String.raw`uid="${replyTo}" deviceName="${hostname}" @@ -36,21 +44,34 @@ shortDescription="${short}" longDescription="${long}"`, (err) => { if(err) { - return console.log(err); + return 1; } }) + if(result == 1) { + ipcRenderer.send('log', 'ORNL Toolbox: Error creating the help email - request aborted', 'err') + } else { + ipcRenderer.send('log', 'ORNL Toolbox: Help email successfully created', 'info') + } + command = `bash /opt/ornltoolbox/resources/app/help/help-emailer.sh "${subject}" "$(cat /tmp/ToolboxEmail.txt)"` //Send the help email - execSync(command, (error, stdout, stderr) => { + result = execSync(command, (error, stdout, stderr) => { if(stderr) { alert(`${stderr}`) + return 1 } }) + if(result == 1) { + ipcRenderer.send('log', 'ORNL Toolbox: Failed to send the help email - request aborted', 'err') + return + } + alert('Incident created - your issue will be addressed as soon as possible') + ipcRenderer.send('log', 'ORNL Toolbox: Completed help email request', 'info') let helpWin = remote.getGlobal('addWindow') helpWin.destroy() if(helpWin) { diff --git a/index.html b/index.html index f80e821de68bd45a03f1c12e2cb801272c369ef2..7a034cd00d572d55e5599131cfdddb63303a5f8f 100644 --- a/index.html +++ b/index.html @@ -13,9 +13,11 @@ + + @@ -26,6 +28,7 @@ + @@ -71,15 +74,15 @@
0
-
+
White Chat Bubble
Feedback
- -
+ +
Question Mark
diff --git a/its/its.html b/its/its.html index 7ff61b14f869874611d2557b9f26a209a8a2a59b..63fdf1872b1f064aa95a8d1d1b6e13a437687f0f 100644 --- a/its/its.html +++ b/its/its.html @@ -10,12 +10,15 @@ + + +
@@ -55,7 +58,7 @@
-
+
White Chat Bubble
@@ -63,7 +66,7 @@
-
+
Question Mark
diff --git a/its/its.js b/its/its.js index db18f7dc7e7285a6521bdc888bf79951eea869e0..c61a4328a12fd3c2fec111185164a6ee753d5a38 100644 --- a/its/its.js +++ b/its/its.js @@ -1,5 +1,6 @@ //Change to IT Support and Services page after closing the minor window function itsWin() { + ipcRenderer.send('log', 'ORNL Toolbox: Opened IT Services & Support', 'info') //Destroying any minor windows that were opened from the main window ipcRenderer.send('close minor window') // Change main window to IT Services and Support window diff --git a/main.js b/main.js index d36d84ce8d0cafeb4d2c8fb4cc990ccff5ed6f25..f8b6c1f8dbdb890dcb3b5194ddd14832f9dbe34b 100644 --- a/main.js +++ b/main.js @@ -47,7 +47,7 @@ function createWindow() { app.quit() }) - //Keyboard shortcuts + //Keyboard shortcuts, mostly for reference, but currently work globalShortcut.register('CommandOrControl+1', () => { mainWindow.minimize() }) @@ -56,6 +56,7 @@ function createWindow() { }) // Creates custom menu template + // This is for the quick menus at the top of the app const menuTemplate = [ { label: 'ORNL Toolbox', @@ -134,6 +135,20 @@ function createWindow() { click: () => { mainWindow.webContents.send('openYubiChanger') } + }, { + type: 'separator' + }, { + label: 'MFA Verification', + click: () => { + mainWindow.webContents.send('openMFAVerification') + } + }, { + type: 'separator' + }, { + label: 'Temporary MFA Registration', + click: () => { + mainWindow.webContents.send('openTempMFARegistration') + } } ] }, { @@ -367,12 +382,28 @@ ipcMain.on('close minor window', () => { if(addWindow != null) addWindow.destroy() }) +ipcMain.on('log', (event, message, level) => { + try { + execSync(`echo '${message}' | logger -p local0.${level}`) + } catch(error) { + console.error(error) + return + } +}) + ipcMain.on('close app', () => { app.quit() - exit() }) -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() @@ -383,3 +414,12 @@ app.on('activate', () => { createWindow() } }) + +app.on('will-quit', () => { + try { + execSync(`echo 'ORNL Toolbox: Toolbox closed' | logger -p local0.info`) + } catch(error) { + console.error(error) + return + } +}) diff --git a/miscjs/addWindow.js b/miscjs/addWindow.js index f259efb137c1d4f3ce4677e875b8cfb9659775eb..0bc7a8e5cbf91502af53bb91afd54982c7bb5909 100644 --- a/miscjs/addWindow.js +++ b/miscjs/addWindow.js @@ -4,5 +4,6 @@ const ipcRenderer = require('electron').ipcRenderer //Sends a signal to the main process to open a new window function addWinMain(file, title, width, height) { + ipcRenderer.send('log', `ORNL Toolbox: Opened ${title}`, 'info') ipcRenderer.send('new window', file, title, width, height) } diff --git a/miscjs/backToMain.js b/miscjs/backToMain.js index 0ca1752200a9f8a76c09a93622c015bb64e88560..42e13ead23d8b5a7b784093e7c9444c89f87b6a7 100644 --- a/miscjs/backToMain.js +++ b/miscjs/backToMain.js @@ -1,6 +1,8 @@ /* Causes minor windows to close and the major page to switch back to the home page when clicking the back button */ function backToMain() { + ipcRenderer.send('log', 'ORNL Toolbox: Opened Main Menu', 'info') + //Destroying any minor windows that were opened from the main window ipcRenderer.send('close minor window') // Change main window to user management window ipcRenderer.send('load-page', './index.html') diff --git a/miscjs/menuFunctionCalls.js b/miscjs/menuFunctionCalls.js index ba1f69a4c1d5dd0c96e84bf5bf59661f798709d3..dc7ca60319e00134ff1c49b65f31991c39de4d3b 100644 --- a/miscjs/menuFunctionCalls.js +++ b/miscjs/menuFunctionCalls.js @@ -17,7 +17,7 @@ ipcRenderer.on('openSudoManagement', () => { }) ipcRenderer.on('openBadgeMinder', () => { - addWinMain('./badgeManagement/badgeMinder/badgeMinder.html', 'Badge Minder', 450, 360) + badgeInstallCheckpoint() }) ipcRenderer.on('openYubiChecker', () => { @@ -28,6 +28,14 @@ ipcRenderer.on('openYubiChanger', () => { yubiBadgeCheckpoint(1) }) +ipcRenderer.on('openMFAVerification', () => { + addWinMain('./badgeManagement/MFAVerification/MFAVerification.html', 'Smart Card Verification', 225, 180) +}) + +ipcRenderer.on('openTempMFARegistration', () => { + addWinMain('./badgeManagement/tempMFARegistration/tempMFARegistration.html', 'Temporary Smart Card Registration', 225, 180) +}) + ipcRenderer.on('openWebsite', (event, message) => { openURL(message) }) @@ -37,7 +45,7 @@ ipcRenderer.on('launchBomgar', () => { }) ipcRenderer.on('openInstaller', () => { - openSoftware(0) + softwareCheckpoint() }) ipcRenderer.on('openUpdater', () => { @@ -45,7 +53,7 @@ ipcRenderer.on('openUpdater', () => { }) ipcRenderer.on('openDriveUsage', () => { - openDiskUsageAnalyzer() + baobabCheckpoint() }) ipcRenderer.on('openAbout', () => { diff --git a/miscjs/openURL.js b/miscjs/openURL.js index e1036743526282e672abdada90494302421721f5..38b036f046b40d43b5de9dde706c3ba8ad867572 100644 --- a/miscjs/openURL.js +++ b/miscjs/openURL.js @@ -2,5 +2,7 @@ const shell = require('electron').shell //Open the given url in the default browser function openURL(url) { + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer + ipcRenderer.send('log', `ORNL Toolbox: Opened ${url}`, 'info') shell.openExternal(`${url}`) } diff --git a/package.json b/package.json index 09e83170652cbff4453aead305ff74139c4f697a..35abb6ad62ad07688aa60e4bf0fb2ab61083cc0c 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Applications Suite of Linux functions for ORNL Linux systems", "main": "main.js", "scripts": { - "start": "electron . &>/dev/null", + "start": "electron .", "build": "electron-packager . ornltoolbox --overwrite --prune=true --out=Releases" }, "keywords": [ diff --git a/softwareManagement/openSoftware/openSoftware.js b/softwareManagement/openSoftware/openSoftware.js index d78505239b14f668b2f882ef2e6af3b9c1a39bbf..12b4455083154e99ee640f8d838c5d6208c0a241 100644 --- a/softwareManagement/openSoftware/openSoftware.js +++ b/softwareManagement/openSoftware/openSoftware.js @@ -1,37 +1,48 @@ const exec = require('child_process').exec function openSoftware(mode) { //Open gnome software application + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer if(mode == 0) { + ipcRenderer.send('log', 'ORNL Toolbox: Submitted request to open Gnome Software', 'info') if(! installedCheck("gnome-software")) { 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: Gnome Software is not installed - request aborted', 'err') return } exec('gnome-software', (error, stdout, stderr) => { if(error) { console.error(`exec error: ${error}`) + ipcRenderer.send('log', 'ORNL Toolbox: Failed to open Gnome Software', 'err') return } }) + ipcRenderer.send('log', 'ORNL Toolbox: Opened Gnome Software', 'info') } else { //For small orange and red badges to redirect to updates page if(!execSync) var execSync = require('child_process').execSync + ipcRenderer.send('log', 'ORNL Toolbox: Submitted request to open OS-specific updates program', 'info') + var isUbuntu = execSync('grep Ubuntu /etc/os-release || true', () => {}) isUbuntu = isUbuntu.toString() if(isUbuntu == "") { //Use RHEL update program exec('/usr/bin/gpk-update-viewer', (error, stdout, stderr) => { if(error) { - console.error(`exec error: ${error}`); + console.error(`exec error: ${error}`) + ipcRenderer.send('log', 'ORNL Toolbox: Failed to open RHEL updates program', 'err') return; } }) + ipcRenderer.send('log', 'ORNL Toolbox: Opened RHEL updates program', 'info') } else { //Use Ubuntu update program exec('/usr/bin/update-manager', (error, stdout, stderr) => { if(error) { - console.error(`exec error: ${error}`); + console.error(`exec error: ${error}`) + ipcRenderer.send('log', 'ORNL Toolbox: Failed to open Ubuntu updates program', 'err') return; } }) + ipcRenderer.send('log', 'ORNL Toolbox: Opened Ubuntu updates program', 'info') } } } diff --git a/softwareManagement/softwareCheckpoint/softwareCheckpoint.css b/softwareManagement/softwareCheckpoint/softwareCheckpoint.css new file mode 100644 index 0000000000000000000000000000000000000000..a9521071b2a502d55ff901e50e838de3e1d4d95f --- /dev/null +++ b/softwareManagement/softwareCheckpoint/softwareCheckpoint.css @@ -0,0 +1,72 @@ +/* Prevents highlighting of text, dragging of images, etc. */ +*, *::after, *::before { + margin: 0; + padding: 0; + -webkit-user-select: none; + -webkit-user-drag: none; + -webkit-app-region: no-drag; + font-family: 'Montserrat', sans-serif; +} + +div { + -webkit-user-select: none; + -webkit-user-drag: none; + -webkit-app-region: no-drag; + font-family: 'Montserrat', sans-serif; +} + +/* Horizontal line formatting */ +hr { + display: block; + margin-top: 0.15em; + margin-bottom: 0.15em; +} + +/* For submission buttons */ +input[type=submit] { + padding: 0; + border: none; + background: none; + font-size: 21px; +} + +#softwareCheckpointPage { + display: flex; + height: 100vh; + flex-direction: column; + justify-content: center; + align-items: center; +} + +#softwareCheckpointText { + font-size: 16px; + text-align: center; + margin-bottom: 25px; + margin-left: 12px; + margin-right: 12px; +} + +.softwareCheckpointButtonsContent { + width: 100vw; + height: 10vh; + display: flex; + flex-direction: row; + justify-content: center; +} + +.softwareCheckpointButtons { + text-align: center; + align-items: center; + width: 22vw; + height: 18vh; + margin-right: 12.5px; + margin-left: 12.5px; + background-color: #007833 !important; + border-radius: 8px; + box-shadow: 0 2px 4px 0 rgba(0,0,0,0.2), 0 4px 8px 0 rgba(0,0,0,0.19); + color: White; +} +.softwareCheckpointButtons:hover { + background-color: Gray !important; + cursor: pointer; +} diff --git a/softwareManagement/softwareCheckpoint/softwareCheckpoint.html b/softwareManagement/softwareCheckpoint/softwareCheckpoint.html new file mode 100644 index 0000000000000000000000000000000000000000..c5de201014e64e3ba95cf04d0c0cdc12342cc477 --- /dev/null +++ b/softwareManagement/softwareCheckpoint/softwareCheckpoint.html @@ -0,0 +1,29 @@ + + + + + Software Checkpoint + + + + + + + + +
+
+ Gnome-Software is not currently installed. 'Install Software' opens + Gnome-Software. Would you like to install it? +
+
+ + + + + + +
+
+ + diff --git a/softwareManagement/softwareCheckpoint/softwareCheckpoint.js b/softwareManagement/softwareCheckpoint/softwareCheckpoint.js new file mode 100644 index 0000000000000000000000000000000000000000..e067be96722f299bad82d983183655f0dc89eb38 --- /dev/null +++ b/softwareManagement/softwareCheckpoint/softwareCheckpoint.js @@ -0,0 +1,42 @@ +function softwareCheckpoint() { + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer + if(!execSync) var execSync = require('child_process').execSync + + ipcRenderer.send('log', 'ORNL Toolbox: Submitted Software Checkpoint request', 'info') + + var os + try { //Detect OS + execSync('grep Ubuntu /etc/os-release') + os = "Ubuntu" + ipcRenderer.send('log', 'ORNL Toolbox: OS determined to be Ubuntu', 'info') + } catch(error) { + //"Ubuntu" not found in file + os = "RHEL" + ipcRenderer.send('log', 'ORNL Toolbox: OS determined to be RHEL', 'info') + } + + try { + if(os == "Ubuntu") { + package = execSync(`apt -qq list --installed gnome-software`) + } else { + package = execSync(`yum list installed gnome-software | grep gnome-software`) + } + } catch(error) { + error = error.toString() + if(os != "Ubuntu" && error.includes("No matching Packages to list")) { + package = "" + } else { + alert(error) + ipcRenderer.send('log', 'ORNL Toolbox: Failed while checking for gnome-software - request aborted', 'err') + return + } + } + + ipcRenderer.send('log', 'ORNL Toolbox: Completed Software Checkpoint request', 'info') + + if(package == "") { + addWinMain('./softwareManagement/softwareCheckpoint/softwareCheckpoint.html', 'Software Checkpoint', 400, 175) + } else { + openSoftware(0) + } +} diff --git a/softwareManagement/softwareCheckpoint/softwareCheckpointConfirm.js b/softwareManagement/softwareCheckpoint/softwareCheckpointConfirm.js new file mode 100644 index 0000000000000000000000000000000000000000..36d7233bee2940235f68cbe0fa3db146b5772d62 --- /dev/null +++ b/softwareManagement/softwareCheckpoint/softwareCheckpointConfirm.js @@ -0,0 +1,50 @@ +function softwareCheckpointConfirm() { + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer + if(!execSync) var execSync = require('child_process').execSync + + ipcRenderer.send('log', 'ORNL Toolbox: Submitted install request for gnome-software', 'info') + + var os + try { //Detect OS + execSync('grep Ubuntu /etc/os-release') + os = "Ubuntu" + ipcRenderer.send('log', 'ORNL Toolbox: OS determined to be Ubuntu', 'info') + } catch(error) { + //"Ubuntu" not found in file + os = "RHEL" + ipcRenderer.send('log', 'ORNL Toolbox: OS determined to be RHEL', 'info') + } + + try { //Install gnome-software + if(os == "Ubuntu") { + execSync(`pkexec apt install gnome-software`) + } else { + execSync(`pkexec yum -y install gnome-software`) + } + } catch(error) { + error = error.toString() + if(error.includes("Request dismissed")) { + ipcRenderer.send('log', 'ORNL Toolbox: Request canceled by user', 'err') + softwareClose() + return + } else { + ipcRenderer.send('log', 'ORNL Toolbox: Failed to install gnome-software - request aborted', 'err') + console.error(error) + alert(error) + softwareClose() + } + } + + alert('Gnome Software successfully installed') + ipcRenderer.send('log', 'ORNL Toolbox: Completed install request for gnome-software', 'info') + + //Open Gnome Software + openSoftware(0) + softwareClose() +} + +function softwareClose() { + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer + ipcRenderer.send('close minor window') + ipcRenderer.send('log', `ORNL Toolbox: Software checkpoint closed`, 'info') +} diff --git a/softwareManagement/softwareManagement.html b/softwareManagement/softwareManagement.html index a35c1154566f9c49b54230b21627519338337692..cf292f9a025002debc3341a949c7eec5fedf6c6c 100644 --- a/softwareManagement/softwareManagement.html +++ b/softwareManagement/softwareManagement.html @@ -10,13 +10,16 @@ + + + @@ -38,7 +41,7 @@
-
Install Software
+
Install Software
Update Software
@@ -55,7 +58,7 @@
0
-
+
White Chat Bubble
@@ -63,7 +66,7 @@
-
+
Question Mark
diff --git a/softwareManagement/softwareManagement.js b/softwareManagement/softwareManagement.js index 35161fd2d35bbf7544a0ca1e9e3b60f6f96ca944..63538061a14ab23d0e9a1ffabf2e4e0c85424fbc 100644 --- a/softwareManagement/softwareManagement.js +++ b/softwareManagement/softwareManagement.js @@ -1,5 +1,7 @@ //Loads the software major page and closes minor windows function softManWin() { + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer + ipcRenderer.send('log', 'ORNL Toolbox: Opened Software Management', 'info') //Destroying any minor windows that were opened from the main window ipcRenderer.send('close minor window') // Change main window to software management window diff --git a/userManagement/addUser/addUser.js b/userManagement/addUser/addUser.js index c2b2ab471a62f183cc8cc90a472a596860859455..1fd4fb059045fc1eee2eaa2ec7cc153190e14361 100644 --- a/userManagement/addUser/addUser.js +++ b/userManagement/addUser/addUser.js @@ -5,7 +5,10 @@ function addUser() { var uid = document.getElementById("addUserTextbox").value //Retrieve UID var sudo = document.getElementById("addUserCheckbox").checked //Retieve if sudo is checked or not + 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: ${uid} is an invalid UID for Add User - request aborted`, 'err') alert('Please enter a valid 3 character UID') return } @@ -16,6 +19,7 @@ function addUser() { name = execSync(`ldapsearch -x "(uid=${uid})" | sed -n 's/^[ \\t]*cn:[ \\t]*\\(.*\\)/\\1/p'`) name = (name.toString()).trim() } catch(error) { + ipcRenderer.send('log', 'ORNL Toolbox: Failed to set name in Add User', 'err') console.error(error) return } @@ -23,10 +27,14 @@ function addUser() { //Have user enter a name if the LDAP server can't be reached //also if the specified user doesn't have the workstation resource if(name == "" || name.includes('Can\'t contact LDAP server')) { + ipcRenderer.send('log', `ORNL Toolbox: LDAP server unable to be reached or ${uid} has no workstation resource`, 'info') + ipcRenderer.send('log', `ORNL Toolbox: Opened manual name entry for ${uid}`, 'info') name = ipcRenderer.sendSync('prompt', 'start') if(name == null) { + ipcRenderer.send('log', 'ORNL Toolbox: Add User canceled', 'info') return } + ipcRenderer.send('log', `ORNL Toolbox: Manual name entered for ${uid}`, 'info') } if(sudo == true) { //Check if the user wants the new user to have sudo @@ -37,8 +45,10 @@ function addUser() { //"Ubuntu" not found in file sudo = "-G wheel " } + ipcRenderer.send('log', `ORNL Toolbox: Sudo privileges set to be given to ${uid}`, 'info') } else { sudo = "" + ipcRenderer.send('log', `ORNL Toolbox: Sudo privileges set to not be given to ${uid}`, 'info') } try { @@ -46,10 +56,11 @@ function addUser() { } catch(error) { error = error.toString() if(error.includes('already exists')) { + 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')) { - alert('Operation canceled') + ipcRenderer.send('log', 'ORNL Toolbox: Add User request canceled by user', 'info') return } console.error(error) @@ -57,6 +68,7 @@ function addUser() { return } + ipcRenderer.send('log', `ORNL Toolbox: ${uid} added as a user`, 'info') alert('User added') ipcRenderer.send('close minor window') } diff --git a/userManagement/removeUser/removeUser.css b/userManagement/removeUser/removeUser.css index ba2ea761331c1dba62be79727863b6b9116700f6..a29a3e16611518756fe32132da2eb2a6805a140a 100644 --- a/userManagement/removeUser/removeUser.css +++ b/userManagement/removeUser/removeUser.css @@ -51,10 +51,9 @@ input[type=submit] { margin-left: 8px; margin-right: 8px; } -#removeUserTextbox { - width: 16vw; - height: 6.4vh; -} +#removeUserSelect { + margin-bottom: 22px; + } #removeUserCheckbox1 { margin-top: 3px; } diff --git a/userManagement/removeUser/removeUser.html b/userManagement/removeUser/removeUser.html index c91bbac95b80b5372d51b9dd5f9829b89e644f7d..e102bfc6da7f8999d019c6666823ddcffe5219f3 100644 --- a/userManagement/removeUser/removeUser.html +++ b/userManagement/removeUser/removeUser.html @@ -7,13 +7,14 @@ - +
- Enter a UID: + Select a user:
- +
diff --git a/userManagement/removeUser/removeUser.js b/userManagement/removeUser/removeUser.js index 0c5122a4f06339c604f71af3c5bb851a48c10f94..400358738a9eef0278f3cd833954371ff4a835e7 100644 --- a/userManagement/removeUser/removeUser.js +++ b/userManagement/removeUser/removeUser.js @@ -3,35 +3,43 @@ const ipcRenderer = require('electron').ipcRenderer //Open a new terminal and start the process for removing a user function removeUser() { - var uid = document.getElementById("removeUserTextbox").value //Retrieve UID + var dropdown = document.getElementById('removeUserSelect') //Retrieve dropdown + var user = dropdown.options[dropdown.selectedIndex].text //Retrieve user to be removed var rhome = document.getElementById("removeUserCheckbox1").checked //Retrieve if user wants to remove the home directory var confirm = document.getElementById("removeUserCheckbox2").checked //Retrieve if user is certain they wish to remove the user - if(uid.length != 3 || /^[a-z0-9]+$/.test(uid) == false) { //Test for valid UID - alert('Please enter a valid 3 character UID') + ipcRenderer.send('log', 'ORNL Toolbox: Submitted Remove User request', 'info') + + if(user == "User") { //User didn't choose from the dropdown menu + ipcRenderer.send('log', 'ORNL Toolbox: No user selected - request aborted', 'info') + alert('No user selected') return } if(rhome == true) { //Adding the remove home folder option if the user wanted + ipcRenderer.send('log', `ORNL Toolbox: Home folder of ${user} set to be removed`, 'info') rhome = "-r" } else { + ipcRenderer.send('log', `ORNL Toolbox: Home folder of ${user} set to be kept`, 'info') rhome = "" } if(confirm == false) { + ipcRenderer.send('log', 'ORNL Toolbox: Confirmation box not checked - request aborted', 'err') alert("Please confirm that you wish to remove this user") return } try { //Launching command to remove the specified user - execSync(`pkexec /usr/sbin/userdel ${rhome} ${uid}`, (error, stdout, stderr) => {}) + execSync(`pkexec /usr/sbin/userdel ${rhome} ${user}`, (error, stdout, stderr) => {}) } catch(error) { error = error.toString() if(error.includes('does not exist')) { - alert('User does not exist') + ipcRenderer.send('log', `ORNL Toolbox: Remove User request failed - ${user} does not exist as a user`, 'err') + alert('User does not exist - home folder may exist') return } else if(error.includes('Request dismissed')) { - alert('Operation canceled') + ipcRenderer.send('log', 'ORNL Toolbox: Remove User request canceled', 'info') return } console.error(error) @@ -39,6 +47,28 @@ function removeUser() { return } + ipcRenderer.send('log', `ORNL Toolbox: ${user} removed as a user`, 'info') alert('User removed') ipcRenderer.send('close minor window') } + +function removeUserLoad() { //Loading the users + if(!execSync) var execSync = require('child_process').execSync + + //Adding the options of the dropdown menu + var optionValue = 1 + var dropdownString = '' + var users = execSync('ls /home', () => {}) + users = users.toString() + userArray = users.split('\n') + for(i = 0; i < userArray.length; i++) { + if(userArray[i].trim() == "") continue + dropdownString = dropdownString + '\n' + `` + optionValue++ + } + document.getElementById('removeUserSelect').innerHTML = dropdownString; + ipcRenderer.send('log', `ORNL Toolbox: List of users loaded`, 'info') + + //Setting removal of home folder as the default + document.getElementById('removeUserCheckbox1').checked = true +} diff --git a/userManagement/sudoManagement/sudoManagement.js b/userManagement/sudoManagement/sudoManagement.js index 64d480591b46bc7c11427973c997b91f52f06400..32dbece3064a8ace83ca146b5d28af051d2f48e4 100644 --- a/userManagement/sudoManagement/sudoManagement.js +++ b/userManagement/sudoManagement/sudoManagement.js @@ -1,11 +1,15 @@ +const ipcRenderer = require('electron').ipcRenderer function sudoManagement() { //Save checkbox setting for the selected user if(!execSync) var execSync = require('child_process').execSync + ipcRenderer.send('log', 'ORNL Toolbox: Submitted request to apply Sudo Management setting', 'info') + //Grab the user var dropdown = document.getElementById('sudoManagementUserSelect') var user = dropdown.options[dropdown.selectedIndex].text if(user == "User") { //User didn't choose from the dropdown menu + ipcRenderer.send('log', 'ORNL Toolbox: No user selected - request aborted', 'info') alert('No user selected') return } else { @@ -14,16 +18,18 @@ function sudoManagement() { //Save checkbox setting for the selected user if(admin == true) { //Add or keep for sudo group - execSync(`pkexec gpasswd -a ${user} sudo`, () => {}) + output = execSync(`pkexec gpasswd -a ${user} sudo`, () => {}) } else { //Remove or keep absent for sudo group - execSync(`pkexec gpasswd -d ${user} sudo`, () => {}) + output = execSync(`pkexec gpasswd -d ${user} sudo`, () => {}) } + ipcRenderer.send('log', 'ORNL Toolbox: Sudo Management setting applied', 'info') } } function sudoManagementLoad() { //Loading the users if(!execSync) var execSync = require('child_process').execSync + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer //Adding the options of the dropdown menu var optionValue = 1 @@ -37,11 +43,13 @@ function sudoManagementLoad() { //Loading the users optionValue++ } document.getElementById('sudoManagementUserSelect').innerHTML = dropdownString; + ipcRenderer.send('log', `ORNL Toolbox: List of users loaded`, 'info') } //Checking if user is sudo and checking the box if so function sudoManagementCheckIfSudo() { if(!execSync) var execSync = require('child_process').execSync + if(!ipcRenderer) var ipcRenderer = require('electron').ipcRenderer //Grab the user var dropdown = document.getElementById('sudoManagementUserSelect') @@ -55,4 +63,5 @@ function sudoManagementCheckIfSudo() { } else { document.getElementById('sudoManagementCheckbox').checked = false } + ipcRenderer.send('log', `ORNL Toolbox: Retrieved current sudo setting for ${user}`, 'info') } diff --git a/userManagement/syncPasswords/syncPasswords.js b/userManagement/syncPasswords/syncPasswords.js index e2baccda76cd735f5e4f7e4e860102e2858c1f93..fe432abbcb6dad30aa5cc88f5eb3ec5890107339 100644 --- a/userManagement/syncPasswords/syncPasswords.js +++ b/userManagement/syncPasswords/syncPasswords.js @@ -1,12 +1,16 @@ 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,44 @@ 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') + 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') 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 +83,6 @@ function findUID() { }) currentUser = currentUser.toString() document.getElementById("syncForUID").placeholder = currentUser + ipcRenderer.send('log', `ORNL Toolbox: Current user UID is ${currentUser}`, 'info') return currentUser } diff --git a/userManagement/userManagement.html b/userManagement/userManagement.html index 4490f81a014bed530013b7168cca689ec964a664..2dae332d5a89d190d3ed887b5a6a8f9a54e72354 100644 --- a/userManagement/userManagement.html +++ b/userManagement/userManagement.html @@ -10,12 +10,15 @@ + + + @@ -51,7 +54,7 @@
-
+
White Chat Bubble
@@ -59,7 +62,7 @@
-
+
Question Mark
diff --git a/userManagement/userManagement.js b/userManagement/userManagement.js index 52e409b6a4ebcd0654d00d1ec45fa3503ec96585..2d5abe9b2c395628fa770fb3afcd49126c3e6ef6 100644 --- a/userManagement/userManagement.js +++ b/userManagement/userManagement.js @@ -2,6 +2,7 @@ let addWin = remote.getGlobal('addWindow') //Change to User Management page after closing the minor window function userManWin() { + ipcRenderer.send('log', 'ORNL Toolbox: Opened User & Group Management', 'info') //Destroying any minor windows that were opened from the main window ipcRenderer.send('close minor window') // Change main window to user management window