ubuntu-system-service-0.2.5/0000755000000000000000000000000012124403002012672 5ustar ubuntu-system-service-0.2.5/COPYING0000644000000000000000000004310312110443347013741 0ustar GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. ubuntu-system-service-0.2.5/setup.cfg0000644000000000000000000000025612111366066014534 0ustar [build] i18n=True [build_i18n] domain=system-service xml_files=[ ("share/polkit-1/actions/", ("backend/com.ubuntu.systemservice.policy.in",) ) ] ubuntu-system-service-0.2.5/debian/0000755000000000000000000000000012302376633014135 5ustar ubuntu-system-service-0.2.5/debian/copyright0000644000000000000000000000233412110443347016064 0ustar This package was debianized by Michael Vogt on Fri, 14 Jul 2008 16:10:41 +0100. It was downloaded via bzr from http://bazaar.launchpad.net/~mvo/system-service Upstream Author: Michael Vogt Copyright: Copyright (C) 2008 Canonical License: This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This package 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 package; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. The Debian packaging is (C) 2008, Michael Vogt and is licensed under the GPL, see above. ubuntu-system-service-0.2.5/debian/changelog0000644000000000000000000001714412302376633016016 0ustar ubuntu-system-service (0.2.5build1) trusty; urgency=medium * Rebuild to drop files installed into /usr/share/pyshared. -- Matthias Klose Sun, 23 Feb 2014 13:54:35 +0000 ubuntu-system-service (0.2.5) saucy; urgency=low * SECURITY UPDATE: possible privilege escalation via policykit UID lookup race. - UbuntuSystemService/utils.py: pass system-bus-name as a subject instead of pid so policykit can get the information from the system bus. - CVE-2013-1062 -- Marc Deslauriers Wed, 18 Sep 2013 13:21:34 -0400 ubuntu-system-service (0.2.4) raring; urgency=low * Drop system compatibility, we use systemd-services instead (lp: #1153567) -- Sebastien Bacher Tue, 26 Mar 2013 21:32:36 +0100 ubuntu-system-service (0.2.3) quantal; urgency=low * Add missing files to POTFILES.in. LP: #1036840 -- Gabor Kelemen Mon, 17 Sep 2012 11:38:58 +0100 ubuntu-system-service (0.2.2) precise; urgency=low [ Rodrigo Moya ] * merged lp:~rodrigo-moya/system-service/fix-877088: - only write apt proxy to a single file -- Michael Vogt Tue, 10 Jan 2012 09:59:59 +0100 ubuntu-system-service (0.2.1) precise; urgency=low [ Rodrigo Moya ] * merged lp:~rodrigo-moya/system-service/new-interfaces: - add org.freedesktop.hostname1 and org.freedesktop.locale1 interfaces for systemd compatbility -- Michael Vogt Mon, 28 Nov 2011 11:48:38 +0100 ubuntu-system-service (0.2) precise; urgency=low [ Gabor Kelemen ] * Let p-d-u handle i18n of the .policy file. LP: #853354 [ Michael Vogt ] * fixes for the new python-apt API * improve code layout, move backend into UbuntuSystemService.backend * improve tests -- Michael Vogt Fri, 21 Oct 2011 19:00:54 +0200 ubuntu-system-service (0.1.26.1) oneiric-proposed; urgency=low [ Rodrigo Moya ] * Fix saving of config options to /etc/apt/ (LP: #877254, #877088) -- Michael Vogt Fri, 21 Oct 2011 18:54:19 +0200 ubuntu-system-service (0.1.26) oneiric; urgency=low * backend/system-service-d: - do not return True for is_reboot_required if there are still package manager operations in progres * test/Makefile, .bzr-buildpackage/default.conf: - modernize and run during bzr-buildpackage -- Michael Vogt Mon, 25 Jul 2011 18:35:38 +0200 ubuntu-system-service (0.1.25) oneiric; urgency=low * backend/system-service-d: - add is_reboot_required call * backend/com.ubuntu.SystemService.conf: - allow introspection on the interface -- Michael Vogt Thu, 21 Jul 2011 09:29:50 +0200 ubuntu-system-service (0.1.24) oneiric; urgency=low * check lock of unattended-upgrades in is_package_system_locked() -- Michael Vogt Tue, 19 Jul 2011 17:02:07 +0200 ubuntu-system-service (0.1.23) oneiric; urgency=low * debian/control: Don't use "current" for X-Python-Version, this doesn't exist any more. Use >= 2.7 instead to only build for the current version. * debian/control: Properly version the python build dependency. -- Martin Pitt Tue, 14 Jun 2011 10:36:24 +0200 ubuntu-system-service (0.1.22) oneiric; urgency=low * Convert from cdbs to dh7 and dh-translations. * Move from pycentral to dh_python2. * debian/control: Bump Standards-Version to 3.9.2. -- Martin Pitt Fri, 10 Jun 2011 08:50:43 +0200 ubuntu-system-service (0.1.21) natty; urgency=low * debian/control: Fix Vcs-Bzr to point to actual branch. * backend/system-service-d: Fix D-Bus type of start-time argument to unbreak polkit query. This makes global proxy settings etc. work again. * debian/control: We don't need python-dev build dependency, just python. * debian/rules: Drop unnecessary and obsolete simple-patchsys.mk. * Convert to 3.0 (native) source format. * debian/control: Bump Standards-Version to 3.9.1. -- Martin Pitt Mon, 31 Jan 2011 09:48:34 +0100 ubuntu-system-service (0.1.20.1) lucid-proposed; urgency=low * backend/system-service-d: - check for download lock files as well when running "is_package_system_locked" (LP: #570583) -- Michael Vogt Tue, 27 Apr 2010 10:47:35 +0200 ubuntu-system-service (0.1.20) lucid; urgency=low * backend/system-service-d - add missing start-time (LP: #530430) -- Michael Vogt Mon, 15 Mar 2010 14:14:50 +0100 ubuntu-system-service (0.1.16) karmic; urgency=low * po/POTFILES.in: - add missing policy file (LP: #362042) Thanks to Gabor Kelemen * po/system-service.pot: - add pot file -- Michael Vogt Thu, 15 Oct 2009 12:37:16 +0200 ubuntu-system-service (0.1.15) karmic; urgency=low * ported to policykit-1 * install backend/com.ubuntu.systemservice.policy.in to the new polkit-1 action location * updated tests -- Michael Vogt Wed, 15 Jul 2009 13:34:15 +0200 ubuntu-system-service (0.1.11) jaunty; urgency=low * backend/system-service-d: - add is_package_system_locked interface to check if a dpkg/apt process is currently in use (part of LP: #334935) -- Michael Vogt Tue, 10 Mar 2009 15:10:31 +0100 ubuntu-system-service (0.1.10) intrepid; urgency=low * backend/system-service-d: - check against "org.gnome.gconf.defaults.set-system" as well -- Michael Vogt Thu, 11 Sep 2008 19:16:07 +0200 ubuntu-system-service (0.1.9) intrepid; urgency=low * backend/system-service-d: - call update-initramfs with its full path -- Michael Vogt Wed, 10 Sep 2008 11:47:53 +0200 ubuntu-system-service (0.1.8) intrepid; urgency=low * backend/system-service-d: - allow "_" in the kbd options -- Michael Vogt Tue, 09 Sep 2008 15:40:45 +0200 ubuntu-system-service (0.1.7) intrepid; urgency=low * backend/system-service-d: - add support for global keyboard settings via console-setup * debian/control: - move Vcs to lp:~ubuntu-core-dev/system-service/ubuntu -- Michael Vogt Mon, 08 Sep 2008 11:58:41 +0200 ubuntu-system-service (0.1.6) intrepid; urgency=low * debian/control: - add missing depends on policykit and python-dbus * add socks support * support no_proxy environment -- Michael Vogt Tue, 19 Aug 2008 14:18:18 +0200 ubuntu-system-service (0.1.5) intrepid; urgency=low * support https in "get_proxy()" * improve the verification for valid proxies * put the modules under UbuntuSystemService -- Michael Vogt Tue, 19 Aug 2008 11:30:43 +0200 ubuntu-system-service (0.1.4) intrepid; urgency=low * fix typo * add Vcs-Bzr header -- Michael Vogt Mon, 18 Aug 2008 22:17:00 +0200 ubuntu-system-service (0.1.3) intrepid; urgency=low * make the API more flexible * better exception handling * properly support ftp, https too -- Michael Vogt Mon, 18 Aug 2008 13:02:52 +0200 ubuntu-system-service (0.1.2) intrepid; urgency=low * initial upload to the archive -- Michael Vogt Fri, 15 Aug 2008 22:48:30 +0200 ubuntu-system-service (0.1.1) intrepid; urgency=low * fix FTBFS -- Michael Vogt Tue, 12 Aug 2008 18:46:28 +0200 ubuntu-system-service (0.1) intrepid; urgency=low * initial release -- Michael Vogt Tue, 12 Aug 2008 17:39:47 +0200 ubuntu-system-service-0.2.5/debian/pycompat0000644000000000000000000000000112110443347015675 0ustar 2ubuntu-system-service-0.2.5/debian/compat0000644000000000000000000000000212110443347015325 0ustar 7 ubuntu-system-service-0.2.5/debian/control0000644000000000000000000000147012124402700015525 0ustar Source: ubuntu-system-service Section: admin Priority: optional Maintainer: Michael Vogt Build-Depends: debhelper (>= 7.0.50~), dh-translations, python-distutils-extra, python (>= 2.6.6-3~), intltool X-Python-Version: >= 2.7 Standards-Version: 3.9.2 Vcs-Bzr: lp:system-service Vcs-Browser: http://bazaar.launchpad.net/~ubuntu-core-dev/system-service/ubuntu Package: ubuntu-system-service Architecture: all Depends: ${python:Depends}, ${misc:Depends}, python-apt (>= 0.7.0), python-dbus, policykit-1 Breaks: gnome-settings-daemon (<< 3.6.4-0ubuntu8), indicator-datetime (<< 12.10.3daily13.03.07) Description: Dbus service to set various system-wide configurations This package implements system wide proxy settings. ubuntu-system-service-0.2.5/debian/rules0000755000000000000000000000007412110443347015210 0ustar #!/usr/bin/make -f %: dh "$@" --with translations,python2 ubuntu-system-service-0.2.5/debian/source/0000755000000000000000000000000012124403002015414 5ustar ubuntu-system-service-0.2.5/debian/source/format0000644000000000000000000000001512110443347016636 0ustar 3.0 (native) ubuntu-system-service-0.2.5/backend/0000755000000000000000000000000012124403002014261 5ustar ubuntu-system-service-0.2.5/backend/com.ubuntu.SystemService.conf0000644000000000000000000000132612110443347022050 0ustar ubuntu-system-service-0.2.5/backend/system-service-d0000755000000000000000000000172612110443521017425 0ustar #!/usr/bin/python # (c) 2008 Canonical Ltd. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import dbus import gobject from UbuntuSystemService.backend import ServiceBackend if __name__ == "__main__": dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) server = ServiceBackend() gobject.MainLoop().run() ubuntu-system-service-0.2.5/backend/com.ubuntu.SystemService.service0000644000000000000000000000014612110443347022562 0ustar [D-BUS Service] Name=com.ubuntu.SystemService Exec=/usr/lib/system-service/system-service-d User=root ubuntu-system-service-0.2.5/backend/com.ubuntu.systemservice.policy.in0000644000000000000000000000455012110443347023131 0ustar SystemService https://launchpad.net/system-service <_description>Get current global proxy <_message>System policy prevents querying proxy settings yes yes <_description>Set current global proxy <_message>System policy prevents setting proxy settings no auth_admin_keep <_description>Set current global proxy exception <_message>System policy prevents setting no_proxy settings no auth_admin_keep <_description>Set current global keyboard <_message>System policy prevents setting global keyboard settings no auth_admin_keep <_description>Get current global keyboard <_message>System policy prevents querying keyboard settings yes yes <_description>Check if the package system is locked <_message>System policy prevents querying package system lock yes yes ubuntu-system-service-0.2.5/test/0000755000000000000000000000000012124403002013651 5ustar ubuntu-system-service-0.2.5/test/interactive/0000755000000000000000000000000012124403002016166 5ustar ubuntu-system-service-0.2.5/test/interactive/test_no_proxy0000644000000000000000000000053412110443347021042 0ustar #!/usr/bin/python import dbus import os priv = "com.ubuntu.systemservice.setnoproxy" session_bus = dbus.SessionBus() system_bus = dbus.SystemBus() ser = dbus.Interface(system_bus.get_object("com.ubuntu.SystemService","/"), "com.ubuntu.SystemService") print "setting no_proxy" res=ser.set_no_proxy("host1,host2") print res ubuntu-system-service-0.2.5/test/interactive/test_reset_proxy0000644000000000000000000000106212110443347021545 0ustar #!/usr/bin/python import dbus import os priv = "com.ubuntu.systemservice.setproxy" session_bus = dbus.SessionBus() system_bus = dbus.SystemBus() ser = dbus.Interface(system_bus.get_object("com.ubuntu.SystemService","/"), "com.ubuntu.SystemService") print ser.get_proxy("http") res = ser.set_proxy("http", "http://test:3128/") print res ser.set_proxy("http","") ser.set_proxy("ftp","") print "new http proxy: '%s'" % ser.get_proxy("http") print "new ftp proxy: '%s'" % ser.get_proxy("ftp") #print ser.get_proxy("http-invalid-proto") ubuntu-system-service-0.2.5/test/interactive/test_proxy0000644000000000000000000000077112110443347020351 0ustar #!/usr/bin/python import dbus import os priv = "com.ubuntu.systemservice.setproxy" session_bus = dbus.SessionBus() system_bus = dbus.SystemBus() ser = dbus.Interface(system_bus.get_object("com.ubuntu.SystemService","/"), "com.ubuntu.SystemService") print ser.get_proxy("http") print "settings proxy" ser.set_proxy("http", "http://test2:3128") ser.set_proxy("ftp", "ftp://test2:3128") print ser.get_proxy("http") print ser.get_proxy("ftp") #print ser.get_proxy("http-invalid") ubuntu-system-service-0.2.5/test/interactive/test_dbus0000644000000000000000000000166012110443347020123 0ustar #!/usr/bin/python import dbus import os import unittest class TestDbus(unittest.TestCase): def setUp(self): self.system_bus = dbus.SystemBus() self.iface = dbus.Interface( self.system_bus.get_object("com.ubuntu.SystemService","/"), "com.ubuntu.SystemService") def test_is_package_system_locked(self): # just check if it not raises res = self.iface.is_package_system_locked() self.assertTrue( res in [True, False] ) def test_is_reboot_required(self): # just check that it does not raise res = self.iface.is_reboot_required() self.assertTrue( res in [True, False] ) def test_get_proxy(self): for proto in ["http", "https", "ftp"]: res = self.iface.get_proxy(proto) # ensure we get a string self.assertTrue( isinstance(res, dbus.String) ) if __name__ == "__main__": unittest.main() ubuntu-system-service-0.2.5/test/interactive/test_keyboard0000644000000000000000000000142312110443347020763 0ustar #!/usr/bin/python import dbus import os priv = "com.ubuntu.systemservice.setkeyboard" session_bus = dbus.SessionBus() system_bus = dbus.SystemBus() ser = dbus.Interface(system_bus.get_object("com.ubuntu.SystemService","/"), "com.ubuntu.SystemService") print ser.get_keyboard() res = ser.set_keyboard("", "us", "", "") if res: print "settings keyboard" res = ser.set_keyboard("pc105", "de","nodeadkeys", "ctrl:nocaps") assert (res == True) # illeal char in variant assert(ser.set_keyboard("pc105", "de", "?", "ctrl:nocaps") == False) # illegal layout assert(ser.set_keyboard("pc105", "dex","nodeadkeys", "ctrl:nocaps") == False) # illegal model assert(ser.set_keyboard("px117", "dex","nodeadkeys", "ctrl:nocaps") == False) print ser.get_keyboard() ubuntu-system-service-0.2.5/test/test_verify_proxy0000755000000000000000000000201512110443347017414 0ustar #!/usr/bin/python import sys sys.path.insert(0, "../") import unittest from UbuntuSystemService.utils import verify_proxy class TestVerifyProxy(unittest.TestCase): test_cases = { "http://hh-1h.bla.com:8080/test/test.jsp?d=dd&id=dki" : False, "http://foo:3128" : True, "http://foo:3128/" : True, "http://foo.bar-z.com:3128/" : True, "http://foo.bar.com/port-not-after-host:3" : False, "http://foo:" : False, "does-not-start-with-proto" : False, "http://bad-host-chars?:3128/" : False, "http://host:2182/invalid-chars-in-str\\" : False, "http:no-forward-slashes:3128" :False, } def test_verify(self): for (str, result) in self.test_cases.iteritems(): self.assertEqual(verify_proxy("http", str), result, "%s expected %s" % (str, result)) if __name__ == "__main__": unittest.main() ubuntu-system-service-0.2.5/test/Makefile0000644000000000000000000000030612110443347015323 0ustar #!/usr/bin/make all: check check: set -e; \ find . -name 'test_*' | \ while read file; do \ if [ -x $$file ]; then \ echo "Testing $$file"; \ PYTHONPATH=.. python $$file ; \ fi \ done ubuntu-system-service-0.2.5/test/test_proxy.py0000755000000000000000000000275312110443347016470 0ustar #!/usr/bin/python import apt_pkg import dbus import os import sys import tempfile import unittest sys.path.insert(0, "../") from UbuntuSystemService.backend import ServiceBackend class TestProxy(unittest.TestCase): def test_write(self): # regression test for #877254 canary = 'Acquire::http::proxy::server2.local "DIRECT";\n' # setup tmpdir tmpdir = tempfile.mkdtemp() os.makedirs(os.path.join(tmpdir, "apt.conf.d")) f=open(os.path.join(tmpdir, "apt.conf"), "w") f.write(canary) f.close() # create backend bus = dbus.SessionBus() apt_pkg.config.set("Dir::etc", tmpdir) backend = ServiceBackend(bus=bus) # write and verify apt proxy settings backend._write_apt_proxy("http", "http://localhost:3128") self.assertEqual(open(os.path.join(tmpdir, "apt.conf")).read(), canary+ 'Acquire::http::proxy "http://localhost:3128";\n') # clear it again backend._clear_apt_proxy("http") self.assertEqual(open(os.path.join(tmpdir, "apt.conf")).read(), canary) # write and verify apt proxy settings backend._write_apt_proxy("http", "http://localhost:3128") self.assertEqual(open(os.path.join(tmpdir, "apt.conf")).read(), canary+ 'Acquire::http::proxy "http://localhost:3128";\n') if __name__ == "__main__": unittest.main() ubuntu-system-service-0.2.5/setup.py0000755000000000000000000000154512111366111014421 0ustar #!/usr/bin/env python from distutils.core import setup, Extension import glob import os from DistUtilsExtra.command import * setup(name='system-service', version='0.1.6', packages = ['UbuntuSystemService', ], data_files=[ # dbus stuff ('share/dbus-1/system-services', ['backend/com.ubuntu.SystemService.service']), ('../etc/dbus-1/system.d/', ["backend/com.ubuntu.SystemService.conf"]), ('lib/system-service/', ["backend/system-service-d"]), ], cmdclass = { "build" : build_extra.build_extra, "build_i18n" : build_i18n.build_i18n, "build_help" : build_help.build_help, "build_icons" : build_icons.build_icons } ) ubuntu-system-service-0.2.5/po/0000755000000000000000000000000012124403002013310 5ustar ubuntu-system-service-0.2.5/po/system-service.pot0000644000000000000000000000604112110443347017032 0ustar # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2012-09-17 11:35+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: ../backend/com.ubuntu.systemservice.policy.in.h:1 msgid "Get current global proxy" msgstr "" #: ../backend/com.ubuntu.systemservice.policy.in.h:2 msgid "System policy prevents querying proxy settings" msgstr "" #: ../backend/com.ubuntu.systemservice.policy.in.h:3 msgid "Set current global proxy" msgstr "" #: ../backend/com.ubuntu.systemservice.policy.in.h:4 msgid "System policy prevents setting proxy settings" msgstr "" #: ../backend/com.ubuntu.systemservice.policy.in.h:5 msgid "Set current global proxy exception" msgstr "" #: ../backend/com.ubuntu.systemservice.policy.in.h:6 msgid "System policy prevents setting no_proxy settings" msgstr "" #: ../backend/com.ubuntu.systemservice.policy.in.h:7 msgid "Set current global keyboard" msgstr "" #: ../backend/com.ubuntu.systemservice.policy.in.h:8 msgid "System policy prevents setting global keyboard settings" msgstr "" #: ../backend/com.ubuntu.systemservice.policy.in.h:9 msgid "Get current global keyboard" msgstr "" #: ../backend/com.ubuntu.systemservice.policy.in.h:10 msgid "System policy prevents querying keyboard settings" msgstr "" #: ../backend/com.ubuntu.systemservice.policy.in.h:11 msgid "Check if the package system is locked" msgstr "" #: ../backend/com.ubuntu.systemservice.policy.in.h:12 msgid "System policy prevents querying package system lock" msgstr "" #: ../backend/org.freedesktop.hostname1.policy.in.h:1 msgid "Set host name" msgstr "" #: ../backend/org.freedesktop.hostname1.policy.in.h:2 msgid "Authentication is required to set the local host name." msgstr "" #: ../backend/org.freedesktop.hostname1.policy.in.h:3 msgid "Set static host name" msgstr "" #: ../backend/org.freedesktop.hostname1.policy.in.h:4 msgid "" "Authentication is required to set the statically configured local host name, " "as well as the pretty host name." msgstr "" #: ../backend/org.freedesktop.hostname1.policy.in.h:5 msgid "Set machine information" msgstr "" #: ../backend/org.freedesktop.hostname1.policy.in.h:6 msgid "Authentication is required to set local machine information." msgstr "" #: ../backend/org.freedesktop.locale1.policy.in.h:1 msgid "Set system locale" msgstr "" #: ../backend/org.freedesktop.locale1.policy.in.h:2 msgid "Authentication is required to set the system locale." msgstr "" #: ../backend/org.freedesktop.locale1.policy.in.h:3 msgid "Set system keyboard settings" msgstr "" #: ../backend/org.freedesktop.locale1.policy.in.h:4 msgid "Authentication is required to set the system keyboard settings." msgstr "" ubuntu-system-service-0.2.5/po/POTFILES.in0000644000000000000000000000005312111366030015070 0ustar backend/com.ubuntu.systemservice.policy.in ubuntu-system-service-0.2.5/UbuntuSystemService/0000755000000000000000000000000012214601050016705 5ustar ubuntu-system-service-0.2.5/UbuntuSystemService/__init__.py0000644000000000000000000000000012110443347021014 0ustar ubuntu-system-service-0.2.5/UbuntuSystemService/utils.py0000644000000000000000000001263312214601050020424 0ustar import os import re import dbus import subprocess CONSOLE_SETUP_DEFAULT = "/etc/default/keyboard" class UnknownProxyTypeError(dbus.DBusException): " an unknown proxy type was passed " pass class InvalidKeyboardTypeError(dbus.DBusException): " an invalid keyboard was set " pass class PermissionDeniedError(dbus.DBusException): " permission denied by policy " pass def authWithPolicyKit(sender, connection, priv, interactive=1): #print "_authWithPolicyKit()" system_bus = dbus.SystemBus() obj = system_bus.get_object("org.freedesktop.PolicyKit1", "/org/freedesktop/PolicyKit1/Authority", "org.freedesktop.PolicyKit1.Authority") policykit = dbus.Interface(obj, "org.freedesktop.PolicyKit1.Authority") #print "priv: ", priv subject = ('system-bus-name', { 'name' : dbus.String(sender, variant_level = 1) } ) details = { '' : '' } flags = dbus.UInt32(interactive) # AllowUserInteraction = 0x00000001 cancel_id = '' (ok, notused, details) = policykit.CheckAuthorization(subject, priv, details, flags, cancel_id) #print "ok: ", ok return ok def get_keyboard_from_etc(): """ helper that reads /etc/default/console-setup and gets the keyboard settings there """ model = "" layout = "" variant = "" options = "" try: f = open(CONSOLE_SETUP_DEFAULT) for line in f: if line.startswith("XKBMODEL="): model = line.split("=")[1].strip('"\n') elif line.startswith("XKBLAYOUT="): layout = line.split("=")[1].strip('"\n') elif line.startswith("XKBVARIANT="): variant = line.split("=")[1].strip('"\n') elif line.startswith("XKBOPTIONS="): options = line.split("=")[1].strip('"\n') f.close() print (model, layout, variant, options) except Exception: print "Couldn't read ", CONSOLE_SETUP_DEFAULT return (model, layout, variant, options) def run_setupcon(): """ helper that runs setupcon to activate the settings, taken from oem-config (/usr/lib/oem-config/console/console-setup-apply) """ ret = subprocess.call(["setupcon","--save-only"]) subprocess.Popen(["/usr/sbin/update-initramfs","-u"]) return (ret == 0) def set_keyboard_to_etc(model, layout, variant, options): """ helper that writes /etc/default/console-setup """ # if no keyboard model is set, try to guess one # this is based on the "console-setup.config" code that # defaults to pc105 if not model: model = "pc105" if layout == "us": model = "pc104" elif layout == "br": model = "abnt2" elif layout == "jp": model = "jp106" # verify the settings if not verify_keyboard_settings(model, layout, variant, options): #print "verify_keyboard failed" raise InvalidKeyboardTypeError, "Invalid keyboard set" # FIXME: what to do if not os.path.exists(CONSOLE_SETUP_DEFAULT) content = [] for line in open(CONSOLE_SETUP_DEFAULT): if line.startswith("XKBMODEL="): line = 'XKBMODEL="%s"\n' % model elif line.startswith("XKBLAYOUT="): line = 'XKBLAYOUT="%s"\n' % layout elif line.startswith("XKBVARIANT="): line = 'XKBVARIANT="%s"\n' % variant elif line.startswith("XKBOPTIONS="): line = 'XKBOPTIONS="%s"\n' % options content.append(line) # if something changed, write if content != open(CONSOLE_SETUP_DEFAULT).readlines(): #print "content changed, writing" open(CONSOLE_SETUP_DEFAULT+".new","w").write("".join(content)) os.rename(CONSOLE_SETUP_DEFAULT+".new", CONSOLE_SETUP_DEFAULT) if not run_setupcon(): #print "setupcon failed" return False return True def verify_keyboard_settings(model, layout, variant, options): " helper that verfies the settings " # check against char whitelist allowed = "^[0-9a-zA-Z:,_]*$" for s in (model, layout, variant, options): if not re.match(allowed, s): #print "illegal chars in '%s'" % s return False # check if 'ckbcomp' can compile it cmd = ["ckbcomp"] if model: cmd += ["-model",model] if layout: cmd += ["-layout", layout] if variant: cmd += ["-variant", variant] if options: cmd += ["-option", options] ret = subprocess.call(cmd, stdout=open(os.devnull)) return (ret == 0) def verify_proxy(proxy_type, proxy): """ This verifies a proxy string. It works by whitelisting certain charackters: 0-9a-zA-Z:/?=-;~+ """ # protocol://host:port/stuff verify_str = "%s://[a-zA-Z0-9.-]+:[0-9]+/*$" % proxy_type if not re.match(verify_str, proxy): return False return True def verify_no_proxy(proxy): """ This verifies a proxy string. It works by whitelisting certain charackters: 0-9a-zA-Z:/?=-;~+ """ # protocol://host:port/stuff verify_str = "[a-zA-Z0-9.-:,]+" if not re.match(verify_str, proxy): return False return True ubuntu-system-service-0.2.5/UbuntuSystemService/backend.py0000644000000000000000000003547212110443347020671 0ustar import sys import gobject import dbus import dbus.service import dbus.mainloop.glib dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) import os import subprocess import apt_pkg import struct import fcntl from UbuntuSystemService.utils import * class ServiceBackend(dbus.service.Object): """ the main backend class that supports various system settings like proxy and keyboard """ # some class properties DBUS_INTERFACE_NAME = "com.ubuntu.SystemService" SUPPORTED_PROXIES = ("http","ftp", "https", "socks") # default files DPKG_LOCK = "/var/lib/dpkg/lock" APT_ARCHIVES_LOCK = "/var/cache/apt/archives/lock" APT_LISTS_LOCK = "/var/lib/apt/lists/lock" UNATTENDED_UPGRADES_LOCK = "/var/run/unattended-upgrades.lock" def __init__(self, bus=None): if bus is None: bus = dbus.SystemBus() bus_name = dbus.service.BusName(self.DBUS_INTERFACE_NAME, bus=bus) dbus.service.Object.__init__(self, bus_name, '/') apt_pkg.init_config() # proxy stuff --------------------------------------------------- def _etc_environment_proxy(self, proxy_type): " internal that returns the /etc/environment proxy " if not os.path.exists("/etc/environment"): return "" for line in open("/etc/environment"): if line.startswith("%s_proxy=" % proxy_type): (key, value) = line.strip().split("=") value = value.strip('"') return value return "" def _http_proxy(self): " internal helper that returns the current http proxy " apt_proxy = self._apt_proxy("http") env_proxy = self._etc_environment_proxy("http") # FIXME: what to do if both proxies are differnet? return env_proxy def _apt_proxy(self, proxy_type): " internal helper that returns the configured apt proxy" apt_pkg.init_config() proxy = apt_pkg.config.find("Acquire::%s::proxy" % proxy_type) return proxy def _ftp_proxy(self): apt_proxy = self._apt_proxy("ftp") env_proxy = self._etc_environment_proxy("ftp") # FIXME: what to do if both proxies are differnet? return env_proxy def _socks_proxy(self): env_proxy = self._etc_environment_proxy("socks") return env_proxy def _ftp_apt_proxy(self): " internal helper that returns the configured apt proxy" apt_pkg.init_config() http_proxy = apt_pkg.config.find("Acquire::ftp::proxy") return http_proxy def _https_proxy(self): " internal helper that returns the current https proxy " env_proxy = self._etc_environment_proxy("https") return env_proxy def _verify_proxy(self, proxy_type, proxy): " internal helper, verify that the proxy string is valid " return verify_proxy(proxy_type, proxy) def _verify_no_proxy(self, proxy): " internal helper, verify that the no_proxy string is valid " return verify_no_proxy(proxy) @dbus.service.method(DBUS_INTERFACE_NAME, in_signature='s', out_signature='s', sender_keyword='sender', connection_keyword='conn') def get_proxy(self, proxy_type, sender=None, conn=None): """ Get the current system-wide proxy for type "proxy_type" This function will look in the apt configuration to find the current http proxy. """ if proxy_type == "http": return self._http_proxy() if proxy_type == "https": return self._https_proxy() elif proxy_type == "ftp": return self._ftp_proxy() elif proxy_type == "socks": return self._socks_proxy() raise UnknownProxyTypeError, "proxy_type '%s' is unknown in get_proxy" % proxy_type def _write_apt_proxy(self, proxy_type, new_proxy): " helper that writes the new apt proxy " confdir = apt_pkg.config.find_dir("Dir::Etc") if not self._verify_proxy(proxy_type, new_proxy): return False # now the difficult case (search the apt configuration files) # build the list of apt configuration files first apt_conffiles = [os.path.join(confdir,"apt.conf.d",n) for n in os.listdir(os.path.join(confdir,"apt.conf.d"))] apt_conffiles.insert(0, os.path.join(confdir,"apt.conf")) # then scan them for the content already_saved = False for f in apt_conffiles: new_content = [] found = False try: file = open(f) for line in file: # Only replace the Acquire::%s::proxy entry, not other more # complicated forms of the proxy settings if line.lower().startswith("acquire::%s::proxy " % proxy_type): if already_saved: continue found = True line = "Acquire::%s::proxy \"%s\";\n" % (proxy_type, new_proxy) already_saved = True new_content.append(line) except Exception: pass # if we didn't find the proxy, write it out now if not found and not already_saved: new_content.append("Acquire::%s::proxy \"%s\";\n" % (proxy_type, new_proxy)) already_saved = True open(f,"w").write("".join(new_content)) return True def _write_etc_environment_proxy(self, proxy_type, new_proxy): if not self._verify_proxy(proxy_type, new_proxy): return False found=False new_content=[] new_proxy_line = '%s_proxy="%s"\n' % (proxy_type, new_proxy) for line in open("/etc/environment"): if line.startswith("%s_proxy=" % proxy_type): line=new_proxy_line found = True new_content.append(line) if found: open("/etc/environment","w").write("".join(new_content)) else: open("/etc/environment","a").write(new_proxy_line) return True def _clear_etc_environment_proxy(self, proxy_type): found=False new_content=[] for line in open("/etc/environment"): if line.startswith("%s_proxy=" % proxy_type): found = True else: new_content.append(line) if found: open("/etc/environment","w").write("".join(new_content)) return True def _clear_apt_proxy(self, proxy_type): " helper that clears the apt proxy " confdir = apt_pkg.config.find_dir("Dir::Etc") apt_conffiles = [os.path.join(confdir,"apt.conf.d",n) for n in os.listdir(os.path.join(confdir,"apt.conf.d"))] apt_conffiles.insert(0, os.path.join(confdir,"apt.conf")) for f in apt_conffiles: new_content = [] found = False for line in open(f): # Only remove the Acquire::%s::proxy entry, not other more # complicated forms of the proxy settings if line.lower().startswith("acquire::%s::proxy " % proxy_type): found = True else: new_content.append(line) # if we found/replaced the proxy, write it out now if found: open(f,"w").write("".join(new_content)) return True @dbus.service.method(DBUS_INTERFACE_NAME, in_signature='ss', out_signature='b', sender_keyword='sender', connection_keyword='conn') def set_proxy(self, proxy_type, new_proxy, sender=None, conn=None): """ Set a new system-wide proxy that looks like e.g.: http://proxy.host.net:port/ This function will set a new apt configuration and modify /etc/environment """ if not authWithPolicyKit(sender, conn, "com.ubuntu.systemservice.setproxy"): if not authWithPolicyKit(sender, conn, "org.gnome.gconf.defaults.set-system"): raise PermissionDeniedError, "Permission denied by policy" # check if something supported is set if not proxy_type in self.SUPPORTED_PROXIES: raise UnknownProxyTypeError, "proxy_type '%s' is unknown in set_proxy" % proxy_type # set (or reset) if new_proxy == "" or new_proxy is None: res = self._clear_apt_proxy(proxy_type) res &= self._clear_etc_environment_proxy(proxy_type) else: res = self._write_apt_proxy(proxy_type, new_proxy) res &= self._write_etc_environment_proxy(proxy_type, new_proxy) return res def _clear_etc_environment_no_proxy(self): found=False new_content=[] for line in open("/etc/environment"): if line.startswith("no_proxy="): found = True else: new_content.append(line) if found: open("/etc/environment","w").write("".join(new_content)) return True def _write_etc_environment_no_proxy(self, new_proxy): if not self._verify_no_proxy(new_proxy): return False found=False new_content=[] new_proxy_line = 'no_proxy="%s"\n' % new_proxy for line in open("/etc/environment"): if line.startswith("no_proxy="): line=new_proxy_line found = True new_content.append(line) if found: open("/etc/environment","w").write("".join(new_content)) else: open("/etc/environment","a").write(new_proxy_line) return True @dbus.service.method(DBUS_INTERFACE_NAME, in_signature='s', out_signature='b', sender_keyword='sender', connection_keyword='conn') def set_no_proxy(self, new_no_proxy, sender=None, conn=None): """ Set a new system-wide no_proxy list that looks like e.g.: localhost,foo.com This function will modify /etc/environment """ if not authWithPolicyKit(sender, conn, "com.ubuntu.systemservice.setnoproxy"): if not authWithPolicyKit(sender, conn, "org.gnome.gconf.defaults.set-system"): raise PermissionDeniedError, "Permission denied by policy" # set (or reset) if new_no_proxy == "" or new_no_proxy is None: res = self._clear_no_proxy() else: res = self._write_etc_environment_no_proxy(new_no_proxy) return res # keyboard stuff --------------------------------------------------- @dbus.service.method(DBUS_INTERFACE_NAME, in_signature='', out_signature='ssss', sender_keyword='sender', connection_keyword='conn') def get_keyboard(self, sender=None, conn=None): """ Set the system default keyboard configuration. It expects four input arguments (strings): model -- the model (evdev, pc105, ...) layout -- the layout (de, us, ...) variant -- the variant (nodeadkeys, ..) options -- keyboard options (nocaps, ...) It returns True on sucess """ (model, layout, variant, options) = get_keyboard_from_etc() return (model, layout, variant, options) @dbus.service.method(DBUS_INTERFACE_NAME, in_signature='ssss', out_signature='b', sender_keyword='sender', connection_keyword='conn') def set_keyboard(self, model, layout, variant, options, sender=None, conn=None): """ Get the current keyboard configuration. This returns four strings: (model, layout, variant, options) """ #print "set_keyboard: ", model, layout, variant, options if not authWithPolicyKit(sender, conn, "com.ubuntu.systemservice.setkeyboard"): if not authWithPolicyKit(sender, conn, "org.gnome.gconf.defaults.set-system"): raise PermissionDeniedError, "Permission denied by policy" # apply if not set_keyboard_to_etc(model, layout, variant, options): print "could not write keyboard to /etc" return False return True @dbus.service.method(DBUS_INTERFACE_NAME, in_signature='', out_signature='b', sender_keyword='sender', connection_keyword='conn') def is_reboot_required(self, sender=None, conn=None): """ Check if a reboot is required to finish installing updates """ REBOOT_REQUIRED="/var/run/reboot-required" # do not show reboot required if there is a transaction in # progress as the reboot required file may be created during # the transaction plus we don't want to show "please reboot" # while a transaction is running return (not self._is_package_system_locked() and os.path.exists(REBOOT_REQUIRED)) def _is_package_system_locked(self): # check for locks for lock in [ self.DPKG_LOCK, self.APT_LISTS_LOCK, self.APT_ARCHIVES_LOCK, self.UNATTENDED_UPGRADES_LOCK, ]: if not os.path.exists(lock): continue # check for lock flk=struct.pack('hhllhl',fcntl.F_WRLCK,0,0,0,0,0) f=open(lock) rv = fcntl.fcntl(f, fcntl.F_GETLK, flk) lockv = struct.unpack('hhllhl', rv)[0] f.close() if lockv == fcntl.F_WRLCK: return True return False @dbus.service.method(DBUS_INTERFACE_NAME, in_signature='', out_signature='b', sender_keyword='sender', connection_keyword='conn') def is_package_system_locked(self, sender=None, conn=None): """ Check if the package system is locked """ #print "set_keyboard: ", model, layout, variant, options if not authWithPolicyKit(sender, conn, "com.ubuntu.systemservice.ispkgsystemlocked"): raise PermissionDeniedError, "Permission denied by policy" return self._is_package_system_locked()