return str;
}
+function file_path(file)
+{
+ return "/dev/fd/" + file.fileno();
+}
+
function network_keygen(pw_file, args, config, out_file, extra_args)
{
let rounds = config.rounds;
if (!out_file) {
output = mkstemp();
- out_file = "/dev/fd/" + output.fileno();
+ out_file = file_path(output);
}
if (extra_args)
if (config.xorkey) {
xorkey = network_get_string_file(config.xorkey);
- args += " -x /dev/fd/" + xorkey.fileno();
+ args += " -x " + file_path(xorkey);
}
pw_file.seek();
writefile(json_file, sprintf("%.J\n", network));
let key_file = mkstemp();
- let ret = network_keygen(pw_file, '-G', network.config, "/dev/fd/" + key_file.fileno());
+ let ret = network_keygen(pw_file, '-G', network.config, file_path(key_file));
if (!ret) {
if (ctx.command_failed)
ctx.command_failed("Failed to generate network key");
return false;
}
- ret = system([ "unet-tool", "-S", "-K", "/dev/fd/" + key_file.fileno(), "-o", bin_file, json_file ]);
+ ret = system([ "unet-tool", "-S", "-K", file_path(key_file), "-o", bin_file, json_file ]);
unlink(json_file);
if (ret != 0) {
if (ctx.command_failed)
let key_file = network_get_string_file(key);
delete config.xorkey;
- config.xorkey = network_keygen(pw_file, '-G -x /dev/fd/' + key_file.fileno(), config);
+ config.xorkey = network_keygen(pw_file, '-G -x ' + file_path(key_file), config);
key_file.close();
if (!config.xorkey) {