File ingestion assumes symlinks are not broken

Bug #1172747 reported by Aaron Bentley
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
charmworld
Fix Released
High
Unassigned

Bug Description

When files are ingested for a charm, we assume that following a symlink will work, but it does not work if the symlink is broken.

In the example below, tests.py is a symlink to "../../buildbot-master/hooks/tests.py", but that path does not exist.

Not only should we guard against missing symlinks, we should also ensure they do not traverse outside the charm's directory, since that would be a security violation.

2013-04-25 10:55:06,409 ERROR [charm.bzr][MainThread] bzr error on {u'name': u'buildbot-slave', u'series': u'oneiric', 'branch_dir': '/home/abentley/var/charms/oneiric/frankban/buildbot-slave/trunk', u'bname': u'trunk', u'commit': <email address hidden>', u'owner': u'frankban', u'branch_spec': u'~frankban/charms/oneiric/buildbot-slave/trunk', '_id': u'~frankban/charms/oneiric/buildbot-slave/trunk', u'distro_series': []}: [Errno 2] No such file or directory: '/home/abentley/var/charms/oneiric/frankban/buildbot-slave/trunk/hooks/tests.py'
Traceback (most recent call last):
  File "/home/abentley/canonical/charmworld/charmworld/jobs/ingest.py", line 202, in run_job
    job.run(charm_data)
  File "/home/abentley/canonical/charmworld/charmworld/jobs/ingest.py", line 184, in run
    charm_data = self.add_files(charm_data)
  File "/home/abentley/canonical/charmworld/charmworld/jobs/ingest.py", line 117, in add_files
    self.store_branch_files(charm_data)
  File "/home/abentley/canonical/charmworld/charmworld/jobs/ingest.py", line 110, in store_branch_files
    self.fs, charm_data, charm_data['branch_dir'])
  File "/home/abentley/canonical/charmworld/charmworld/models.py", line 367, in save_files
    subdir=directory))
  File "/home/abentley/canonical/charmworld/charmworld/models.py", line 292, in save_file
    with open(file_path) as handle:
IOError: [Errno 2] No such file or directory: '/home/abentley/var/charms/oneiric/frankban/buildbot-slave/trunk/hooks/tests.py'

Tags: ingest

Related branches

Curtis Hovey (sinzui)
tags: added: ingest
Aaron Bentley (abentley)
description: updated
Abel Deuring (adeuring)
Changed in charmworld:
status: Triaged → Fix Committed
Curtis Hovey (sinzui)
Changed in charmworld:
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.