Fix fcontext comparator
The comparator for fcontext is wrong.
This should fix the problem Dan is having with the fcontext exists function - let me know if it works.
libsemanage/src/fcontext_record.c +24 -4
@@ -81,8 +81,18 @@ int semanage_fcontext_compare(const semanage_fcontext_t * fcontext, const semanage_fcontext_key_t* key) { - return strcmp(fcontext->expr, key->expr) && - (fcontext->type == key->type); + int rv = strcmp(fcontext->expr, key->expr); +if (rv !=0 ) +return rv; +else { +if (fcontext->type < key->type) +return -1 ; + +else if (key->type < fcontext->type) +return 1 ; + +else return 0 ; + } }hidden_def (semanage_fcontext_compare)
@@ -90,8 +100,18 @@ int semanage_fcontext_compare2(const semanage_fcontext_t * fcontext, const semanage_fcontext_t* fcontext2) { - return strcmp(fcontext->expr, fcontext2->expr) && - (fcontext->type == fcontext2->type); + int rv = strcmp(fcontext->expr, fcontext2->expr); +if (rv !=0 ) +return rv; +else { +if (fcontext->type < fcontext2->type) +return -1 ; + +else if (fcontext2->type < fcontext->type) +return 1 ; + +else return 0 ; + } }hidden_def (semanage_fcontext_compare2)
Quoted 3 lines · Ivan Gyurdiev
The comparator for fcontext is wrong.
This should fix the problem Dan is having with the fcontext exists function - let me know if it works.
Merged as of libsemanage 1.5.11.
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.