/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2015-05-30 16:47:00 UTC
  • Revision ID: teddy@recompile.se-20150530164700-77zrd7964gdhbk1f
mandos: Disable D-Bus if any DBusException is raised when connecting.

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
import tempfile
79
79
import itertools
80
80
import collections
81
 
import codecs
82
81
 
83
82
import dbus
84
83
import dbus.service
2511
2510
            pidfilename = "/var/run/mandos.pid"
2512
2511
        pidfile = None
2513
2512
        try:
2514
 
            pidfile = codecs.open(pidfilename, "w", encoding="utf-8")
 
2513
            pidfile = open(pidfilename, "w")
2515
2514
        except IOError as e:
2516
2515
            logger.error("Could not open file %r", pidfilename,
2517
2516
                         exc_info=e)
2713
2712
    
2714
2713
    if not foreground:
2715
2714
        if pidfile is not None:
2716
 
            pid = os.getpid()
2717
2715
            try:
2718
2716
                with pidfile:
2719
 
                    print(pid, file=pidfile)
 
2717
                    pid = os.getpid()
 
2718
                    pidfile.write("{}\n".format(pid).encode("utf-8"))
2720
2719
            except IOError:
2721
2720
                logger.error("Could not write to file %r with PID %d",
2722
2721
                             pidfilename, pid)