Hello community, here is the log from the commit of package webyast-reboot-ws for openSUSE:Factory checked in at Sun Oct 16 13:01:28 CEST 2011.
-------- --- openSUSE:Factory/webyast-reboot-ws/webyast-reboot-ws.changes 2011-09-23 12:50:27.000000000 +0200 +++ /mounts/work_src_done/STABLE/webyast-reboot-ws/webyast-reboot-ws.changes 2011-10-13 10:48:28.000000000 +0200 @@ -1,0 +2,6 @@ +Thu Oct 13 08:36:46 UTC 2011 - [email protected] + +- use ConsoleKit DBus interface for system actions, because of missing hal on openSuSE >= 11.4 +- 0.2.4 + +------------------------------------------------------------------- calling whatdependson for head-i586 New: ---- 01-org.opensuse.yast.system.power-management.pkla ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ webyast-reboot-ws.spec ++++++ --- /var/tmp/diff_new_pack.9OHu5S/_old 2011-10-16 13:01:23.000000000 +0200 +++ /var/tmp/diff_new_pack.9OHu5S/_new 2011-10-16 13:01:23.000000000 +0200 @@ -23,16 +23,21 @@ Obsoletes: yast2-webservice-system < %{version} PreReq: yast2-webservice # requires HAL for reboot/shutdown actions -Requires: hal +#Requires: hal +# requires ConsoleKit for reboot/shutdown actions +Requires: ConsoleKit License: GPL-2.0 Group: Productivity/Networking/Web/Utilities Url: http://en.opensuse.org/Portal:WebYaST AutoReqProv: on -Version: 0.2.3 -Release: 1 +Version: 0.2.4 +Release: 0 Summary: WebYaST - reboot/shutdown service Source: www.tar.bz2 + Source1: org.opensuse.yast.system.power-management.policy +Source2: 01-org.opensuse.yast.system.power-management.pkla + BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildArch: noarch BuildRequires: rubygem-webyast-rake-tasks >= 0.1.3 @@ -47,7 +52,6 @@ # %package testsuite - Group: Productivity/Networking/Web/Utilities Requires: %{name} = %{version} Requires: webyast-base-ws-testsuite @@ -58,7 +62,7 @@ Authors: -------- - Ladislav Slezak <[email protected]> +Ladislav Slezak <[email protected]> %description testsuite Testsuite for webyast-reboot-ws webservice package. @@ -91,36 +95,63 @@ mkdir -p $RPM_BUILD_ROOT/usr/share/PolicyKit/policy install -m 0644 %SOURCE1 $RPM_BUILD_ROOT/usr/share/PolicyKit/policy/ +%if 0%{?suse_version} == 0 || 0%{?suse_version} > 1130 +# openSUSE-11.4 has policykit-1 which uses .pkla files +mkdir -p $RPM_BUILD_ROOT/var/lib/polkit-1/localauthority/10-vendor.d +install -m 0644 %SOURCE2 $RPM_BUILD_ROOT/var/lib/polkit-1/localauthority/10-vendor.d/ +%if 0%{?suse_version} == 1130 +# openSUSE-11.3+ has policykit-1 which uses .pkla files +mkdir -p $RPM_BUILD_ROOT/etc/polkit-1/localauthority/10-vendor.d +install -m 0644 %SOURCE2 $RPM_BUILD_ROOT/etc/polkit-1/localauthority/10-vendor.d/ +%endif +%endif + %clean rm -rf $RPM_BUILD_ROOT -# %posttrans is used instead of %post so it ensures the rights are +# {%}posttrans is used instead of {%}post so it ensures the rights are # granted even after upgrading from old package (before renaming) (bnc#645310) # (see https://fedoraproject.org/wiki/Packaging/ScriptletSnippets#Syntax ) %posttrans # granting all permissions for the web user #FIXME don't silently fail -polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.hal.power-management.shutdown >& /dev/null || true -polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.hal.power-management.shutdown-multiple-sessions >& /dev/null || true -polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.hal.power-management.reboot >& /dev/null || true -polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.hal.power-management.reboot-multiple-sessions >& /dev/null || true - -# granting all permissions for root -polkit-auth --user root --grant org.freedesktop.hal.power-management.shutdown >& /dev/null || true -polkit-auth --user root --grant org.freedesktop.hal.power-management.shutdown-multiple-sessions >& /dev/null || true -polkit-auth --user root --grant org.freedesktop.hal.power-management.reboot >& /dev/null || true -polkit-auth --user root --grant org.freedesktop.hal.power-management.reboot-multiple-sessions >& /dev/null || true +#polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.hal.power-management.shutdown >& /dev/null || true +#polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.hal.power-management.shutdown-multiple-sessions >& /dev/null || true +#polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.hal.power-management.reboot >& /dev/null || true +#polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.hal.power-management.reboot-multiple-sessions >& /dev/null || true + +polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.consolekit.system.stop >& /dev/null || true +polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.consolekit.system.stop-multiple-users >& /dev/null || true +polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.consolekit.system.restart >& /dev/null || true +polkit-auth --user %{webyast_ws_user} --grant org.freedesktop.consolekit.system.restart-multiple-users >& /dev/null || true + +## granting all permissions for root +polkit-auth --user root --grant org.freedesktop.consolekit.system.stop >& /dev/null || true +polkit-auth --user root --grant org.freedesktop.consolekit.system.stop-multiple-users >& /dev/null || true +polkit-auth --user root --grant org.freedesktop.consolekit.system.restart >& /dev/null || true +polkit-auth --user root --grant org.freedesktop.consolekit.system.restart-multiple-users >& /dev/null || true + +#polkit-auth --user root --grant org.freedesktop.hal.power-management.shutdown >& /dev/null || true +#polkit-auth --user root --grant org.freedesktop.hal.power-management.shutdown-multiple-sessions >& /dev/null || true +#polkit-auth --user root --grant org.freedesktop.hal.power-management.reboot >& /dev/null || true +#polkit-auth --user root --grant org.freedesktop.hal.power-management.reboot-multiple-sessions >& /dev/null || true %postun # don't remove the rights during package update ($1 > 0) # see https://fedoraproject.org/wiki/Packaging/ScriptletSnippets#Syntax for details if [ $1 -eq 0 ] ; then # discard all configured permissions for the web user - polkit-auth --user %{webyast_ws_user} --revoke org.freedesktop.hal.power-management.shutdown >& /dev/null || : - polkit-auth --user %{webyast_ws_user} --revoke org.freedesktop.hal.power-management.shutdown-multiple-sessions >& /dev/null || : - polkit-auth --user %{webyast_ws_user} --revoke org.freedesktop.hal.power-management.reboot >& /dev/null || : - polkit-auth --user %{webyast_ws_user} --revoke org.freedesktop.hal.power-management.reboot-multiple-sessions >& /dev/null || : + #polkit-auth --user %{webyast_ws_user} --revoke org.freedesktop.hal.power-management.shutdown >& /dev/null || : + #polkit-auth --user %{webyast_ws_user} --revoke org.freedesktop.hal.power-management.shutdown-multiple-sessions >& /dev/null || : + #polkit-auth --user %{webyast_ws_user} --revoke org.freedesktop.hal.power-management.reboot >& /dev/null || : + #polkit-auth --user %{webyast_ws_user} --revoke org.freedesktop.hal.power-management.reboot-multiple-sessions >& /dev/null || : + + polkit-auth --user %{webyast_ws_user} --revoke org.freedesktop.consolekit.system.stop >& /dev/null || true + polkit-auth --user %{webyast_ws_user} --revoke org.freedesktop.consolekit.system.stop-multiple-users >& /dev/null || true + polkit-auth --user %{webyast_ws_user} --revoke org.freedesktop.consolekit.system.restart >& /dev/null || true + polkit-auth --user %{webyast_ws_user} --revoke org.freedesktop.consolekit.system.restart-multiple-users >& /dev/null || true + fi %files @@ -143,9 +174,17 @@ %dir /usr/share/PolicyKit %dir /usr/share/PolicyKit/policy %attr(644,root,root) %config /usr/share/PolicyKit/policy/org.opensuse.yast.system.power-management.policy - %doc COPYING +%if 0%{?suse_version} == 0 || 0%{?suse_version} > 1130 +%dir /var/lib/polkit-1/localauthority +%dir /var/lib/polkit-1/localauthority/10-vendor.d +%config /var/lib/polkit-1/localauthority/10-vendor.d/* +%if 0%{?suse_version} == 1130 +%config /etc/polkit-1/localauthority/10-vendor.d/* +%endif +%endif + %files testsuite %defattr(-,root,root) %{plugin_dir}/test ++++++ 01-org.opensuse.yast.system.power-management.pkla ++++++ [Allow ConsoleKit operations for the WebYaST REST service] Identity=unix-user:yastws # allow package update and repository management Action=org.freedesktop.consolekit.system.stop;org.freedesktop.consolekit.system.stop-multiple-users;org.freedesktop.consolekit.system.restart;org.freedesktop.consolekit.system.restart-multiple-users ResultAny=yes ++++++ org.opensuse.yast.system.power-management.policy ++++++ --- /var/tmp/diff_new_pack.9OHu5S/_old 2011-10-16 13:01:23.000000000 +0200 +++ /var/tmp/diff_new_pack.9OHu5S/_new 2011-10-16 13:01:23.000000000 +0200 @@ -7,16 +7,13 @@ <vendor>YaST Webservice Project</vendor> <vendor_url>http://en.opensuse.org/YAST</vendor_url> -<!-- -Rights for status ---> - <action id="org.opensuse.yast.system.power-management.reboot"> <description>Rebooting system</description> <message>Authentication is required to reboot the system</message> <defaults> + <allow_any>no</allow_any> <allow_inactive>no</allow_inactive> - <allow_active>no</allow_active> + <allow_active>auth_admin</allow_active> </defaults> </action> @@ -24,8 +21,9 @@ <description>Shutdown the system</description> <message>Authentication is required to shutdown the system</message> <defaults> + <allow_any>no</allow_any> <allow_inactive>no</allow_inactive> - <allow_active>no</allow_active> + <allow_active>auth_admin</allow_active> </defaults> </action> ++++++ www.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/www/app/controllers/system_controller.rb new/www/app/controllers/system_controller.rb --- old/www/app/controllers/system_controller.rb 2011-05-16 09:20:57.000000000 +0200 +++ new/www/app/controllers/system_controller.rb 2011-10-13 10:00:51.000000000 +0200 @@ -1,91 +1,90 @@ #-- # Copyright (c) 2009-2010 Novell, Inc. -# +# # All Rights Reserved. -# +# # This program is free software; you can redistribute it and/or modify it # under the terms of version 2 of the GNU General Public License # as published by the Free Software Foundation. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, contact Novell, Inc. -# +# # To contact Novell about this file by physical or electronic mail, # you may find current contact information at www.novell.com #++ class SystemController < ApplicationController + before_filter :login_required - before_filter :login_required + def show + @actions = System.instance.actions - def show - @actions = System.instance.actions + respond_to do |format| + format.xml { render :xml => @actions.to_xml(:root => :actions), :location => "none" } + format.json { render :json => @actions.to_json, :location => "none" } + end + end - respond_to do |format| - format.xml { render :xml => @actions.to_xml(:root => :actions), :location => "none" } - format.json { render :json => @actions.to_json, :location => "none" } - end + def update + root = params[:system] + if root == nil || root == {} + render ErrorResult.error(404, 2, "format error - missing actions") and return end - - def update - root = params[:system] - if root == nil || root == {} - render ErrorResult.error(404, 2, "format error - missing actions") and return - end - - @system = System.instance - - do_reboot = false - do_shutdown = false - - # do the action - root.each do |k, v| - if v.nil? or !v.respond_to?('has_key?') or !v.has_key? 'active' - render ErrorResult.error(404, 2, "format error - missing requested status") and return - end - - if v['active'] != true and v['active'] != false - render ErrorResult.error(404, 2, "format error - non-boolean active parameter") and return - end - - # unknown action requested - if [email protected]_key? k.to_sym - render ErrorResult.error(404, 2, "format error - unknown action requested") and return - end - - case k - when 'reboot' - permission_check( 'org.opensuse.yast.system.power-management.reboot') - - if v['active'] == true and @system.actions[k.to_sym][:active] == false - do_reboot = true - end - when 'shutdown' - permission_check( 'org.opensuse.yast.system.power-management.shutdown') - - if v['active'] == true and @system.actions[k.to_sym][:active] == false - do_shutdown = true - end - else - render ErrorResult.error(404, 2, "internal error - unknown action requested") and return - end - end - if do_reboot then @system.reboot end - if do_shutdown then @system.shutdown end + @system = System.instance - show - end + do_reboot = false + do_shutdown = false - # See update - def create - update + # do the action + root.each do |k, v| + if v.nil? or !v.respond_to?('has_key?') or !v.has_key? 'active' + render ErrorResult.error(404, 2, "format error - missing requested status") and return + end + + if v['active'] != true and v['active'] != false + render ErrorResult.error(404, 2, "format error - non-boolean active parameter") and return + end + + # unknown action requested + if [email protected]_key? k.to_sym + render ErrorResult.error(404, 2, "format error - unknown action requested") and return + end + + case k + when 'reboot' + permission_check( 'org.opensuse.yast.system.power-management.reboot') + + if v['active'] == true and @system.actions[k.to_sym][:active] == false + do_reboot = true + end + when 'shutdown' + permission_check( 'org.opensuse.yast.system.power-management.shutdown') + + if v['active'] == true and @system.actions[k.to_sym][:active] == false + do_shutdown = true + end + else + render ErrorResult.error(404, 2, "internal error - unknown action requested") and return + end end + if do_reboot then @system.reboot end + if do_shutdown then @system.shutdown end + + show + end + + # See update + def create + update + end end + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/www/app/models/system.rb new/www/app/models/system.rb --- old/www/app/models/system.rb 2011-02-01 10:49:25.000000000 +0100 +++ new/www/app/models/system.rb 2011-10-14 09:38:28.000000000 +0200 @@ -1,20 +1,20 @@ #-- # Copyright (c) 2009-2010 Novell, Inc. -# +# # All Rights Reserved. -# +# # This program is free software; you can redistribute it and/or modify it # under the terms of version 2 of the GNU General Public License # as published by the Free Software Foundation. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, contact Novell, Inc. -# +# # To contact Novell about this file by physical or electronic mail, # you may find current contact information at www.novell.com #++ @@ -25,79 +25,76 @@ class System - attr_reader :actions + attr_reader :actions + include Singleton - include Singleton - - def initialize - @actions = {:reboot => {:active => false}, :shutdown => {:active => false} } - end - - def reboot - if hal_power_management(:reboot) - @actions[:reboot][:active] = true - end + def initialize + @actions = {:reboot => {:active => false}, :shutdown => {:active => false} } + end + + def reboot + if consolekit_power_management(:reboot) + @actions[:reboot][:active] = true end + end - def shutdown - if hal_power_management(:shutdown) - @actions[:shutdown][:active] = true - end + def shutdown + if consolekit_power_management(:shutdown) + @actions[:shutdown][:active] = true end + end -# private methods - private + private - def hal_power_management(action, params = {}) + def consolekit_power_management(action, params = {}) + return false unless action == :reboot or action == :shutdown - return false unless action == :reboot or action == :shutdown + begin + # connect to the system bus + # Make a fresh connection, to be able to reboot + # after DBus is restarted, bnc#582759 + system_bus = DBus::SystemBus.send :new # RORSCAN_ITL + consolekit = system_bus.service('org.freedesktop.ConsoleKit') # RORSCAN_ITL + system = consolekit.object('/org/freedesktop/ConsoleKit/Manager') + system.introspect + system.default_iface = 'org.freedesktop.ConsoleKit.Manager' + + case action + + when :reboot + if ENV['RAILS_ENV'] == 'production' + Rails.logger.info "Rebooting the computer..." + return system.Restart + else + Rails.logger.warn "Skipping reboot in #{ENV['RAILS_ENV']} mode" + return true + end + + when :shutdown + if ENV['RAILS_ENV'] == 'production' + Rails.logger.info "Shutting down the computer..." + return system.Stop + else + Rails.logger.warn "Skipping shutdown in #{ENV['RAILS_ENV']} mode" + return true + end + + else + Rails.logger.error "Unsupported ConsoleKit command: #{action}" + end + + # handle DBus errors + rescue DBus::Error => dbe + Rails.logger.error "DBus error: #{dbe.dbus_message.error_name}" + return false + + # handle generic errors + rescue Exception => e + Rails.logger.error "Caught exception: #{e.message}" + return false - begin - # connect to the system bus - # Make a fresh connection, to be able to reboot - # after DBus is restarted, bnc#582759 - system_bus = DBus::SystemBus.send :new # RORSCAN_ITL - - # get the HAL service - hal_service = system_bus.service('org.freedesktop.Hal') # RORSCAN_ITL - - computer = hal_service.object('/org/freedesktop/Hal/devices/computer') - computer.introspect - computer.default_iface = 'org.freedesktop.Hal.Device.SystemPowerManagement' # RORSCAN_ITL - - case action - - when :reboot - if ENV['RAILS_ENV'] == 'production' - Rails.logger.info 'Rebooting the computer...' - return computer.Reboot.zero? - else - Rails.logger.warn "Skipping reboot in #{ENV['RAILS_ENV']} mode" - return true - end - when :shutdown - if ENV['RAILS_ENV'] == 'production' - Rails.logger.info 'Shutting down the computer...' - return computer.Shutdown.zero? - else - Rails.logger.warn "Skipping shutdown in #{ENV['RAILS_ENV']} mode" - return true - end - else - Rails.logger.error "Unsupported HAL command: #{action}" - end - - # handle DBus errors - rescue DBus::Error => dbe - Rails.logger.error "DBus error: #{dbe.dbus_message.error_name}" - return false - # handle generic errors - rescue Exception => e - Rails.logger.error "Caught exception: #{e.message}" - return false - end end - - + end end + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/www/test/functional/system_controller_test.rb new/www/test/functional/system_controller_test.rb --- old/www/test/functional/system_controller_test.rb 2010-08-27 14:58:55.000000000 +0200 +++ new/www/test/functional/system_controller_test.rb 2011-10-13 10:22:31.000000000 +0200 @@ -1,20 +1,20 @@ #-- # Copyright (c) 2009-2010 Novell, Inc. -# +# # All Rights Reserved. -# +# # This program is free software; you can redistribute it and/or modify it # under the terms of version 2 of the GNU General Public License # as published by the Free Software Foundation. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, contact Novell, Inc. -# +# # To contact Novell about this file by physical or electronic mail, # you may find current contact information at www.novell.com #++ @@ -33,11 +33,11 @@ @request.session[:account_id] = 1 # defined in fixtures @model = System.instance - @model.stubs(:hal_power_management).with(:reboot).returns(true) - @model.stubs(:hal_power_management).with(:shutdown).returns(true) + @model.stubs(:consolekit_power_management).with(:reboot).returns(true) + @model.stubs(:consolekit_power_management).with(:shutdown).returns(true) end - + test "check 'show' result" do ret = get :show # success (200 OK) @@ -153,3 +153,4 @@ end end + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/www/test/unit/system_test.rb new/www/test/unit/system_test.rb --- old/www/test/unit/system_test.rb 2010-08-27 14:58:55.000000000 +0200 +++ new/www/test/unit/system_test.rb 2011-10-13 10:22:37.000000000 +0200 @@ -1,20 +1,20 @@ #-- # Copyright (c) 2009-2010 Novell, Inc. -# +# # All Rights Reserved. -# +# # This program is free software; you can redistribute it and/or modify it # under the terms of version 2 of the GNU General Public License # as published by the Free Software Foundation. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, contact Novell, Inc. -# +# # To contact Novell about this file by physical or electronic mail, # you may find current contact information at www.novell.com #++ @@ -25,10 +25,10 @@ class SystemTest < ActiveSupport::TestCase - def setup + def setup @model = System.instance - @model.stubs(:hal_power_management).with(:reboot).returns(true) - @model.stubs(:hal_power_management).with(:shutdown).returns(true) + @model.stubs(:consolekit_power_management).with(:reboot).returns(true) + @model.stubs(:consolekit_power_management).with(:shutdown).returns(true) end def test_actions @@ -49,3 +49,4 @@ end end + continue with "q"... Remember to have fun... -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
