Added config for gpg key

This commit is contained in:
Deon George 2019-10-20 22:31:15 +11:00
parent e6e9396c8d
commit a5231cb7ff
3 changed files with 28 additions and 4 deletions

4
ctrl/videotex.ini Normal file
View File

@ -0,0 +1,4 @@
; Videotex Options
; Our key used to sign frames we send to other systems
; gpg_key=516@videotex

View File

@ -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);
}

View File

@ -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+']');