mirror of
https://github.com/openwrt/luci.git
synced 2025-12-26 11:16:38 +04:00
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:
@@ -21,6 +21,7 @@ LUCI_DEPENDS:=\
|
|||||||
+cgi-io \
|
+cgi-io \
|
||||||
+ucode \
|
+ucode \
|
||||||
+ucode-mod-fs \
|
+ucode-mod-fs \
|
||||||
|
+ucode-mod-log \
|
||||||
+ucode-mod-uci \
|
+ucode-mod-uci \
|
||||||
+ucode-mod-ubus \
|
+ucode-mod-ubus \
|
||||||
+ucode-mod-math \
|
+ucode-mod-math \
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { striptags, entityencode } from 'html';
|
|||||||
import { connect } from 'ubus';
|
import { connect } from 'ubus';
|
||||||
import { cursor } from 'uci';
|
import { cursor } from 'uci';
|
||||||
import { rand } from 'math';
|
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 { hash, load_catalog, change_catalog, translate, ntranslate, getuid } from 'luci.core';
|
||||||
import { revision as luciversion, branch as luciname } from 'luci.version';
|
import { revision as luciversion, branch as luciname } from 'luci.version';
|
||||||
@@ -485,10 +486,6 @@ function randomid(num_bytes) {
|
|||||||
return join('', bytes);
|
return join('', bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
function syslog(prio, msg) {
|
|
||||||
warn(sprintf("[%s] %s\n", prio, msg));
|
|
||||||
}
|
|
||||||
|
|
||||||
function session_setup(user, pass, path) {
|
function session_setup(user, pass, path) {
|
||||||
let timeout = uci.get('luci', 'sauth', 'sessiontime');
|
let timeout = uci.get('luci', 'sauth', 'sessiontime');
|
||||||
let login = ubus.call("session", "login", {
|
let login = ubus.call("session", "login", {
|
||||||
@@ -497,19 +494,22 @@ function session_setup(user, pass, path) {
|
|||||||
timeout: timeout ? +timeout : null
|
timeout: timeout ? +timeout : null
|
||||||
});
|
});
|
||||||
|
|
||||||
|
openlog('dispatcher.uc');
|
||||||
if (type(login?.ubus_rpc_session) == 'string') {
|
if (type(login?.ubus_rpc_session) == 'string') {
|
||||||
ubus.call("session", "set", {
|
ubus.call("session", "set", {
|
||||||
ubus_rpc_session: login.ubus_rpc_session,
|
ubus_rpc_session: login.ubus_rpc_session,
|
||||||
values: { token: randomid(16) }
|
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") || "?"));
|
join('/', path), user || "?", http.getenv("REMOTE_ADDR") || "?"));
|
||||||
|
|
||||||
return session_retrieve(login.ubus_rpc_session);
|
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") || "?"));
|
join('/', path), user || "?", http.getenv("REMOTE_ADDR") || "?"));
|
||||||
|
|
||||||
|
closelog();
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_authentication(method) {
|
function check_authentication(method) {
|
||||||
|
|||||||
Reference in New Issue
Block a user