void HIDDEN xbps_pkg_find_conflicts(struct xbps_handle *xhp, prop_dictionary_t pkg_repod) { prop_array_t pkg_cflicts, trans_cflicts; prop_dictionary_t pkgd; const char *cfpkg, *repopkgver, *pkgver; char *buf; size_t i; pkg_cflicts = prop_dictionary_get(pkg_repod, "conflicts"); if (pkg_cflicts == NULL || prop_array_count(pkg_cflicts) == 0) return; trans_cflicts = prop_dictionary_get(xhp->transd, "conflicts"); prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver); for (i = 0; i < prop_array_count(pkg_cflicts); i++) { prop_array_get_cstring_nocopy(pkg_cflicts, i, &cfpkg); /* * Check if current pkg conflicts with an installed package. */ if ((pkgd = xbps_pkgdb_get_pkgd(xhp, cfpkg, true))) { prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); buf = xbps_xasprintf("%s conflicts with " "installed pkg %s", repopkgver, pkgver); assert(buf != NULL); prop_array_add_cstring(trans_cflicts, buf); free(buf); continue; } /* * Check if current pkg conflicts with any pkg in transaction. */ pkgd = xbps_find_pkg_in_dict_by_pattern(xhp, xhp->transd, "unsorted_deps", cfpkg); if (pkgd != NULL) { prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); buf = xbps_xasprintf("%s conflicts with " "%s in transaction", repopkgver, pkgver); assert(buf != NULL); prop_array_add_cstring(trans_cflicts, buf); free(buf); continue; } } }
static int quota_handle_cmd_quotaoff(struct mount *mp, struct lwp *l, prop_dictionary_t cmddict, int type, prop_array_t datas) { struct ufsmount *ump = VFSTOUFS(mp); int error; if ((ump->um_flags & UFS_QUOTA2) != 0) return EOPNOTSUPP; if (prop_array_count(datas) != 0) return EINVAL; error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, KAUTH_REQ_SYSTEM_FS_QUOTA_ONOFF, mp, NULL, NULL); if (error != 0) { return error; } #ifdef QUOTA error = quota1_handle_cmd_quotaoff(l, ump, type); #else error = EOPNOTSUPP; #endif return error; }
static int quota_handle_cmd_quotaon(struct mount *mp, struct lwp *l, prop_dictionary_t cmddict, int type, prop_array_t datas) { prop_dictionary_t data; struct ufsmount *ump = VFSTOUFS(mp); int error; const char *qfile; if ((ump->um_flags & UFS_QUOTA2) != 0) return EBUSY; if (prop_array_count(datas) != 1) return EINVAL; data = prop_array_get(datas, 0); if (data == NULL) return ENOMEM; if (!prop_dictionary_get_cstring_nocopy(data, "quotafile", &qfile)) return EINVAL; error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, KAUTH_REQ_SYSTEM_FS_QUOTA_ONOFF, mp, NULL, NULL); if (error != 0) { return error; } #ifdef QUOTA error = quota1_handle_cmd_quotaon(l, ump, type, qfile); #else error = EOPNOTSUPP; #endif return error; }
static void _npf_ruleset_transform1(prop_array_t rlset, prop_array_t rules) { prop_object_iterator_t it; prop_dictionary_t rldict; prop_array_t subrlset; it = prop_array_iterator(rules); while ((rldict = prop_object_iterator_next(it)) != NULL) { unsigned idx; /* Add rules to the array (reference is retained). */ prop_array_add(rlset, rldict); subrlset = prop_dictionary_get(rldict, "subrules"); if (subrlset) { /* Process subrules recursively. */ _npf_ruleset_transform1(rlset, subrlset); /* Add the skip-to position. */ idx = prop_array_count(rlset); prop_dictionary_set_uint32(rldict, "skip-to", idx); prop_dictionary_remove(rldict, "subrules"); } } prop_object_iterator_release(it); }
static void print_summary(prop_array_t runlist) { float total_run; float total_tests; total_tests = 0.0 + prop_array_count(runlist); total_run = 0.0 + total_tests - count_by_result[RESULT_BUILDFAIL] - count_by_result[RESULT_PREFAIL] - count_by_result[RESULT_NOTRUN] - count_by_result[RESULT_UNKNOWN]; printf("\n\n"); print_row('='); printf("Summary:\n\n"); printf("Tests not built:\t%d\n", count_by_result[RESULT_BUILDFAIL]); printf("Tests not run:\t\t%.0f\n", total_tests - total_run); printf("Tests pre-failed:\t%d\n", count_by_result[RESULT_PREFAIL]); printf("Tests post-failed:\t%d\n", count_by_result[RESULT_POSTFAIL]); printf("Tests passed:\t\t%d\n", count_by_result[RESULT_PASS]); printf("Tests failed:\t\t%d\n", count_by_result[RESULT_FAIL]); printf("Tests crashed:\t\t%d\n", count_by_result[RESULT_SIGNALLED]); printf("Tests timed out:\t%d\n", count_by_result[RESULT_TIMEOUT]); printf("------\n"); printf("Run rate:\t\t%.2f\n", total_run/total_tests); printf("Pass rate:\t\t%.2f\n", count_by_result[RESULT_PASS]/total_run); }
/* * npfctl_load: store passed data i.e. update settings, create passed * tables, rules and atomically activate all them. */ int npfctl_load(u_long cmd, void *data) { struct plistref *pref = data; prop_dictionary_t npf_dict, errdict; prop_array_t alglist, natlist, tables, rprocs, rules, conlist; npf_tableset_t *tblset = NULL; npf_rprocset_t *rpset = NULL; npf_ruleset_t *rlset = NULL; npf_ruleset_t *nset = NULL; npf_conndb_t *conndb = NULL; uint32_t ver = 0; size_t nitems; bool flush; int error; /* Retrieve the dictionary. */ #ifndef _NPF_TESTING error = prop_dictionary_copyin_ioctl(pref, cmd, &npf_dict); if (error) return error; #else npf_dict = (prop_dictionary_t)pref; #endif /* Dictionary for error reporting and version check. */ errdict = prop_dictionary_create(); prop_dictionary_get_uint32(npf_dict, "version", &ver); if (ver != NPF_VERSION) { error = EPROGMISMATCH; goto fail; } /* ALGs. */ alglist = prop_dictionary_get(npf_dict, "algs"); error = npf_mk_algs(alglist, errdict); if (error) { goto fail; } /* NAT policies. */ natlist = prop_dictionary_get(npf_dict, "nat"); if ((nitems = prop_array_count(natlist)) > NPF_MAX_RULES) { error = E2BIG; goto fail; } nset = npf_ruleset_create(nitems); error = npf_mk_natlist(nset, natlist, errdict); if (error) { goto fail; } /* Tables. */ tables = prop_dictionary_get(npf_dict, "tables"); if ((nitems = prop_array_count(tables)) > NPF_MAX_TABLES) { error = E2BIG; goto fail; } tblset = npf_tableset_create(nitems); error = npf_mk_tables(tblset, tables, errdict); if (error) { goto fail; } /* Rule procedures. */ rprocs = prop_dictionary_get(npf_dict, "rprocs"); if ((nitems = prop_array_count(rprocs)) > NPF_MAX_RPROCS) { error = E2BIG; goto fail; } rpset = npf_rprocset_create(); error = npf_mk_rprocs(rpset, rprocs, errdict); if (error) { goto fail; } /* Rules. */ rules = prop_dictionary_get(npf_dict, "rules"); if ((nitems = prop_array_count(rules)) > NPF_MAX_RULES) { error = E2BIG; goto fail; } rlset = npf_ruleset_create(nitems); error = npf_mk_rules(rlset, rules, rpset, errdict); if (error) { goto fail; } /* Connections (if loading any). */ if ((conlist = prop_dictionary_get(npf_dict, "conn-list")) != NULL) { error = npf_mk_connlist(conlist, nset, &conndb, errdict); if (error) { goto fail; } } flush = false; prop_dictionary_get_bool(npf_dict, "flush", &flush); /* * Finally - perform the load. */ npf_config_load(rlset, tblset, nset, rpset, conndb, flush); /* Done. Since data is consumed now, we shall not destroy it. */ tblset = NULL; rpset = NULL; rlset = NULL; nset = NULL; fail: /* * Note: destroy rulesets first, to drop references to the tableset. */ KASSERT(error == 0 || (nset || rpset || rlset || tblset)); if (nset) { npf_ruleset_destroy(nset); } if (rlset) { npf_ruleset_destroy(rlset); } if (rpset) { npf_rprocset_destroy(rpset); } if (tblset) { npf_tableset_destroy(tblset); } prop_object_release(npf_dict); /* Error report. */ #ifndef _NPF_TESTING prop_dictionary_set_int32(errdict, "errno", error); prop_dictionary_copyout_ioctl(pref, cmd, errdict); prop_object_release(errdict); error = 0; #endif return error; }