libcli: Add security_token_system_privilege().
authorAndreas Schneider <asn@samba.org>
Tue, 6 Aug 2013 11:26:53 +0000 (13:26 +0200)
committerGünther Deschner <gd@samba.org>
Tue, 6 Aug 2013 12:41:58 +0000 (14:41 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
libcli/security/privileges.c
libcli/security/privileges.h

index adb67c19f2d62c1f2fa7eec158a1748305c468da..d2731c3dd05845151d298996740d14aae56a2fab 100644 (file)
@@ -422,6 +422,19 @@ bool security_token_has_privilege(const struct security_token *token, enum sec_p
        return false;
 }
 
+bool security_token_system_privilege(const struct security_token *token)
+{
+       if (token == NULL) {
+               return false;
+       }
+
+       if (token->privilege_mask == (uint64_t)~0) {
+               return true;
+       }
+
+       return false;
+}
+
 /*
   set a bit in the privilege mask
 */
index a65dbdfcd7727440bfe0f3c71ad00033826a6d68..eb3ab5e784de96034990cbfb0306eab350f4cbf1 100644 (file)
@@ -89,6 +89,16 @@ const char *sec_privilege_name_from_index(int idx);
 */
 bool security_token_has_privilege(const struct security_token *token, enum sec_privilege privilege);
 
+
+/**
+ * @brief Check if the security token has system privileges.
+ *
+ * @param[in]  token    The token to check.
+ *
+ * @return              True if the token has system privileges, false if not.
+ */
+bool security_token_system_privilege(const struct security_token *token);
+
 /*
   set a bit in the privilege mask
 */