| 1263 | */ |
| 1264 | |
| 1265 | static int hpux_acl_sort(int acl_count, int calclass, struct acl *aclp) |
| 1266 | { |
| 1267 | #if !defined(HAVE_HPUX_ACLSORT) |
| 1268 | /* |
| 1269 | * The aclsort() system call is available on the latest HPUX General |
| 1270 | * Patch Bundles. So for HPUX, we developed our version of acl_sort |
| 1271 | * function. Because, we don't want to update to a new |
| 1272 | * HPUX GR bundle just for aclsort() call. |
| 1273 | */ |
| 1274 | |
| 1275 | struct hpux_acl_types acl_obj_count; |
| 1276 | int n_class_obj_perm = 0; |
| 1277 | int i, j; |
| 1278 | |
| 1279 | if (!acl_count) { |
| 1280 | DEBUG(10, ("Zero acl count passed. Returning Success\n")); |
| 1281 | return 0; |
| 1282 | } |
| 1283 | |
| 1284 | if (aclp == NULL) { |
| 1285 | DEBUG(0, ("Null ACL pointer in hpux_acl_sort. Returning Failure. \n")); |
| 1286 | return -1; |
| 1287 | } |
| 1288 | |
| 1289 | /* Count different types of ACLs in the ACLs array */ |
| 1290 | |
| 1291 | hpux_count_obj(acl_count, aclp, &acl_obj_count); |
| 1292 | |
| 1293 | /* There should be only one entry each of type USER_OBJ, GROUP_OBJ, |
| 1294 | * CLASS_OBJ and OTHER_OBJ |
| 1295 | */ |
| 1296 | |
| 1297 | if (acl_obj_count.n_user_obj != 1 |
| 1298 | || acl_obj_count.n_group_obj != 1 |
| 1299 | || acl_obj_count.n_class_obj != 1 |
| 1300 | || acl_obj_count.n_other_obj != 1) { |
| 1301 | DEBUG(0, ("hpux_acl_sort: More than one entry or no entries for \ |
| 1302 | USER OBJ or GROUP_OBJ or OTHER_OBJ or CLASS_OBJ\n")); |
| 1303 | return -1; |
| 1304 | } |
| 1305 | |
| 1306 | /* If any of the default objects are present, there should be only |
| 1307 | * one of them each. |
| 1308 | */ |
| 1309 | if (acl_obj_count.n_def_user_obj > 1 || acl_obj_count.n_def_group_obj > 1 |
| 1310 | || acl_obj_count.n_def_other_obj > 1 || acl_obj_count.n_def_class_obj > 1) { |
| 1311 | DEBUG(0, ("hpux_acl_sort: More than one entry for DEF_CLASS_OBJ \ |
| 1312 | or DEF_USER_OBJ or DEF_GROUP_OBJ or DEF_OTHER_OBJ\n")); |
| 1313 | return -1; |
| 1314 | } |
| 1315 | |
| 1316 | /* We now have proper number of OBJ and DEF_OBJ entries. Now sort the acl |
| 1317 | * structures. |
| 1318 | * |
| 1319 | * Sorting crieteria - First sort by ACL type. If there are multiple entries of |
| 1320 | * same ACL type, sort by ACL id. |
| 1321 | * |
| 1322 | * I am using the trivial kind of sorting method here because, performance isn't |
no test coverage detected