~free.ekanayaka/landscape-client/lucid-1.5.2.1-0ubuntu0.10.04.0

« back to all changes in this revision

Viewing changes to landscape/watchdog.py

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug, Free Ekanayaka
  • Date: 2009-07-22 14:54:50 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090722145450-pvbp13gh8734c8ft
Tags: 1.3.2.2-0ubuntu0.9.10.1
[ Free Ekanayaka ]
* New upstream release:
  - Include the README file in landscape-client (LP: #396260)
  - Fix client capturing stderr from run_command when constructing
    hash-id-databases url (LP: #397480)
  - Use substvars to conditionally depend on update-motd or
    libpam-modules (LP: #393454)
  - Fix reporting wrong version to the server (LP: #391225)
  - The init script does not wait for the network to be available
    before checking for EC2 user data (LP: #383336)
  - When the broker is restarted by the watchdog, the state of the client
    is inconsistent (LP: #380633)
  - Package stays unknown forever in the client with hash-id-databases
    support (LP: #381356)
  - Standard error not captured when calling smart-update (LP: #387441)
  - Changer calls reporter without switching groups, just user (LP: #388092)
  - Run smart update in the package-reporter instead of having a cronjob (LP: #362355)
  - Package changer does not inherit proxy settings (LP: #381241)
  - The ./test script doesn't work in landscape-client (LP: #381613)
  - The source package should build on all supported releases (LP: #385098)
  - Strip smart update's output (LP: #387331)
  - The fetch() timeout isn't based on activity (#389224)
  - Client can use a UUID of "None" when fetching the hash-id-database (LP: #381291)
  - Registration should use the fqdn rather than just the hostname (LP: #385730)

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
        """
77
77
        self._bus = bus
78
78
        self._reactor = reactor
 
79
        self._env = os.environ.copy()
79
80
        if os.getuid() == 0:
80
 
            info = pwd.getpwnam(self.username)
81
 
            self._uid = info.pw_uid
82
 
            self._gid = info.pw_gid
 
81
            pwd_info = pwd.getpwnam(self.username)
 
82
            self._uid = pwd_info.pw_uid
 
83
            self._gid = pwd_info.pw_gid
 
84
            self._env["HOME"] = pwd_info.pw_dir
 
85
            self._env["USER"] = self.username
 
86
            self._env["LOGNAME"] = self.username
83
87
        else:
84
88
            # We can only switch UIDs if we're root, so simply don't switch
85
89
            # UIDs if we're not.
127
131
        if self._config:
128
132
            args.extend(["-c", self._config])
129
133
        self._reactor.spawnProcess(self._process, exe, args=args,
130
 
                                   env=os.environ,uid=self._uid, gid=self._gid)
 
134
                                   env=self._env, uid=self._uid, gid=self._gid)
131
135
 
132
136
    def stop(self):
133
137
        """Stop this daemon."""
499
503
bootstrap_list = BootstrapList([
500
504
    BootstrapDirectory("$data_path", "landscape", "root", 0755),
501
505
    BootstrapDirectory("$data_path/package", "landscape", "root", 0755),
 
506
    BootstrapDirectory("$data_path/package/hash-id", "landscape", "root", 0755),
502
507
    BootstrapDirectory("$data_path/messages", "landscape", "root", 0755),
503
508
    BootstrapDirectory(
504
509
        "$data_path/custom-graph-scripts", "landscape", "root", 0755),
508
513
 
509
514
 
510
515
def clean_environment():
511
 
    """Unset any environment variables that begin with DEBIAN_ or DEBCONF_.
 
516
    """Unset dangerous environment variables.
512
517
 
513
 
    We do this to avoid any problems when landscape-client is invoked from its
 
518
    In particular unset all variables beginning with DEBIAN_ or DEBCONF_,
 
519
    to avoid any problems when landscape-client is invoked from its
514
520
    postinst script.  Some environment variables may be set which would affect
515
521
    *other* maintainer scripts which landscape-client invokes (via smart).
516
522
    """
517
523
    for key in os.environ.keys():
518
524
        if (key.startswith("DEBIAN_")
519
525
            or key.startswith("DEBCONF_")
520
 
            or key == "LANDSCAPE_ATTACHMENTS"):
 
526
            or key in ["LANDSCAPE_ATTACHMENTS", "MAIL"]):
521
527
            del os.environ[key]
522
528
 
523
529