chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fbb6341
)
logind: log which process is delaying suspend and not closing locks
author
Lennart Poettering
<lennart@poettering.net>
Wed, 27 Nov 2013 01:38:06 +0000
(
02:38
+0100)
committer
Lennart Poettering
<lennart@poettering.net>
Wed, 27 Nov 2013 01:39:19 +0000
(
02:39
+0100)
src/login/logind-action.c
patch
|
blob
|
history
src/login/logind-core.c
patch
|
blob
|
history
src/login/logind-dbus.c
patch
|
blob
|
history
src/login/logind-inhibit.c
patch
|
blob
|
history
src/login/logind-inhibit.h
patch
|
blob
|
history
diff --git
a/src/login/logind-action.c
b/src/login/logind-action.c
index cb64df086c815f45fa5bac4c2033d8f26153941c..7744addf69211982eb519a30e9715b7c1d672173 100644
(file)
--- a/
src/login/logind-action.c
+++ b/
src/login/logind-action.c
@@
-58,6
+58,7
@@
int manager_handle_action(
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
InhibitWhat inhibit_operation;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
InhibitWhat inhibit_operation;
+ Inhibitor *offending = NULL;
bool supported;
int r;
bool supported;
int r;
@@
-71,7
+72,7
@@
int manager_handle_action(
/* If the key handling is inhibited, don't do anything */
if (inhibit_key > 0) {
/* If the key handling is inhibited, don't do anything */
if (inhibit_key > 0) {
- if (manager_is_inhibited(m, inhibit_key, INHIBIT_BLOCK, NULL, true, false, 0)) {
+ if (manager_is_inhibited(m, inhibit_key, INHIBIT_BLOCK, NULL, true, false, 0
, NULL
)) {
log_debug("Refusing operation, %s is inhibited.", inhibit_what_to_string(inhibit_key));
return 0;
}
log_debug("Refusing operation, %s is inhibited.", inhibit_what_to_string(inhibit_key));
return 0;
}
@@
-109,15
+110,26
@@
int manager_handle_action(
/* If the actual operation is inhibited, warn and fail */
if (!ignore_inhibited &&
/* If the actual operation is inhibited, warn and fail */
if (!ignore_inhibited &&
- manager_is_inhibited(m, inhibit_operation, INHIBIT_BLOCK, NULL, false, false, 0)) {
+ manager_is_inhibited(m, inhibit_operation, INHIBIT_BLOCK, NULL, false, false, 0, &offending)) {
+ _cleanup_free_ char *comm = NULL, *u = NULL;
+
+ get_process_comm(offending->pid, &comm);
+ u = uid_to_name(offending->uid);
/* If this is just a recheck of the lid switch then don't warn about anything */
if (!is_edge) {
/* If this is just a recheck of the lid switch then don't warn about anything */
if (!is_edge) {
- log_debug("Refusing operation, %s is inhibited.", inhibit_what_to_string(inhibit_operation));
+ log_debug("Refusing operation, %s is inhibited by UID %lu/%s, PID %lu/%s.",
+ inhibit_what_to_string(inhibit_operation),
+ (unsigned long) offending->uid, strna(u),
+ (unsigned long) offending->pid, strna(comm));
return 0;
}
return 0;
}
- log_error("Refusing operation, %s is inhibited.", inhibit_what_to_string(inhibit_operation));
+ log_error("Refusing operation, %s is inhibited by UID %lu/%s, PID %lu/%s.",
+ inhibit_what_to_string(inhibit_operation),
+ (unsigned long) offending->uid, strna(u),
+ (unsigned long) offending->pid, strna(comm));
+
warn_melody();
return -EPERM;
}
warn_melody();
return -EPERM;
}
diff --git
a/src/login/logind-core.c
b/src/login/logind-core.c
index 9c31bf8a80fba1610b3ef1495ce55ec1ba9a8082..72ee9fe5727769bc1a78a9cd5f3ff578041661f8 100644
(file)
--- a/
src/login/logind-core.c
+++ b/
src/login/logind-core.c
@@
-389,7
+389,7
@@
int manager_get_idle_hint(Manager *m, dual_timestamp *t) {
assert(m);
assert(m);
- idle_hint = !manager_is_inhibited(m, INHIBIT_IDLE, INHIBIT_BLOCK, t, false, false, 0);
+ idle_hint = !manager_is_inhibited(m, INHIBIT_IDLE, INHIBIT_BLOCK, t, false, false, 0
, NULL
);
HASHMAP_FOREACH(s, m->sessions, i) {
dual_timestamp k;
HASHMAP_FOREACH(s, m->sessions, i) {
dual_timestamp k;
diff --git
a/src/login/logind-dbus.c
b/src/login/logind-dbus.c
index a972d93774eb9946539e107a605ee5a6c5407c99..e0333cd6b0bc883784551c88eb7a43554e523e22 100644
(file)
--- a/
src/login/logind-dbus.c
+++ b/
src/login/logind-dbus.c
@@
-1399,7
+1399,7
@@
int bus_manager_shutdown_or_sleep_now_or_later(
delayed =
m->inhibit_delay_max > 0 &&
delayed =
m->inhibit_delay_max > 0 &&
- manager_is_inhibited(m, w, INHIBIT_DELAY, NULL, false, false, 0);
+ manager_is_inhibited(m, w, INHIBIT_DELAY, NULL, false, false, 0
, NULL
);
if (delayed)
/* Shutdown is delayed, keep in mind what we
if (delayed)
/* Shutdown is delayed, keep in mind what we
@@
-1465,7
+1465,7
@@
static int method_do_shutdown_or_sleep(
return r;
multiple_sessions = r > 0;
return r;
multiple_sessions = r > 0;
- blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid);
+ blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid
, NULL
);
if (multiple_sessions) {
r = bus_verify_polkit_async(m->bus, &m->polkit_registry, message,
if (multiple_sessions) {
r = bus_verify_polkit_async(m->bus, &m->polkit_registry, message,
@@
-1610,7
+1610,7
@@
static int method_can_shutdown_or_sleep(
return r;
multiple_sessions = r > 0;
return r;
multiple_sessions = r > 0;
- blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid);
+ blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid
, NULL
);
if (multiple_sessions) {
r = bus_verify_polkit(m->bus, message, action_multiple_sessions, false, &challenge, error);
if (multiple_sessions) {
r = bus_verify_polkit(m->bus, message, action_multiple_sessions, false, &challenge, error);
@@
-2105,6
+2105,7
@@
int manager_send_changed(Manager *manager, const char *property, ...) {
int manager_dispatch_delayed(Manager *manager) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
int manager_dispatch_delayed(Manager *manager) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+ Inhibitor *offending = NULL;
int r;
assert(manager);
int r;
assert(manager);
@@
-2113,12
+2114,18
@@
int manager_dispatch_delayed(Manager *manager) {
return 0;
/* Continue delay? */
return 0;
/* Continue delay? */
- if (manager_is_inhibited(manager, manager->action_what, INHIBIT_DELAY, NULL, false, false, 0)) {
+ if (manager_is_inhibited(manager, manager->action_what, INHIBIT_DELAY, NULL, false, false, 0, &offending)) {
+ _cleanup_free_ char *comm = NULL, *u = NULL;
+
+ get_process_comm(offending->pid, &comm);
+ u = uid_to_name(offending->uid);
if (manager->action_timestamp + manager->inhibit_delay_max > now(CLOCK_MONOTONIC))
return 0;
if (manager->action_timestamp + manager->inhibit_delay_max > now(CLOCK_MONOTONIC))
return 0;
- log_info("Delay lock is active but inhibitor timeout is reached.");
+ log_info("Delay lock is active (UID %lu/%s, PID %lu/%s) but inhibitor timeout is reached.",
+ (unsigned long) offending->uid, strna(u),
+ (unsigned long) offending->pid, strna(comm));
}
/* Actually do the operation */
}
/* Actually do the operation */
diff --git
a/src/login/logind-inhibit.c
b/src/login/logind-inhibit.c
index 1b6f1362b3fbfb34dc2dee5731cfb570297fd907..35e1abd72918fcea2d8893829ecc57f17efc3d0f 100644
(file)
--- a/
src/login/logind-inhibit.c
+++ b/
src/login/logind-inhibit.c
@@
-372,7
+372,8
@@
bool manager_is_inhibited(
dual_timestamp *since,
bool ignore_inactive,
bool ignore_uid,
dual_timestamp *since,
bool ignore_inactive,
bool ignore_uid,
- uid_t uid) {
+ uid_t uid,
+ Inhibitor **offending) {
Inhibitor *i;
Iterator j;
Inhibitor *i;
Iterator j;
@@
-400,6
+401,9
@@
bool manager_is_inhibited(
ts = i->since;
inhibited = true;
ts = i->since;
inhibited = true;
+
+ if (offending)
+ *offending = i;
}
if (since)
}
if (since)
diff --git
a/src/login/logind-inhibit.h
b/src/login/logind-inhibit.h
index da3d7e736e8a6874a4f5a7eb7a6797263403d971..f767876a4c8d72abe203a7487ae2d7ace9cfcd97 100644
(file)
--- a/
src/login/logind-inhibit.h
+++ b/
src/login/logind-inhibit.h
@@
-85,7
+85,7
@@
int inhibitor_create_fifo(Inhibitor *i);
void inhibitor_remove_fifo(Inhibitor *i);
InhibitWhat manager_inhibit_what(Manager *m, InhibitMode mm);
void inhibitor_remove_fifo(Inhibitor *i);
InhibitWhat manager_inhibit_what(Manager *m, InhibitMode mm);
-bool manager_is_inhibited(Manager *m, InhibitWhat w, InhibitMode mm, dual_timestamp *since, bool ignore_inactive, bool ignore_uid, uid_t uid);
+bool manager_is_inhibited(Manager *m, InhibitWhat w, InhibitMode mm, dual_timestamp *since, bool ignore_inactive, bool ignore_uid, uid_t uid
, Inhibitor **offending
);
const char *inhibit_what_to_string(InhibitWhat k);
InhibitWhat inhibit_what_from_string(const char *s);
const char *inhibit_what_to_string(InhibitWhat k);
InhibitWhat inhibit_what_from_string(const char *s);