Verified Commit b604add8 authored by Karel Koci's avatar Karel Koci 🤘
Browse files

Add usign argument to set path to usign tool

parent 8ae11b46
Pipeline #3824 failed with stage
in 16 minutes and 1 second
......@@ -74,6 +74,8 @@ static const char *opt_help[COT_LAST] = {
"--output=<file> Put the output to given file.\n",
[COT_EXCLUDE] =
"--exclude=<name> Exclude this from output.\n",
[COT_USIGN] =
"--usign=<path> Path to usign tool used to verify packages signature. In default /usr/bin/usign.\n",
[COT_TASK_LOG] =
"--task-log=<file> Append list of executed tasks into a log file.\n"
};
......
......@@ -66,6 +66,8 @@ enum cmd_op_type {
COT_TASK_LOG,
// Exclude this from output
COT_EXCLUDE,
// Path to usign tool
COT_USIGN,
// Argument isn't option.
COT_NO_OP,
// Automatic last dummy value to know size of enum
......
......@@ -47,7 +47,7 @@ local sha256 = sha256
module "uri"
-- luacheck: globals wait signature_check parse new system_cas no_crl
-- luacheck: globals wait signature_check parse new system_cas no_crl usign_exec_set
-- Constants used for inheritance breakage
system_cas = "uri_system_cas"
......@@ -226,6 +226,13 @@ local function tmpstore(content)
return fname
end
-- Path to usign tool (can be overriden usign usign_exec_set)
local usign_exec = "/usr/bin/usign"
function usign_exec_set(path)
usign_exec = path
end
function signature_check(content, key, signature)
local ok
local fcontent = tmpstore(content)
......@@ -233,7 +240,7 @@ function signature_check(content, key, signature)
local fsig = tmpstore(signature)
events_wait(run_command(function (ecode)
ok = (ecode == 0)
end, nil, nil, -1, -1, '/usr/bin/usign', '-V', '-p', fkey, '-x', fsig, '-m', fcontent))
end, nil, nil, -1, -1, usign_exec, '-V', '-p', fkey, '-x', fsig, '-m', fcontent))
os.remove(fcontent)
os.remove(fkey)
os.remove(fsig)
......
......@@ -29,7 +29,7 @@
extern struct file_index_element uriinternal[];
static const enum cmd_op_type cmd_op_allowed[] = {
COT_BATCH, COT_NO_OP, COT_ROOT_DIR, COT_SYSLOG_LEVEL, COT_STDERR_LEVEL, COT_SYSLOG_NAME, COT_OUTPUT, COT_EXCLUDE, COT_LAST
COT_BATCH, COT_NO_OP, COT_ROOT_DIR, COT_SYSLOG_LEVEL, COT_STDERR_LEVEL, COT_SYSLOG_NAME, COT_OUTPUT, COT_EXCLUDE, COT_USIGN, COT_LAST
};
void print_help() {
......@@ -53,6 +53,7 @@ int main(int argc, char *argv[]) {
const char *root_dir = NULL;
const char *output = "/etc/updater/auto.lua";
const char **excludes = NULL;
const char *usign_exec = NULL;
size_t exclude_count = 0;
bool batch = false, early_exit = false;
for (; op->type != COT_EXIT && op->type != COT_CRASH; op ++)
......@@ -100,6 +101,9 @@ int main(int argc, char *argv[]) {
excludes = realloc(excludes, (++ exclude_count) * sizeof *excludes);
excludes[exclude_count - 1] = op->parameter;
break;
case COT_USIGN:
usign_exec = op->parameter;
break;
default:
DIE("Unknown COT");
}
......@@ -117,6 +121,10 @@ int main(int argc, char *argv[]) {
error = interpreter_call(interpreter, "backend.root_dir_set", NULL, "s", root_dir);
ASSERT_MSG(!error, "%s", error);
}
if (usign_exec) {
const char *err = interpreter_call(interpreter, "uri.usign_exec_set", NULL, "s", usign_exec);
ASSERT_MSG(!err, "%s", err);
}
if (early_exit)
goto CLEANUP;
......
......@@ -39,7 +39,7 @@ static bool results_interpret(struct interpreter *interpreter, size_t result_cou
}
static const enum cmd_op_type cmd_op_allows[] = {
COT_JOURNAL_ABORT, COT_JOURNAL_RESUME, COT_INSTALL, COT_REMOVE, COT_ROOT_DIR, COT_SYSLOG_LEVEL, COT_STDERR_LEVEL, COT_SYSLOG_NAME, COT_REEXEC, COT_LAST };
COT_JOURNAL_ABORT, COT_JOURNAL_RESUME, COT_INSTALL, COT_REMOVE, COT_ROOT_DIR, COT_SYSLOG_LEVEL, COT_STDERR_LEVEL, COT_SYSLOG_NAME, COT_REEXEC, COT_USIGN, COT_LAST };
static void print_help() {
fputs("Usage: opkg-trans [OPTION]...\n", stderr);
......@@ -71,6 +71,7 @@ int main(int argc, char *argv[]) {
bool transaction_run = false;
bool trans_ok = true;
bool early_exit = false;
const char *usign_exec = NULL;
for (; op->type != COT_EXIT && op->type != COT_CRASH; op ++)
switch (op->type) {
case COT_HELP:
......@@ -111,6 +112,11 @@ int main(int argc, char *argv[]) {
ASSERT_MSG(!err, "%s", err);
break;
}
case COT_USIGN: {
const char *err = interpreter_call(interpreter, "uri.usign_exec_set", NULL, "s", usign_exec);
ASSERT_MSG(!err, "%s", err);
break;
}
case COT_SYSLOG_LEVEL: {
enum log_level level = log_level_get(op->parameter);
ASSERT_MSG(level != LL_UNKNOWN, "Unknown log level %s", op->parameter);
......
......@@ -46,7 +46,7 @@ static bool results_interpret(struct interpreter *interpreter, size_t result_cou
}
static const enum cmd_op_type cmd_op_allows[] = {
COT_BATCH, COT_NO_OP, COT_REEXEC, COT_REBOOT, COT_STATE_LOG, COT_ROOT_DIR, COT_SYSLOG_LEVEL, COT_STDERR_LEVEL, COT_SYSLOG_NAME, COT_ASK_APPROVAL, COT_APPROVE, COT_TASK_LOG, COT_LAST
COT_BATCH, COT_NO_OP, COT_REEXEC, COT_REBOOT, COT_STATE_LOG, COT_ROOT_DIR, COT_SYSLOG_LEVEL, COT_STDERR_LEVEL, COT_SYSLOG_NAME, COT_ASK_APPROVAL, COT_APPROVE, COT_TASK_LOG, COT_USIGN, COT_LAST
};
static void print_help() {
......@@ -121,6 +121,7 @@ int main(int argc, char *argv[]) {
const char **approvals = NULL;
size_t approval_count = 0;
const char *task_log = NULL;
const char *usign_exec = NULL;
for (; op->type != COT_EXIT && op->type != COT_CRASH; op ++)
switch (op->type) {
case COT_HELP:
......@@ -180,6 +181,9 @@ int main(int argc, char *argv[]) {
case COT_TASK_LOG:
task_log = op->parameter;
break;
case COT_USIGN:
usign_exec = op->parameter;
break;
default:
DIE("Unknown COT");
}
......@@ -198,6 +202,10 @@ int main(int argc, char *argv[]) {
ASSERT_MSG(!err, "%s", err);
} else
root_dir = "";
if (usign_exec) {
const char *err = interpreter_call(interpreter, "uri.usign_exec_set", NULL, "s", usign_exec);
ASSERT_MSG(!err, "%s", err);
}
bool trans_ok = true;
if (exit_type != COT_EXIT)
goto CLEANUP;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment