Skip to content

Commit

Permalink
Insure that makedirs() results in directories group can write to.
Browse files Browse the repository at this point in the history
Tracked down a lot of makedirs() calls and replaced them with misc.mkdir()

Note: required-PR is needed to fix the permission problem, but the code
will build/work without it.

fixes #7654
Required PR: pulp/pulp#4000

(cherry picked from commit 69dbf8d)
  • Loading branch information
ggainey authored and zjhuntin committed Oct 13, 2020
1 parent 2763643 commit 9f6570e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
11 changes: 4 additions & 7 deletions plugins/pulp_docker/plugins/importers/sync.py
Expand Up @@ -2,7 +2,6 @@
This module contains the primary sync entry point for Docker v2 registries.
"""
from gettext import gettext as _
import errno
import httplib
import itertools
import logging
Expand All @@ -12,6 +11,8 @@

from pulp.common.plugins import importer_constants
from pulp.plugins.util import nectar_config, publish_step
from pulp.plugins.util import misc

from pulp.server.controllers import repository
from pulp.server.exceptions import MissingValue, PulpCodedException

Expand Down Expand Up @@ -161,12 +162,8 @@ def v1_generate_download_requests(self):
"""
for unit in self.v1_step_get_local_units.units_to_download:
destination_dir = os.path.join(self.get_working_dir(), unit.image_id)
try:
os.makedirs(destination_dir, mode=0755)
except OSError, e:
# it's ok if the directory exists
if e.errno != errno.EEXIST:
raise
misc.mkdir(destination_dir, mode=0775)

# we already retrieved the ancestry files for the tagged images, so
# some of these will already exist
if not os.path.exists(os.path.join(destination_dir, 'ancestry')):
Expand Down
11 changes: 4 additions & 7 deletions plugins/pulp_docker/plugins/registry.py
@@ -1,7 +1,6 @@
from cStringIO import StringIO
from gettext import gettext as _
import copy
import errno
import httplib
import json
import logging
Expand All @@ -16,6 +15,8 @@
from nectar.request import DownloadRequest
from pulp.server import exceptions as pulp_exceptions

from pulp.plugins.util import misc

from pulp_docker.common import constants, error_codes
from pulp_docker.plugins import models
from pulp_docker.plugins import auth_util
Expand Down Expand Up @@ -226,12 +227,8 @@ def get_ancestry(self, image_ids):
path = self.ANCESTRY_PATH % image_id
url = urlparse.urljoin(self.get_image_url(), path)
destination = os.path.join(self.working_dir, image_id, 'ancestry')
try:
os.mkdir(os.path.split(destination)[0])
except OSError, e:
# it's ok if the directory already exists
if e.errno != errno.EEXIST:
raise
misc.mkdir(os.path.split(destination)[0])

request = DownloadRequest(url, destination)
self.add_auth_header(request)
requests.append(request)
Expand Down

0 comments on commit 9f6570e

Please sign in to comment.