jobservice-0.8.0/0000755000175000017500000000000011426605603012573 5ustar jacobjacobjobservice-0.8.0/com.ubuntu.JobService.service0000644000175000017500000000011711424360015020276 0ustar jacobjacob[D-BUS Service] Name=com.ubuntu.JobService Exec=/usr/sbin/jobservice User=root jobservice-0.8.0/setup.py0000644000175000017500000000572011426605366014317 0ustar jacobjacob#!/usr/bin/python from os import listdir from os.path import exists from subprocess import Popen, PIPE from distutils.core import setup from distutils.command.install import install from distutils.core import Command class install_fix_paths(Command): def initialize_options(self): pass def finalize_options(self): pass def run(self): prefix = self.get_finalized_command('install').prefix data_dir = self.get_finalized_command('install_data').install_dir lib_dir = self.get_finalized_command('install_lib').install_dir # dbus service for iface in ('com.ubuntu.JobService', 'com.ubuntu.JobService.Job'): fn = data_dir + '/share/dbus-1/system-services/' + iface + '.service' with open(fn) as f: data = f.read() with open(fn, 'w') as f: f.write(data.replace('Exec=/usr', 'Exec=' + prefix)) # info.py fn = lib_dir + '/JobService/info.py' with open(fn) as f: data = f.read() with open(fn, 'w') as f: f.write(data.replace("prefix = '/usr'", "prefix = '{0}'".format(prefix))) setup_info = dict( name='jobservice', version='0.8.0', description='jobservice', author='Jacob Peddicord', author_email='jpeddicord@ubuntu.com', url='https://launchpad.net/jobservice', cmdclass={'install_fix_paths': install_fix_paths}, packages=['JobService', 'JobService.backends'], data_files=[ ('/etc/dbus-1/system.d/', ['com.ubuntu.JobService.conf']), ('share/dbus-1/system-services/', ['com.ubuntu.JobService.service', 'com.ubuntu.JobService.Job.service']), ('share/polkit-1/actions/', ['com.ubuntu.jobservice.policy']), ('share/jobservice/default/', ['sls/'+x for x in listdir('sls')]), ('lib/jobservice/helpers/', ['helpers/'+x for x in listdir('helpers')]), ('sbin/', ['jobservice']), ], ) # get the bzr revision if applicable if 'bzr' in setup_info['version']: try: setup_info['version'] += Popen(['bzr', 'revno'],stdout=PIPE).communicate()[0].strip() except: pass # write out info with open('JobService/info.py', 'w') as f: for item in ('name', 'version', 'author', 'author_email', 'url'): f.write("%s = '%s'\n" % (item, setup_info[item])) f.write("prefix = '/usr'\n") # overwritten by fix_paths # update translations if available (needed for branch builds) if exists('./translations.sh'): Popen(['./translations.sh']).communicate() # generate documentation try: from docutils.core import publish_file from docutils.writers import manpage, html4css1 publish_file(source_path='doc/manpage.txt', destination_path='jobservice.1', writer=manpage.Writer()) publish_file(source_path='doc/sls-format-0.8.txt', destination_path='doc/sls-format-0.8.html', writer=html4css1.Writer(), settings_overrides={'stylesheet_path': 'doc/style.css'}) except: pass install.sub_commands.append(('install_fix_paths', None)) setup(**setup_info) jobservice-0.8.0/helpers/0000755000175000017500000000000011426605603014235 5ustar jacobjacobjobservice-0.8.0/helpers/network-interface0000755000175000017500000001564311426150331017614 0ustar jacobjacob#!/usr/bin/env python # This file is part of jobservice. # Copyright 2010 Jacob Peddicord # # jobservice 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 3 of the License, or # (at your option) any later version. # # jobservice 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 jobservice. If not, see . import sys import os def p(t): print >> sys.stderr, t return t iface = sys.argv[1].split('/')[1] mode = sys.argv[2] def main(): interfaces = Interfaces() if mode == 'get': # manual mode if iface in interfaces.auto: print "manual yes" else: print "manual no" return # network mode if iface in interfaces.family and iface in interfaces.method: fam = interfaces.family[iface] meth = interfaces.method[iface] if fam == 'inet' and (meth == 'static' or meth == 'dhcp'): print "netmode {0}".format(meth) # address if iface in interfaces.address: print "address {0}".format(interfaces.address[iface]) # netmask if iface in interfaces.netmask: print "netmask {0}".format(interfaces.netmask[iface]) # gateway if iface in interfaces.gateway: print "gateway {0}".format(interfaces.gateway[iface]) elif mode == 'set': for line in sys.stdin.readlines(): setting, value = line.split() if setting == 'address' or setting == 'netmask' or setting == 'gateway': interfaces.update_option(iface, setting, value) elif setting == 'netmode': interfaces.update_mode(iface, value) elif setting == 'manual': interfaces.update_manual(iface, value == 'yes') class Interfaces: def __init__(self): self.auto = [] self.iface_stanza = {} self.family = {} self.method = {} self.address = {} self.netmask = {} self.gateway = {} # parse it! f = open('/etc/network/interfaces') current_iface = None for line in f: data = line.strip().split() if not data: continue # check the type of line if data[0] == 'auto': current_iface = None self.auto.extend(data[1:]) elif data[0].find('allow-') == 0 or data[0].find('mapping') == 0: current_iface = None elif data[0] == 'iface': current_iface = data[1] self.iface_stanza[current_iface] = [] self.family[data[1]] = data[2] self.method[data[1]] = data[3] elif data[0] == 'address': self.address[current_iface] = data[1] elif data[0] == 'netmask': self.netmask[current_iface] = data[1] elif data[0] == 'gateway': self.gateway[current_iface] = data[1] # store stanzas if current_iface and data[0] != 'iface': self.iface_stanza[current_iface].append(line) f.close() def open_change_files(self): orig = open('/etc/network/interfaces') new = open('/etc/network/interfaces.new', 'w') return (orig, new) def finalize_change_files(self, orig, new): orig.close() new.close() os.rename(orig.name, orig.name + '~') os.rename(new.name, orig.name) def update_manual(self, iface, manual): """Remove or add an auto line & iface stanza.""" orig, f = self.open_change_files() # adding an auto line & iface stanza if manual and not iface in self.auto: for line in orig: f.write(line) f.write('\nauto ' + iface + '\n') # only write an iface section if it's not already there if not iface in self.iface_stanza: # dhcp will be replaced in a later run if it's different f.write(' '.join(('iface', iface, 'inet', 'dhcp')) + '\n') # removing the auto line elif not manual and iface in self.auto: for line in orig: if line.strip() == 'auto ' + iface: continue f.write(line) self.finalize_change_files(orig, f) def update_mode(self, iface, mode): """Update an iface's mode (dhcp/static).""" orig, f = self.open_change_files() for line in orig: lstrip = line.strip() if lstrip.find('iface ' + iface) == 0: data = lstrip.split() f.write(' '.join(('iface', iface, data[2], mode)) + '\n') continue f.write(line) self.finalize_change_files(orig, f) def update_option(self, iface, setting, value): """Update an option inside a stanza.""" orig, f = self.open_change_files() stanza = False finished = False for line in orig: # if we've found our stanza lstrip = line.strip() if not stanza and lstrip.find('iface ' + iface) == 0: stanza = True f.write(line) # if it was already in the stanza if self.in_stanza(iface, setting): for s in self.iface_stanza[iface]: if s.find(setting) == 0: f.write(setting + ' ' + value + '\n') else: f.write(s) # not previously in file, write it else: f.write(setting + ' ' + value + '\n') f.write(''.join(self.iface_stanza[iface])) continue # figure out where to end the stanza if stanza: data = lstrip.split() if not data: f.write(line) continue if self.is_stanza_begin(data): stanza = False if not stanza: f.write(line) self.finalize_change_files(orig, f) def in_stanza(self, iface, setting): for s in self.iface_stanza[iface]: if s.find(setting) == 0: return True return False def is_stanza_begin(self, data): if data[0] == 'iface' or data[0] == 'mapping' or \ data[0] == 'auto' or data[0].find('allow-') == 0: return True else: return False if __name__ == '__main__': sys.exit(main()) jobservice-0.8.0/helpers/ufw-active0000755000175000017500000000014711426075331016236 0ustar jacobjacob#!/bin/bash read active if [[ $active == 'inactive' ]]; then ufw disable else ufw enable fi jobservice-0.8.0/jobservice0000755000175000017500000000353611426073540014662 0ustar jacobjacob#!/usr/bin/python # This file is part of jobservice. # Copyright 2010 Jacob Peddicord # # jobservice 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 3 of the License, or # (at your option) any later version. # # jobservice 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 jobservice. If not, see . import logging from optparse import OptionParser from gobject import threads_init, MainLoop from dbus import SystemBus from dbus.service import BusName from dbus.mainloop.glib import DBusGMainLoop import JobService from JobService.root import RootJobService from JobService.util import IdleTimeout # options op = OptionParser() op.add_option('--debug', action='store_true', dest='debug', default=False) op.add_option('--no-enforce', action='store_false', dest='enforce', default=True) (options, args) = op.parse_args() # logging level = logging.DEBUG if options.debug else logging.INFO logging.basicConfig(level=level, datefmt="%H:%M:%S", format="%(asctime)s %(name)s %(levelname)s: %(message)s") log = logging.getLogger('jobservice') log.debug('Starting up') # local sls if options.debug: log.debug('Using local SLS definitions') JobService.SLS_LOCAL = 'sls/{0}.xml' # start up! DBusGMainLoop(set_as_default=True) threads_init() loop = MainLoop() srv = RootJobService( BusName('com.ubuntu.JobService', bus=SystemBus()), JobService.DBUS_PATH, idle=IdleTimeout(loop, 600), enforce=options.enforce ) loop.run() jobservice-0.8.0/com.ubuntu.JobService.Job.service0000644000175000017500000000012311426067564021023 0ustar jacobjacob[D-BUS Service] Name=com.ubuntu.JobService.Job Exec=/usr/sbin/jobservice User=root jobservice-0.8.0/doc/0000755000175000017500000000000011426605603013340 5ustar jacobjacobjobservice-0.8.0/doc/sls-format-0.8.html0000644000175000017500000010455711426605603016634 0ustar jacobjacob Service-Level Settings Format

Service-Level Settings Format

Author: Jacob Peddicord <jpeddicord@ubuntu.com>
Description:SLS format 0.8 introduction and specification

Introduction

Are you the maintainer (or interested developer) of a system service? Do you want to make certain aspects of your service easily configurable by system administrators and users, without the need to edit config files? You've come to the right place.

Service-Level Settings (SLS) is a small XML format that describes tunable settings about a service. It contains information on setting names and types, where and how they are stored, and how they should be presented to a user. This information is all loaded by jobservice, a system job management daemon. jobservice parses this information and sends details to client programs, such as jobs-admin, for rendering to the user.

This document describes the format of an SLS definition with examples and further instructions. After reading this, you should be able to write your own in no time. If you can't, then I've failed as a documentation writer and you should email me directly for help. My email is located at the top of this document.

If you've written a SLS file and want me to look over it or give some pointers, feel free to contact me.

Examples are provided throughout the document. This is intended to be read from the top, but if you just want to start hacking you may be able to jump straight to the Type Reference for a quick reference.

XML Format

I'm going to assume you have at least basic knowledge of XML. If you don't know what XML is, just think of HTML, but more mundane. A basic SLS XML file looks something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE settings PUBLIC
 "-//Ubuntu//DTD jobservice Service-Level Settings 0.8//EN"
 "http://people.ubuntu.com/~jpeddicord/SLS/0.8/sls.dtd">
<settings>
    <setting name="setting_name" type="setting_type">
        <description>Some descriptive name</description>
        <data>
            <parse file="some_filename">%n=%s</parse>
        </data>
        <values>
            <value name="true">
                <raw>1</raw>
                <description>A description for this value</description>
            </value>
            <value name="false">
                <raw>0</raw>
            </value>
            ...
        </values>
    </setting>

    ...
</settings>

Let's break this down a little. The first four lines are standard XML practice: the XML and DOCTYPE tags. Always keep these present in your file. Nothing bad should happen with jobservice if they're not there, but the standards police may arrive on your doorstep and take you away.

Next up is the <settings> element. This must be present or nothing's going to read your file.

Inside the <settings> tag is a <setting> (singular) tag. Any number of <setting> tags can be present inside <settings>. A setting tag has two required attributes: name and type. name must be a unique name for this setting within the file. type tells jobservice what it should be expecting. We'll talk more about types shortly.

Inside an individual <setting> tag are three elements: <description>, <data>, and <values>. Only <description> is actually required, meaning this is valid:

<setting name="group_warning" type="label">
    <description>The following settings may break things.</description>
</setting>

That's usually not very useful, though, as it doesn't really do anything. (It's really only for the label type, which I'll describe later.)

<data> tells jobservice where it can find and save the actual settings it changes. This will be covered in the Data section below.

<values> describes possible values a particular setting can take. Covered in the Setting Values section.

Data

Single File

The data section tells jobservice where to look for the setting value and where to store it when it changes. 90% of the time, it will look something like this:

<data>
    <parse file="/etc/config/file">SOME_OPTION = %s</parse>
</data>

This tells the parser to look in /etc/config/file for a line that has SOME_OPTION =, followed by the actual value it will pick up. So, if that file has SOME_OPTION = sega in it, then the value returned by jobservice will be sega. When the user changes this value, it is written back to the file in the same place.

Keep in mind that values are only parsed on a single line. If you need multiple line support, you may want to use a helper script (see External Helpers).

At this point, unless your configuration is more complex, you may want to skip the rest of this section and continue to Setting Values.

Multiple Locations

Multiple <parse> tags are accepted. In apache2, for example, changing the server port requires it to be configured in multiple locations. Such a setup could be written as the following (simplified, this isn't actually correct for apache):

<data>
    <parse file="/etc/apache2/ports.conf">Listen %s</parse>
    <parse file="/etc/apache2/sites-available/000-default.conf">VirtualHost *:%s</parse>
</data>

With the above, when a value is changed, it is written to both of those files. (Note that jobservice only reads the value from the first, however.)

External Helpers

There are very rare cases where simply writing to a file is not enough. For that, there is the ability to call on external programs or helper scripts to fetch and set the value:

<data>
    <parse get="/usr/lib/jobservice/my-helper">SomeSetting %s</parse>
    <parse set="/usr/lib/jobservice/my-helper">SomeSetting=%s</parse>
</data>

This calls my-helper and parses STDOUT for SomeSetting %s as is done for normal files. When saving, my-helper is called with STDIN set to SomeSetting=%s (with %s replaced with the value, of course), again much like how things are written with normal files. The scripts given in get/set must have absolute paths or jobservice may not be able to find them.

Other than that, there are no real limitations: you can use extra arguments to scripts, get and set can be different programs, and you can even mix this with regular files as in the above examples. These are all rather advanced, however, and using regular files should cover most use cases.

Additionally, any instance of %j in the get/set attributes or parse body will be replaced with the full job name. This can be useful when multiple instances of a job use the same SLS file and you need to differentiate between them.

The "%n" shortcut

One very handy shortcut you can use inside <parse> tags is %n, which is replaced with the name of the setting before parsing. So:

<setting name="MySetting" type="str">
    <data>
        <parse file="/some/file">MySetting = "%s"</parse>
    ...

is identical to:

<setting name="MySetting" type="str">
    <data>
        <parse file="/some/file">%n = "%s"</parse>
    ...

This can make your setting files more concise and reduce the work needed to write them (even if just by a small amount).

Static values

Lastly, a data tag can also have a fixed value. This is really only useful for the exec type, but you may find other uses for it:

<data val="gufw" />

In this case the tag is self-closing. As previously mentioned, if you're using a label type, you can omit the <data> tag entirely.

Setting Values

The <values> tag is a tricky thing to get, but is a very powerful tool to use once you know how to wield it. Similar to <settings>, <values> contains any number of <value> tags, including none at all.

The usage of a <value> tag varies greatly with the setting type (see the Type Reference), but I'll give you a basic overview here. Let's start by example:

<values>
    <value name="true">
        <raw>1</raw>
    </value>
    <value name="false">
        <raw>0</raw>
    </value>
</values>

This is common to see for a bool type. Basically, this states that when the value for this is determined to be true (i.e. the checkbox in the interface is active), then a value of 1 will be written to the file (see Data for information on how). When the value is false, a 0 is written.

The key point to understand here is that the value parser is a translator between the user and the raw file data. The text in the name attribute is what is sent to and received from the client, and the raw tag text is what is written to or read from the file. Any value sent from the user or read from a file can be translated. This allows you to do some neat things, but also very nasty things. While you could translate str values from the user, this would be a very bad thing to do.

We'll call this value translation in other parts of this document.

<description> can be used inside value tags when necessary (depends on the type):

<value name="two">
    <description>Second item</description>
    <raw>2</raw>
</value>

When writing value sections, be sure to pay close attention to what is needed for the type of setting you are using. Don't stray from that and you should be fine.

Value Constraints

Values allow some constraints to be suggested. This is the responsibility of the client program to implement, and can even be ignored -- but that might compromise the stability of your system if an invalid value is entered.

Constraints are just attributes on the main <values> tag:

<values min="80" max="600" />

The above would be useful for an int setting. Note that constraints can be used regardless if there are values present or if the tag is empty (and thus self-closing, as in this example).

Again, pay attention to what constraints are available for the specific type you are working with and you should have no problems.

Type Reference

This is the main portion of this document. Different types have different requirements, and types effect the display of information to the user in client programs. If you're looking for a specific type, just locate the relevant section and read the details for information on how to use it.

bool

A bool type is a simple true/false setting. This is represented in jobs-admin as a checkbox.

Values

true and false are the client values, and need to be translated into raw values for writing.

Example

<setting name="enabled" type="bool">
    <description>Enable this setting</description>
    <data>
        <parse file="/etc/myfile">SettingEnabled %s</parse>
    </data>
    <values>
        <value name="true">
            <raw>yes</raw>
        </value>
        <value name="false">
            <raw>no</raw>
        </value>
    </values>
</setting>

This creates a setting of type bool named enabled with a description of "Enable this setting." The data is stored in /etc/myfile in the format SettingEnabled %s. true is translated into yes (SettingEnabled yes is written) and false becomes no.

int/float

An int corresponds to an unsigned integer, and float corresponds to a decimal. jobs-admin renders these as GtkSpinButton widgets.

Values

It is not necessary to provide translated values for these types. However, constraints may be used on an empty <values> tag.

Constraints
min
Minimum value accepted.
max
Maximum value accepted.

Example

<setting type="int" name="Port">
    <description>Port</description>
    <data>
        <parse file="/etc/ssh/sshd_config">%n %s</parse>
    </data>
    <values min="0" max="65535"/>
</setting>

A setting named Port of type int is created. Its description is simply "Port." The value is written to /etc/ssh/sshd_config using the format %n %s (or: Port %s). A minimum value of 0 and a maximum of 65535 is set.

str

A str is a simple text string. jobs-admin renders this as a text box. If a client program isn't sure how to render another type, it may treat it as a str.

Value translation should almost never be used here.

Example

<setting type="str" name="server">
    <description>NTP Server</description>
    <data>
        <parse file="/etc/ntp.conf">%n %s</parse>
    </data>
</setting>

Hopefully simple enough: a str setting named server with a description of NTP Server. Stored in /etc/ntp.conf as server %s.

label

Perhaps the easiest setting to use, the label just displays some text. This cannot be configured by the user: it is for informational purposes.

Example

<setting type="label" name="some_info">
    <description>Careful: fire is dangerous.</description>
</setting>

This will insert "Careful: fire is dangerous." as a setting. Because settings are displayed in the order present in the XML, you can use this to group some settings or show additional information about a setting.

choice

A choice setting requires one of its values be selected. Rendered in jobs-admin as a combo box.

Values

Value translation isn't important here, as most clients will render the description instead of the client value. You can make the value name the same as the raw text or different; it shouldn't matter for most cases.

The <description> tag inside a <value> is strongly suggested here, as it will likely be rendered by the client:

<value name="some_choice">
    <description>Some choice option</description>
    <raw>choice_rawdata</raw>
</value>

Example

<setting type="choice" name="default_input_policy">
    <description>Default inbound policy</description>
    <data>
        <parse file="/etc/default/ufw">DEFAULT_INPUT_POLICY="%s"</parse>
    </data>
    <values>
        <value name="drop">
            <raw>DROP</raw>
            <description>Drop</description>
        </value>
        <value name="accept">
            <raw>ACCEPT</raw>
            <description>Accept</description>
        </value>
    </values>
</setting>

Renders a choice setting named default_input_policy. Stored in /etc/default/ufw in DEFAULT_INPUT_POLICY="%s". Two choices are available: Drop, and Accept. Selecting Drop will store DEFAULT_INPUT_POLICY="DROP" in the file, and DEFAULT_INPUT_POLICY="ACCEPT" for Accept.

file/dir

A file or dir setting points to a file or directory on the system. Normally, this is rendered as a GtkFileChooserButton in jobs-admin, however it may render as a textbox if the exist constraint is false.

Values

Value translation should not be used. However, constraints are available:

Constraints
exist
If true, requires that the selected file or directory already exists on the system. If false, any filesystem location may be specified, existing or not. Defaults to true.

Example

<setting type="dir" name="log_location">
    <description>Log location</description>
    <data>
        <parse file="/etc/someservice.conf">%n %s</parse>
    </data>
    <values exist="false" />
</setting>

Creates a dir setting named log_location, stored in /etc/someservice.conf as log_location %s. The specified location doesn't have to exist; which implies that it is created on-demand by the service.

user/group

Much like a choice setting, but using system users or groups instead of configurable choices.

Values

Value translation should not be used, but constraints are available:

Constraints
useid
If true, the client should send and recieve values as numerical user IDs. If false, user or group names should be used. Defaults to false.

Example

<setting type="group" name="SystemGroup">
    <description>System Group</description>
    <data>
        <parse file="/etc/cups/cupsd.conf">%n %s</parse>
    </data>
    <values useid="false" />
</setting>

A group setting named SystemGroup. Stored in /etc/cups/cupsd.conf as SystemGroup %s. Because useid is false, the entire <values> tag may be omitted.

exec

Suggests to the client program that another application should be run to manage this particular service. The client program is responsible for launching this process, in fact, it may choose not to show settings of this type at all. jobs-admin presents these as a description followed by a "Launch" button to start the application.

Uses a static value with the shell-interpreted command to launch:

<data val="someapplication" />

Alternatively, if values are provided, the client program should check for the existence of each, deferring to the next if one is not available.

Values

If not using a static value in the data section, use values to list the commands that should be run. If one is not available, the next will be presented, until there are no more options left.

Example

<setting type="exec" name="manage">
    <_description>Manage CUPS</_description>
    <data val="xdg-open 'http://localhost:631/'"/>
    <values>
        <value name="system-config-printer">
            <_description>Configure printers</_description>
        </value>
        <value name="xdg-open 'http://localhost:631/'">
            <_description>Launch web interface</_description>
        </value>
    </values>
</setting>

An exec setting named manage that suggests that the user launch system-config-printer to manage printers. If that is not available, the web interface will be suggested instead. Note that the action to launch is in the value name. The text of <raw> tags is not passed over D-Bus, so you need to specify the action in the name.

Translation

Because <description> tags contain text that is displayed to the user, this text may be translated. Translations must be shipped inside the SLS file using xml:lang notation for alternate languages:

<setting name="stuff" type="label">
    <description>Hello!</description>
    <description xml:lang="es_ES">¡Hola!</description>
    ...

The intltool suite is capable of generating translatable XML files from gettext .po files. If you can't support the translation infrastructure needed here, we may be able to ship the SLS definition and translations with jobservice itself. Read on.

Distribution

Once you've gotten your SLS definition written, working, and hopefully translated, it's time to ship it out to your users.

With your service

If you are able to, I recommend simply shipping the SLS definition with your system service. It won't introduce any additional dependencies, as it is just a single XML file that is loaded only when needed.

To do so, just have your installation script or package install your SLS file to /usr/share/jobservice/sls. So, if you want to ship your apache2.xml SLS, it should go in /usr/share/jobservice/sls/apache2.xml. If the sls directory doesn't already exist, it should be created.

When jobservice starts up, it will read in your SLS file and display your settings. That's it!

With jobservice

If, for some reason, you don't want to ship your SLS file with your service, we may be able to ship it with jobservice directly. This may be useful if you are unable to properly support the translation infrastructure needed for internationalizing SLS description tags. Email your SLS definition to me (my email is at the top of this document) or branch lp:jobservice and add your SLS definition to it for merging.

Your SLS file will then be shipped as a "default" set of settings. If you choose to ship these in your own service later, these will be automatically overriden. We'll add the description tags for translation.

End

If you've survived this far, congratulations! You are now an SLS guru. If you need me to look over your SLS file, need assistance, or just want to chat, feel free to email me, ping me on twitter (@jpeddicord), identi.ca (@jacob), or on irc.freenode.net (nick jacob). Other contact methods are on my website.

Keep tabs on jobservice and jobs-admin for updates and new features, as well!

jobservice-0.8.0/doc/sls.dtd0000644000175000017500000000161011426101165014626 0ustar jacobjacob jobservice-0.8.0/doc/sls-format-0.8.txt0000644000175000017500000005110611426116171016473 0ustar jacobjacob=============================== Service-Level Settings Format =============================== :Author: Jacob Peddicord :Description: SLS format 0.8 introduction and specification .. contents:: :depth: 3 Introduction ============ Are you the maintainer (or interested developer) of a system service? Do you want to make certain aspects of your service easily configurable by system administrators and users, without the need to edit config files? You've come to the right place. Service-Level Settings (SLS) is a small XML format that describes tunable settings about a service. It contains information on setting names and types, where and how they are stored, and how they should be presented to a user. This information is all loaded by jobservice, a system job management daemon. jobservice_ parses this information and sends details to client programs, such as jobs-admin_, for rendering to the user. This document describes the format of an SLS definition with examples and further instructions. After reading this, you should be able to write your own in no time. If you can't, then I've failed as a documentation writer and you should email me directly for help. My email is located at the top of this document. If you've written a SLS file and want me to look over it or give some pointers, feel free to contact me. Examples are provided throughout the document. This is intended to be read from the top, but if you just want to start hacking you may be able to jump straight to the `Type Reference`_ for a quick reference. XML Format ========== I'm going to assume you have at least basic knowledge of XML. If you don't know what XML is, just think of HTML, but more mundane. A basic SLS XML file looks something like this:: Some descriptive name %n=%s 1 A description for this value 0 ... ... Let's break this down a little. The first four lines are standard XML practice: the XML and DOCTYPE tags. Always keep these present in your file. Nothing bad should happen with jobservice_ if they're not there, but the standards police may arrive on your doorstep and take you away. Next up is the element. This **must** be present or nothing's going to read your file. Inside the tag is a (singular) tag. Any number of tags can be present inside . A setting tag has two required attributes: ``name`` and ``type``. ``name`` must be a unique name for this setting within the file. ``type`` tells jobservice_ what it should be expecting. We'll talk more about types shortly. Inside an individual tag are three elements: , , and . Only is actually required, meaning this is valid:: The following settings may break things. That's usually not very useful, though, as it doesn't really do anything. (It's really only for the ``label`` type, which I'll describe later.) tells jobservice_ where it can find and save the actual settings it changes. This will be covered in the Data_ section below. describes possible values a particular setting can take. Covered in the `Setting Values`_ section. Data ---- Single File ~~~~~~~~~~~ The data section tells jobservice_ where to look for the setting value and where to store it when it changes. 90% of the time, it will look something like this:: SOME_OPTION = %s This tells the parser to look in ``/etc/config/file`` for a line that has ``SOME_OPTION =``, followed by the actual value it will pick up. So, if that file has ``SOME_OPTION = sega`` in it, then the value returned by jobservice_ will be ``sega``. When the user changes this value, it is written back to the file in the same place. Keep in mind that values are only parsed on a single line. If you need multiple line support, you may want to use a helper script (see `External Helpers`_). At this point, unless your configuration is more complex, you may want to skip the rest of this section and continue to `Setting Values`_. Multiple Locations ~~~~~~~~~~~~~~~~~~ Multiple tags are accepted. In ``apache2``, for example, changing the server port requires it to be configured in multiple locations. Such a setup could be written as the following (simplified, this isn't actually correct for apache):: Listen %s VirtualHost *:%s With the above, when a value is changed, it is written to both of those files. (Note that jobservice_ only *reads* the value from the first, however.) External Helpers ~~~~~~~~~~~~~~~~ There are *very rare* cases where simply writing to a file is not enough. For that, there is the ability to call on external programs or helper scripts to fetch and set the value:: SomeSetting %s SomeSetting=%s This calls ``my-helper`` and parses STDOUT for ``SomeSetting %s`` as is done for normal files. When saving, ``my-helper`` is called with STDIN set to ``SomeSetting=%s`` (with %s replaced with the value, of course), again much like how things are written with normal files. The scripts given in get/set **must have absolute paths** or jobservice_ may not be able to find them. Other than that, there are no real limitations: you can use extra arguments to scripts, get and set can be different programs, and you can even mix this with regular files as in the above examples. These are all rather advanced, however, and using regular files should cover most use cases. Additionally, any instance of ``%j`` in the get/set attributes or parse body will be replaced with the full job name. This can be useful when multiple instances of a job use the same SLS file and you need to differentiate between them. The "%n" shortcut ~~~~~~~~~~~~~~~~~ One very handy shortcut you can use inside tags is ``%n``, which is replaced with the name of the setting before parsing. So:: MySetting = "%s" ... is identical to:: %n = "%s" ... This can make your setting files more concise and reduce the work needed to write them (even if just by a small amount). Static values ~~~~~~~~~~~~~ Lastly, a data tag can also have a fixed value. This is really only useful for the ``exec`` type, but you may find other uses for it:: In this case the tag is self-closing. As previously mentioned, if you're using a ``label`` type, you can omit the tag entirely. Setting Values -------------- The tag is a tricky thing to get, but is a very powerful tool to use once you know how to wield it. Similar to , contains any number of tags, including none at all. The usage of a tag varies greatly with the setting type (see the `Type Reference`_), but I'll give you a basic overview here. Let's start by example:: 1 0 This is common to see for a ``bool`` type. Basically, this states that when the value for this is determined to be ``true`` (i.e. the checkbox in the interface is active), then a value of ``1`` will be written to the file (see Data_ for information on how). When the value is ``false``, a ``0`` is written. The key point to understand here is that the value parser is a **translator** between the user and the raw file data. The text in the ``name`` attribute is what is sent to and received from the client, and the ``raw`` tag text is what is written to or read from the file. Any value sent from the user or read from a file can be translated. This allows you to do some neat things, but also very nasty things. While you could translate ``str`` values from the user, this would be a *very bad* thing to do. We'll call this **value translation** in other parts of this document. can be used inside value tags when necessary (depends on the type):: Second item 2 When writing value sections, be sure to pay close attention to what is needed for the type of setting you are using. Don't stray from that and you should be fine. Value Constraints ~~~~~~~~~~~~~~~~~ Values allow some constraints to be suggested. This is the responsibility of the client program to implement, and can even be ignored -- but that might compromise the stability of your system if an invalid value is entered. Constraints are just attributes on the main tag:: The above would be useful for an ``int`` setting. Note that constraints can be used regardless if there are values present or if the tag is empty (and thus self-closing, as in this example). Again, pay attention to what constraints are available for the specific type you are working with and you should have no problems. Type Reference -------------- This is the main portion of this document. Different types have different requirements, and types effect the display of information to the user in client programs. If you're looking for a specific type, just locate the relevant section and read the details for information on how to use it. .. contents:: :local: :depth: 1 bool ~~~~ A ``bool`` type is a simple true/false setting. This is represented in jobs-admin_ as a checkbox. Values '''''' ``true`` and ``false`` are the client values, and need to be translated into raw values for writing. Example ''''''' :: Enable this setting SettingEnabled %s yes no This creates a setting of type ``bool`` named ``enabled`` with a description of "Enable this setting." The data is stored in ``/etc/myfile`` in the format ``SettingEnabled %s``. ``true`` is translated into ``yes`` (``SettingEnabled yes`` is written) and ``false`` becomes ``no``. int/float ~~~~~~~~~ An ``int`` corresponds to an unsigned integer, and ``float`` corresponds to a decimal. jobs-admin_ renders these as GtkSpinButton widgets. Values '''''' It is not necessary to provide translated values for these types. However, constraints may be used on an empty tag. Constraints ``````````` min Minimum value accepted. max Maximum value accepted. Example ''''''' :: Port %n %s A setting named ``Port`` of type ``int`` is created. Its description is simply "Port." The value is written to ``/etc/ssh/sshd_config`` using the format ``%n %s`` (or: ``Port %s``). A minimum value of ``0`` and a maximum of ``65535`` is set. str ~~~ A ``str`` is a simple text string. jobs-admin_ renders this as a text box. If a client program isn't sure how to render another type, it may treat it as a ``str``. Value translation should almost *never* be used here. Example ''''''' :: NTP Server %n %s Hopefully simple enough: a ``str`` setting named ``server`` with a description of ``NTP Server``. Stored in ``/etc/ntp.conf`` as ``server %s``. label ~~~~~ Perhaps the easiest setting to use, the ``label`` just displays some text. This cannot be configured by the user: it is for informational purposes. Example ''''''' :: Careful: fire is dangerous. This will insert "Careful: fire is dangerous." as a setting. Because settings are displayed in the order present in the XML, you can use this to group some settings or show additional information about a setting. choice ~~~~~~ A ``choice`` setting requires one of its values be selected. Rendered in jobs-admin_ as a combo box. Values '''''' Value translation isn't important here, as most clients will render the description instead of the client value. You can make the value name the same as the raw text or different; it shouldn't matter for most cases. The tag inside a is strongly suggested here, as it will likely be rendered by the client:: Some choice option choice_rawdata Example ''''''' :: Default inbound policy DEFAULT_INPUT_POLICY="%s" DROP Drop ACCEPT Accept Renders a ``choice`` setting named ``default_input_policy``. Stored in ``/etc/default/ufw`` in ``DEFAULT_INPUT_POLICY="%s"``. Two choices are available: Drop, and Accept. Selecting Drop will store ``DEFAULT_INPUT_POLICY="DROP"`` in the file, and ``DEFAULT_INPUT_POLICY="ACCEPT"`` for Accept. file/dir ~~~~~~~~ A ``file`` or ``dir`` setting points to a file or directory on the system. Normally, this is rendered as a GtkFileChooserButton in jobs-admin_, however it may render as a textbox if the ``exist`` constraint is ``false``. Values '''''' Value translation should not be used. However, constraints are available: Constraints ``````````` exist If ``true``, requires that the selected file or directory already exists on the system. If ``false``, any filesystem location may be specified, existing or not. Defaults to ``true``. Example ''''''' :: Log location %n %s Creates a ``dir`` setting named ``log_location``, stored in ``/etc/someservice.conf`` as ``log_location %s``. The specified location doesn't have to exist; which implies that it is created on-demand by the service. user/group ~~~~~~~~~~ Much like a ``choice`` setting, but using system users or groups instead of configurable choices. Values '''''' Value translation should not be used, but constraints are available: Constraints ``````````` useid If ``true``, the client should send and recieve values as numerical user IDs. If ``false``, user or group names should be used. Defaults to ``false``. Example ''''''' :: System Group %n %s A ``group`` setting named ``SystemGroup``. Stored in ``/etc/cups/cupsd.conf`` as ``SystemGroup %s``. Because ``useid`` is false, the entire tag may be omitted. exec ~~~~ Suggests to the client program that another application should be run to manage this particular service. The client program is responsible for launching this process, in fact, it may choose not to show settings of this type at all. jobs-admin_ presents these as a description followed by a "Launch" button to start the application. Uses a static value with the shell-interpreted command to launch:: Alternatively, if values are provided, the client program should check for the existence of each, deferring to the next if one is not available. Values '''''' If not using a static value in the data section, use values to list the commands that should be run. If one is not available, the next will be presented, until there are no more options left. Example ''''''' :: <_description>Manage CUPS <_description>Configure printers <_description>Launch web interface An ``exec`` setting named ``manage`` that suggests that the user launch ``system-config-printer`` to manage printers. If that is not available, the web interface will be suggested instead. Note that the action to launch is in the value name. The text of tags is not passed over D-Bus, so you need to specify the action in the name. Translation =========== Because tags contain text that is displayed to the user, this text may be translated. Translations must be shipped inside the SLS file using xml:lang notation for alternate languages:: Hello! ¡Hola! ... The **intltool** suite is capable of generating translatable XML files from gettext .po files. If you can't support the translation infrastructure needed here, we may be able to ship the SLS definition and translations with jobservice_ itself. Read on. Distribution ============ Once you've gotten your SLS definition written, working, and hopefully translated, it's time to ship it out to your users. With your service ----------------- If you are able to, I recommend simply shipping the SLS definition *with* your system service. It won't introduce any additional dependencies, as it is just a single XML file that is loaded only when needed. To do so, just have your installation script or package install your SLS file to ``/usr/share/jobservice/sls``. So, if you want to ship your ``apache2.xml`` SLS, it should go in ``/usr/share/jobservice/sls/apache2.xml``. If the ``sls`` directory doesn't already exist, it should be created. When jobservice_ starts up, it will read in your SLS file and display your settings. That's it! With jobservice --------------- If, for some reason, you don't want to ship your SLS file with your service, we may be able to ship it with jobservice_ directly. This may be useful if you are unable to properly support the translation infrastructure needed for internationalizing SLS description tags. Email your SLS definition to me (my email is at the top of this document) or branch lp:jobservice and add your SLS definition to it for merging. Your SLS file will then be shipped as a "default" set of settings. If you choose to ship these in your own service later, these will be automatically overriden. We'll add the description tags for translation. End === If you've survived this far, congratulations! You are now an SLS guru. If you need me to look over your SLS file, need assistance, or just want to chat, feel free to email me, ping me on twitter (@jpeddicord), identi.ca (@jacob), or on irc.freenode.net (nick jacob). Other contact methods are on `my website `_. Keep tabs on jobservice_ and jobs-admin_ for updates and new features, as well! .. _jobservice: https://launchpad.net/jobservice .. _jobs-admin: https://launchpad.net/jobsadmin jobservice-0.8.0/doc/manpage.txt0000644000175000017500000000160711426353336015520 0ustar jacobjacob============ jobservice ============ ---------------------------- system job management daemon ---------------------------- :Author: Jacob Peddicord :Date: 2010-08-03 :Manual section: 1 :Copyright: This manual page is available under the terms of the GPL version 3. SYNOPSIS ======== **jobservice** [options] OPTIONS ======= **jobservice** accepts the following development options: --debug Run in debug mode, displaying more output to the console. Enables loading of SLS files from relative directory ``./sls``. --no-enforce Disable PolicyKit prompts. This should *never* be used in production. DESCRIPTION =========== jobservice is normally started on-demand by D-Bus. Launching manually should only be used for debugging or development purposes. BUGS ==== Bugs can be reported at https://bugs.launchpad.net/jobservice. jobservice-0.8.0/doc/style.css0000644000175000017500000000043111425346066015214 0ustar jacobjacobbody { font: 10pt sans-serif; } div.contents { font-size: 0.9em; } div.contents ul { padding-left: 15px; } div.section { margin-left: 30px; } a.toc-backref { text-decoration: none; color: #000; } pre.literal-block { padding: 10px; border: 1px solid #ccc; background-color: #eee; } jobservice-0.8.0/README0000644000175000017500000000022611426605351013453 0ustar jacobjacobjobservice ========== https://launchpad.net/jobservice jobservice is a simple dbus backend that can be used to easily control system jobs/services. jobservice-0.8.0/sls/0000755000175000017500000000000011426605603013374 5ustar jacobjacobjobservice-0.8.0/sls/apport.xml0000644000175000017500000000114111426605602015417 0ustar jacobjacob Enable crash reporting %n=%s 1 0 jobservice-0.8.0/sls/networking.xml0000644000175000017500000000104011426605602016277 0ustar jacobjacob Hostname changes will not take effect until the next restart. Hostname %s jobservice-0.8.0/sls/avahi-daemon.xml0000644000175000017500000000123411426605602016446 0ustar jacobjacob Enable publishing to network disable-publishing=%s no yes jobservice-0.8.0/sls/ufw.xml0000644000175000017500000000561011426605603014721 0ustar jacobjacob Manage your firewall Firewall active Status: %s %s active inactive Use IPV6 IPV6=%s yes no Default inbound policy DEFAULT_INPUT_POLICY="%s" DROP Drop ACCEPT Accept ACCEPT_NO_TRACK Accept (no connection tracking) REJECT Reject Default outbound policy DEFAULT_OUTPUT_POLICY="%s" DROP Drop ACCEPT Accept ACCEPT_NO_TRACK Accept (no connection tracking) REJECT Reject jobservice-0.8.0/sls/network-interface.xml0000644000175000017500000000444411426605603017553 0ustar jacobjacob Manage manually %n %s %n %s yes no Network mode %n %s %n %s DHCP dhcp Static static IP address %n %s %n %s Subnet mask %n %s %n %s Default gateway %n %s %n %s jobservice-0.8.0/sls/ntp.xml0000644000175000017500000000060511426605603014720 0ustar jacobjacob NTP Server %n %s jobservice-0.8.0/sls/pulseaudio.xml0000644000175000017500000000160711426605603016274 0ustar jacobjacob System mode PULSEAUDIO_SYSTEM_START=%s 1 0 PulseAudio Preferences Volume Control jobservice-0.8.0/sls/kerneloops.xml0000644000175000017500000000115411426605602016277 0ustar jacobjacob Enable kernel crash reporting %n=%s 1 0 jobservice-0.8.0/sls/bluetooth.xml0000644000175000017500000000203311426605602016120 0ustar jacobjacob Active on boot %n = %s true false Remember powered state %n = %s true false jobservice-0.8.0/sls/ssh.xml0000644000175000017500000000474511426605603014725 0ustar jacobjacob Port %n %s X11 Forwarding %n %s yes no Allow password authentication %n %s yes no Allow public key authentication %n %s yes no Permit remote root login %n %s yes no Keep idle connections alive %n %s yes no jobservice-0.8.0/sls/cups.xml0000644000175000017500000000146311426605602015073 0ustar jacobjacob Manage CUPS Configure printers Launch web interface System Group %n %s jobservice-0.8.0/PKG-INFO0000644000175000017500000000035211426605603013670 0ustar jacobjacobMetadata-Version: 1.0 Name: jobservice Version: 0.8.0 Summary: jobservice Home-page: https://launchpad.net/jobservice Author: Jacob Peddicord Author-email: jpeddicord@ubuntu.com License: UNKNOWN Description: UNKNOWN Platform: UNKNOWN jobservice-0.8.0/setup.cfg0000644000175000017500000000003111376536474014423 0ustar jacobjacob[install] prefix = /usr jobservice-0.8.0/JobService/0000755000175000017500000000000011426605603014626 5ustar jacobjacobjobservice-0.8.0/JobService/job.py0000644000175000017500000001166011424374275015764 0ustar jacobjacob# This file is part of jobservice. # Copyright 2010 Jacob Peddicord # # jobservice 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 3 of the License, or # (at your option) any later version. # # jobservice 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 jobservice. If not, see . import logging from dbus import PROPERTIES_IFACE from dbus.service import BusName, Object as DBusObject, method as DBusMethod from JobService import DBUS_JOB_IFACE, JobException log = logging.getLogger('jobservice') class SingleJobService(DBusObject): """Export a single job as its own object on our bus.""" def __init__(self, conn=None, object_path=None, bus_name=None, name=None, root=None): DBusObject.__init__(self, conn, object_path, bus_name) self.name = name self.root = root self.path = self.__dbus_object_path__ self._props = {} @DBusMethod(PROPERTIES_IFACE, in_signature='s', out_signature='a{sv}') def GetAll(self, interface): self.root.idle.ping() if interface != DBUS_JOB_IFACE: raise JobException('Interface not supported.') self._load_properties() return self._props @DBusMethod(PROPERTIES_IFACE, in_signature='ss', out_signature='v') def Get(self, interface, prop): self.root.idle.ping() if interface != DBUS_JOB_IFACE: raise JobException('Interface not supported.') self._load_properties() return self._props[prop] @DBusMethod(DBUS_JOB_IFACE, in_signature='', out_signature='', sender_keyword='sender', connection_keyword='conn') def Start(self, sender=None, conn=None): """Start a job by name. Does not enable/disable the job.""" self.root.idle.ping() log.debug('Start called on {0}'.format(self.name)) self.root.policy.check(sender, conn) self.root.proxy.start_service(self.name) self._props = {} @DBusMethod(DBUS_JOB_IFACE, in_signature='', out_signature='', sender_keyword='sender', connection_keyword='conn') def Stop(self, sender=None, conn=None): """Stop a job by name. Does not enable/disable the job.""" self.root.idle.ping() log.debug('Stop called on {0}'.format(self.name)) self.root.policy.check(sender, conn) self.root.proxy.stop_service(self.name) self._props = {} @DBusMethod(DBUS_JOB_IFACE, in_signature='b', out_signature='', sender_keyword='sender', connection_keyword='conn') def SetAutomatic(self, auto, sender=None, conn=None): """Make a job automatic or manual. Does not change state.""" self.root.idle.ping() log.debug('SetAutomatic ({1}) called on {0}'.format(self.name, auto)) self.root.policy.check(sender, conn) self.root.proxy.set_service_automatic(self.name, auto) self._props = {} @DBusMethod(DBUS_JOB_IFACE, in_signature='s', out_signature='a(ssssa(ss)a{ss})', sender_keyword='sender', connection_keyword='conn') def GetSettings(self, lang, sender=None, conn=None): """ Return a job's available settings and constraints. Takes a single argument (locale) used to determine what language the descriptions should be sent in. If unknown, use an empty string. Returns list of struct settings ( string name string type string description string current-value list of struct values ( string name string description ) dict constraints { key: string type value: string value } ) """ self.root.idle.ping() log.debug('GetSettings ({1}) called on {0}'.format(self.name, lang)) return self.root.proxy.get_service_settings(self.name, lang) @DBusMethod(DBUS_JOB_IFACE, in_signature='a{ss}', out_signature='', sender_keyword='sender', connection_keyword='conn') def SetSettings(self, settings, sender=None, conn=None): """Change a job's settings.""" self.root.idle.ping() log.debug('SetSettings called on {0}'.format(self.name)) self.root.policy.check(sender, conn) self.root.proxy.set_service_settings(self.name, settings) self._props = {} def _load_properties(self): if not self._props: self._props = self.root.proxy.get_service(self.name) jobservice-0.8.0/JobService/info.py0000644000175000017500000000024111426605601016126 0ustar jacobjacobname = 'jobservice' version = '0.8.0' author = 'Jacob Peddicord' author_email = 'jpeddicord@ubuntu.com' url = 'https://launchpad.net/jobservice' prefix = '/usr' jobservice-0.8.0/JobService/util.py0000644000175000017500000000347411424374275016173 0ustar jacobjacob# This file is part of jobservice. # Copyright 2010 Jacob Peddicord # # jobservice 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 3 of the License, or # (at your option) any later version. # # jobservice 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 jobservice. If not, see . import logging from time import time from glib import timeout_add_seconds log = logging.getLogger('jobservice') class IdleTimeout: """ Keeps track of the time since last use. If idle for too long, quit. """ def __init__(self, loop, idlemax): self.loop = loop self.idlemax = idlemax self.lastused = time() self.timeout = timeout_add_seconds(idlemax, self.callback) def callback(self): now = time() # we were left idle, time to quit if now - self.lastused > self.idlemax: log.info("Left idle - shutting down") self.loop.quit() return False return True def ping(self): self.lastused = time() def dbus_safe_name(unsafe): """ Returns a name that is safe to export over DBus. Based on the implementation in upstart/libnih. """ safe = '' for ch in unsafe: if (ch >= 'a' and ch <= 'z') or (ch >= 'a' and ch <= 'z') or (ch >= '0' and ch <= '9'): safe += ch else: safe += '_{0:02x}'.format(ord(ch)) return safe jobservice-0.8.0/JobService/policy.py0000644000175000017500000000437711424374275016520 0ustar jacobjacob# This file is part of jobservice. # Copyright 2010 Jacob Peddicord # # jobservice 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 3 of the License, or # (at your option) any later version. # # jobservice 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 jobservice. If not, see . import logging from dbus import SystemBus, DBusException, Interface log = logging.getLogger('policy') class DeniedByPolicy(DBusException): _dbus_error_name = 'com.ubuntu.JobService.DeniedByPolicy' class Policy: def __init__(self, enforce=True): self.enforce = enforce self.bus = SystemBus() self.dbus_iface = None self.pk = Interface(self.bus.get_object('org.freedesktop.PolicyKit1', '/org/freedesktop/PolicyKit1/Authority'), 'org.freedesktop.PolicyKit1.Authority') if not enforce: log.warn("Not enforcing PolicyKit privileges!") def check(self, sender, conn, priv='com.ubuntu.jobservice.manage'): """ Check or ask for authentication for job management. """ if not self.enforce: return log.debug("Asking for PolicyKit authorization") # get the PID of the sender if not self.dbus_iface: self.dbus_iface = Interface(conn.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus/Bus'), 'org.freedesktop.DBus') pid = self.dbus_iface.GetConnectionUnixProcessID(sender) # ask PolicyKit auth, challenge, details = self.pk.CheckAuthorization( ('unix-process', {'pid': pid, 'start-time': 0}), priv, {'': ''}, 1, '', timeout=500) if not auth: log.info("Authorization failed") raise DeniedByPolicy('Not authorized to manage jobs.') log.debug("Authorization passed") jobservice-0.8.0/JobService/settings.py0000644000175000017500000001545211426116021017036 0ustar jacobjacob# This file is part of jobservice. # Copyright 2010 Jacob Peddicord # # jobservice 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 3 of the License, or # (at your option) any later version. # # jobservice 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 jobservice. If not, see . import logging from os import rename from os.path import exists from cStringIO import StringIO from subprocess import Popen, PIPE from xml.etree.cElementTree import ElementTree import JobService log = logging.getLogger('sls') class ServiceSettings: """Service-level settings (SLS) for a single service.""" def __init__(self, jobname): self.jobname = jobname if '/' in jobname: basename = jobname.split('/')[0] else: basename = jobname self.filename = '' for loc in (JobService.SLS_LOCAL, JobService.SLS_SYSTEM, JobService.SLS_DEFAULT): if not loc: continue self.filename = loc.format(basename) if exists(self.filename): log.debug('Using ' + self.filename) break self.tree = ElementTree() self.tree.parse(self.filename) self.selements = {} self.settings = {} def get_all_settings(self): """Return a list of setting names available on this service.""" lst = [] for e in self.tree.findall('setting'): name = e.get('name') self.selements[name] = e lst.append(name) return lst def get_setting(self, name, lang=''): """Return details of a specific setting by name in the format: (name, type, description, current, possible[], constraints{}) """ ele = self.selements[name] # current value raw = '' data = ele.find('data') if data != None: fixed = data.get('val') if fixed: raw = fixed else: # find the first source we can obtain a value from for p in ele.findall('data/parse'): parse = p.text.replace('%n', name) parse = parse.replace('%j', self.jobname) # load from file if p.get('file'): prescan = p.get('after') with open(p.get('file')) as f: raw = self._raw_value(parse, f, prescan=prescan) break # load from external helper elif p.get('get'): cmd = p.get('get').replace('%j', self.jobname) proc = Popen(cmd, shell=True, stdout=PIPE) sio = StringIO(proc.communicate()[0]) raw = self._raw_value(parse, sio) break # get available values values = [] self.settings[name] = raw for v in ele.findall('values/value'): values.append((v.get('name'), v.findtext('description', ''))) if v.findtext('raw') == raw: self.settings[name] = v.get('name') vals = ele.find('values') constraints = vals.attrib if vals != None else {} return (name, ele.get('type'), ele.findtext('description'), self.settings[name], values, constraints) def set_setting(self, name, value): ele = self.selements[name] # don't do anything with an empty data element data = ele.find('data') if not len(data): return # translate the value into something for the file newval = value for v in ele.findall('values/value'): if v.get('name') == value: newval = v.findtext('raw') break # write out values for p in data.findall('parse'): parse = p.text.replace('%n', name) parse = parse.replace('%j', self.jobname) # write to file if p.get('file'): filename = p.get('file') prescan = p.get('after') # write the new values read = open(filename) write = open('{0}.new'.format(filename), 'w') self._raw_value(parse, read, write, newval, prescan) write.close() read.close() # replace the original with backup rename(read.name, '{0}~'.format(read.name)) rename(write.name, read.name) # send to an external program for processing elif p.get('set'): cmd = p.get('set').replace('%j', self.jobname) proc = Popen(cmd, shell=True, stdin=PIPE) proc.communicate(parse.replace('%s', newval)) def _raw_value(self, parse, read, write=None, newval=None, prescan=None): """ Read or write (if write is not None) a raw value to a conf file. read & write are file objects. If the setting line has been commented, it will still be read normally. On write, the comment will be removed. Default settings are assumed to be commented out, so when changing them we'll need to uncomment. If "prescan" is set, will not begin scanning until the string provided has been passed. """ assert parse before, after = parse.strip().split('%s') value = False scanning = False if prescan else True for line in read: if not scanning and prescan: if line.find(prescan) != -1: scanning = True beforepos = line.find(before) # the last check is to make sure this is the right line, # but we only perform it if we _might_ have it for speed. if scanning and beforepos >= 0 and line.lstrip(' #;\t').find(before) == 0: if write: data = ''.join((line[:beforepos], before, newval, after, '\n')) write.write(data.lstrip('#;')) else: start = beforepos + len(before) if after: value = line[start:line.find(after, start)] else: value = line[start:len(line)-1] # \n at the end return value continue if write: write.write(line) return '' jobservice-0.8.0/JobService/root.py0000644000175000017500000000447011424374275016176 0ustar jacobjacob# This file is part of jobservice. # Copyright 2010 Jacob Peddicord # # jobservice 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 3 of the License, or # (at your option) any later version. # # jobservice 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 jobservice. If not, see . import sys import logging from dbus.service import Object as DBusObject, method as DBusMethod from JobService import DBUS_PATH, DBUS_IFACE from JobService.backends import ServiceProxy from JobService.job import SingleJobService from JobService.policy import Policy from JobService.util import dbus_safe_name log = logging.getLogger('jobservice') class RootJobService(DBusObject): def __init__(self, conn=None, object_path=None, bus_name=None, idle=None, enforce=True): """ Fire up this service as well as all of the paths for individual jobs. """ DBusObject.__init__(self, conn, object_path, bus_name) self.idle = idle self.policy = Policy(enforce) self.proxy = ServiceProxy() self.jobs = [] allsvcs = self.proxy.get_all_services() for job in allsvcs: self.jobs.append(SingleJobService(conn, '/'.join((DBUS_PATH, dbus_safe_name(job))), name=job, root=self )) log.info('Ready') @DBusMethod(DBUS_IFACE, in_signature='', out_signature='a(so)', sender_keyword='sender', connection_keyword='conn') def GetAllJobs(self, sender=None, conn=None): """ Returns all jobs known by the backend(s), along with their states. Returns array of struct ( string name object path ) """ self.idle.ping() log.debug("GetAllJobs called") svclist = [] for job in self.jobs: svclist.append((job.name, job.path)) return svclist jobservice-0.8.0/JobService/__init__.py0000644000175000017500000000221411426067540016740 0ustar jacobjacob# This file is part of jobservice. # Copyright 2010 Jacob Peddicord # # jobservice 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 3 of the License, or # (at your option) any later version. # # jobservice 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 jobservice. If not, see . from dbus import DBusException try: from JobService.info import prefix except: prefix = '/usr' DBUS_IFACE = 'com.ubuntu.JobService' DBUS_PATH = '/com/ubuntu/JobService' DBUS_JOB_IFACE = DBUS_IFACE + '.Job' SLS_SYSTEM = prefix + '/share/jobservice/sls/{0}.xml' SLS_DEFAULT = prefix + '/share/jobservice/default/{0}.xml' SLS_LOCAL = None class JobException(DBusException): _dbus_error_name = DBUS_IFACE + '.JobException' jobservice-0.8.0/JobService/backends/0000755000175000017500000000000011426605603016400 5ustar jacobjacobjobservice-0.8.0/JobService/backends/upstart_0_6.py0000644000175000017500000002142011424631265021120 0ustar jacobjacob# This file is part of jobservice. # Copyright 2010 Jacob Peddicord # # jobservice 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 3 of the License, or # (at your option) any later version. # # jobservice 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 jobservice. If not, see . from os import rename from dbus import SystemBus, Interface, PROPERTIES_IFACE, Array from JobService.backends import ServiceBase class ServiceBackend(ServiceBase): def __init__(self): """ Connect to Upstart's dbus service. """ self.jobpaths = {} self.instpaths = {} self.bus = SystemBus() self.upstart = Interface( self.bus.get_object('com.ubuntu.Upstart', '/com/ubuntu/Upstart'), 'com.ubuntu.Upstart0_6' ) def get_all_services(self): svclist = [] for path in self.upstart.GetAllJobs(): job_obj = self.bus.get_object('com.ubuntu.Upstart', path) job_name = job_obj.Get('com.ubuntu.Upstart0_6.Job', 'name', dbus_interface=PROPERTIES_IFACE) job = Interface(job_obj, 'com.ubuntu.Upstart0_6.Job') self.jobpaths[job_name] = path # get the instance(s) and their states instances = job.GetAllInstances() self.instpaths[path] = [] if instances: for inst_path in instances: self.instpaths[path].append(inst_path) inst_obj = self.bus.get_object('com.ubuntu.Upstart', inst_path) inst_name = inst_obj.Get('com.ubuntu.Upstart0_6.Instance', 'name', dbus_interface=PROPERTIES_IFACE) if inst_name: svclist.append(job_name + '/' + inst_name) # if there is no instance name, there's probably only one else: svclist.append(job_name) # no running instances else: svclist.append(job_name) return svclist def get_service(self, name): # some defaults for values we might not find info = { 'running': False, 'automatic': False, 'pid': 0, 'starton': Array(signature='s'), 'stopon': Array(signature='s'), } job_name, inst_name = self._split_job(name) # job-level properties job_obj = self.bus.get_object('com.ubuntu.Upstart', self.jobpaths[job_name]) props = job_obj.GetAll('com.ubuntu.Upstart0_6.Job', dbus_interface=PROPERTIES_IFACE) # starton/stopon info['file'] = '/etc/init/{0}.conf'.format(job_name) with open(info['file']) as conf: starton = self._parse_conf(conf, 'start on') stopon = self._parse_conf(conf, 'stop on') info['starton'] += self._extract_events(starton) info['stopon'] += self._extract_events(stopon) # automatic if starton isn't commented out info['automatic'] = (starton[0] != '#') # running state: check the instance(s) inst_obj, inst_props = self._get_inst(job_name, inst_name) if inst_obj: info['running'] = (inst_props['state'] == 'running') if inst_props['processes']: info['pid'] = inst_props['processes'][0][1] # differentiate instances in descriptions if inst_name and 'description' in props: props['description'] += " ({0})".format(inst_name) info.update(props) return info def start_service(self, name): """ If a job is given, try to start its instance first if it has one. If it doesn't have one, start via job. If an instance is given, start it directly. """ job_name, inst_name = self._split_job(name) # no instances, start the job if not self.instpaths[self.jobpaths[job_name]]: job_obj = self.bus.get_object('com.ubuntu.Upstart', self.jobpaths[job_name]) job = Interface(job_obj, 'com.ubuntu.Upstart0_6.Job') job.Start([], True) # one or more instances available else: inst_obj, inst_props = self._get_inst(job_name, inst_name) inst_obj.Start(True, dbus_interface='com.ubuntu.Upstart0_6.Instance') # reload self.get_all_services() def stop_service(self, name): """Find the appropritate job instance and stop it.""" job_name, inst_name = self._split_job(name) inst_obj, inst_props = self._get_inst(job_name, inst_name) inst_obj.Stop(True, dbus_interface='com.ubuntu.Upstart0_6.Instance') # reload self.get_all_services() def set_service_automatic(self, name, auto): job_name, inst_name = self._split_job(name) with open('/etc/init/{0}.conf'.format(job_name)) as conf: self._set_automatic(conf, auto) def _split_job(self, name): """Return (job_name, inst_name) from name.""" if '/' in name: job_name, inst_name = name.split('/') else: job_name = name inst_name = None return (job_name, inst_name) def _get_inst(self, job_name, inst_name): """Return (inst_obj, inst_props) matching job_name & inst_name.""" paths = self.instpaths[self.jobpaths[job_name]] if not paths: return (None, None) for inst_path in paths: inst_obj = self.bus.get_object('com.ubuntu.Upstart', inst_path) inst_props = inst_obj.GetAll('com.ubuntu.Upstart0_6.Instance', dbus_interface=PROPERTIES_IFACE) if inst_props['name'] == inst_name: break return (inst_obj, inst_props) def _set_automatic(self, conf, automatic=True): """Comment/uncomment a job conf file's start on line. Closes conf.""" newname = '{0}.new'.format(conf.name) with open(newname, 'w') as new: for line in conf: # if we find a start on line pos = line.find('start on') if pos >= 0 and pos <= 2: starton = '\n' + self._parse_conf(conf, 'start on') # enabling if automatic: starton = starton.rstrip().replace('\n#', '\n') # disabling else: starton = starton.rstrip().replace('\n', '\n#') new.write(starton.lstrip() + '\n') continue new.write(line) conf.close() rename(conf.name, '{0}~'.format(conf.name)) rename(newname, conf.name) def _parse_conf(self, conf, find): """ Parse file 'conf' for text 'find' and return the value. Useful for grabbing the full contents of a start/stop on line. """ conf.seek(0) reading = False data = "" paren = 0 for line in conf: # could be at pos 1 or 2 if line is commented out pos = line.find(find) if pos >= 0 and pos <= 2: reading = True if reading: data += line paren += line.count('(') - line.count(')') if not paren: break return data def _extract_events(self, data): """ Grab events present in a text string (ie, a start/stop on line). An event could be a runlevel or a starting/stopping string. """ events = [] keywords = ('starting', 'stopping', 'started', 'stopped', 'runlevel') words = [d.strip(' ()') for d in data.split()] i = 0 for w in words: if w in keywords: if w == 'runlevel': try: levels = words[i+1].strip('[]') except: levels = '' if levels and levels[0] == '!': events.append('not runlevels {0}'.format(' '.join(levels[1:]))) else: events.append('runlevels {0}'.format(' '.join(levels))) else: events.append('{0} {1}'.format(w, words[i+1])) i += 1 return events jobservice-0.8.0/JobService/backends/upstart_0_10.py0000644000175000017500000000003711424650540021171 0ustar jacobjacob# Placeholder for Upstart 0.10 jobservice-0.8.0/JobService/backends/sysv.py0000644000175000017500000001715511424652011017760 0ustar jacobjacob# This file is part of jobservice. # Copyright 2010 Jacob Peddicord # # jobservice 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 3 of the License, or # (at your option) any later version. # # jobservice 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 jobservice. If not, see . import os from stat import ST_MODE, S_ISLNK, S_IXUSR from subprocess import Popen, PIPE, check_call, CalledProcessError from dbus import Array from JobService import DBUS_IFACE, JobException from JobService.backends import ServiceBase class SysVException(JobException): _dbus_error_name = DBUS_IFACE + '.SysVException' class ServiceBackend(ServiceBase): def __init__(self): self.runlevels = self._get_runlevel_info() self.current = self._get_current_runlevel() def get_all_services(self): svclist = [] for root, dirs, files in os.walk('/etc/init.d/'): for svc in files: path = os.path.join(root, svc) mode = os.lstat(path).st_mode # we only want regular, executable files if not S_ISLNK(mode) and bool(mode & S_IXUSR): # ignore files not linked in rc.d if svc in self.runlevels: svclist.append(svc) break return svclist def get_service(self, name): info = { 'name': name, 'description': '', 'version': '', 'author': '', 'running': False, 'automatic': False, 'pid': 0, 'starton': Array(signature='s'), 'stopon': Array(signature='s'), 'file': '', } # check the file for info props = self._get_lsb_properties(name) info['file'] = props['file'] if 'Short-Description' in props: info['description'] = props['Short-Description'] # look through runlevel information if name in self.runlevels: for rlvl, start in self.runlevels[name].iteritems(): if start[0] == True: info['starton'].append(rlvl) else: info['stopon'].append(rlvl) if rlvl == self.current: info['automatic'] = start[0] p = Popen(['/etc/init.d/' + name, 'status'], stdout=PIPE, stderr=PIPE) p.communicate() # eat stdout/stdin info['running'] = (p.returncode == 0) return info def start_service(self, name): try: check_call(['/etc/init.d/' + name, 'start']) except CalledProcessError, e: raise SysVException('Start failed: code {0}'.format(e.returncode)) try: check_call(['/etc/init.d/' + name, 'status'], stdout=PIPE, stderr=PIPE) except CalledProcessError, e: raise SysVException('Service stopped running unexpectedly.') def stop_service(self, name): try: check_call(['/etc/init.d/' + name, 'stop']) except CalledProcessError, e: raise SysVException('Stop failed: code {0}'.format(e.returncode)) def set_service_automatic(self, name, auto): self._remove_rc(name, self.current) self._link_rc(name, self.current, auto) self.runlevels[name][self.current] = (auto, self.runlevels[name][self.current][1]) def get_service_settings(self, name, lang): settings = [] if not name in self.runlevels: return settings for rlvl in sorted(self.runlevels[name].keys()): if rlvl == '0' or rlvl == '6' or rlvl == 'S': # skip 0 (shutdown), 6 (restart), or S (boot once) continue if rlvl == '1': label = "Active in recovery mode" #XXX: i18n elif rlvl == self.current: label = "Active in current runlevel ({runlevel})".format(runlevel=rlvl) #XXX: i18n else: label = "Active on runlevel {runlevel}".format(runlevel=rlvl) #XXX: i18n settings.append(('runlevel_{0}'.format(rlvl), 'bool', label, 'true' if self.runlevels[name][rlvl][0] else 'false', (('true', ''), ('false', '')), {} )) if settings: settings.insert(0, ('lbl_runlevels', 'label', "Runlevels", '', (), {})) #XXX: i18n return settings def set_service_settings(self, name, newsettings): for sname, sval in newsettings.iteritems(): if sname.find('runlevel_') == 0: rlvl = sname[-1:] auto = (sval == 'true') self._remove_rc(name, rlvl) self._link_rc(name, rlvl, auto) self.runlevels[name][rlvl] = (auto, self.runlevels[name][rlvl][1]) def _get_runlevel_info(self): """Parse /etc/rc?.d and store symlink information. Returns a dictionary with service names as keys, and a dict of runlevel: (bool start, int priority) pairs with found information. """ svcs = {} for runlevel in ('0', '1', '2', '3', '4', '5', '6', '7', 'S'): for root, dirs, files in os.walk('/etc/rc{0}.d'.format(runlevel)): for svc in files: path = os.path.join(root, svc) # exec only if not bool(os.lstat(path).st_mode & S_IXUSR): continue start = (svc[:1] == 'S') pri = int(svc[1:3]) name = svc[3:] if not name in svcs: svcs[name] = {} svcs[name][runlevel] = (start, pri) break return svcs def _remove_rc(self, name, rlvl): """Unlink a service from an rc#.d directory""" pri = str(self.runlevels[name][rlvl][1]) mode = 'S' if self.runlevels[name][rlvl][0] else 'K' os.unlink('/etc/rc{0}.d/{1}{2}{3}'.format(rlvl, mode, pri, name)) def _link_rc(self, name, rlvl, start): """Re-link an init script to the proper rc#.d location""" pri = str(self.runlevels[name][rlvl][1]) mode = 'S' if start else 'K' os.symlink('/etc/init.d/' + name, '/etc/rc{0}.d/{1}{2}{3}'.format(rlvl, mode, pri, name)) def _get_current_runlevel(self): out = Popen(['/sbin/runlevel'], stdout=PIPE).communicate()[0] return out.split()[1] def _get_lsb_properties(self, name): """ Scan a service's init.d entry for LSB information about it. Returns a dictionary of the entries provided. """ props = {'file': '/etc/init.d/' + name} try: entry = open(props['file']) except IOError: return props parsing = False for line in entry: if not parsing: if '### BEGIN INIT INFO' in line: parsing = True continue if '### END INIT INFO' in line: break try: key, value = line[2:].split(': ') except: continue props[key] = value.strip() entry.close() return props jobservice-0.8.0/JobService/backends/__init__.py0000644000175000017500000001226711426151502020513 0ustar jacobjacob# This file is part of jobservice. # Copyright 2010 Jacob Peddicord # # jobservice 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 3 of the License, or # (at your option) any later version. # # jobservice 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 jobservice. If not, see . import logging from re import search from subprocess import Popen, PIPE from dbus import Array from JobService.settings import ServiceSettings log = logging.getLogger('backends') BACKENDS = [] # automatic if empty class ServiceBase: def get_all_services(self): return [] def get_service(self, name): return { 'name': 'undefined', 'description': 'service unknown', 'version': '0', 'author': 'Nobody', 'running': False, 'automatic': False, 'pid': 0, 'starton': Array(signature='s'), 'stopon': Array(signature='s'), 'file': '', } def start_service(self, name): pass def stop_service(self, name): pass def set_service_automatic(self, name, auto): pass def get_service_settings(self, name, lang): return [] def set_service_settings(self, name, newsettings): pass class ServiceProxy(ServiceBase): """ Fake backend object that calls upon one or more real service backends to do the heavy lifting. """ def __init__(self): """ Load the appropriate backends for the current system. """ self.backends = [] self.bkmap = {} self.sls = {} self.bksls = {} if BACKENDS: load = BACKENDS log.debug('Backends set to: ' + ', '.join(load)) else: load = _auto_backends() log.debug('Autoloading backends: ' + ', '.join(load)) # load the backends for mod in load: newmod = __import__('JobService.backends.' + mod, fromlist=['ServiceBackend']) self.backends.append(newmod.ServiceBackend()) def get_all_services(self): svclist = [] # get the services for bk in self.backends: services = bk.get_all_services() for svc in services: self.bkmap[svc] = bk # check for SLS try: self.sls[svc] = ServiceSettings(svc) except: pass # and query the backend for additional settings self.bksls[svc] = bk.get_service_settings(svc, '') # no duplicates (backends will still properly override) if not svc in svclist: svclist.append(svc) return svclist def get_service(self, name): bk = self.bkmap[name] info = {'backend': bk.__module__[bk.__module__.rfind('.')+1:], 'settings': name in self.sls or len(self.bksls[name])} info.update(bk.get_service(name)) return info def start_service(self, name): self.bkmap[name].start_service(name) log.info("Started {0}".format(name)) def stop_service(self, name): self.bkmap[name].stop_service(name) log.info("Stopped {0}".format(name)) def set_service_automatic(self, name, auto): self.bkmap[name].set_service_automatic(name, auto) log.info("Set {0} to {1}".format(name, 'auto' if auto else 'manual')) def get_service_settings(self, name, lang=''): settings = [] snames = [] # xml settings if name in self.sls: for s in self.sls[name].get_all_settings(): settings.append(self.sls[name].get_setting(s, lang)) snames.append(s) # settings added by backend for s in self.bkmap[name].get_service_settings(name, lang): if not s[0] in snames: settings.append(s) return settings def set_service_settings(self, name, newsettings): for s in self.sls[name].get_all_settings(): if s in newsettings: self.sls[name].set_setting(s, newsettings[s]) del newsettings[s] # send the leftover settings to the backend self.bkmap[name].set_service_settings(name, newsettings) def _auto_backends(): """Return a list of available backends on this system.""" # start with sysv load = ['sysv'] # check for upstart p = Popen(['/sbin/init', '--version'], stdout=PIPE) out = p.stdout.read() match = search('upstart (\d+\.\d+)', out) if match: if match.group(1) == '0.6': load += ['upstart_0_6'] elif match.group(1) == '0.10': load += ['upstart_0_10'] return load jobservice-0.8.0/com.ubuntu.jobservice.policy0000644000175000017500000000137211401367377020256 0ustar jacobjacob jobservice https://launchpad.net/jobservice Allows access to system job management Authorization is required to manage jobs auth_admin auth_admin auth_admin_keep jobservice-0.8.0/COPYING0000644000175000017500000010451311416701453013631 0ustar jacobjacob GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. 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. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 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 state 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program 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, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU 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. But first, please read . jobservice-0.8.0/com.ubuntu.JobService.conf0000644000175000017500000000112211406742607017573 0ustar jacobjacob system