All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] semanage-functionality 4/17
@ 2005-09-27 12:46 Karl MacMillan
  2005-09-27 16:54 ` Ivan Gyurdiev
  2005-09-28 14:52 ` Stephen Smalley
  0 siblings, 2 replies; 18+ messages in thread
From: Karl MacMillan @ 2005-09-27 12:46 UTC (permalink / raw)
  To: selinux; +Cc: 'Joshua Brindle'

[-- Attachment #1: Type: text/plain, Size: 144 bytes --]

This patch adds semanage.h - this is the new public interface for
libsemanage.

------
Karl MacMillan
Tresys Technology
http://www.tresys.com 


[-- Attachment #2: libsemanage_include_semanage_semanage.h.diff --]
[-- Type: application/octet-stream, Size: 9065 bytes --]

diff -purN -x .svn libsemanage/include/semanage/semanage.h libsemanage/include/semanage/semanage.h
--- libsemanage/include/semanage/semanage.h	1969-12-31 19:00:00.000000000 -0500
+++ libsemanage/include/semanage/semanage.h	2005-09-26 09:59:04.000000000 -0400
@@ -0,0 +1,203 @@
+/* Authors: Joshua Brindle  <jbrindle@tresys.com>
+ *	    Jason Tang	    <jtang@tresys.com>
+ *
+ * Copyright (C) 2005 Tresys Technology, LLC
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library 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
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef SEMANAGE_H
+#define SEMANAGE_H
+
+/* This #include needed to get struct timeval. */
+#include <sys/time.h>
+
+/* All accesses with semanage is through a "semanage_handle".  This
+ * handler may be with the monolithic policy, directly to a module
+ * store, or with a policy management server.  The handler represents
+ * a persistent connection to that policy manager.  It is created
+ * through a semanage_connect() call and must be afterwards
+ * deallocated with semanage_handle_destroy(). */
+typedef struct semanage_handle semanage_handle_t;
+
+/* Initialize the library - this needs to be called first. This loads
+ * any defaults from the configuration files and performs any other
+ * needed initialization.
+ * 
+ * returns:
+ *	0	success
+ *	-1	general error
+ *	-2	error parsing configuration files
+ *
+ * WARNING: This function is NOT thread-safe.
+ */
+int semanage_init(void);
+
+/* "Connect" to a manager, as specified in the file
+ * /etc/selinux/semanage.conf.	This function always allocates a new
+ * semanage_handle_t and assigns it to the passed reference pointer.
+ * The caller is later responsible for deallocating the pointer by
+ * calling semanage_handle_destroy().  If the connect fails then this
+ * function returns a negative value, else it returns zero.
+ */
+int semanage_connect(semanage_handle_t **);
+
+/* Disconnect from the manager given by the handle.  If already
+ * disconnected then this function does nothing.  Return 0 if
+ * disconnected properly or already disconnected, negative value on
+ * error. */
+int semanage_disconnect(semanage_handle_t *);
+
+/* Deallocate all space associated with a semanage_handle_t, including
+ * the pointer itself.	CAUTION: this function does not disconnect
+ * from the manager; be sure that a semanage_disconnect() was
+ * previously called. */
+void semanage_handle_destroy(semanage_handle_t *);
+
+/* Return a string describing the most recently encountered error
+ * associated with a semanage_handle_t.	 The returned string must not
+ * be modified by the caller.  Be aware that this string is not
+ * persistent; future calls to this library may alter the buffer
+ * contents, so make a copy of it if necessary.
+ */
+const char *semanage_strerror(semanage_handle_t *);
+
+
+/* Attempt to obtain a transaction lock on the manager.	 If another
+ * process has the lock then this function may block, depending upon
+ * the timeout value in the handle.
+ *
+ * Note that if the semanage_handle has not yet obtained a transaction
+ * lock whenever a writer function is called, there will be an
+ * implicit call to this function. */
+int semanage_begin_transaction(semanage_handle_t *);
+
+/* Attempt to commit all changes since this transaction began.	If the
+ * commit is successful then increment the "policy sequence number"
+ * and then release the transaction lock.  Return that policy number
+ * afterwards, or -1 on error.
+ */
+int semanage_commit(semanage_handle_t *);
+
+
+/* META NOTES
+ *
+ * All of the below functions expect a semanage_handle as its first
+ * parameter.  If an error occurs then the function returns a negative
+ * value.  Call semanage_strerror() to retrieve a string that fully
+ * describes the error.
+ *
+ * For all functions a non-negative number indicates success. For query 
+ * fucntions a >=0 returned value is the "policy sequence number".  This
+ * number keeps tracks of policy revisions and is used to detect if
+ * one semanage client has committed policy changes while another is
+ * still connected.
+ */
+
+/* High level module management functions. These are all part of
+ * a transaction  
+ */
+
+int semanage_module_install(semanage_handle_t *,
+			    char *module_data, size_t data_len);
+int semanage_module_upgrade(semanage_handle_t *,
+			    char *module_data, size_t data_len);
+int semanage_module_install_base(semanage_handle_t *,
+				 char *module_data, size_t data_len);
+int semanage_module_remove(semanage_handle_t *,
+			   char *module_name);
+
+
+/* semanage_module_info is for getting information on installed
+   modules, only name and version at this time */
+typedef struct semanage_module_info semanage_module_info_t;
+
+int semanage_module_list(semanage_handle_t *,
+			 semanage_module_info_t **, int *num_modules);
+void semanage_module_info_datum_destroy(semanage_module_info_t *);
+semanage_module_info_t *semanage_module_list_nth(semanage_module_info_t *list, int n);
+const char *semanage_module_get_name(semanage_module_info_t *);
+const char *semanage_module_get_version(semanage_module_info_t *);
+
+/* accessors for mls and role support structs */
+typedef struct semanage_mls semanage_mls_t;
+typedef struct semanage_role semanage_role_t;
+
+const char* semanage_mls_get_range(semanage_mls_t *);
+const char* semanage_mls_get_level(semanage_mls_t *);
+
+int semanage_mls_set_range(semanage_mls_t *);
+int semanage_mls_set_level(semanage_mls_t *);
+
+const char* semanage_role_get_name(semanage_role_t *);
+
+int semanage_role_set_name(semanage_role_t *, char *name);
+
+/* semanage_user represents selinux users in the policy */
+typedef struct semanage_user semanage_user_t;
+
+/* semanage_user management functions */
+int semanage_user_init(semanage_handle_t **);
+int semanage_user_add(semanage_handle_t *, semanage_user_t *userdata);
+int semanage_user_remove(semanage_handle_t *, char *userdata);
+int semanage_user_list(semanage_handle_t *, semanage_user_t **users, int *num_users);
+int semanage_user_change(semanage_handle_t *, semanage_user_t *userdata, char *key);
+void semanage_user_free(semanage_user_t *);
+
+/* semanage_user accessor functions */
+const char* semanage_user_get_name(semanage_user_t *);
+int semanage_user_get_roles(semanage_user_t *, semanage_role_t **roles, int num_roles);
+int semanage_user_get_mls(semanage_user_t *, semanage_mls_t *mls);
+ 
+int semanage_user_set_name(semanage_user_t *, char *name);
+int semanage_user_set_roles(semanage_user_t *, semanage_role_t **roles, int num_roles);
+int semanage_user_set_mls(semanage_user_t *, semanage_mls_t *mls);
+
+/* semanage_homedir manages selinux_user->directory maps so that 
+   we can expand home directory contexts */
+typedef struct semanage_homedir semanage_homedir_t;
+
+int semanage_homedir_add(semanage_handle_t *, semanage_homedir_t *homedir);
+int semanage_homedir_remove(semanage_handle_t *, semanage_homedir_t *homedir);
+int semanage_homedir_list(semanage_handle_t *, semanage_homedir_t **, int *num_homedirs);
+void semanage_homedir_free(semanage_homedir_t *);
+
+/* semanage_homedir accessors */
+
+const char* semanage_homedir_get_user(semanage_handle_t *);
+const char* semanage_homedir_get_path(semanage_handle_t *);
+
+int semanage_homedir_set_user(semanage_handle_t *, char *user);
+int semanage_homedir_set_path(semanage_handle_t *, char *path); 
+
+/* semanage_boolean manages default boolean states */
+typedef struct semanage_boolean semanage_boolean_t;
+
+int semanage_boolean_set(semanage_handle_t *, semanage_boolean_t *bool);
+/* if for some reason the caller does not have permission to read a
+ * particular boolean value, it will not be added to the returned
+ * array -- only if something enforces that (eg. policy server) */
+int semanage_boolean_list(semanage_handle_t *, semanage_boolean_t **, int *num_bools);
+void semanage_boolean_free(semanage_boolean_t *);
+
+/* semanage_boolean accessors */
+
+const char *semanage_boolean_get_name(semanage_boolean_t *);
+char semanage_boolean_get_state(semanage_boolean_t *);
+
+int semanage_boolean_set_name(semanage_boolean_t *, char *name);
+int semanage_boolean_set_state(semanage_boolean_t *, char state);
+
+#endif

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2005-09-30 13:47 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-27 12:46 [PATCH] semanage-functionality 4/17 Karl MacMillan
2005-09-27 16:54 ` Ivan Gyurdiev
2005-09-27 20:08   ` Stephen Smalley
2005-09-27 20:48     ` Ivan Gyurdiev
2005-09-27 20:57       ` Stephen Smalley
2005-09-30 13:02         ` Ivan Gyurdiev
2005-09-30 13:47           ` Karl MacMillan
2005-09-28 15:21     ` Karl MacMillan
2005-09-27 20:38   ` Karl MacMillan
2005-09-27 21:06     ` Ivan Gyurdiev
2005-09-27 21:10     ` Stephen Smalley
2005-09-28 15:15       ` Karl MacMillan
2005-09-28 14:52 ` Stephen Smalley
2005-09-28 15:21   ` Ivan Gyurdiev
2005-09-28 15:33     ` Karl MacMillan
2005-09-28 15:31   ` Karl MacMillan
2005-09-28 15:59     ` Stephen Smalley
2005-09-28 16:24       ` Karl MacMillan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.