Changeset 42
- Timestamp:
- 05/22/07 13:21:55
(2 years ago)
- Author:
- zcutlip
- Message:
modified xar to do a find and a -printf to generate a file contexts backup, elim
itating the dependency on indexcon and searchcon.
modified relable function to:
-not assume files don't have spaces
-work with slightly different output of the above find command, while continuing
to work with the output of searchcon as generated previously by xar.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1 |
r42 |
|
| 73 | 73 | # Check to see that the path isn't one we're excluding |
|---|
| 74 | 74 | if is_legal_path(path): |
|---|
| 75 | | cmd_str = "indexcon %s -d'%s' &>/dev/null" % \ |
|---|
| 76 | | (INDEXCON_OUTFILE, path) |
|---|
| 77 | | if verbose: |
|---|
| | 75 | #ZJC use find instead of indexcon/searchcon |
|---|
| | 76 | #output in the form of |
|---|
| | 77 | #user_u:object_r:file_t<tab>/path/to/file |
|---|
| | 78 | cmd_str= "find '%s/' -printf '%%Z\t%%p\\n' >> %s" % \ |
|---|
| | 79 | (path, ctx_file) |
|---|
| | 80 | if verbose: |
|---|
| 78 | 81 | print path |
|---|
| 79 | 82 | os.system(cmd_str) |
|---|
| 80 | 83 | |
|---|
| 81 | | # Verify that indexcon succeeded |
|---|
| 82 | | if not os.path.isfile(INDEXCON_OUTFILE): |
|---|
| | 84 | # Verify that archive succeeded |
|---|
| | 85 | if not os.path.isfile(ctx_file): |
|---|
| 83 | 86 | print "ERROR: indexing of %s failed" % \ |
|---|
| 84 | 87 | os.path.join(root,dirname) |
|---|
| 85 | 88 | continue |
|---|
| 86 | 89 | |
|---|
| 87 | | # Run searchcon on indexcon's output to generate something |
|---|
| 88 | | # that can be parsed in relabel() |
|---|
| 89 | | cmd_str = "searchcon %s >> %s" % (INDEXCON_OUTFILE, ctx_file) |
|---|
| 90 | | os.system(cmd_str) |
|---|
| 91 | | |
|---|
| 92 | | # Remove the temporary file generated by indexcon |
|---|
| 93 | | os.remove(INDEXCON_OUTFILE); |
|---|
| 94 | 90 | else: |
|---|
| 95 | 91 | # Don't process any other entries in this directory |
|---|
| … | … | |
| 136 | 132 | |
|---|
| 137 | 133 | for l in lines: |
|---|
| 138 | | # Grab the filename, context from the line |
|---|
| 139 | | vals = re.split("\s", l) |
|---|
| 140 | | ctx = vals[0]; path = vals[2] |
|---|
| | 134 | #ZJC--continue to work with the previous input format |
|---|
| | 135 | #or the new one generated by find |
|---|
| | 136 | |
|---|
| | 137 | #ZJC Grab the filename, context from the line |
|---|
| | 138 | #remove whitespace (eol markers, etc) from line start/end |
|---|
| | 139 | l=l.strip() |
|---|
| | 140 | |
|---|
| | 141 | #ZJC split line only on time on whitepace, grab the 1st field |
|---|
| | 142 | vals = re.split("\s", l, 1) |
|---|
| | 143 | ctx = vals[0] |
|---|
| | 144 | |
|---|
| | 145 | #ZJC split line only one time on slash, |
|---|
| | 146 | #path is a "/" plus the 2nd field |
|---|
| | 147 | vals = re.split("/", l, 1) |
|---|
| | 148 | path = "/" +vals[1] |
|---|
| 141 | 149 | |
|---|
| 142 | 150 | if verbose: |
|---|
Download in other formats:
* Generating other formats may take time.