MCPcopy
hub / github.com/ntfstool/ntfstool / checkSudoPassword

Function checkSudoPassword

src/common/utils/AlfwShell.js:190–220  ·  view source on GitHub ↗
(setPwd = false)

Source from the content-addressed store, hash-verified

188 * @returns {Promise}
189 */
190export function checkSudoPassword(setPwd = false) {
191 if (setPwd !== false) {
192 var password = setPwd
193 } else {
194 var password = getSudoPwd();
195 }
196 return new Promise((resolve, reject) => {
197 try {
198 //sudo -Sk Force password
199 exec(`echo '${password}'|sudo -Sk ls /usr`, (error, stdout, stderr) => {
200 saveLog.log({
201 error, stdout, stderr
202 }, "checkSudoPassword res");
203
204 if (checkIncorrectPasswordStr(stderr)) {
205 console.log("start send SudoPWDEvent >>>>>>>>>>>>>>>>>>>>>>>>>>>>")
206 ipcRenderer.send("IPCMain",AlConst.SudoPwdEvent);
207
208 resolve(false);
209 } else {
210 resolve(true);
211
212 }
213 });
214 } catch (e) {
215 saveLog.error(e, "checkSudoPassword catch error");
216 noticeTheSystemError("checkSudoPasswordError");
217 resolve(true);
218 }
219 });
220}

Callers 3

showSudoFunction · 0.90
checkSudoPwdFunction · 0.90
execShellSudoFunction · 0.85

Calls 3

getSudoPwdFunction · 0.90
noticeTheSystemErrorFunction · 0.90

Tested by

no test coverage detected