Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use separate homu user for Homu-related states
- Loading branch information
1 parent
05e30f0
commit 3449dfa
Showing
2 changed files
with
35 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,26 @@ | ||
import os | ||
import pwd | ||
import stat | ||
|
||
from tests.util import Failure, Success | ||
|
||
|
||
def get_owner(filename): | ||
return pwd.getpwuid(os.stat(filename).st_uid).pw_name | ||
|
||
|
||
def is_world_readable(filename): | ||
st = os.stat(filename) | ||
return bool(st.st_mode & stat.S_IROTH) | ||
|
||
|
||
def run(): | ||
for root, directories, filenames in os.walk('/home/servo/homu/'): | ||
for filename in filenames: | ||
full_path = os.path.join(root, filename) | ||
if get_owner(full_path) != 'homu': | ||
return Failure('Homu file is not owned by \'homu\' user:', | ||
full_path) | ||
if is_world_readable(full_path): | ||
return Failure('Homu file is world-readable:', full_path) | ||
return Success('Homu files have valid permissions') |