This repository has been archived by the owner on Apr 24, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added a way to change the owner of created directories.
- Loading branch information
Christian Zagrodnick
committed
Oct 20, 2008
1 parent
7969d12
commit 2c9fe2a
Showing
4 changed files
with
112 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Creating Directories with owner change | ||
====================================== | ||
|
||
We can change the owner of the created directory if run as root: | ||
|
||
>>> write(sample_buildout, 'buildout.cfg', | ||
... """ | ||
... [buildout] | ||
... parts = data-dir | ||
... find-links = http://download.zope.org/distribution | ||
... | ||
... [data-dir] | ||
... recipe = lovely.recipe:mkdir | ||
... createpath = True | ||
... path = with/subdir | ||
... owner = nobody | ||
... """) | ||
>>> import os | ||
>>> import pwd | ||
>>> nobody_uid = pwd.getpwnam('nobody')[2] | ||
>>> print system(buildout), | ||
Installing data-dir. | ||
data-dir: Creating parent directory .../_TEST_/sample-buildout/with | ||
data-dir: Creating directory with/subdir | ||
|
||
The owner of the subdir is changed: | ||
|
||
>>> path = os.path.join(sample_buildout, 'with/subdir') | ||
>>> os.stat(path).st_uid == nobody_uid | ||
True | ||
|
||
But not the owner of the parent dir: | ||
|
||
>>> path = os.path.join(sample_buildout, 'with') | ||
>>> os.stat(path).st_uid == nobody_uid | ||
False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters