"Erich E. Hoover" ehoover@mymail.mines.edu writes:
+static struct security_descriptor *key_get_sd( struct object *obj ) +{
- struct security_descriptor *sd = default_get_sd( obj );
- const SID *admins_sid = security_builtin_admins_sid;
- int admin_len;
- char *ptr;
- if (sd) return sd;
- admin_len = FIELD_OFFSET(SID, SubAuthority[admins_sid->SubAuthorityCount]);
- sd = mem_alloc( sizeof(struct security_descriptor) + 2*admin_len );
- if (!sd) return sd;
- sd->control = 0;
- sd->owner_len = admin_len;
- sd->group_len = admin_len;
- sd->sacl_len = 0;
- sd->dacl_len = 0;
- ptr = (char *)(sd + 1);
- memcpy( ptr, security_builtin_admins_sid, sd->owner_len );
- ptr += sd->owner_len;
- memcpy( ptr, security_builtin_admins_sid, sd->group_len );
- ptr += sd->group_len;
- free( obj->sd );
- obj->sd = sd;
- return sd;
+}
It shouldn't be necessary to allocate one for every key.