4 * Copyright (C) 1998 Alexandre Julliard
5 * Copyright (C) 2003 Mike McCormack
6 * Copyright (C) 2005 Robert Shearman
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #define WIN32_NO_STATUS
42 #include "wine/unicode.h"
44 #define MAX_SUBAUTH_COUNT 1
46 const LUID SeIncreaseQuotaPrivilege
= { 5, 0 };
47 const LUID SeSecurityPrivilege
= { 8, 0 };
48 const LUID SeTakeOwnershipPrivilege
= { 9, 0 };
49 const LUID SeLoadDriverPrivilege
= { 10, 0 };
50 const LUID SeSystemProfilePrivilege
= { 11, 0 };
51 const LUID SeSystemtimePrivilege
= { 12, 0 };
52 const LUID SeProfileSingleProcessPrivilege
= { 13, 0 };
53 const LUID SeIncreaseBasePriorityPrivilege
= { 14, 0 };
54 const LUID SeCreatePagefilePrivilege
= { 15, 0 };
55 const LUID SeBackupPrivilege
= { 17, 0 };
56 const LUID SeRestorePrivilege
= { 18, 0 };
57 const LUID SeShutdownPrivilege
= { 19, 0 };
58 const LUID SeDebugPrivilege
= { 20, 0 };
59 const LUID SeSystemEnvironmentPrivilege
= { 22, 0 };
60 const LUID SeChangeNotifyPrivilege
= { 23, 0 };
61 const LUID SeRemoteShutdownPrivilege
= { 24, 0 };
62 const LUID SeUndockPrivilege
= { 25, 0 };
63 const LUID SeManageVolumePrivilege
= { 28, 0 };
64 const LUID SeImpersonatePrivilege
= { 29, 0 };
65 const LUID SeCreateGlobalPrivilege
= { 30, 0 };
67 static const SID world_sid
= { SID_REVISION
, 1, { SECURITY_WORLD_SID_AUTHORITY
}, { SECURITY_WORLD_RID
} };
68 static const SID local_sid
= { SID_REVISION
, 1, { SECURITY_LOCAL_SID_AUTHORITY
}, { SECURITY_LOCAL_RID
} };
69 static const SID interactive_sid
= { SID_REVISION
, 1, { SECURITY_NT_AUTHORITY
}, { SECURITY_INTERACTIVE_RID
} };
70 static const SID anonymous_logon_sid
= { SID_REVISION
, 1, { SECURITY_NT_AUTHORITY
}, { SECURITY_ANONYMOUS_LOGON_RID
} };
71 static const SID authenticated_user_sid
= { SID_REVISION
, 1, { SECURITY_NT_AUTHORITY
}, { SECURITY_AUTHENTICATED_USER_RID
} };
72 static const SID local_system_sid
= { SID_REVISION
, 1, { SECURITY_NT_AUTHORITY
}, { SECURITY_LOCAL_SYSTEM_RID
} };
73 static const struct /* same fields as struct SID */
76 BYTE SubAuthorityCount
;
77 SID_IDENTIFIER_AUTHORITY IdentifierAuthority
;
78 DWORD SubAuthority
[5];
79 } local_user_sid
= { SID_REVISION
, 5, { SECURITY_NT_AUTHORITY
}, { SECURITY_NT_NON_UNIQUE
, 0, 0, 0, 1000 } };
80 static const struct /* same fields as struct SID */
83 BYTE SubAuthorityCount
;
84 SID_IDENTIFIER_AUTHORITY IdentifierAuthority
;
85 DWORD SubAuthority
[2];
86 } builtin_admins_sid
= { SID_REVISION
, 2, { SECURITY_NT_AUTHORITY
}, { SECURITY_BUILTIN_DOMAIN_RID
, DOMAIN_ALIAS_RID_ADMINS
} };
87 static const struct /* same fields as struct SID */
90 BYTE SubAuthorityCount
;
91 SID_IDENTIFIER_AUTHORITY IdentifierAuthority
;
92 DWORD SubAuthority
[2];
93 } builtin_users_sid
= { SID_REVISION
, 2, { SECURITY_NT_AUTHORITY
}, { SECURITY_BUILTIN_DOMAIN_RID
, DOMAIN_ALIAS_RID_USERS
} };
95 const PSID security_world_sid
= (PSID
)&world_sid
;
96 static const PSID security_local_sid
= (PSID
)&local_sid
;
97 static const PSID security_interactive_sid
= (PSID
)&interactive_sid
;
98 static const PSID security_authenticated_user_sid
= (PSID
)&authenticated_user_sid
;
99 const PSID security_local_system_sid
= (PSID
)&local_system_sid
;
100 const PSID security_local_user_sid
= (PSID
)&local_user_sid
;
101 const PSID security_builtin_admins_sid
= (PSID
)&builtin_admins_sid
;
102 const PSID security_builtin_users_sid
= (PSID
)&builtin_users_sid
;
104 static luid_t prev_luid_value
= { 1000, 0 };
108 struct object obj
; /* object header */
109 luid_t token_id
; /* system-unique id of token */
110 luid_t modified_id
; /* new id allocated every time token is modified */
111 struct list privileges
; /* privileges available to the token */
112 struct list groups
; /* groups that the user of this token belongs to (sid_and_attributes) */
113 SID
*user
; /* SID of user this token represents */
114 SID
*primary_group
; /* SID of user's primary group */
115 unsigned primary
; /* is this a primary or impersonation token? */
116 ACL
*default_dacl
; /* the default DACL to assign to objects created by this user */
117 TOKEN_SOURCE source
; /* source of the token */
118 int impersonation_level
; /* impersonation level this token is capable of if non-primary token */
125 unsigned enabled
: 1; /* is the privilege currently enabled? */
126 unsigned def
: 1; /* is the privilege enabled by default? */
132 unsigned enabled
: 1; /* is the sid currently enabled? */
133 unsigned def
: 1; /* is the sid enabled by default? */
134 unsigned logon
: 1; /* is this a logon sid? */
135 unsigned mandatory
: 1; /* is this sid always enabled? */
136 unsigned owner
: 1; /* can this sid be an owner of an object? */
137 unsigned resource
: 1; /* is this a domain-local group? */
138 unsigned deny_only
: 1; /* is this a sid that should be use for denying only? */
142 static void token_dump( struct object
*obj
, int verbose
);
143 static unsigned int token_map_access( struct object
*obj
, unsigned int access
);
144 static void token_destroy( struct object
*obj
);
146 static const struct object_ops token_ops
=
148 sizeof(struct token
), /* size */
149 token_dump
, /* dump */
150 no_get_type
, /* get_type */
151 no_add_queue
, /* add_queue */
152 NULL
, /* remove_queue */
154 NULL
, /* satisfied */
155 no_signal
, /* signal */
156 no_get_fd
, /* get_fd */
157 token_map_access
, /* map_access */
158 default_get_sd
, /* get_sd */
159 default_set_sd
, /* set_sd */
160 no_lookup_name
, /* lookup_name */
161 no_open_file
, /* open_file */
162 no_close_handle
, /* close_handle */
163 token_destroy
/* destroy */
167 static void token_dump( struct object
*obj
, int verbose
)
169 fprintf( stderr
, "Security token\n" );
170 /* FIXME: dump token members */
173 static unsigned int token_map_access( struct object
*obj
, unsigned int access
)
175 if (access
& GENERIC_READ
) access
|= TOKEN_READ
;
176 if (access
& GENERIC_WRITE
) access
|= TOKEN_WRITE
;
177 if (access
& GENERIC_EXECUTE
) access
|= STANDARD_RIGHTS_EXECUTE
;
178 if (access
& GENERIC_ALL
) access
|= TOKEN_ALL_ACCESS
;
179 return access
& ~(GENERIC_READ
| GENERIC_WRITE
| GENERIC_EXECUTE
| GENERIC_ALL
);
182 static SID
*security_sid_alloc( const SID_IDENTIFIER_AUTHORITY
*idauthority
, int subauthcount
, const unsigned int subauth
[] )
185 SID
*sid
= mem_alloc( FIELD_OFFSET(SID
, SubAuthority
[subauthcount
]) );
186 if (!sid
) return NULL
;
187 sid
->Revision
= SID_REVISION
;
188 sid
->SubAuthorityCount
= subauthcount
;
189 sid
->IdentifierAuthority
= *idauthority
;
190 for (i
= 0; i
< subauthcount
; i
++)
191 sid
->SubAuthority
[i
] = subauth
[i
];
195 void security_set_thread_token( struct thread
*thread
, obj_handle_t handle
)
200 release_object( thread
->token
);
201 thread
->token
= NULL
;
205 struct token
*token
= (struct token
*)get_handle_obj( current
->process
,
212 release_object( thread
->token
);
213 thread
->token
= token
;
218 const SID
*security_unix_uid_to_sid( uid_t uid
)
220 /* very simple mapping: either the current user or not the current user */
222 return (const SID
*)&local_user_sid
;
224 return &anonymous_logon_sid
;
227 static int acl_is_valid( const ACL
*acl
, data_size_t size
)
230 const ACE_HEADER
*ace
;
232 if (size
< sizeof(ACL
))
235 size
= min(size
, MAX_ACL_LEN
);
239 ace
= (const ACE_HEADER
*)(acl
+ 1);
240 for (i
= 0; i
< acl
->AceCount
; i
++)
243 data_size_t sid_size
;
245 if (size
< sizeof(ACE_HEADER
))
247 if (size
< ace
->AceSize
)
249 size
-= ace
->AceSize
;
250 switch (ace
->AceType
)
252 case ACCESS_DENIED_ACE_TYPE
:
253 sid
= (const SID
*)&((const ACCESS_DENIED_ACE
*)ace
)->SidStart
;
254 sid_size
= ace
->AceSize
- FIELD_OFFSET(ACCESS_DENIED_ACE
, SidStart
);
256 case ACCESS_ALLOWED_ACE_TYPE
:
257 sid
= (const SID
*)&((const ACCESS_ALLOWED_ACE
*)ace
)->SidStart
;
258 sid_size
= ace
->AceSize
- FIELD_OFFSET(ACCESS_ALLOWED_ACE
, SidStart
);
260 case SYSTEM_AUDIT_ACE_TYPE
:
261 sid
= (const SID
*)&((const SYSTEM_AUDIT_ACE
*)ace
)->SidStart
;
262 sid_size
= ace
->AceSize
- FIELD_OFFSET(SYSTEM_AUDIT_ACE
, SidStart
);
264 case SYSTEM_ALARM_ACE_TYPE
:
265 sid
= (const SID
*)&((const SYSTEM_ALARM_ACE
*)ace
)->SidStart
;
266 sid_size
= ace
->AceSize
- FIELD_OFFSET(SYSTEM_ALARM_ACE
, SidStart
);
268 case SYSTEM_MANDATORY_LABEL_ACE_TYPE
:
269 sid
= (const SID
*)&((const SYSTEM_MANDATORY_LABEL_ACE
*)ace
)->SidStart
;
270 sid_size
= ace
->AceSize
- FIELD_OFFSET(SYSTEM_MANDATORY_LABEL_ACE
, SidStart
);
275 if (sid_size
< FIELD_OFFSET(SID
, SubAuthority
[0]) || sid_size
< security_sid_len( sid
))
277 ace
= ace_next( ace
);
282 /* checks whether all members of a security descriptor fit inside the size
283 * of memory specified */
284 int sd_is_valid( const struct security_descriptor
*sd
, data_size_t size
)
286 size_t offset
= sizeof(struct security_descriptor
);
296 if ((sd
->owner_len
>= FIELD_OFFSET(SID
, SubAuthority
[255])) ||
297 (offset
+ sd
->owner_len
> size
))
299 owner
= sd_get_owner( sd
);
302 size_t needed_size
= security_sid_len( owner
);
303 if ((sd
->owner_len
< sizeof(SID
)) || (needed_size
> sd
->owner_len
))
306 offset
+= sd
->owner_len
;
308 if ((sd
->group_len
>= FIELD_OFFSET(SID
, SubAuthority
[255])) ||
309 (offset
+ sd
->group_len
> size
))
311 group
= sd_get_group( sd
);
314 size_t needed_size
= security_sid_len( group
);
315 if ((sd
->group_len
< sizeof(SID
)) || (needed_size
> sd
->group_len
))
318 offset
+= sd
->group_len
;
320 if ((sd
->sacl_len
>= MAX_ACL_LEN
) || (offset
+ sd
->sacl_len
> size
))
322 sacl
= sd_get_sacl( sd
, &dummy
);
323 if (sacl
&& !acl_is_valid( sacl
, sd
->sacl_len
))
325 offset
+= sd
->sacl_len
;
327 if ((sd
->dacl_len
>= MAX_ACL_LEN
) || (offset
+ sd
->dacl_len
> size
))
329 dacl
= sd_get_dacl( sd
, &dummy
);
330 if (dacl
&& !acl_is_valid( dacl
, sd
->dacl_len
))
332 offset
+= sd
->dacl_len
;
337 /* determines whether an object_attributes struct is valid in a buffer
338 * and calls set_error appropriately */
339 int objattr_is_valid( const struct object_attributes
*objattr
, data_size_t size
)
341 if ((size
< sizeof(*objattr
)) || (size
- sizeof(*objattr
) < objattr
->sd_len
) ||
342 (size
- sizeof(*objattr
) - objattr
->sd_len
< objattr
->name_len
))
344 set_error( STATUS_ACCESS_VIOLATION
);
350 const struct security_descriptor
*sd
= (const struct security_descriptor
*)(objattr
+ 1);
351 if (!sd_is_valid( sd
, objattr
->sd_len
))
353 set_error( STATUS_INVALID_SECURITY_DESCR
);
361 /* maps from generic rights to specific rights as given by a mapping */
362 static inline void map_generic_mask(unsigned int *mask
, const GENERIC_MAPPING
*mapping
)
364 if (*mask
& GENERIC_READ
) *mask
|= mapping
->GenericRead
;
365 if (*mask
& GENERIC_WRITE
) *mask
|= mapping
->GenericWrite
;
366 if (*mask
& GENERIC_EXECUTE
) *mask
|= mapping
->GenericExecute
;
367 if (*mask
& GENERIC_ALL
) *mask
|= mapping
->GenericAll
;
371 static inline int is_equal_luid( const LUID
*luid1
, const LUID
*luid2
)
373 return (luid1
->LowPart
== luid2
->LowPart
&& luid1
->HighPart
== luid2
->HighPart
);
376 static inline void allocate_luid( luid_t
*luid
)
378 prev_luid_value
.low_part
++;
379 *luid
= prev_luid_value
;
382 DECL_HANDLER( allocate_locally_unique_id
)
384 allocate_luid( &reply
->luid
);
387 static inline void luid_and_attr_from_privilege( LUID_AND_ATTRIBUTES
*out
, const struct privilege
*in
)
389 out
->Luid
= in
->luid
;
391 (in
->enabled
? SE_PRIVILEGE_ENABLED
: 0) |
392 (in
->def
? SE_PRIVILEGE_ENABLED_BY_DEFAULT
: 0);
395 static struct privilege
*privilege_add( struct token
*token
, const LUID
*luid
, int enabled
)
397 struct privilege
*privilege
= mem_alloc( sizeof(*privilege
) );
400 privilege
->luid
= *luid
;
401 privilege
->def
= privilege
->enabled
= (enabled
!= 0);
402 list_add_tail( &token
->privileges
, &privilege
->entry
);
407 static inline void privilege_remove( struct privilege
*privilege
)
409 list_remove( &privilege
->entry
);
413 static void token_destroy( struct object
*obj
)
416 struct list
*cursor
, *cursor_next
;
418 assert( obj
->ops
== &token_ops
);
419 token
= (struct token
*)obj
;
423 LIST_FOR_EACH_SAFE( cursor
, cursor_next
, &token
->privileges
)
425 struct privilege
*privilege
= LIST_ENTRY( cursor
, struct privilege
, entry
);
426 privilege_remove( privilege
);
429 LIST_FOR_EACH_SAFE( cursor
, cursor_next
, &token
->groups
)
431 struct group
*group
= LIST_ENTRY( cursor
, struct group
, entry
);
432 list_remove( &group
->entry
);
436 free( token
->default_dacl
);
439 /* creates a new token.
440 * groups may be NULL if group_count is 0.
441 * privs may be NULL if priv_count is 0.
442 * default_dacl may be NULL, indicating that all objects created by the user
444 * modified_id may be NULL, indicating that a new modified_id luid should be
447 static struct token
*create_token( unsigned primary
, const SID
*user
,
448 const SID_AND_ATTRIBUTES
*groups
, unsigned int group_count
,
449 const LUID_AND_ATTRIBUTES
*privs
, unsigned int priv_count
,
450 const ACL
*default_dacl
, TOKEN_SOURCE source
,
451 const luid_t
*modified_id
,
452 int impersonation_level
)
454 struct token
*token
= alloc_object( &token_ops
);
459 allocate_luid( &token
->token_id
);
461 token
->modified_id
= *modified_id
;
463 allocate_luid( &token
->modified_id
);
464 list_init( &token
->privileges
);
465 list_init( &token
->groups
);
466 token
->primary
= primary
;
467 /* primary tokens don't have impersonation levels */
469 token
->impersonation_level
= -1;
471 token
->impersonation_level
= impersonation_level
;
472 token
->default_dacl
= NULL
;
473 token
->primary_group
= NULL
;
476 token
->user
= memdup( user
, security_sid_len( user
));
479 release_object( token
);
484 for (i
= 0; i
< group_count
; i
++)
486 size_t size
= FIELD_OFFSET( struct group
, sid
.SubAuthority
[((const SID
*)groups
[i
].Sid
)->SubAuthorityCount
] );
487 struct group
*group
= mem_alloc( size
);
491 release_object( token
);
494 memcpy( &group
->sid
, groups
[i
].Sid
, security_sid_len( groups
[i
].Sid
));
495 group
->enabled
= TRUE
;
497 group
->logon
= (groups
[i
].Attributes
& SE_GROUP_LOGON_ID
) != 0;
498 group
->mandatory
= (groups
[i
].Attributes
& SE_GROUP_MANDATORY
) != 0;
499 group
->owner
= (groups
[i
].Attributes
& SE_GROUP_OWNER
) != 0;
500 group
->resource
= FALSE
;
501 group
->deny_only
= FALSE
;
502 list_add_tail( &token
->groups
, &group
->entry
);
503 /* Use first owner capable group as an owner */
504 if (!token
->primary_group
&& group
->owner
)
505 token
->primary_group
= &group
->sid
;
508 /* copy privileges */
509 for (i
= 0; i
< priv_count
; i
++)
511 /* note: we don't check uniqueness: the caller must make sure
512 * privs doesn't contain any duplicate luids */
513 if (!privilege_add( token
, &privs
[i
].Luid
,
514 privs
[i
].Attributes
& SE_PRIVILEGE_ENABLED
))
516 release_object( token
);
523 token
->default_dacl
= memdup( default_dacl
, default_dacl
->AclSize
);
524 if (!token
->default_dacl
)
526 release_object( token
);
531 token
->source
= source
;
536 struct token
*token_duplicate( struct token
*src_token
, unsigned primary
,
537 int impersonation_level
)
539 const luid_t
*modified_id
=
540 primary
|| (impersonation_level
== src_token
->impersonation_level
) ?
541 &src_token
->modified_id
: NULL
;
542 struct token
*token
= NULL
;
543 struct privilege
*privilege
;
547 (impersonation_level
< SecurityAnonymous
||
548 impersonation_level
> SecurityDelegation
||
549 (!src_token
->primary
&& (impersonation_level
> src_token
->impersonation_level
))))
551 set_error( STATUS_BAD_IMPERSONATION_LEVEL
);
555 token
= create_token( primary
, src_token
->user
, NULL
, 0,
556 NULL
, 0, src_token
->default_dacl
,
557 src_token
->source
, modified_id
,
558 impersonation_level
);
559 if (!token
) return token
;
562 LIST_FOR_EACH_ENTRY( group
, &src_token
->groups
, struct group
, entry
)
564 size_t size
= FIELD_OFFSET( struct group
, sid
.SubAuthority
[group
->sid
.SubAuthorityCount
] );
565 struct group
*newgroup
= mem_alloc( size
);
568 release_object( token
);
571 memcpy( newgroup
, group
, size
);
572 list_add_tail( &token
->groups
, &newgroup
->entry
);
574 token
->primary_group
= src_token
->primary_group
;
575 assert( token
->primary_group
);
577 /* copy privileges */
578 LIST_FOR_EACH_ENTRY( privilege
, &src_token
->privileges
, struct privilege
, entry
)
579 if (!privilege_add( token
, &privilege
->luid
, privilege
->enabled
))
581 release_object( token
);
588 static ACL
*create_default_dacl( const SID
*user
)
590 ACCESS_ALLOWED_ACE
*aaa
;
593 size_t default_dacl_size
= sizeof(ACL
) +
594 2*(sizeof(ACCESS_ALLOWED_ACE
) - sizeof(DWORD
)) +
595 sizeof(local_system_sid
) +
596 security_sid_len( user
);
598 default_dacl
= mem_alloc( default_dacl_size
);
599 if (!default_dacl
) return NULL
;
601 default_dacl
->AclRevision
= ACL_REVISION
;
602 default_dacl
->Sbz1
= 0;
603 default_dacl
->AclSize
= default_dacl_size
;
604 default_dacl
->AceCount
= 2;
605 default_dacl
->Sbz2
= 0;
607 /* GENERIC_ALL for Local System */
608 aaa
= (ACCESS_ALLOWED_ACE
*)(default_dacl
+ 1);
609 aaa
->Header
.AceType
= ACCESS_ALLOWED_ACE_TYPE
;
610 aaa
->Header
.AceFlags
= 0;
611 aaa
->Header
.AceSize
= (sizeof(ACCESS_ALLOWED_ACE
) - sizeof(DWORD
)) +
612 sizeof(local_system_sid
);
613 aaa
->Mask
= GENERIC_ALL
;
614 sid
= (SID
*)&aaa
->SidStart
;
615 memcpy( sid
, &local_system_sid
, sizeof(local_system_sid
) );
617 /* GENERIC_ALL for specified user */
618 aaa
= (ACCESS_ALLOWED_ACE
*)((char *)aaa
+ aaa
->Header
.AceSize
);
619 aaa
->Header
.AceType
= ACCESS_ALLOWED_ACE_TYPE
;
620 aaa
->Header
.AceFlags
= 0;
621 aaa
->Header
.AceSize
= (sizeof(ACCESS_ALLOWED_ACE
) - sizeof(DWORD
)) + security_sid_len( user
);
622 aaa
->Mask
= GENERIC_ALL
;
623 sid
= (SID
*)&aaa
->SidStart
;
624 memcpy( sid
, user
, security_sid_len( user
));
631 SID_IDENTIFIER_AUTHORITY idauth
;
633 unsigned int subauth
[MAX_SUBAUTH_COUNT
];
636 struct token
*token_create_admin( void )
638 struct token
*token
= NULL
;
639 static const SID_IDENTIFIER_AUTHORITY nt_authority
= { SECURITY_NT_AUTHORITY
};
640 static const unsigned int alias_admins_subauth
[] = { SECURITY_BUILTIN_DOMAIN_RID
, DOMAIN_ALIAS_RID_ADMINS
};
641 static const unsigned int alias_users_subauth
[] = { SECURITY_BUILTIN_DOMAIN_RID
, DOMAIN_ALIAS_RID_USERS
};
642 /* on Windows, this value changes every time the user logs on */
643 static const unsigned int logon_subauth
[] = { SECURITY_LOGON_IDS_RID
, 0, 1 /* FIXME: should be randomly generated when tokens are inherited by new processes */ };
644 PSID alias_admins_sid
;
645 PSID alias_users_sid
;
647 const SID
*user_sid
= security_unix_uid_to_sid( getuid() );
648 ACL
*default_dacl
= create_default_dacl( user_sid
);
650 alias_admins_sid
= security_sid_alloc( &nt_authority
, sizeof(alias_admins_subauth
)/sizeof(alias_admins_subauth
[0]),
651 alias_admins_subauth
);
652 alias_users_sid
= security_sid_alloc( &nt_authority
, sizeof(alias_users_subauth
)/sizeof(alias_users_subauth
[0]),
653 alias_users_subauth
);
654 logon_sid
= security_sid_alloc( &nt_authority
, sizeof(logon_subauth
)/sizeof(logon_subauth
[0]),
657 if (alias_admins_sid
&& alias_users_sid
&& logon_sid
&& default_dacl
)
659 const LUID_AND_ATTRIBUTES admin_privs
[] =
661 { SeChangeNotifyPrivilege
, SE_PRIVILEGE_ENABLED
},
662 { SeSecurityPrivilege
, 0 },
663 { SeBackupPrivilege
, 0 },
664 { SeRestorePrivilege
, 0 },
665 { SeSystemtimePrivilege
, 0 },
666 { SeShutdownPrivilege
, 0 },
667 { SeRemoteShutdownPrivilege
, 0 },
668 { SeTakeOwnershipPrivilege
, 0 },
669 { SeDebugPrivilege
, 0 },
670 { SeSystemEnvironmentPrivilege
, 0 },
671 { SeSystemProfilePrivilege
, 0 },
672 { SeProfileSingleProcessPrivilege
, 0 },
673 { SeIncreaseBasePriorityPrivilege
, 0 },
674 { SeLoadDriverPrivilege
, SE_PRIVILEGE_ENABLED
},
675 { SeCreatePagefilePrivilege
, 0 },
676 { SeIncreaseQuotaPrivilege
, 0 },
677 { SeUndockPrivilege
, 0 },
678 { SeManageVolumePrivilege
, 0 },
679 { SeImpersonatePrivilege
, SE_PRIVILEGE_ENABLED
},
680 { SeCreateGlobalPrivilege
, SE_PRIVILEGE_ENABLED
},
682 /* note: we don't include non-builtin groups here for the user -
683 * telling us these is the job of a client-side program */
684 const SID_AND_ATTRIBUTES admin_groups
[] =
686 { security_world_sid
, SE_GROUP_ENABLED
|SE_GROUP_ENABLED_BY_DEFAULT
|SE_GROUP_MANDATORY
},
687 { security_local_sid
, SE_GROUP_ENABLED
|SE_GROUP_ENABLED_BY_DEFAULT
|SE_GROUP_MANDATORY
},
688 { security_interactive_sid
, SE_GROUP_ENABLED
|SE_GROUP_ENABLED_BY_DEFAULT
|SE_GROUP_MANDATORY
},
689 { security_authenticated_user_sid
, SE_GROUP_ENABLED
|SE_GROUP_ENABLED_BY_DEFAULT
|SE_GROUP_MANDATORY
},
690 { alias_admins_sid
, SE_GROUP_ENABLED
|SE_GROUP_ENABLED_BY_DEFAULT
|SE_GROUP_MANDATORY
|SE_GROUP_OWNER
},
691 { alias_users_sid
, SE_GROUP_ENABLED
|SE_GROUP_ENABLED_BY_DEFAULT
|SE_GROUP_MANDATORY
},
692 { logon_sid
, SE_GROUP_ENABLED
|SE_GROUP_ENABLED_BY_DEFAULT
|SE_GROUP_MANDATORY
|SE_GROUP_LOGON_ID
},
694 static const TOKEN_SOURCE admin_source
= {"SeMgr", {0, 0}};
695 token
= create_token( TRUE
, user_sid
, admin_groups
, sizeof(admin_groups
)/sizeof(admin_groups
[0]),
696 admin_privs
, sizeof(admin_privs
)/sizeof(admin_privs
[0]), default_dacl
,
697 admin_source
, NULL
, -1 );
698 /* we really need a primary group */
699 assert( token
->primary_group
);
703 free( alias_admins_sid
);
704 free( alias_users_sid
);
705 free( default_dacl
);
710 static struct privilege
*token_find_privilege( struct token
*token
, const LUID
*luid
, int enabled_only
)
712 struct privilege
*privilege
;
713 LIST_FOR_EACH_ENTRY( privilege
, &token
->privileges
, struct privilege
, entry
)
715 if (is_equal_luid( luid
, &privilege
->luid
))
717 if (enabled_only
&& !privilege
->enabled
)
725 static unsigned int token_adjust_privileges( struct token
*token
, const LUID_AND_ATTRIBUTES
*privs
,
726 unsigned int count
, LUID_AND_ATTRIBUTES
*mod_privs
,
727 unsigned int mod_privs_count
)
729 unsigned int i
, modified_count
= 0;
731 /* mark as modified */
732 allocate_luid( &token
->modified_id
);
734 for (i
= 0; i
< count
; i
++)
736 struct privilege
*privilege
=
737 token_find_privilege( token
, &privs
[i
].Luid
, FALSE
);
740 set_error( STATUS_NOT_ALL_ASSIGNED
);
744 if (privs
[i
].Attributes
& SE_PRIVILEGE_REMOVED
)
745 privilege_remove( privilege
);
748 /* save previous state for caller */
751 luid_and_attr_from_privilege(mod_privs
, privilege
);
757 if (privs
[i
].Attributes
& SE_PRIVILEGE_ENABLED
)
758 privilege
->enabled
= TRUE
;
760 privilege
->enabled
= FALSE
;
763 return modified_count
;
766 static void token_disable_privileges( struct token
*token
)
768 struct privilege
*privilege
;
770 /* mark as modified */
771 allocate_luid( &token
->modified_id
);
773 LIST_FOR_EACH_ENTRY( privilege
, &token
->privileges
, struct privilege
, entry
)
774 privilege
->enabled
= FALSE
;
777 int token_check_privileges( struct token
*token
, int all_required
,
778 const LUID_AND_ATTRIBUTES
*reqprivs
,
779 unsigned int count
, LUID_AND_ATTRIBUTES
*usedprivs
)
781 unsigned int i
, enabled_count
= 0;
783 for (i
= 0; i
< count
; i
++)
785 struct privilege
*privilege
=
786 token_find_privilege( token
, &reqprivs
[i
].Luid
, TRUE
);
789 usedprivs
[i
] = reqprivs
[i
];
791 if (privilege
&& privilege
->enabled
)
795 usedprivs
[i
].Attributes
|= SE_PRIVILEGE_USED_FOR_ACCESS
;
800 return (enabled_count
== count
);
802 return (enabled_count
> 0);
805 int token_sid_present( struct token
*token
, const SID
*sid
, int deny
)
809 if (security_equal_sid( token
->user
, sid
)) return TRUE
;
811 LIST_FOR_EACH_ENTRY( group
, &token
->groups
, struct group
, entry
)
813 if (!group
->enabled
) continue;
814 if (group
->deny_only
&& !deny
) continue;
816 if (security_equal_sid( &group
->sid
, sid
)) return TRUE
;
822 /* Checks access to a security descriptor. 'sd' must have been validated by
823 * caller. It returns STATUS_SUCCESS if call succeeded or an error indicating
824 * the reason. 'status' parameter will indicate if access is granted or denied.
826 * If both returned value and 'status' are STATUS_SUCCESS then access is granted.
828 static unsigned int token_access_check( struct token
*token
,
829 const struct security_descriptor
*sd
,
830 unsigned int desired_access
,
831 LUID_AND_ATTRIBUTES
*privs
,
832 unsigned int *priv_count
,
833 const GENERIC_MAPPING
*mapping
,
834 unsigned int *granted_access
,
835 unsigned int *status
)
837 unsigned int current_access
= 0;
838 unsigned int denied_access
= 0;
842 const ACE_HEADER
*ace
;
845 /* assume no access rights */
848 /* fail if desired_access contains generic rights */
849 if (desired_access
& (GENERIC_READ
|GENERIC_WRITE
|GENERIC_EXECUTE
|GENERIC_ALL
))
851 if (priv_count
) *priv_count
= 0;
852 return STATUS_GENERIC_NOT_MAPPED
;
855 dacl
= sd_get_dacl( sd
, &dacl_present
);
856 owner
= sd_get_owner( sd
);
857 if (!owner
|| !sd_get_group( sd
))
859 if (priv_count
) *priv_count
= 0;
860 return STATUS_INVALID_SECURITY_DESCR
;
863 /* 1: Grant desired access if the object is unprotected */
864 if (!dacl_present
|| !dacl
)
866 if (priv_count
) *priv_count
= 0;
867 *granted_access
= desired_access
;
868 return *status
= STATUS_SUCCESS
;
871 /* 2: Check if caller wants access to system security part. Note: access
872 * is only granted if specifically asked for */
873 if (desired_access
& ACCESS_SYSTEM_SECURITY
)
875 const LUID_AND_ATTRIBUTES security_priv
= { SeSecurityPrivilege
, 0 };
876 LUID_AND_ATTRIBUTES retpriv
= security_priv
;
877 if (token_check_privileges( token
, TRUE
, &security_priv
, 1, &retpriv
))
881 /* assumes that there will only be one privilege to return */
882 if (*priv_count
>= 1)
890 return STATUS_BUFFER_TOO_SMALL
;
893 current_access
|= ACCESS_SYSTEM_SECURITY
;
894 if (desired_access
== current_access
)
896 *granted_access
= current_access
;
897 return *status
= STATUS_SUCCESS
;
902 if (priv_count
) *priv_count
= 0;
903 *status
= STATUS_PRIVILEGE_NOT_HELD
;
904 return STATUS_SUCCESS
;
907 else if (priv_count
) *priv_count
= 0;
909 /* 3: Check whether the token is the owner */
910 /* NOTE: SeTakeOwnershipPrivilege is not checked for here - it is instead
911 * checked when a "set owner" call is made, overriding the access rights
912 * determined here. */
913 if (token_sid_present( token
, owner
, FALSE
))
915 current_access
|= (READ_CONTROL
| WRITE_DAC
);
916 if (desired_access
== current_access
)
918 *granted_access
= current_access
;
919 return *status
= STATUS_SUCCESS
;
923 /* 4: Grant rights according to the DACL */
924 ace
= (const ACE_HEADER
*)(dacl
+ 1);
925 for (i
= 0; i
< dacl
->AceCount
; i
++, ace
= ace_next( ace
))
927 const ACCESS_ALLOWED_ACE
*aa_ace
;
928 const ACCESS_DENIED_ACE
*ad_ace
;
931 if (ace
->AceFlags
& INHERIT_ONLY_ACE
)
934 switch (ace
->AceType
)
936 case ACCESS_DENIED_ACE_TYPE
:
937 ad_ace
= (const ACCESS_DENIED_ACE
*)ace
;
938 sid
= (const SID
*)&ad_ace
->SidStart
;
939 if (token_sid_present( token
, sid
, TRUE
))
941 unsigned int access
= ad_ace
->Mask
;
942 map_generic_mask(&access
, mapping
);
943 if (desired_access
& MAXIMUM_ALLOWED
)
944 denied_access
|= access
;
947 denied_access
|= (access
& ~current_access
);
948 if (desired_access
& access
) goto done
;
952 case ACCESS_ALLOWED_ACE_TYPE
:
953 aa_ace
= (const ACCESS_ALLOWED_ACE
*)ace
;
954 sid
= (const SID
*)&aa_ace
->SidStart
;
955 if (token_sid_present( token
, sid
, FALSE
))
957 unsigned int access
= aa_ace
->Mask
;
958 map_generic_mask(&access
, mapping
);
959 if (desired_access
& MAXIMUM_ALLOWED
)
960 current_access
|= access
;
962 current_access
|= (access
& ~denied_access
);
967 /* don't bother carrying on checking if we've already got all of
969 if (desired_access
== *granted_access
)
974 if (desired_access
& MAXIMUM_ALLOWED
)
975 *granted_access
= current_access
& ~denied_access
;
977 if ((current_access
& desired_access
) == desired_access
)
978 *granted_access
= current_access
& desired_access
;
982 *status
= *granted_access
? STATUS_SUCCESS
: STATUS_ACCESS_DENIED
;
983 return STATUS_SUCCESS
;
986 const ACL
*token_get_default_dacl( struct token
*token
)
988 return token
->default_dacl
;
991 const SID
*token_get_user( struct token
*token
)
996 const SID
*token_get_primary_group( struct token
*token
)
998 return token
->primary_group
;
1001 int check_object_access(struct object
*obj
, unsigned int *access
)
1003 GENERIC_MAPPING mapping
;
1004 struct token
*token
= current
->token
? current
->token
: current
->process
->token
;
1005 unsigned int status
;
1008 mapping
.GenericAll
= obj
->ops
->map_access( obj
, GENERIC_ALL
);
1012 if (*access
& MAXIMUM_ALLOWED
)
1013 *access
= mapping
.GenericAll
;
1017 mapping
.GenericRead
= obj
->ops
->map_access( obj
, GENERIC_READ
);
1018 mapping
.GenericWrite
= obj
->ops
->map_access( obj
, GENERIC_WRITE
);
1019 mapping
.GenericExecute
= obj
->ops
->map_access( obj
, GENERIC_EXECUTE
);
1021 res
= token_access_check( token
, obj
->sd
, *access
, NULL
, NULL
,
1022 &mapping
, access
, &status
) == STATUS_SUCCESS
&&
1023 status
== STATUS_SUCCESS
;
1025 if (!res
) set_error( STATUS_ACCESS_DENIED
);
1030 /* open a security token */
1031 DECL_HANDLER(open_token
)
1033 if (req
->flags
& OPEN_TOKEN_THREAD
)
1035 struct thread
*thread
= get_thread_from_handle( req
->handle
, 0 );
1040 if (!thread
->token
->primary
&& thread
->token
->impersonation_level
<= SecurityAnonymous
)
1041 set_error( STATUS_CANT_OPEN_ANONYMOUS
);
1043 reply
->token
= alloc_handle( current
->process
, thread
->token
,
1044 req
->access
, req
->attributes
);
1047 set_error( STATUS_NO_TOKEN
);
1048 release_object( thread
);
1053 struct process
*process
= get_process_from_handle( req
->handle
, 0 );
1057 reply
->token
= alloc_handle( current
->process
, process
->token
, req
->access
,
1060 set_error( STATUS_NO_TOKEN
);
1061 release_object( process
);
1066 /* adjust the privileges held by a token */
1067 DECL_HANDLER(adjust_token_privileges
)
1069 struct token
*token
;
1070 unsigned int access
= TOKEN_ADJUST_PRIVILEGES
;
1072 if (req
->get_modified_state
) access
|= TOKEN_QUERY
;
1074 if ((token
= (struct token
*)get_handle_obj( current
->process
, req
->handle
,
1075 access
, &token_ops
)))
1077 const LUID_AND_ATTRIBUTES
*privs
= get_req_data();
1078 LUID_AND_ATTRIBUTES
*modified_privs
= NULL
;
1079 unsigned int priv_count
= get_req_data_size() / sizeof(LUID_AND_ATTRIBUTES
);
1080 unsigned int modified_priv_count
= 0;
1082 if (req
->get_modified_state
&& !req
->disable_all
)
1085 /* count modified privs */
1086 for (i
= 0; i
< priv_count
; i
++)
1088 struct privilege
*privilege
=
1089 token_find_privilege( token
, &privs
[i
].Luid
, FALSE
);
1090 if (privilege
&& req
->get_modified_state
)
1091 modified_priv_count
++;
1093 reply
->len
= modified_priv_count
;
1094 modified_priv_count
= min( modified_priv_count
, get_reply_max_size() / sizeof(*modified_privs
) );
1095 if (modified_priv_count
)
1096 modified_privs
= set_reply_data_size( modified_priv_count
* sizeof(*modified_privs
) );
1098 reply
->len
= modified_priv_count
* sizeof(*modified_privs
);
1100 if (req
->disable_all
)
1101 token_disable_privileges( token
);
1103 modified_priv_count
= token_adjust_privileges( token
, privs
,
1104 priv_count
, modified_privs
, modified_priv_count
);
1106 release_object( token
);
1110 /* retrieves the list of privileges that may be held be the token */
1111 DECL_HANDLER(get_token_privileges
)
1113 struct token
*token
;
1115 if ((token
= (struct token
*)get_handle_obj( current
->process
, req
->handle
,
1120 LUID_AND_ATTRIBUTES
*privs
;
1121 struct privilege
*privilege
;
1123 LIST_FOR_EACH_ENTRY( privilege
, &token
->privileges
, struct privilege
, entry
)
1126 reply
->len
= priv_count
* sizeof(*privs
);
1127 if (reply
->len
<= get_reply_max_size())
1129 privs
= set_reply_data_size( priv_count
* sizeof(*privs
) );
1133 LIST_FOR_EACH_ENTRY( privilege
, &token
->privileges
, struct privilege
, entry
)
1135 luid_and_attr_from_privilege( &privs
[i
], privilege
);
1141 set_error(STATUS_BUFFER_TOO_SMALL
);
1143 release_object( token
);
1147 /* creates a duplicate of the token */
1148 DECL_HANDLER(duplicate_token
)
1150 struct token
*src_token
;
1152 if ((src_token
= (struct token
*)get_handle_obj( current
->process
, req
->handle
,
1156 struct token
*token
= token_duplicate( src_token
, req
->primary
, req
->impersonation_level
);
1159 reply
->new_handle
= alloc_handle( current
->process
, token
, req
->access
, req
->attributes
);
1160 release_object( token
);
1162 release_object( src_token
);
1166 /* checks the specified privileges are held by the token */
1167 DECL_HANDLER(check_token_privileges
)
1169 struct token
*token
;
1171 if ((token
= (struct token
*)get_handle_obj( current
->process
, req
->handle
,
1175 unsigned int count
= get_req_data_size() / sizeof(LUID_AND_ATTRIBUTES
);
1177 if (!token
->primary
&& token
->impersonation_level
<= SecurityAnonymous
)
1178 set_error( STATUS_BAD_IMPERSONATION_LEVEL
);
1179 else if (get_reply_max_size() >= count
* sizeof(LUID_AND_ATTRIBUTES
))
1181 LUID_AND_ATTRIBUTES
*usedprivs
= set_reply_data_size( count
* sizeof(*usedprivs
) );
1182 reply
->has_privileges
= token_check_privileges( token
, req
->all_required
, get_req_data(), count
, usedprivs
);
1185 set_error( STATUS_BUFFER_OVERFLOW
);
1186 release_object( token
);
1190 /* checks that a user represented by a token is allowed to access an object
1191 * represented by a security descriptor */
1192 DECL_HANDLER(access_check
)
1194 data_size_t sd_size
= get_req_data_size();
1195 const struct security_descriptor
*sd
= get_req_data();
1196 struct token
*token
;
1198 if (!sd_is_valid( sd
, sd_size
))
1200 set_error( STATUS_ACCESS_VIOLATION
);
1204 if ((token
= (struct token
*)get_handle_obj( current
->process
, req
->handle
,
1208 GENERIC_MAPPING mapping
;
1209 unsigned int status
;
1210 LUID_AND_ATTRIBUTES priv
;
1211 unsigned int priv_count
= 1;
1213 memset(&priv
, 0, sizeof(priv
));
1215 /* only impersonation tokens may be used with this function */
1218 set_error( STATUS_NO_IMPERSONATION_TOKEN
);
1219 release_object( token
);
1222 /* anonymous impersonation tokens can't be used */
1223 if (token
->impersonation_level
<= SecurityAnonymous
)
1225 set_error( STATUS_BAD_IMPERSONATION_LEVEL
);
1226 release_object( token
);
1230 mapping
.GenericRead
= req
->mapping_read
;
1231 mapping
.GenericWrite
= req
->mapping_write
;
1232 mapping
.GenericExecute
= req
->mapping_execute
;
1233 mapping
.GenericAll
= req
->mapping_all
;
1235 status
= token_access_check(
1236 token
, sd
, req
->desired_access
, &priv
, &priv_count
, &mapping
,
1237 &reply
->access_granted
, &reply
->access_status
);
1239 reply
->privileges_len
= priv_count
*sizeof(LUID_AND_ATTRIBUTES
);
1241 if ((priv_count
> 0) && (reply
->privileges_len
<= get_reply_max_size()))
1243 LUID_AND_ATTRIBUTES
*privs
= set_reply_data_size( priv_count
* sizeof(*privs
) );
1244 memcpy( privs
, &priv
, sizeof(priv
) );
1247 set_error( status
);
1248 release_object( token
);
1252 /* retrieves the SID of the user that the token represents */
1253 DECL_HANDLER(get_token_sid
)
1255 struct token
*token
;
1259 if ((token
= (struct token
*)get_handle_obj( current
->process
, req
->handle
,
1263 const SID
*sid
= NULL
;
1265 switch (req
->which_sid
)
1268 assert(token
->user
);
1271 case TokenPrimaryGroup
:
1272 sid
= token
->primary_group
;
1276 struct group
*group
;
1277 LIST_FOR_EACH_ENTRY( group
, &token
->groups
, struct group
, entry
)
1288 set_error( STATUS_INVALID_PARAMETER
);
1294 reply
->sid_len
= security_sid_len( sid
);
1295 if (reply
->sid_len
<= get_reply_max_size()) set_reply_data( sid
, reply
->sid_len
);
1296 else set_error( STATUS_BUFFER_TOO_SMALL
);
1298 release_object( token
);
1302 /* retrieves the groups that the user represented by the token belongs to */
1303 DECL_HANDLER(get_token_groups
)
1305 struct token
*token
;
1307 reply
->user_len
= 0;
1309 if ((token
= (struct token
*)get_handle_obj( current
->process
, req
->handle
,
1313 size_t size_needed
= sizeof(struct token_groups
);
1314 size_t sid_size
= 0;
1315 unsigned int group_count
= 0;
1316 const struct group
*group
;
1318 LIST_FOR_EACH_ENTRY( group
, &token
->groups
, const struct group
, entry
)
1321 sid_size
+= security_sid_len( &group
->sid
);
1323 size_needed
+= sid_size
;
1324 /* attributes size */
1325 size_needed
+= sizeof(unsigned int) * group_count
;
1327 /* reply buffer contains size_needed bytes formatted as:
1330 unsigned int attrib[count];
1333 user_len includes extra data needed for TOKEN_GROUPS representation,
1334 required caller buffer size calculated here to avoid extra server call */
1335 reply
->user_len
= FIELD_OFFSET( TOKEN_GROUPS
, Groups
[group_count
] ) + sid_size
;
1337 if (reply
->user_len
<= get_reply_max_size())
1339 struct token_groups
*tg
= set_reply_data_size( size_needed
);
1342 unsigned int *attr_ptr
= (unsigned int *)(tg
+ 1);
1343 SID
*sid_ptr
= (SID
*)(attr_ptr
+ group_count
);
1345 tg
->count
= group_count
;
1347 LIST_FOR_EACH_ENTRY( group
, &token
->groups
, const struct group
, entry
)
1351 if (group
->mandatory
) *attr_ptr
|= SE_GROUP_MANDATORY
;
1352 if (group
->def
) *attr_ptr
|= SE_GROUP_ENABLED_BY_DEFAULT
;
1353 if (group
->enabled
) *attr_ptr
|= SE_GROUP_ENABLED
;
1354 if (group
->owner
) *attr_ptr
|= SE_GROUP_OWNER
;
1355 if (group
->deny_only
) *attr_ptr
|= SE_GROUP_USE_FOR_DENY_ONLY
;
1356 if (group
->resource
) *attr_ptr
|= SE_GROUP_RESOURCE
;
1357 if (group
->logon
) *attr_ptr
|= SE_GROUP_LOGON_ID
;
1359 memcpy(sid_ptr
, &group
->sid
, security_sid_len( &group
->sid
));
1361 sid_ptr
= (SID
*)((char *)sid_ptr
+ security_sid_len( &group
->sid
));
1366 else set_error( STATUS_BUFFER_TOO_SMALL
);
1368 release_object( token
);
1372 DECL_HANDLER(get_token_impersonation_level
)
1374 struct token
*token
;
1376 if ((token
= (struct token
*)get_handle_obj( current
->process
, req
->handle
,
1381 set_error( STATUS_INVALID_PARAMETER
);
1383 reply
->impersonation_level
= token
->impersonation_level
;
1385 release_object( token
);
1389 DECL_HANDLER(get_token_statistics
)
1391 struct token
*token
;
1393 if ((token
= (struct token
*)get_handle_obj( current
->process
, req
->handle
,
1397 reply
->token_id
= token
->token_id
;
1398 reply
->modified_id
= token
->modified_id
;
1399 reply
->primary
= token
->primary
;
1400 reply
->impersonation_level
= token
->impersonation_level
;
1401 reply
->group_count
= list_count( &token
->groups
);
1402 reply
->privilege_count
= list_count( &token
->privileges
);
1404 release_object( token
);
1408 DECL_HANDLER(get_token_default_dacl
)
1410 struct token
*token
;
1414 if ((token
= (struct token
*)get_handle_obj( current
->process
, req
->handle
,
1418 if (token
->default_dacl
)
1419 reply
->acl_len
= token
->default_dacl
->AclSize
;
1421 if (reply
->acl_len
<= get_reply_max_size())
1423 ACL
*acl_reply
= set_reply_data_size( reply
->acl_len
);
1425 memcpy( acl_reply
, token
->default_dacl
, reply
->acl_len
);
1427 else set_error( STATUS_BUFFER_TOO_SMALL
);
1429 release_object( token
);
1433 DECL_HANDLER(set_token_default_dacl
)
1435 struct token
*token
;
1437 if ((token
= (struct token
*)get_handle_obj( current
->process
, req
->handle
,
1438 TOKEN_ADJUST_DEFAULT
,
1441 const ACL
*acl
= get_req_data();
1442 unsigned int acl_size
= get_req_data_size();
1444 free( token
->default_dacl
);
1445 token
->default_dacl
= NULL
;
1448 token
->default_dacl
= memdup( acl
, acl_size
);
1450 release_object( token
);