public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH 3/4] sync: ensure sync_{umask,user} is respected when creating repo
Date: Sat,  6 Dec 2014 01:03:35 +0100	[thread overview]
Message-ID: <1417824216-7990-4-git-send-email-mgorny@gentoo.org> (raw)
In-Reply-To: <1417824216-7990-1-git-send-email-mgorny@gentoo.org>

---
 pym/portage/sync/controller.py | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/pym/portage/sync/controller.py b/pym/portage/sync/controller.py
index 3104524..4fa1e5a 100644
--- a/pym/portage/sync/controller.py
+++ b/pym/portage/sync/controller.py
@@ -185,11 +185,6 @@ class SyncManager(object):
 			st = os.stat(repo.location)
 		except OSError:
 			st = None
-		if st is None:
-			writemsg_level(">>> '%s' not found, creating it."
-				% _unicode_decode(repo.location))
-			portage.util.ensure_dirs(repo.location, mode=0o755)
-			st = os.stat(repo.location)
 
 		self.usersync_uid = None
 		spawn_kwargs = {}
@@ -243,7 +238,24 @@ class SyncManager(object):
 			spawn_kwargs["gid"] = gid
 			spawn_kwargs["groups"] = [gid]
 			spawn_kwargs["env"]["HOME"] = home
-		elif ('usersync' in self.settings.features and
+
+		if st is None:
+			perms = {'mode': 0o755}
+			# respect sync-user if set
+			if 'umask' in spawn_kwargs:
+				perms['mode'] &= ~spawn_kwargs['umask']
+			if 'uid' in spawn_kwargs:
+				perms['uid'] = spawn_kwargs['uid']
+			if 'gid' in spawn_kwargs:
+				perms['gid'] = spawn_kwargs['gid']
+
+			writemsg_level(">>> '%s' not found, creating it."
+				% _unicode_decode(repo.location))
+			portage.util.ensure_dirs(repo.location, **perms)
+			st = os.stat(repo.location)
+
+		if (repo.sync_user is None and
+			'usersync' in self.settings.features and
 			portage.data.secpass >= 2 and
 			(st.st_uid != os.getuid() and st.st_mode & 0o700 or
 			st.st_gid != os.getgid() and st.st_mode & 0o070)):
-- 
2.2.0



  parent reply	other threads:[~2014-12-06  0:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-06  0:03 [gentoo-portage-dev] [PATCH 0/4] sync: sync-umask and sync-user support Michał Górny
2014-12-06  0:03 ` [gentoo-portage-dev] [PATCH 1/4] sync: allow overriding sync-umask for the repository Michał Górny
2014-12-07  6:46   ` Zac Medico
2014-12-07  9:00     ` [gentoo-portage-dev] [PATCH] " Michał Górny
2014-12-06  0:03 ` [gentoo-portage-dev] [PATCH 2/4] sync: allow overriding sync-user " Michał Górny
2014-12-07  7:02   ` Zac Medico
2014-12-07  9:01     ` [gentoo-portage-dev] [PATCH] " Michał Górny
2014-12-07  9:07       ` Michał Górny
2014-12-07 18:32         ` Zac Medico
2014-12-08  6:53       ` Arfrever Frehtes Taifersar Arahesis
2014-12-06  0:03 ` Michał Górny [this message]
2014-12-07  7:10   ` [gentoo-portage-dev] [PATCH 3/4] sync: ensure sync_{umask,user} is respected when creating repo Zac Medico
2014-12-06  0:03 ` [gentoo-portage-dev] [PATCH 4/4] sync: Add backwards compat with SYNC_{UMASK,USER} variables Michał Górny
2014-12-07  7:15   ` Zac Medico
2014-12-07  8:22     ` Michał Górny
2014-12-07  9:04       ` Zac Medico
2014-12-07  9:06         ` Michał Górny
2014-12-07 18:33           ` Zac Medico
2014-12-07 18:39             ` Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1417824216-7990-4-git-send-email-mgorny@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox