~ubuntu-branches/ubuntu/trusty/systemd/trusty

« back to all changes in this revision

Viewing changes to src/python-systemd/daemon.py

  • Committer: Package Import Robot
  • Author(s): Michael Biebl, Michael Biebl, Michael Stapelberg, Daniel Schaal, Ondrej Balaz
  • Date: 2013-09-12 00:13:11 UTC
  • mfrom: (1.1.11) (9.1.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 53.
  • Revision ID: package-import@ubuntu.com-20130912001311-dz35it34wr2lbday
Tags: 204-3
[ Michael Biebl ]
* Upload to unstable.
* Use /bin/bash in debug-shell.service as Debian doesn't have /sbin/sushell.
* Only import net.ifaces cmdline property for network devices.
* Generate strict dependencies between the binary packages using a
  shlibs.local file and add an explicit versioned dependency on
  libsystemd-login0 to systemd to ensure packages are upgraded in sync.
  Closes: #719444
* Drop obsolete Replaces: libudev0 from udev package.
* Use correct paths for various binaries, like /sbin/quotaon, which are
  installed in / and not /usr in Debian.  Closes: #721347
* Don't install kernel-install(8) man page since we don't install the
  corresponding binary either.  Closes: #722180
* Cherry-pick upstream fixes to make switching runlevels and starting
  reboot via ctrl-alt-del more robust.
* Cherry-pick upstream fix to properly apply ACLs to Journal files.

[ Michael Stapelberg ]
* Make systemctl enable|disable call update-rc.d for SysV init scripts.
  Closes: #709780
* Don't mount /tmp as tmpfs by default and make it possible to enable this
  feature via "systemctl enable tmp.mount".

[ Daniel Schaal ]
* Add bug-script to systemd and udev.  Closes: #711245

[ Ondrej Balaz ]
* Recognize discard option in /etc/crypttab.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from ._daemon import (__version__,
 
2
                      booted,
 
3
                      _listen_fds,
 
4
                      _is_fifo,
 
5
                      _is_socket,
 
6
                      _is_socket_inet,
 
7
                      _is_socket_unix,
 
8
                      _is_mq,
 
9
                      LISTEN_FDS_START)
 
10
from socket import AF_UNSPEC as _AF_UNSPEC
 
11
 
 
12
def _convert_fileobj(fileobj):
 
13
    try:
 
14
        return fileobj.fileno()
 
15
    except AttributeError:
 
16
        return fileobj
 
17
 
 
18
def is_fifo(fileobj, path=None):
 
19
    fd = _convert_fileobj(fileobj)
 
20
    return _is_fifo(fd, path)
 
21
 
 
22
def is_socket(fileobj, family=_AF_UNSPEC, type=0, listening=-1):
 
23
    fd = _convert_fileobj(fileobj)
 
24
    return _is_socket(fd, family, type, listening)
 
25
 
 
26
def is_socket_inet(fileobj, family=_AF_UNSPEC, type=0, listening=-1, port=0):
 
27
    fd = _convert_fileobj(fileobj)
 
28
    return _is_socket_inet(fd, family, type, listening)
 
29
 
 
30
def is_socket_unix(fileobj, type=0, listening=-1, path=None):
 
31
    fd = _convert_fileobj(fileobj)
 
32
    return _is_socket_unix(fd, type, listening, path)
 
33
 
 
34
def is_mq(fileobj, path=None):
 
35
    fd = _convert_fileobj(fileobj)
 
36
    return _is_mq(fd, path)
 
37
 
 
38
def listen_fds(unset_environment=True):
 
39
    """Return a list of socket activated descriptors
 
40
 
 
41
    Example::
 
42
 
 
43
      (in primary window)
 
44
      $ systemd-activate -l 2000 python3 -c \\
 
45
          'from systemd.daemon import listen_fds; print(listen_fds())'
 
46
      (in another window)
 
47
      $ telnet localhost 2000
 
48
      (in primary window)
 
49
      ...
 
50
      Execing python3 (...)
 
51
      [3]
 
52
    """
 
53
    num = _listen_fds(unset_environment)
 
54
    return list(range(LISTEN_FDS_START, LISTEN_FDS_START + num))