Missing rsbac_auth_f_capset_member function

Tristan Cacqueray <[email protected]>
Newsgroups gmane.linux.rsbac
Organization Global Computer Management SARL
Message-ID <20101010195415.5831fb4c@bacon>
Hi list !

Just out of curiosity, auth_data_structures features a function called 
rsbac_auth_f_capset_member that return truth value if a given rsbac
user id is present in a process capset.
Any reason why such function does not exist for a file capset ?

Well, as discuss yesterday, a draft patch for rsbac_auth_f_capset_member
is attached.


Best regards!
-- 
Tristan de Cacqueray
Global Computer Management SARL
43 rue Perronet - 92200 Neuilly - France
[email protected]

  
Please, consider the environment - do you need to print this email?

Confidentiality Notice: This e-mail message, including any attachments,
is the property of Global Computer Management SARL, and is intended
solely for business purposes. This email message may contain
confidential and privileged information, the unauthorized review, copy,
use, disclosure, or distribution of which is prohibited.

_______________________________________________
rsbac mailing list
[email protected]
http://www.rsbac.org/mailman/listinfo/rsbac
0001-rsbac_auth_f_capset_member-function-added-to-auth_da.patch (text/x-patch, 2.8 KB)
From 28e6762f07e4e1ee46c5232ab2dfeb8bcf0c55b1 Mon Sep 17 00:00:00 2001
From: Tristan Cacqueray <[email protected]>
Date: Sun, 10 Oct 2010 16:45:55 +0200
Subject: [PATCH] rsbac_auth_f_capset_member function added to auth_data_structures.c


Signed-off-by: Tristan Cacqueray <[email protected]>
---
 include/rsbac/auth.h                         |    7 ++++
 rsbac/data_structures/auth_data_structures.c |   41 ++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/include/rsbac/auth.h b/include/rsbac/auth.h
index b213a03..2990460 100644
--- a/include/rsbac/auth.h
+++ b/include/rsbac/auth.h
@@ -112,6 +112,13 @@ rsbac_boolean_t  rsbac_auth_p_capset_member(rsbac_pid_t pid,
                                     enum rsbac_auth_cap_type_t cap_type,
                                     rsbac_uid_t member);
 
+/* rsbac_auth_f_capset_member */
+/* Return truth value, whether member is in set */
+
+rsbac_boolean_t rsbac_auth_f_capset_member(struct rsbac_fs_file_t file,
+                                   enum rsbac_auth_cap_type_t cap_type,
+                                   rsbac_uid_t member);
+
 /* rsbac_auth_remove_p_capset */
 /* Remove a full set. After this call the given id can only be used for */
 /* creating a new set, anything else returns an error.                  */
diff --git a/rsbac/data_structures/auth_data_structures.c b/rsbac/data_structures/auth_data_structures.c
index 98659db..88a6b25 100644
--- a/rsbac/data_structures/auth_data_structures.c
+++ b/rsbac/data_structures/auth_data_structures.c
@@ -3765,6 +3765,47 @@ rsbac_boolean_t rsbac_auth_p_capset_member(rsbac_pid_t pid,
 	return result;
 }
 
+/* rsbac_auth_capset_member */
+/* Return truth value, whether member is in set */
+
+rsbac_boolean_t rsbac_auth_f_capset_member(struct rsbac_fs_file_t file,
+					   enum rsbac_auth_cap_type_t
+					   cap_type, rsbac_uid_t member)
+{
+	rsbac_boolean_t result;
+	struct rsbac_auth_cap_range_t * k_caplist;
+	rsbac_time_t * k_ttllist;
+	int count, i;
+	rsbac_list_ta_number_t ta_number = 0;
+
+	count = rsbac_auth_get_f_caplist(ta_number, file, cap_type, &k_caplist, &k_ttllist);
+
+	result = FALSE;
+	if(count >= 0) {
+		for (i = 0; i < count; i++) {
+			if (k_caplist[i].first == k_caplist[i].last) {
+				if (k_caplist[i].first == member)
+					result = TRUE;
+			} else {
+				if (k_caplist[i].first <= member && member <= k_caplist[i].last)
+					result = TRUE;
+			}
+		}
+		rsbac_kfree(k_caplist);
+		rsbac_kfree(k_ttllist);
+	} else {
+		char *tmp;
+
+		tmp = rsbac_kmalloc(RSBAC_MAXNAMELEN);
+		rsbac_printk(KERN_WARNING "rsbac_auth_f_capset_member(): auth_get_f_caplist failled with error %s!",
+			get_error_name(tmp, count)
+		);
+		rsbac_kfree(tmp);
+	}
+
+	return result;
+}
+
 /* rsbac_auth_remove_capset */
 /* Remove a full set. For cleanup, if object is deleted. */
 /* To empty an existing set use rsbac_auth_clear_capset. */
-- 
1.7.3.1
signature.asc (application/pgp-signature, 230 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)

iF4EAREIAAYFAkyx/c0ACgkQRqLhr4IfPxObbAEA3g4VFVVZAOyNUi7XNxPg3rm/
mQ9XnSX7bTQIMRwRMyYA/1Et8hfwOF7n6A3RN1pd7XF+cRicbZplu5DhLSaJYrYv
=aVhn
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.