[apparmor] [PATCH 03/11] Fix transition character reporting of dfa dumps

John Johansen john.johansen at canonical.com
Wed Mar 7 20:05:33 UTC 2012


On 03/07/2012 10:19 AM, Steve Beattie wrote:
> On Wed, Mar 07, 2012 at 06:17:22AM -0800, John Johansen wrote:
>> Make them report a hex value strings instead of the default C++
>> \vvvvv
>>
>> Make them consistent,
>> - Dump to report the default transition and what isn't transitioned
>>   on it.
>>
>>
>> Signed-off-by: John Johansen <john.johansen at canonical.com>
> 
> This doesn't want to apply after parts 1 and 2 have been applied. Do you
> know what's going wrong here?
> 
Hrmm, I don't know is your tree up to date? correct dev tree?  I pulled the
patches from the list and applied to a clean tree, and they applied cleanly


>> ---
>>  parser/libapparmor_re/hfa.cc |   46 ++++++++++++++++++++++++++++++++++-------
>>  1 files changed, 38 insertions(+), 8 deletions(-)
>>
>> diff --git a/parser/libapparmor_re/hfa.cc b/parser/libapparmor_re/hfa.cc
>> index f6ad385..887b135 100644
>> --- a/parser/libapparmor_re/hfa.cc
>> +++ b/parser/libapparmor_re/hfa.cc
>> @@ -646,12 +646,34 @@ void DFA::dump(ostream & os)
>>  	os << "\n";
>>  
>>  	for (Partition::iterator i = states.begin(); i != states.end(); i++) {
>> -		if ((*i)->otherwise != nonmatching)
>> -			os << **i << " -> " << *(*i)->otherwise << "\n";
>> +		Chars excluded;
>> +
>>  		for (StateTrans::iterator j = (*i)->trans.begin();
>>  		     j != (*i)->trans.end(); j++) {
>> -			os << **i << " -> " << *(j)->second << ":  "
>> -			   << j->first << "\n";
>> +			if (j->second == nonmatching) {
>> +				excluded.insert(j->first);
>> +			} else {
>> +				os << **i << " -> " << *(j)->second << ": 0x"
>> +				   << hex << (int) j->first;
>> +				if (isprint(j->first))
>> +					os << " " << j->first;
>> +				os << "\n";
>> +			}
>> +		}
>> +
>> +		if ((*i)->otherwise != nonmatching) {
>> +			os << **i << " -> " << *(*i)->otherwise << ": [";
>> +			if (!excluded.empty()) {
>> +				os << "^";
>> +				for (Chars::iterator k = excluded.begin();
>> +				     k != excluded.end(); k++) {
>> +					if (isprint(*k))
>> +						os << *k;
>> +					else
>> +						os << "\\0x" << hex << (int) *k;
>> +				}
>> +			}
>> +			os << "]\n";
>>  		}
>>  	}
>>  	os << "\n";
>> @@ -690,18 +712,26 @@ void DFA::dump_dot_graph(ostream & os)
>>  			else {
>>  				os << "\t\"" << **i << "\" -> \"" << *j->second
>>  				   << "\" [" << "\n";
>> -				os << "\t\tlabel=\"" << j->first << "\"\n";
>> -				os << "\t]" << "\n";
>> +				os << "\t\tlabel=\"";
>> +				if (isprint(j->first))
>> +					os << j->first;
>> +				else
>> +					os << "\\0xhex" << (int) j->first;
>> +
>> +				os << "\"\n\t]" << "\n";
>>  			}
>>  		}
>>  		if ((*i)->otherwise != nonmatching) {
>> -		  os << "\t\"" << **i << "\" -> \"" << *(*i)->otherwise
>> +			os << "\t\"" << **i << "\" -> \"" << *(*i)->otherwise
>>  			   << "\" [" << "\n";
>>  			if (!excluded.empty()) {
>>  				os << "\t\tlabel=\"[^";
>>  				for (Chars::iterator i = excluded.begin();
>>  				     i != excluded.end(); i++) {
>> -					os << *i;
>> +					if (isprint(*i))
>> +						os << *i;
>> +					else
>> +						os << "\\0x" << hex << (int) *i;
>>  				}
>>  				os << "]\"" << "\n";
>>  			}
>> -- 
>> 1.7.9
>>
>>
>> -- 
>> AppArmor mailing list
>> AppArmor at lists.ubuntu.com
>> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
> 
> 
> 




More information about the AppArmor mailing list