uspot: radius_call: unlink tmp file after exec

If debug is disabled, this commit deletes the temporary json files
passed to radius-client.

Furthermore, to reduce the risk of collision, use a different prefix in
accounting.uc ('uacct') vs common.uc ('acct').

Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
This commit is contained in:
Thibaut VARÈNE
2023-05-12 11:27:14 +02:00
committed by John Crispin
parent db37e3727d
commit fc80a4aa84
2 changed files with 15 additions and 5 deletions

View File

@@ -73,11 +73,15 @@ function radius_init(interface, mac, payload) {
}
function radius_call(interface, mac, payload) {
let cfg = fs.open('/tmp/acct' + mac + '.json', 'w');
let path = '/tmp/uacct' + mac + '.json';
let cfg = fs.open(path, 'w');
cfg.write(payload);
cfg.close();
system('/usr/bin/radius-client /tmp/acct' + mac + '.json');
system('/usr/bin/radius-client ' + path);
if (!+config[interface].debug)
fs.unlink(path);
}
function radius_stop(interface, mac, payload, remove) {

View File

@@ -221,13 +221,19 @@ return {
return payload;
},
// call radius-client with the provided payload and return reply
radius_call: function(ctx, payload) {
let type = payload.acct ? 'acct' : 'auth';
let cfg = fs.open('/tmp/' + type + ctx.mac + '.json', 'w');
let path = '/tmp/' + (payload.acct ? 'acct' : 'auth') + ctx.mac + '.json';
let cfg = fs.open(path, 'w');
cfg.write(payload);
cfg.close();
return this.fs_popen('/usr/bin/radius-client /tmp/' + type + ctx.mac + '.json');
let reply = this.fs_popen('/usr/bin/radius-client ' + path);
if (!+config.def_captive.debug)
fs.unlink(path);
return reply;
},
uam_url: function(ctx, res) {