[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Sat Sep 11 02:47:59 MDT 2010


The branch, master has been updated
       via  a02a2c3 libcli/security Use talloc_zero when making a struct security_token
       via  fdcadb5 libcli/privileges Fix comment
       via  0eea8ec s4-privs Seperate rights and privileges
       via  3b4db34 s3-krb5 Fix Kerberos on FreeBSD with Samba4 DCs
       via  ee943fb libcli/security Remove unused SE_NONE define
       via  eb6a0cc libcli/security Move 'private' privileges functions to another header
       via  b733d9d s3-samr Explian better the use of two privileges in this call
       via  6d2b1ef libcli/security Remove 'always true' return from se_priv_put_all_privileges
       via  aefe60d s3-util_sid Tidy up global struct security_token
       via  da9bca6 s4-rpc_server Put all 'logon failure' messages at the same debug level 4
       via  eb84c7a libcli/auth Failure to find the cached session key for SCHANNEL isn't level 0
       via  e3edd7c s3-privs Add const
       via  4bf0996 s3-privs Remove extra pointer on privilege mask
       via  86fdb4c s3-privileges: add handling of both old and new formats in database
       via  45aecc2 s4-lsa: privilege IDs should use the enum, not an int
       via  382e2b3 privileges: privilege luids are not all below 64
       via  a32cdad libcli/security Make sec_privilege_from_index() return SEC_PRIV_INVALID on failure
       via  0b41ef7 libcli/security Remove unused declarations from privileges.h
       via  96e59fa s3-privs Remove unused function
       via  9883993 s3-privs Overhaul PRIVILEGE_SET handling, avoid dealing with the bitmap
       via  ad5ec58 s3-privs Hide the bitmap-based grant_privilege and revoke_privilege
       via  4080ff7 s3-privs Make privilege_enum_sids() take an LUID, not a bitmap
       via  71832a4 libcli/security Expose sec_privilege_mask()
       via  6d78e11 libcli/security make sec_privilege_id() return SEC_PRIV_INVALID on failure.
       via  8ff6bc2 libcli/security Remove unused functions and constants.
       via  62e5900 s3-privs Rework access_check_object() to take two privileges
       via  a53a42f libcli/security Rename all privilege bitmaps constants
       via  e0cbc68 s3-privs Rework privilege enumeration to also use new DB format
       via  2bb7b82 libcli/security Remove luid_to_se_priv() and luid_to_privilege_name()
       via  ed6b4dd s3-privs Directly manipulate the privileges bitmap.
       via  92efe9a libcli/security Add an invalid LUID privilege value
       via  aab0b55 libcli/security Improve dump of privileges:  Just walk the table
       via  3bb7751 s3-privs Convert from user_has_privileges() -> security_token_has_privilege()
       via  b057867 s3-privs Remove a pointer from grant_privilege()
       via  0e2142a s3-privs Remove pointer indirection from se_priv_to_privilege_set()
       via  2387e3b s3-privs Call security_token_set_privilege() rather than manual assignment
       via  a02ae67 s3-privs Remove a pointer indirection from revoke_privilege()
       via  cbd72ab libcli/security Don't export privs[] as a global variable
       via  33ce863 s3-lsa Use sec_privilege_id() to lookup name to LUID
       via  3c93d1e libcli/security Merge privilege lists from source3 and source4
       via  d2e4110 libcli/security Return number of entries in the old source3 list
       via  eb8e315 libcli/privileges Simplify get_privilege_luid() to return just the enum
       via  cdda15c libcli/security Don't memcpy a uint64_t value, just assign it.
       via  780de03 libcli/security Use ARRAY_SIZE() consistantly.
       via  66ac968 libcli/security Fix and clarify privilege manipulation function comments
       via  9fb92c6 libcli/security Make the two privileges tables share a common struct definition
       via  dbee98d libcli/security Move source4/ privileges code into the common libcli/security
       via  0d25212 s3-privs Move manual prototypes to common privileges.h
       via  b29b6c1 s3-privs Inline dump_se_priv into callers now that it's just a uint64_t
       via  f85b822 libcli/security Use talloc_realloc() not TALLOC_REALLOC_ARRAY()
       via  3f589c2 libcli/security Use C99 types
       via  b0690d6 libcli/security Use true and false, not True and False
       via  f20bba9 s3-privs Move source3/ privileges implmentation into common
       via  cae7bab s3-privs Rename structure elements for greater clarity
       via  25b0da5 s3-privs More clarity in variable names
       via  f20c781 s3-privs Rename mask -> privilege_mask to be more clear
       via  d1bb21b s3:auth Remove NT_USER_TOKEN
       via  4bfc8d3 s3-auth Change struct nt_user_token -> struct security_token
       via  4bf783d s3-auth Change type of num_sids to uint32_t
       via  6a0176b security.idl Add comments
       via  2606dfa security.idl Update Windows privileges list to Win2008R2
       via  3e36aef s3-privs Only store low bits of luid in privileges table
       via  9abfd8f s4-privs Add a lookup by index of privilages
       via  e113af6 privs Add my Copyright
       via  d2883ff security.idl clarify which privilages are LUID and bitmap values
       via  86233ec s3-privs Remove comment already moved to security.idl
       via  82f84ff s3-privs Use constants from security.idl
       via  e655e9f s4-privs Remove link between enum sec_privilege and the privilege bitmap
       via  fcaa86f s3-privs Further changes to remove SE_PRIV
       via  821b9e6 privs Move privilege bitmasks to security.idl
       via  99aae4a s3:privs Change to new host endian neutral privilages tdb format
       via  c79336e s3:Change SE_PRIV to uint64_t
       via  42a98a5 s3:privileges Change SE_PRIV to be just a uint64_t
      from  b8f28c2 lib/replace:wscript - don't check twice for type "bool"

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit a02a2c3557928e507d1220303d9a3f79e8c46bb1
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Sep 11 17:00:10 2010 +1000

    libcli/security Use talloc_zero when making a struct security_token

commit fdcadb5c3c2e3de1e2d1755653a9d02ccb548db8
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Sep 11 16:59:53 2010 +1000

    libcli/privileges Fix comment

commit 0eea8ecfe262e515011e7637c5a574f23923f169
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Sep 11 16:58:45 2010 +1000

    s4-privs Seperate rights and privileges
    
    These are related, but slightly different concepts.  The biggest difference
    is that rights are not enumerated as a system-wide list.
    
    This moves the rights to security.idl due to dependencies.
    
    Andrew Bartlett

commit 3b4db34011f06fb785153fa9070fb1da9d8f5c78
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Sep 11 16:13:33 2010 +1000

    s3-krb5 Fix Kerberos on FreeBSD with Samba4 DCs
    
    The idea of this patch is: Don't support a mix of different kerberos
    features.
    
    Either we should prepare a GSSAPI (8003) checksum and mark the request as
    such, or we should use the old behaviour (a normal kerberos checksum of 0 data).
    
    Sending the GSSAPI checksum data, but without marking it as GSSAPI broke
    Samba4, and seems well outside the expected behaviour, even if Windows accepts it.
    
    Andrew Bartlett

commit ee943fb2bfc1fe7bad924aea9096c246bef6d60b
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Sep 4 09:32:21 2010 +1000

    libcli/security Remove unused SE_NONE define
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit eb6a0cc3268beabc09218b965d79083e80fb0464
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Sep 4 09:23:12 2010 +1000

    libcli/security Move 'private' privileges functions to another header
    
    These functions work on the bitmap, and are only exposed because
    the source3/ privileges storage uses the bitmap in account_policy.tdb
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit b733d9dee0624d80ed965bd231995026218de5a4
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Sep 4 09:18:05 2010 +1000

    s3-samr Explian better the use of two privileges in this call
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 6d2b1ef71d5e0b61559c99d58857ce533a036044
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Sep 4 09:16:23 2010 +1000

    libcli/security Remove 'always true' return from se_priv_put_all_privileges
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit aefe60da8c6a5e48d807fa2e64d332b67fae25b8
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Sep 4 08:37:21 2010 +1000

    s3-util_sid Tidy up global struct security_token
    
    This no longer needs to be global, and should be const.  We now also
    init it with the C99 style initialisers.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit da9bca62825f838ac57d7a56dc8b0e9b5de181c8
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Sep 4 07:02:38 2010 +1000

    s4-rpc_server Put all 'logon failure' messages at the same debug level 4
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit eb84c7ac908ad68443496c70775f16ce5d30310a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Sep 4 07:01:38 2010 +1000

    libcli/auth Failure to find the cached session key for SCHANNEL isn't level 0
    
    This happens all the time, particularly now that we don't keep the
    db around after a reboot.  Don't scare the admins with the level 0.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit e3edd7ca3ad73ff81a6ffddfeae208b930766e86
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Sep 3 20:30:50 2010 +1000

    s3-privs Add const
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 4bf09967a40814619199a1ec6c7424612a767071
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Sep 3 20:30:16 2010 +1000

    s3-privs Remove extra pointer on privilege mask
    
    Now that this is a scalar, this isn't required.
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 86fdb4c152d40ce862dea0ca7b5790df4b168289
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Sep 3 16:33:41 2010 +1000

    s3-privileges: add handling of both old and new formats in database
    
    We update privileges on a per-record basis instead of all at once, as
    this maintains maximum compatibility is someone uses old tools with a
    new version of Samba. The also auto-detects the byte order of the old
    entries in the database, and copes with either native or reversed byte
    order.
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 45aecc283398a061f185ebc5577fcb4de0b89262
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu Sep 2 14:15:13 2010 +1000

    s4-lsa: privilege IDs should use the enum, not an int
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit 382e2b321b6b79cfd0db59ae2c506fcd750a3df6
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu Sep 2 14:14:51 2010 +1000

    privileges: privilege luids are not all below 64
    
    the ones brought across from s3 have higher values
    
    Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>

commit a32cdadb7cbff255b5a0133a3bb54352d0d42f61
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Aug 31 09:28:51 2010 +1000

    libcli/security Make sec_privilege_from_index() return SEC_PRIV_INVALID on failure
    
    This is clearer and more consistent than using a magic -1 return
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 0b41ef789575e5194e9b499cf5fe0df4616f1bb8
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Aug 31 09:20:39 2010 +1000

    libcli/security Remove unused declarations from privileges.h
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 96e59faa623ffa1faa50ecf7974c5ff00c9b6399
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 16:29:05 2010 +1000

    s3-privs Remove unused function
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 9883993b66826d2f692ebdd3c928f4f7a0cddc7d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 15:38:18 2010 +1000

    s3-privs Overhaul PRIVILEGE_SET handling, avoid dealing with the bitmap
    
    This avoids us dealing with the privilege bitmap in the LSA server, and
    overhauls much of the rest of the handling to be currnet with the modern
    world of talloc.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit ad5ec58a714aba1f6c0894ca4e7207f1c5072949
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 15:27:40 2010 +1000

    s3-privs Hide the bitmap-based grant_privilege and revoke_privilege
    
    The new wrappers avoid anything but the core privileges code
    dealing with the bitmap values directly.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 4080ff7af5eec946a01c52f8d9ba01f1ef81fe71
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 14:17:02 2010 +1000

    s3-privs Make privilege_enum_sids() take an LUID, not a bitmap
    
    This moves one more privileges call away from direct bitmap manipuation.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 71832a404e5028c1c3933351c608a99e4fc80e42
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 14:16:36 2010 +1000

    libcli/security Expose sec_privilege_mask()
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 6d78e11e17b80bc932e5f4fb1ff6b27909f405d0
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 14:00:50 2010 +1000

    libcli/security make sec_privilege_id() return SEC_PRIV_INVALID on failure.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 8ff6bc2350894924ad362e0f058a24de3e459270
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 13:33:19 2010 +1000

    libcli/security Remove unused functions and constants.
    
    All the callers to these functions have been removed or reworked.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 62e5900cd13f6daf77ab65f70245fe21ac5fd053
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 13:30:38 2010 +1000

    s3-privs Rework access_check_object() to take two privileges
    
    This allows the privileges bitmap to be used only when setting
    privileges, and uses an the LUID constant for all 'does this user
    have this privilege' operations.
    
    The advantage is that we now only need one API to determine if a
    token has a privilege, and much less code needs to know what type
    is used for the underlying bitmap.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit a53a42ffb88fd6b758b8cacf492bceeb93da09c1
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 13:28:19 2010 +1000

    libcli/security Rename all privilege bitmaps constants
    
    The idea here to to make it very clear how they differ from the
    enumerated LUID values.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit e0cbc68c0a29bc036949adb7be5e140edd07a3b2
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 13:24:43 2010 +1000

    s3-privs Rework privilege enumeration to also use new DB format
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 2bb7b827d60424aaccd12bd811d4a42de72f0185
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 13:17:48 2010 +1000

    libcli/security Remove luid_to_se_priv() and luid_to_privilege_name()
    
    These functions duplicate other functions in the merged code.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit ed6b4ddd71ebdcdbdea7949ecbef11f409766534
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 13:14:40 2010 +1000

    s3-privs Directly manipulate the privileges bitmap.
    
    There is no longer any reason to go via the se_ functions to
    manipulate this bitmap.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 92efe9a86aae64d85323a9fcf6d20fd3f85bc22c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 13:09:29 2010 +1000

    libcli/security Add an invalid LUID privilege value
    
    This helps code that may not want to specify any privilege
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit aab0b557b9577d2ef8bed7a0674b702ea94c0d4a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 13:06:18 2010 +1000

    libcli/security Improve dump of privileges:  Just walk the table
    
    This removes some logic recently added that was just too smart - it
    is easier to just walk the table and do a bit match here.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 3bb77516b841def60e08e50bafc37517dd9d3ae0
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 13:04:27 2010 +1000

    s3-privs Convert from user_has_privileges() -> security_token_has_privilege()
    
    This new call is available in the merged privileges code, and
    takes an enum as the parameter, rather than a bitmask.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit b057867de3fbb423ef6afb9b7038ab99c83124d8
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 12:59:38 2010 +1000

    s3-privs Remove a pointer from grant_privilege()
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 0e2142a9275b567a3c6a8f90e95240d9e686ec27
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 12:50:49 2010 +1000

    s3-privs Remove pointer indirection from se_priv_to_privilege_set()
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 2387e3bcfeb4c2e54342a8fff4b157e9ba68024b
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 12:47:29 2010 +1000

    s3-privs Call security_token_set_privilege() rather than manual assignment
    
    This avoids as much direct modifiction of the bitmask as possible.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit a02ae674dd6ffaa8ebc4017af6a644162c59a00d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Aug 30 12:44:08 2010 +1000

    s3-privs Remove a pointer indirection from revoke_privilege()
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit cbd72ab93bc35aa71a55b190cd999dda4106be07
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 12:19:09 2010 +1000

    libcli/security Don't export privs[] as a global variable
    
    Instead, provide access functions for the LSA and net sam callers
    for the information they need.
    
    They still only enumerate the first 8 privileges that have traditionally
    been exposed.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 33ce8633d6a5e5cc54209c92397025114f0a46ea
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 12:12:10 2010 +1000

    s3-lsa Use sec_privilege_id() to lookup name to LUID
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 3c93d1ecbf563f46c4aa5fe9f0c5f3ee053f702d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 11:56:37 2010 +1000

    libcli/security Merge privilege lists from source3 and source4
    
    The LSA enumeration in source3 will not show the new privileges,
    but otherwise, they are now in common, and can be set by name.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit d2e41105e2caab83251d54c3fde72971038dd5df
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 11:52:51 2010 +1000

    libcli/security Return number of entries in the old source3 list
    
    This ensures there isn't a behaviour change when the source3 list is combined
    with the longer source4 list.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit eb8e3155dee3e4258a603da61a9e7822503cd8dd
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 11:27:57 2010 +1000

    libcli/privileges Simplify get_privilege_luid() to return just the enum
    
    As Samba only deals with the lower 32 bits of the LUID, just return those
    and let the LSA layer deal with the upper 0 bits.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit cdda15c062369d94bc468dce7b541ea505d664e5
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 11:26:20 2010 +1000

    libcli/security Don't memcpy a uint64_t value, just assign it.
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 780de03f009d9583541f6bbc6932b0c1b142231b
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 10:52:38 2010 +1000

    libcli/security Use ARRAY_SIZE() consistantly.
    
    This avoids the use of SE_END, and has all callers walking the
    array using the same termination condition.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 66ac968dd50ebe8481995a34bb6651c0e24e928d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 10:30:18 2010 +1000

    libcli/security Fix and clarify privilege manipulation function comments
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 9fb92c6014e48b000b26010bc21aa3821bab10cf
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 10:21:13 2010 +1000

    libcli/security Make the two privileges tables share a common struct definition
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit dbee98d30fc9c7db6693170215b8c1819b3e2f3d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 09:35:55 2010 +1000

    libcli/security Move source4/ privileges code into the common libcli/security
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 0d25212cc161dee2f38c8ad60e50543596000f18
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 09:22:31 2010 +1000

    s3-privs Move manual prototypes to common privileges.h
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit b29b6c13a373c39190db0e2bd0440f7f2619b33c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 10:04:05 2010 +1000

    s3-privs Inline dump_se_priv into callers now that it's just a uint64_t
    
    The previous 128 bit structure needed this helper function.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit f85b822bd4feaab179ffbf00496fcb7d1905fc8c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 09:50:31 2010 +1000

    libcli/security Use talloc_realloc() not TALLOC_REALLOC_ARRAY()
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 3f589c2155557c02c9dc0eeee972bb68c1fd147f
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 09:50:12 2010 +1000

    libcli/security Use C99 types
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit b0690d6da7c60ef54d243e487260540666cc58ff
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 09:41:32 2010 +1000

    libcli/security Use true and false, not True and False
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit f20bba97d8146e830dbaeb761a05dcede1bdfee2
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 08:56:15 2010 +1000

    s3-privs Move source3/ privileges implmentation into common
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit cae7babb1fcfbb0655bc1f7f6be51212f3d13c69
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 22:49:27 2010 +1000

    s3-privs Rename structure elements for greater clarity
    
    It is important to make clear which is the LUID and which
    is the Samba-only bitmap mask.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 25b0da5c532bbaee819fe239217e2d2f2c81a6c6
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 22:35:35 2010 +1000

    s3-privs More clarity in variable names
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit f20c78150946c2822722858c2f614babfd857317
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 22:30:26 2010 +1000

    s3-privs Rename mask -> privilege_mask to be more clear
    
    After SE_PRIV was removed, it became less clear what these
    parameters were for.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit d1bb21b0d531ef8f40400716b3e1f6314c7c1e8a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 22:08:22 2010 +1000

    s3:auth Remove NT_USER_TOKEN
    
    The all UPPER case typedef is no longer the preferred Samba style
    and this makes it easier to see that this is the IDL-derivied structure
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 4bfc8d3b1a6f6deacb8845c5d81b4897cc292cfb
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 20:04:11 2010 +1000

    s3-auth Change struct nt_user_token -> struct security_token
    
    This common structure is defined in security.idl
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 4bf783d4d6693f927f5e7ef7a9855766c91983f2
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 20:54:13 2010 +1000

    s3-auth Change type of num_sids to uint32_t
    
    size_t is overkill here, and in struct security_token in the num_sids
    is uint32_t.
    
    This includes a change to the prototype of add_sid_to_array()
    and add_sid_to_array_unique(), which has had a number of
    consequnetial changes as I try to sort out all the callers using
    a pointer to the number of sids.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 6a0176b07da0b416bc9d750ddea92c612849597c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 19:42:01 2010 +1000

    security.idl Add comments
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 2606dfa9a42d19c971f6c04e4030af51b57484bc
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 19:21:53 2010 +1000

    security.idl Update Windows privileges list to Win2008R2
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 3e36aefc66d482e5fd78b8be6c21aa116fe587c8
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 19:20:32 2010 +1000

    s3-privs Only store low bits of luid in privileges table
    
    Samba only uses the low bits, and this makes the code simpler.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 9abfd8fe3bf4fd3bfae34e7b621369d3f67cf73c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 18:38:59 2010 +1000

    s4-privs Add a lookup by index of privilages
    
    Now that privileges are no longer given luid values sequentially,
    we need another way to look them up for enumeration.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit e113af6fb11504a87fd821fb0d77ff855a36e6d5
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 18:38:16 2010 +1000

    privs Add my Copyright
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit d2883ffde92b60c57466146975a3a279b5826c89
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 16:04:53 2010 +1000

    security.idl clarify which privilages are LUID and bitmap values
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 86233ec13527ad93ef3add7d24bd8f781693f2b0
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 16:03:41 2010 +1000

    s3-privs Remove comment already moved to security.idl
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 82f84ff3828a8a4e2249db367b1a38f69190e616
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 16:02:12 2010 +1000

    s3-privs Use constants from security.idl
    
    The values in security.idl have been updated to match these.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit e655e9f6765f951447a36cc3890437f21a13ca0d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 15:56:21 2010 +1000

    s4-privs Remove link between enum sec_privilege and the privilege bitmap
    
    This allows us to set the enum sec_privilege constants to the LUID
    values that are seen from windows, which we need to match, in order
    to preserve the support for the NT Print Migrator tool after a merge
    with the source3/ privileges code.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit fcaa86f4026cac94ed257406cbf4a59947b6029f
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 14:37:00 2010 +1000

    s3-privs Further changes to remove SE_PRIV
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 821b9e61aa057530212438988c204d79f1f70b1d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Aug 27 12:44:35 2010 +1000

    privs Move privilege bitmasks to security.idl
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 99aae4a0ee4f5d069bebe998337d1cdb0c1c390a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 10:35:45 2010 +1000

    s3:privs Change to new host endian neutral privilages tdb format
    
    These values are stored in account_policy.tdb, and the old format,
    using a 128 bit bitmap was not endian neutral.
    
    The previous endian-dependent format was introduced in
    46e5effea948931509283cb84b27007d34b521c8
    replacing a 32 bit number which was used at the time.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit c79336e48a12723a4c7d1d1e377a84b7aac4163d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Aug 26 08:49:28 2010 +1000

    s3:Change SE_PRIV to uint64_t
    
    This removes the SE_PRIV typedef
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 42a98a570b57c3b4625f56179c6697a45427e8a6
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Aug 24 14:47:26 2010 +1000

    s3:privileges Change SE_PRIV to be just a uint64_t
    
    We don't need 128 possible privileges here, as we only use 12.
    
    This reverts some of 46e5effea948931509283cb84b27007d34b521c8
    by Jerry back in 2005, where he introduced the SE_PRIV structure
    to replace the uint32_t used at the time.
    
    Andrew Bartlett
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 libcli/auth/schannel_state_tdb.c                   |    2 +-
 libcli/security/privileges.c                       |  474 ++++++++++++++++++
 libcli/security/privileges.h                       |  103 ++++
 .../security/privileges_private.h                  |   51 +--
 libcli/security/wscript_build                      |    2 +-
 libgpo/gpext/gpext.c                               |    6 +-
 libgpo/gpext/gpext.h                               |    8 +-
 libgpo/gpo.h                                       |   14 +-
 libgpo/gpo_ldap.c                                  |   10 +-
 libgpo/gpo_sec.c                                   |    8 +-
 libgpo/gpo_util.c                                  |   10 +-
 librpc/idl/lsa.idl                                 |   16 -
 librpc/idl/security.idl                            |  162 +++++--
 source3/Makefile.in                                |    2 +-
 source3/auth/auth_util.c                           |    4 +-
 source3/auth/token_util.c                          |   56 ++-
 source3/groupdb/mapping_tdb.c                      |   13 +-
 source3/include/auth.h                             |    2 +-
 source3/include/includes.h                         |    2 +-
 source3/include/privileges.h                       |   98 ----
 source3/include/proto.h                            |  109 ++---
 source3/include/registry.h                         |   12 +-
 source3/include/smb.h                              |    9 +-
 source3/lib/netapi/localgroup.c                    |    4 +-
 source3/lib/privileges.c                           |  288 ++++++------
 source3/lib/privileges_basic.c                     |  515 --------------------
 source3/lib/sharesec.c                             |    2 +-
 source3/lib/smbconf/smbconf_reg.c                  |    4 +-
 source3/lib/util_nttoken.c                         |   29 +-
 source3/lib/util_seaccess.c                        |   10 +-
 source3/lib/util_sid.c                             |   28 +-
 source3/libgpo/gpext/registry.c                    |    4 +-
 source3/libgpo/gpext/scripts.c                     |    6 +-
 source3/libgpo/gpext/security.c                    |    2 +-
 source3/libgpo/gpo_proto.h                         |    8 +-
 source3/libgpo/gpo_reg.c                           |   24 +-
 source3/libsmb/clikrb5.c                           |    4 +-
 source3/passdb/pdb_ldap.c                          |    5 +-
 source3/printing/nt_printing.c                     |    3 +-
 source3/registry/reg_api.c                         |   10 +-
 source3/registry/reg_backend_smbconf.c             |    4 +-
 source3/registry/reg_dispatcher.c                  |    2 +-
 source3/registry/reg_dispatcher.h                  |    2 +-
 source3/registry/reg_util_legacy.c                 |    2 +-
 source3/registry/reg_util_legacy.h                 |    2 +-
 source3/registry/reg_util_token.c                  |    9 +-
 source3/registry/reg_util_token.h                  |    2 +-
 source3/rpc_server/srv_eventlog_nt.c               |    2 +-
 source3/rpc_server/srv_lsa_nt.c                    |  146 ++----
 source3/rpc_server/srv_samr_nt.c                   |  121 +++---
 source3/rpc_server/srv_spoolss_nt.c                |   51 +--
 source3/rpc_server/srv_srvsvc_nt.c                 |   12 +-
 source3/rpc_server/srv_svcctl_nt.c                 |    8 +-
 source3/rpc_server/srv_winreg_nt.c                 |    9 +-
 source3/rpc_server/srv_wkssvc_nt.c                 |    8 +-
 source3/rpcclient/cmd_samr.c                       |    2 +-
 source3/services/services_db.c                     |   10 +-
 source3/smbd/globals.h                             |    2 +-
 source3/smbd/open.c                                |    2 +-
 source3/smbd/posix_acls.c                          |    6 +-
 source3/smbd/sec_ctx.c                             |    2 +-
 source3/smbd/share_access.c                        |    8 +-
 source3/smbd/uid.c                                 |    2 +-
 source3/utils/net_ads_gpo.c                        |    6 +-
 source3/utils/net_proto.h                          |   12 +-
 source3/utils/net_registry.c                       |    2 +-
 source3/utils/net_rpc.c                            |   14 +-
 source3/utils/net_sam.c                            |   27 +-
 source3/winbindd/winbindd_ads.c                    |   14 +-
 source3/winbindd/winbindd_async.c                  |    4 +-
 source3/winbindd/winbindd_getsidaliases.c          |    2 +-
 source3/winbindd/winbindd_pam.c                    |    6 +-
 source3/winbindd/winbindd_proto.h                  |   16 +-
 source3/winbindd/winbindd_util.c                   |    4 +-
 source4/dsdb/samdb/samdb.c                         |    2 -
 source4/dsdb/samdb/samdb_privilege.c               |   10 +-
 source4/libcli/security/privilege.c                |  245 ----------
 source4/libcli/security/security.h                 |    1 +
 source4/libcli/security/security_token.c           |    6 +-
 source4/libcli/security/wscript_build              |    2 +-
 source4/rpc_server/dcesrv_auth.c                   |   10 +-
 source4/rpc_server/lsa/dcesrv_lsa.c                |  102 +++--
 82 files changed, 1363 insertions(+), 1655 deletions(-)
 create mode 100644 libcli/security/privileges.c
 create mode 100644 libcli/security/privileges.h
 copy source4/libcli/raw/rawlpq.c => libcli/security/privileges_private.h (51%)
 delete mode 100644 source3/include/privileges.h
 delete mode 100644 source3/lib/privileges_basic.c
 delete mode 100644 source4/libcli/security/privilege.c


Changeset truncated at 500 lines:

diff --git a/libcli/auth/schannel_state_tdb.c b/libcli/auth/schannel_state_tdb.c
index 4b83a33..09bd407 100644
--- a/libcli/auth/schannel_state_tdb.c
+++ b/libcli/auth/schannel_state_tdb.c
@@ -154,7 +154,7 @@ NTSTATUS schannel_fetch_session_key_tdb(struct tdb_wrap *tdb_sc,
 
 	value = tdb_fetch_bystring(tdb_sc->tdb, keystr);
 	if (!value.dptr) {
-		DEBUG(0,("schannel_fetch_session_key_tdb: Failed to find entry with key %s\n",
+		DEBUG(10,("schannel_fetch_session_key_tdb: Failed to find entry with key %s\n",
 			keystr ));
 		status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
 		goto done;
diff --git a/libcli/security/privileges.c b/libcli/security/privileges.c
new file mode 100644
index 0000000..65000aa
--- /dev/null
+++ b/libcli/security/privileges.c
@@ -0,0 +1,474 @@
+/*
+   Unix SMB/CIFS implementation.
+   Privileges handling functions
+   Copyright (C) Jean François Micouleau	1998-2001
+   Copyright (C) Simo Sorce			2002-2003
+   Copyright (C) Gerald (Jerry) Carter          2005
+   Copyright (C) Michael Adam			2007
+   Copyright (C) Andrew Bartlett		2010
+   Copyright (C) Andrew Tridgell                2004
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ * Basic privileges functions (mask-operations and conversion
+ * functions between the different formats (se_priv, privset, luid)
+ * moved here * from lib/privileges.c to minimize linker deps.
+ *
+ * generally SID- and LUID-related code is left in lib/privileges.c
+ *
+ * some extra functions to hide privs array from lib/privileges.c
+ */
+
+#include "includes.h"
+#include "libcli/security/privileges.h"
+#include "libcli/security/privileges_private.h"
+#include "librpc/gen_ndr/security.h"
+
+/* The use of strcasecmp here is safe, all the comparison strings are ASCII */
+#undef strcasecmp
+
+#define NUM_SHORT_LIST_PRIVS 8
+
+static const struct {
+	enum sec_privilege luid;
+	uint64_t privilege_mask;
+	const char *name;
+	const char *description;
+} privs[] = {
+
+	{SEC_PRIV_MACHINE_ACCOUNT, SEC_PRIV_MACHINE_ACCOUNT_BIT,   "SeMachineAccountPrivilege",	"Add machines to domain"},
+	{SEC_PRIV_TAKE_OWNERSHIP,  SEC_PRIV_TAKE_OWNERSHIP_BIT,    "SeTakeOwnershipPrivilege",    "Take ownership of files or other objects"},
+        {SEC_PRIV_BACKUP,          SEC_PRIV_BACKUP_BIT,            "SeBackupPrivilege",           "Back up files and directories"},
+        {SEC_PRIV_RESTORE,         SEC_PRIV_RESTORE_BIT,           "SeRestorePrivilege",          "Restore files and directories"},
+	{SEC_PRIV_REMOTE_SHUTDOWN, SEC_PRIV_REMOTE_SHUTDOWN_BIT,   "SeRemoteShutdownPrivilege",	"Force shutdown from a remote system"},
+
+	{SEC_PRIV_PRINT_OPERATOR,  SEC_PRIV_PRINT_OPERATOR_BIT,	 "SePrintOperatorPrivilege",	"Manage printers"},
+	{SEC_PRIV_ADD_USERS,       SEC_PRIV_ADD_USERS_BIT,	 "SeAddUsersPrivilege",		"Add users and groups to the domain"},
+	{SEC_PRIV_DISK_OPERATOR,   SEC_PRIV_DISK_OPERATOR_BIT,	 "SeDiskOperatorPrivilege",	"Manage disk shares"},
+
+	/* The list from here on is not displayed in the code from
+	 * source3, and is after index NUM_SHORT_LIST_PRIVS for that
+	 * reason */ 
+
+	{SEC_PRIV_SECURITY,
+	 SEC_PRIV_SECURITY_BIT,
+	 "SeSecurityPrivilege",
+	"System security"},
+
+	{SEC_PRIV_SYSTEMTIME,
+	 SEC_PRIV_SYSTEMTIME_BIT,
+	 "SeSystemtimePrivilege",
+	"Set the system clock"},
+
+	{SEC_PRIV_SHUTDOWN,
+	 SEC_PRIV_SHUTDOWN_BIT,
+	 "SeShutdownPrivilege",
+	"Shutdown the system"},
+
+	{SEC_PRIV_DEBUG,
+	 SEC_PRIV_DEBUG_BIT,
+	 "SeDebugPrivilege",
+	"Debug processes"},
+
+	{SEC_PRIV_SYSTEM_ENVIRONMENT,
+	 SEC_PRIV_SYSTEM_ENVIRONMENT_BIT,
+	 "SeSystemEnvironmentPrivilege",
+	"Modify system environment"},
+
+	{SEC_PRIV_SYSTEM_PROFILE,
+	 SEC_PRIV_SYSTEM_PROFILE_BIT,
+	 "SeSystemProfilePrivilege",
+	"Profile the system"},
+
+	{SEC_PRIV_PROFILE_SINGLE_PROCESS,
+	 SEC_PRIV_PROFILE_SINGLE_PROCESS_BIT,
+	 "SeProfileSingleProcessPrivilege",
+	"Profile one process"},
+
+	{SEC_PRIV_INCREASE_BASE_PRIORITY,
+	 SEC_PRIV_INCREASE_BASE_PRIORITY_BIT,
+	 "SeIncreaseBasePriorityPrivilege",
+	 "Increase base priority"},
+
+	{SEC_PRIV_LOAD_DRIVER,
+	 SEC_PRIV_LOAD_DRIVER_BIT,
+	 "SeLoadDriverPrivilege",
+	"Load drivers"},
+
+	{SEC_PRIV_CREATE_PAGEFILE,
+	 SEC_PRIV_CREATE_PAGEFILE_BIT,
+	 "SeCreatePagefilePrivilege",
+	"Create page files"},
+
+	{SEC_PRIV_INCREASE_QUOTA,
+	 SEC_PRIV_INCREASE_QUOTA_BIT,
+	 "SeIncreaseQuotaPrivilege",
+	"Increase quota"},
+
+	{SEC_PRIV_CHANGE_NOTIFY,
+	 SEC_PRIV_CHANGE_NOTIFY_BIT,
+	 "SeChangeNotifyPrivilege",
+	"Register for change notify"},
+
+	{SEC_PRIV_UNDOCK,
+	 SEC_PRIV_UNDOCK_BIT,
+	 "SeUndockPrivilege",
+	"Undock devices"},
+
+	{SEC_PRIV_MANAGE_VOLUME,
+	 SEC_PRIV_MANAGE_VOLUME_BIT,
+	 "SeManageVolumePrivilege",
+	"Manage system volumes"},
+
+	{SEC_PRIV_IMPERSONATE,
+	 SEC_PRIV_IMPERSONATE_BIT,
+	 "SeImpersonatePrivilege",
+	"Impersonate users"},
+
+	{SEC_PRIV_CREATE_GLOBAL,
+	 SEC_PRIV_CREATE_GLOBAL_BIT,
+	 "SeCreateGlobalPrivilege",
+	"Create global"},
+
+	{SEC_PRIV_ENABLE_DELEGATION,
+	 SEC_PRIV_ENABLE_DELEGATION_BIT,
+	 "SeEnableDelegationPrivilege",
+	"Enable Delegation"},
+};
+
+/* These are rights, not privileges, and should not be confused.  The
+ * names are very similar, and they are quite similar in behaviour,
+ * but they are not to be enumerated as a system-wide list or have an
+ * LUID value */
+static const struct {
+	uint32_t right_mask;
+	const char *name;
+	const char *description;
+} rights[] = {
+	{LSA_POLICY_MODE_INTERACTIVE,
+	 "SeInteractiveLogonRight",
+	"Interactive logon"},
+
+	{LSA_POLICY_MODE_NETWORK,
+	 "SeNetworkLogonRight",
+	"Network logon"},
+
+	{LSA_POLICY_MODE_REMOTE_INTERACTIVE,
+	 "SeRemoteInteractiveLogonRight",
+	"Remote Interactive logon"}
+};
+
+/*
+  return a privilege mask given a privilege id
+*/
+uint64_t sec_privilege_mask(enum sec_privilege privilege)
+{
+	int i;
+	for (i=0;i<ARRAY_SIZE(privs);i++) {
+		if (privs[i].luid == privilege) {
+			return privs[i].privilege_mask;
+		}
+	}
+
+	return 0;
+}
+
+/***************************************************************************
+ put all valid privileges into a mask
+****************************************************************************/
+
+void se_priv_put_all_privileges(uint64_t *privilege_mask)
+{
+	int i;
+	uint32_t num_privs = ARRAY_SIZE(privs);
+
+	*privilege_mask = 0;
+	for ( i=0; i<num_privs; i++ ) {
+		*privilege_mask |= privs[i].privilege_mask;
+	}
+}
+
+/*********************************************************************
+ Lookup the uint64_t bitmask value for a privilege name
+*********************************************************************/
+
+bool se_priv_from_name( const char *name, uint64_t *privilege_mask )
+{
+	int i;
+	uint32_t num_privs = ARRAY_SIZE(privs);
+	for ( i=0; i<num_privs; i++ ) {
+		if ( strequal( privs[i].name, name ) ) {
+			*privilege_mask = privs[i].privilege_mask;
+			return true;
+		}
+	}
+
+	return false;
+}
+
+const char* get_privilege_dispname( const char *name )
+{
+	int i;
+
+	uint32_t num_privs = ARRAY_SIZE(privs);
+
+	if (!name) {
+		return NULL;
+	}
+
+	for ( i=0; i<num_privs; i++ ) {
+		if ( strequal( privs[i].name, name ) ) {
+			return privs[i].description;
+		}
+	}
+
+	return NULL;
+}
+
+/*******************************************************************
+ return the number of elements in the 'short' privlege array (traditional source3 behaviour)
+*******************************************************************/
+
+int num_privileges_in_short_list( void )
+{
+	return NUM_SHORT_LIST_PRIVS;
+}
+
+/****************************************************************************
+ add a privilege to a privilege array
+ ****************************************************************************/
+
+static bool privilege_set_add(PRIVILEGE_SET *priv_set, struct lsa_LUIDAttribute set)
+{
+	struct lsa_LUIDAttribute *new_set;
+
+	/* we can allocate memory to add the new privilege */
+
+	new_set = talloc_realloc(priv_set->mem_ctx, priv_set->set, struct lsa_LUIDAttribute, priv_set->count + 1);
+	if ( !new_set ) {
+		DEBUG(0,("privilege_set_add: failed to allocate memory!\n"));
+		return false;
+	}
+
+	new_set[priv_set->count].luid.high = set.luid.high;
+	new_set[priv_set->count].luid.low = set.luid.low;
+	new_set[priv_set->count].attribute = set.attribute;
+
+	priv_set->count++;
+	priv_set->set = new_set;
+
+	return true;
+}
+
+/*******************************************************************
+*******************************************************************/
+
+bool se_priv_to_privilege_set( PRIVILEGE_SET *set, uint64_t privilege_mask )
+{
+	int i;
+	uint32_t num_privs = ARRAY_SIZE(privs);
+	struct lsa_LUIDAttribute luid;
+
+	luid.attribute = 0;
+	luid.luid.high = 0;
+
+	for ( i=0; i<num_privs; i++ ) {
+		if ((privilege_mask & privs[i].privilege_mask) == 0)
+			continue;
+
+		luid.luid.high = 0;
+		luid.luid.low = privs[i].luid;
+
+		if ( !privilege_set_add( set, luid ) )
+			return false;
+	}
+
+	return true;
+}
+
+/*******************************************************************
+*******************************************************************/
+
+bool privilege_set_to_se_priv( uint64_t *privilege_mask, struct lsa_PrivilegeSet *privset )
+{
+	int i;
+
+	ZERO_STRUCTP( privilege_mask );
+
+	for ( i=0; i<privset->count; i++ ) {
+		uint64_t r;
+
+		/* sanity check for invalid privilege.  we really
+		   only care about the low 32 bits */
+
+		if ( privset->set[i].luid.high != 0 )
+			return false;
+
+		r = sec_privilege_mask(privset->set[i].luid.low);
+		if (r) {
+			*privilege_mask |= r;
+		}
+	}
+
+	return true;
+}
+
+/*
+  map a privilege id to the wire string constant
+*/
+const char *sec_privilege_name(enum sec_privilege privilege)
+{
+	int i;
+	for (i=0;i<ARRAY_SIZE(privs);i++) {
+		if (privs[i].luid == privilege) {
+			return privs[i].name;
+		}
+	}
+	return NULL;
+}
+
+/*
+  map a privilege id to a privilege display name. Return NULL if not found
+
+  TODO: this should use language mappings
+*/
+const char *sec_privilege_display_name(enum sec_privilege privilege, uint16_t *language)
+{
+	int i;
+	for (i=0;i<ARRAY_SIZE(privs);i++) {
+		if (privs[i].luid == privilege) {
+			return privs[i].description;
+		}
+	}
+	return NULL;
+}
+
+/*
+  map a privilege name to a privilege id. Return SEC_PRIV_INVALID if not found
+*/
+enum sec_privilege sec_privilege_id(const char *name)
+{
+	int i;
+	for (i=0;i<ARRAY_SIZE(privs);i++) {
+		if (strcasecmp(privs[i].name, name) == 0) {
+			return privs[i].luid;
+		}
+	}
+	return SEC_PRIV_INVALID;
+}
+
+/*
+  map a 'right' name to it's bitmap value. Return 0 if not found
+*/
+uint32_t sec_right_bit(const char *name)
+{
+	int i;
+	for (i=0;i<ARRAY_SIZE(rights);i++) {
+		if (strcasecmp(rights[i].name, name) == 0) {
+			return rights[i].right_mask;
+		}
+	}
+	return 0;
+}
+
+/*
+  assist in walking the table of privileges - return the LUID (low 32 bits) by index
+*/
+enum sec_privilege sec_privilege_from_index(int idx)
+{
+	if (idx >= 0 && idx<ARRAY_SIZE(privs)) {
+		return privs[idx].luid;
+	}
+	return SEC_PRIV_INVALID;
+}
+
+/*
+  assist in walking the table of privileges - return the string constant by index
+*/
+const char *sec_privilege_name_from_index(int idx)
+{
+	if (idx >= 0 && idx<ARRAY_SIZE(privs)) {
+		return privs[idx].name;
+	}
+	return NULL;
+}
+
+
+
+/*
+  return true if a security_token has a particular privilege bit set
+*/
+bool security_token_has_privilege(const struct security_token *token, enum sec_privilege privilege)
+{
+	uint64_t mask;
+
+	mask = sec_privilege_mask(privilege);
+	if (mask == 0) {
+		return false;
+	}
+
+	if (token->privilege_mask & mask) {
+		return true;
+	}
+	return false;
+}
+
+/*
+  set a bit in the privilege mask
+*/
+void security_token_set_privilege(struct security_token *token, enum sec_privilege privilege)
+{
+	/* Relies on the fact that an invalid privilage will return 0, so won't change this */
+	token->privilege_mask |= sec_privilege_mask(privilege);
+}
+
+/*
+  set a bit in the rights mask
+*/
+void security_token_set_right_bit(struct security_token *token, uint32_t right_bit)
+{
+	token->rights_mask |= right_bit;
+}
+
+void security_token_debug_privileges(int dbg_lev, const struct security_token *token)
+{
+	DEBUGADD(dbg_lev, (" Privileges (0x%16llX):\n",
+			    (unsigned long long) token->privilege_mask));
+
+	if (token->privilege_mask) {
+		int idx = 0;
+		int i = 0;
+		for (idx = 0; idx<ARRAY_SIZE(privs); idx++) {
+			if (token->privilege_mask & privs[idx].privilege_mask) {
+				DEBUGADD(dbg_lev, ("  Privilege[%3lu]: %s\n", (unsigned long)i++,
+						   privs[idx].name));
+			}
+		}
+	}
+	DEBUGADD(dbg_lev, (" Rights (0x%16lX):\n",
+			    (unsigned long) token->rights_mask));
+
+	if (token->rights_mask) {
+		int idx = 0;
+		int i = 0;
+		for (idx = 0; idx<ARRAY_SIZE(rights); idx++) {
+			if (token->rights_mask & rights[idx].right_mask) {
+				DEBUGADD(dbg_lev, ("  Right[%3lu]: %s\n", (unsigned long)i++,
+						   rights[idx].name));
+			}
+		}
+	}
+}
diff --git a/libcli/security/privileges.h b/libcli/security/privileges.h
new file mode 100644
index 0000000..f67a38b
--- /dev/null
+++ b/libcli/security/privileges.h
@@ -0,0 +1,103 @@
+/*


-- 
Samba Shared Repository


More information about the samba-cvs mailing list