bin_file += "." + time();
writefile(json_file, sprintf("%.J\n", network));
- let ret = network_keygen(pw_file, '-S', network.config, bin_file, json_file);
- unlink(json_file);
+
+ let key_file = mkstemp();
+ let ret = network_keygen(pw_file, '-G', network.config, "/dev/fd/" + key_file.fileno());
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 ]);
+ unlink(json_file);
+ if (ret != 0) {
if (ctx.command_failed)
ctx.command_failed("Failed to sign network configuration");
return false;
}
+ key_file.close();
if (!upload)
return true;