summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2019-09-25 20:34:12 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2019-09-25 20:34:12 +0000
commit989e7482e838740a5c4ca19e776f1c33b277cb51 (patch)
treede4edc082b4961cd29b38ae5808b898ec8b95dfe /usr.sbin
parent1ba0468c00bb8a5f7de78d39390eb3afbb5aa929 (diff)
When battery state switches to critical, apmd(8) generates an
emergency log message. Then syslogd(8) could select on that and write a warning to all users. OK benno@ deraadt@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/apmd/apmd.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.sbin/apmd/apmd.c b/usr.sbin/apmd/apmd.c
index 1c0f5e03bc9..a38958bbe01 100644
--- a/usr.sbin/apmd/apmd.c
+++ b/usr.sbin/apmd/apmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apmd.c,v 1.88 2019/07/25 07:29:44 kn Exp $ */
+/* $OpenBSD: apmd.c,v 1.89 2019/09/25 20:34:11 bluhm Exp $ */
/*
* Copyright (c) 1995, 1996 John T. Kohl
@@ -145,7 +145,7 @@ power_status(int fd, int force, struct apm_power_info *pinfo)
{
struct apm_power_info bstate;
static struct apm_power_info last;
- int acon = 0;
+ int acon = 0, priority = LOG_NOTICE;
if (fd == -1) {
if (pinfo) {
@@ -164,6 +164,9 @@ power_status(int fd, int force, struct apm_power_info *pinfo)
* enough since last report, or asked to force a print */
if (bstate.ac_state == APM_AC_ON)
acon = 1;
+ if (bstate.battery_state == APM_BATT_CRITICAL &&
+ bstate.battery_state != last.battery_state)
+ priority = LOG_EMERG;
if (force ||
bstate.ac_state != last.ac_state ||
bstate.battery_state != last.battery_state ||
@@ -182,7 +185,7 @@ power_status(int fd, int force, struct apm_power_info *pinfo)
#else
if ((int)bstate.minutes_left > 0)
#endif
- logmsg(LOG_NOTICE, "battery status: %s. "
+ logmsg(priority, "battery status: %s. "
"external power status: %s. "
"estimated battery life %d%% (%u minutes)",
battstate(bstate.battery_state),
@@ -190,7 +193,7 @@ power_status(int fd, int force, struct apm_power_info *pinfo)
bstate.battery_life,
bstate.minutes_left);
else
- logmsg(LOG_NOTICE, "battery status: %s. "
+ logmsg(priority, "battery status: %s. "
"external power status: %s. "
"estimated battery life %d%%",
battstate(bstate.battery_state),