Status genUid(id_t& uid, uuid_string_t& uuid_str) { CFDataRef uuid = nullptr; if (!genUnlockIdent(uuid).ok()) { if (uuid != nullptr) { CFRelease(uuid); } return Status(1, "Could not get unlock ident"); } CFDataGetBytes(uuid, CFRangeMake(0, CFDataGetLength(uuid)), (UInt8*)uuid_str); if (uuid != nullptr) { CFRelease(uuid); } uuid_t uuidT = {0}; if (uuid_parse(uuid_str, uuidT) != 0) { return Status(1, "Could not parse UUID"); } // id_type >=0 are all valid id types int id_type = -1; if (mbr_uuid_to_id(uuidT, &uid, &id_type) != 0 && id_type != ID_TYPE_UID) { return Status(1, "Could not get uid from uuid"); } return Status(0, "ok"); }
static char * uuid_to_name(uuid_t *uu, uid_t *id, int *isgid) { struct group *tgrp = NULL; struct passwd *tpass = NULL; if (0 == mbr_uuid_to_id(*uu, id, isgid)) { switch (*isgid) { case ID_TYPE_UID: if (!(tpass = getpwuid(*id))) goto errout; return strdup(tpass->pw_name); break; case ID_TYPE_GID: if (!(tgrp = getgrgid((gid_t) *id))) goto errout; return strdup(tgrp->gr_name); break; default: errout: ; //warn("Unable to translate qualifier on ACL\n"); } } return NULL; }