diff --git a/ctrl/videotex.ini b/ctrl/videotex.ini new file mode 100644 index 0000000..0da7dab --- /dev/null +++ b/ctrl/videotex.ini @@ -0,0 +1,4 @@ +; Videotex Options + +; Our key used to sign frames we send to other systems +; gpg_key=516@videotex diff --git a/mods/ansitex_save.js b/mods/ansitex_save.js index 0972f62..fca9039 100644 --- a/mods/ansitex_save.js +++ b/mods/ansitex_save.js @@ -1,6 +1,8 @@ load('texdefs.js'); load('texfuncs.js'); +var options = loadOptions(); + // Modes of operation: // -s -p x -i y = To send a stored page via the msgbase // {-s} -p x -i y -f file = To update (and optionally send) a page with new content @@ -92,7 +94,11 @@ if (! send || ! frame || file) { } // @NOTE: We need to use a binary signature then base64 encode it, as mailers may strip 0x0a while messages are in transit. -if (send == 1) { +if (send == 1 && options.gpg_key) { + if (! file) { + file = system.text_dir+'ansitex/'+frame.page+'.tex'; + } + if (! file_exists(file)) { log(LOG_ERROR,'! ERROR: File '+file+' doesnt exist?'); exit(1); @@ -101,7 +107,7 @@ if (send == 1) { if (file_exists(file+'.gpg')) file_remove(file+'.gpg') - result = system.exec('gpg --homedir /opt/sbbs/mods/keys --batch --local-user 516@videotex -s '+file); + result = system.exec('gpg --homedir /opt/sbbs/mods/keys --batch --local-user '+options.gpg_key+' -s '+file); w = new File(file+'.gpg'); if (w.open('r')) { @@ -114,6 +120,6 @@ if (send == 1) { w.close(); - msgBaseExport(null,frame.page,msg); + msgBaseImport(null,frame.page,msg); printf('GPG Result: %s',result); } \ No newline at end of file diff --git a/mods/load/texfuncs.js b/mods/load/texfuncs.js index 2265fd6..6447b2b 100644 --- a/mods/load/texfuncs.js +++ b/mods/load/texfuncs.js @@ -117,7 +117,21 @@ function getFrame(page) { return frame; } -function msgBaseExport(msgbase,page,text) { +function loadOptions() { + ini = new File(file_cfgname(system.ctrl_dir,'videotex.ini')); + + if (!ini.open("r")) { + return undefined; + } + + val = ini.iniGetObject(null); + + ini.close(); + + return val; +} + +function msgBaseImport(msgbase,page,text) { var msgbase = new MsgBase(findMsgBase(msgbase)); log(LOG_DEBUG,'Sending ['+page+'] to message base ['+msgbase.cfg.code+']');