sysinfo should not read or write stuff in /root, but rather /etc and /var/log

Bug #268560 reported by Christopher Armstrong
6
Affects Status Importance Assigned to Milestone
Landscape Client
Fix Released
Low
Christopher Armstrong
Landscape Server
Fix Released
Low
Christopher Armstrong
landscape-client (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Since the default mode of operation in the Ubuntu package is to set up sysinfo to be run in update-motd, it gets run as root. This causes log files to be written to /root/.landscape/sysinfo.log and config file read from /root/.landscape/sysinfo.conf.

Instead it should read the configuration from /etc/landscape/client.conf and perhaps write logs to /var/log/landscape/sysinfo.log.

Revision history for this message
Christopher Armstrong (radix) wrote :

Please review the attached branch.

Revision history for this message
Thomas Herve (therve) wrote :

I have the following error:

[ERROR]: landscape.sysinfo.tests.test_deployment.RunTest.test_setup_logging_logs_to_var_log_if_run_as_root

Traceback (most recent call last):
  File "/home/therve/projects/Landscape/client/trunk/landscape/tests/mocker.py", line 102, in test_method_wrapper
    result = test_method()
  File "/home/therve/projects/Landscape/client/trunk/landscape/sysinfo/tests/test_deployment.py", line 219, in test_setup_logging_logs_to_var_log_if_run_as_root
    setup_logging()
  File "/home/therve/projects/Landscape/client/trunk/landscape/sysinfo/deployment.py", line 74, in setup_logging
    os.mkdir(landscape_dir)
exceptions.OSError: [Errno 13] Permission denied: '/var/log/landscape'

Changed in landscape-client:
importance: Undecided → Low
status: New → In Progress
Changed in landscape:
milestone: none → thames-pre-8
status: New → In Progress
importance: Undecided → Low
Changed in landscape-client:
assignee: nobody → radix
Revision history for this message
Christopher Armstrong (radix) wrote :

Ok, that should be fixed.

Revision history for this message
Thomas Herve (therve) wrote :

+1

Revision history for this message
Jamu Kakar (jkakar) wrote :
Download full text (11.2 KiB)

I have 9 test failures even after running 'make clean':

===============================================================================
[ERROR]: landscape.sysinfo.tests.test_deployment.RunTest.test_default_arguments_load_default_plugins

Traceback (most recent call last):
  File "/home/jkakar/src/canonical/landscape-client/radix/sysinfo-no-root/landscape/tests/mocker.py", line 102, in test_method_wrapper
    result = test_method()
  File "/home/jkakar/src/canonical/landscape-client/radix/sysinfo-no-root/landscape/sysinfo/tests/test_deployment.py", line 136, in test_default_arguments_load_default_plugins
    result = run([])
  File "/home/jkakar/src/canonical/landscape-client/radix/sysinfo-no-root/landscape/sysinfo/deployment.py", line 91, in run
    config.load(args)
  File "/home/jkakar/src/canonical/landscape-client/radix/sysinfo-no-root/landscape/deployment.py", line 145, in load
    self.load_configuration_file(potential_config_file)
  File "/home/jkakar/src/canonical/landscape-client/radix/sysinfo-no-root/landscape/deployment.py", line 174, in load_configuration_file
    config_parser.items(self.config_section))
  File "/usr/lib/python2.5/ConfigParser.py", line 544, in items
    raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'sysinfo'
===============================================================================
[ERROR]: landscape.sysinfo.tests.test_deployment.RunTest.test_format_sysinfo_gets_correct_information

Traceback (most recent call last):
  File "/home/jkakar/src/canonical/landscape-client/radix/sysinfo-no-root/landscape/tests/mocker.py", line 102, in test_method_wrapper
    result = test_method()
  File "/home/jkakar/src/canonical/landscape-client/radix/sysinfo-no-root/landscape/sysinfo/tests/test_deployment.py", line 108, in test_format_sysinfo_gets_correct_information
    run(["--sysinfo-plugins", "TestPlugin"])
  File "/home/jkakar/src/canonical/landscape-client/radix/sysinfo-no-root/landscape/sysinfo/deployment.py", line 91, in run
    config.load(args)
  File "/home/jkakar/src/canonical/landscape-client/radix/sysinfo-no-root/landscape/deployment.py", line 145, in load
    self.load_configuration_file(potential_config_file)
  File "/home/jkakar/src/canonical/landscape-client/radix/sysinfo-no-root/landscape/deployment.py", line 174, in load_configuration_file
    config_parser.items(self.config_section))
  File "/usr/lib/python2.5/ConfigParser.py", line 544, in items
    raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'sysinfo'
===============================================================================
[ERROR]: landscape.sysinfo.tests.test_deployment.RunTest.test_format_sysinfo_output_is_printed

Traceback (most recent call last):
  File "/home/jkakar/src/canonical/landscape-client/radix/sysinfo-no-root/landscape/tests/mocker.py", line 102, in test_method_wrapper
    result = test_method()
  File "/home/jkakar/src/canonical/landscape-client/radix/sysinfo-no-root/landscape/sysinfo/tests/test_deployment.py", line 117, in test_format_sysinfo_output_is_printed
    run(["--sysinfo-plugins", "TestPlugin"])
  File "/home/jkakar/src/canonical/landscape-client/radix/sysinfo-no-root...

Revision history for this message
Christopher Armstrong (radix) wrote :

Ok, I updated this branch with some rather significant changes.

I fixed up configuration file reading to deal with missing sections, as well as to not delete unrelated sections when writing a config file. I also fixed the tests to not read global config file.

Revision history for this message
Jamu Kakar (jkakar) wrote :

Looks good and the tests pass. +1!

Revision history for this message
Christopher Armstrong (radix) wrote :

Thanks, merged to trunk

Changed in landscape:
assignee: nobody → radix
status: In Progress → Fix Committed
Changed in landscape-client:
status: In Progress → Fix Committed
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Bug #271886 has a fix for this.

Changed in landscape-client:
status: New → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package landscape-client - 1.0.21-0ubuntu1

---------------
landscape-client (1.0.21-0ubuntu1) intrepid; urgency=low

  [ Christopher Armstrong ]
  * New upstream release (LP: #271886):
    - Bug fix release:
    - Avoid the PotentialZombieWarning on landscape-client startup.
     (LP: #257346)
    - When run as root, read sysinfo configuration from /etc and and write
      logs to /var/log instead of /root. (LP: #268560)
    - Avoid ZeroDivisionErrors when /home is an autofs. (LP: #269634)
    - Don't corrupt a pid file when trying to start the client when it's
      already running. (LP: #269634)
    - Remove the pid file when shutting down the client. (LP: #257081)

  [ Mathias Gug ]
  * debian/landscape-client.init: specify the pid file and use --startas
    instead of --exec when starting landscape-client so that the init script
    doesn't fail if landscape-client is already running.

 -- Mathias Gug <email address hidden> Fri, 19 Sep 2008 17:28:08 -0400

Changed in landscape-client:
status: In Progress → Fix Released
Changed in landscape-client:
status: Fix Committed → Fix Released
Changed in landscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.