Changeset 42

Show
Ignore:
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
  • trunk/RHEL5/scripts/xar

    r1 r42  
    7373            # Check to see that the path isn't one we're excluding 
    7474            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: 
    7881                    print path 
    7982                os.system(cmd_str) 
    8083 
    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): 
    8386                    print "ERROR: indexing of %s failed" % \ 
    8487                          os.path.join(root,dirname) 
    8588                    continue  
    8689 
    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); 
    9490            else: 
    9591                # Don't process any other entries in this directory 
     
    136132     
    137133    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] 
    141149 
    142150        if verbose: