luci-base: tweak dispatcher logging to post under correct facility

Previously we might see:

... daemon.err uhttpd[5153]: [info] luci: accepted login on / for root from x.x.x.x

Now:

... authpriv.info dispatcher.uc: luci: accepted login on / for root from x.x.x.x

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
Paul Donald
2025-07-08 14:27:05 +02:00
parent 0f69aa9f1b
commit 81692c6c38
2 changed files with 7 additions and 6 deletions

View File

@@ -21,6 +21,7 @@ LUCI_DEPENDS:=\
+cgi-io \
+ucode \
+ucode-mod-fs \
+ucode-mod-log \
+ucode-mod-uci \
+ucode-mod-ubus \
+ucode-mod-math \

View File

@@ -6,6 +6,7 @@ import { striptags, entityencode } from 'html';
import { connect } from 'ubus';
import { cursor } from 'uci';
import { rand } from 'math';
import { openlog, syslog, closelog, LOG_INFO, LOG_WARNING, LOG_AUTHPRIV } from 'log';
import { hash, load_catalog, change_catalog, translate, ntranslate, getuid } from 'luci.core';
import { revision as luciversion, branch as luciname } from 'luci.version';
@@ -485,10 +486,6 @@ function randomid(num_bytes) {
return join('', bytes);
}
function syslog(prio, msg) {
warn(sprintf("[%s] %s\n", prio, msg));
}
function session_setup(user, pass, path) {
let timeout = uci.get('luci', 'sauth', 'sessiontime');
let login = ubus.call("session", "login", {
@@ -497,19 +494,22 @@ function session_setup(user, pass, path) {
timeout: timeout ? +timeout : null
});
openlog('dispatcher.uc');
if (type(login?.ubus_rpc_session) == 'string') {
ubus.call("session", "set", {
ubus_rpc_session: login.ubus_rpc_session,
values: { token: randomid(16) }
});
syslog("info", sprintf("luci: accepted login on /%s for %s from %s",
syslog(LOG_INFO|LOG_AUTHPRIV, sprintf("luci: accepted login on /%s for %s from %s",
join('/', path), user || "?", http.getenv("REMOTE_ADDR") || "?"));
return session_retrieve(login.ubus_rpc_session);
}
syslog("info", sprintf("luci: failed login on /%s for %s from %s",
syslog(LOG_WARNING|LOG_AUTHPRIV, sprintf("luci: failed login on /%s for %s from %s",
join('/', path), user || "?", http.getenv("REMOTE_ADDR") || "?"));
closelog();
}
function check_authentication(method) {