summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAles Ledvinka <aledvink@redhat.com>2014-04-15 08:19:56 +0200
committerAles Ledvinka <aledvink@redhat.com>2014-04-15 08:19:56 +0200
commit48f32d82d6cc16d4938b8f672b175dc2c06d7a8d (patch)
treec658d87337eb0fb96c3689bd890b28dec762b814 /src
parentec703e253f947df32f29516fac094359e8e57131 (diff)
parentc272bcc49d87021b715162405787a9e9ef191ac0 (diff)
downloadopenlmi-providers-48f32d82d6cc16d4938b8f672b175dc2c06d7a8d.tar.gz
openlmi-providers-48f32d82d6cc16d4938b8f672b175dc2c06d7a8d.tar.xz
openlmi-providers-48f32d82d6cc16d4938b8f672b175dc2c06d7a8d.zip
Merge branch 'master' of https://git.fedorahosted.org/git/openlmi-providers
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/indmanager/CMakeLists.txt2
-rw-r--r--src/power/power.c25
3 files changed, 15 insertions, 14 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4227ccb..ed81b0e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -16,7 +16,7 @@ set_target_properties(openlmicommon PROPERTIES SOVERSION ${OPENLMICOMMON_VERSION
install(TARGETS openlmicommon DESTINATION lib${LIB_SUFFIX})
install(FILES openlmi.h DESTINATION include/openlmi)
-configure_file(openlmi.pc.in openlmi.pc @ONLY)
+configure_file(openlmi.pc.in ${CMAKE_CURRENT_BINARY_DIR}/openlmi.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openlmi.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig)
install(FILES openlmi.conf DESTINATION ${SYSCONF_INSTALL_DIR}/openlmi)
diff --git a/src/indmanager/CMakeLists.txt b/src/indmanager/CMakeLists.txt
index 57f21b9..3a265c9 100644
--- a/src/indmanager/CMakeLists.txt
+++ b/src/indmanager/CMakeLists.txt
@@ -15,5 +15,5 @@ target_link_libraries(openlmiindmanager pthread)
install(TARGETS openlmiindmanager DESTINATION lib${LIB_SUFFIX})
install(FILES ind_manager.h DESTINATION include/openlmi)
-configure_file(openlmiindmanager.pc.in openlmiindmanager.pc @ONLY)
+configure_file(openlmiindmanager.pc.in ${CMAKE_CURRENT_BINARY_DIR}/openlmiindmanager.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openlmiindmanager.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig)
diff --git a/src/power/power.c b/src/power/power.c
index 49d4ec2..6ec24b6 100644
--- a/src/power/power.c
+++ b/src/power/power.c
@@ -139,6 +139,14 @@ Proxy *power_create_logind()
error("Unable to connect to logind via DBus: %s", err->message);
g_error_free(err);
+ return NULL;
+ }
+ // Logind always has some properties, if no property is cached,
+ // the proxied object doesn't exist => don't use logind
+ if (g_dbus_proxy_get_cached_property_names(logind_proxy) == NULL) {
+ g_object_unref(logind_proxy);
+ debug("Logind DBus interface is not available");
+ return NULL;
}
return logind_proxy;
#else
@@ -164,6 +172,7 @@ bool power_call_logind(Proxy *proxy, const char *method)
return true;
}
}
+ return false;
#endif
return false;
}
@@ -265,7 +274,7 @@ void *state_change_thread(void *data)
#ifdef HAS_SYSTEMCTL
succeeded = system("systemctl --force poweroff &") == 0;
#else
- succeeded = system("shutdown --halt now &") == 0;
+ succeeded = system("poweroff --force &") == 0;
#endif
break;
case LMI_AssociatedPowerManagementService_PowerState_Off___Soft_Graceful:
@@ -273,7 +282,7 @@ void *state_change_thread(void *data)
succeeded = power_call_logind(logind_proxy, "PowerOff");
if (!succeeded) {
- succeeded = system("shutdown --poweroff now &") == 0;
+ succeeded = system("poweroff &") == 0;
}
break;
case LMI_AssociatedPowerManagementService_PowerState_Power_Cycle_Off___Soft_Graceful:
@@ -281,7 +290,7 @@ void *state_change_thread(void *data)
succeeded = power_call_logind(logind_proxy, "Reboot");
if (!succeeded) {
- succeeded = system("shutdown --reboot now &") == 0;
+ succeeded = system("reboot &") == 0;
}
break;
}
@@ -385,15 +394,7 @@ unsigned short *power_available_requested_power_states(Power *power, int *count)
int i = 0;
#ifdef HAS_GDBUS
- GError *err = NULL;
- GDBusProxy *logind_proxy;
- if ((logind_proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE, NULL, LOGIND_NAME, LOGIND_PATH,
- LOGIND_INTERFACE, NULL, &err)) == NULL) {
-
- error("Unable to connect to logind via DBus: %s", err->message);
- g_error_free(err);
- }
+ GDBusProxy *logind_proxy = power_create_logind();
#else
void *logind_proxy = NULL;
#endif