Skip to contentSkip to conversation

selinux management API

RFC Joshua Brindle 4 participants 13 messages Jul 15, 2005 – Aug 2, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

After some discussion about the newly introduced libsemod and the user management that Red Hat wants to introduce we've tried to come up with an API that all management applications can use, which allow management of many components of SELinux policy, including users, booleans states, and soon ports. It's written with the expectation to add more managed components later, without disturbing the API. We plan on make a new library called libsemanage with this API exported through a shared library and getting rid of libsemod.

This library should seamlessly handle management on systems with the current policy, policy modules or the policy management server. This way the management apps do not need to know what kind of SELinux system is running.

Comments are appreciated.

Joshua Brindle

/* 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_free(). */
typedef struct semanage_handle semanage_handle_t;

/* "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_free(). 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_free(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. */
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. The timeout parameter acts similarly to
* select(2).
*
* 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 with timeout set to zero (i.e.,
* return immediately if unable to obtain). */
int semanage_begin_transaction(semanage_handle_t *,

                               struct timeval *timeout);

/* 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.
*/
int semanage_commit(semanage_handle_t *);

/* META NOTES
*
* All of the below functions exepct 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. The
* particular 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.
*
* The info structs are nebulous at this time. They will have
* accessor functions from which to retrieve particular information.
* The particular accessors are unknown at this time; as design
* progresses those accessors will be decided. Two such proposed
* accessors are:

const char *semanage_module_get_name(semanage_module_info_t *); const char *semanage_module_get_version(semanage_module_info_t *);

*/

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);
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_free(semanage_module_info_t *);

int semanage_user_add(semanage_handle_t *,

                      char *selinux_user_name,
                      char **roles, int num_roles);
int semanage_user_remove(semanage_handle_t *,
                         char *selinux_user_name);
typedef struct semanage_user_info semanage_user_info_t;
int semanage_user_list(semanage_handle_t *,
                       semanage_user_info_t **, int *num_users);

void semanage_user_info_free(semanage_user_info_t *);

int semanage_homedir_add(semanage_handle_t *,

                         char *dirname, char *context);
int semanage_homedir_remove(semanage_handle_t *,
                            char *dirname);
typedef struct semanage_homedir_info semanage_homedir_info_t;
int semanage_homedir_list(semanage_handle_t *,
                          semanage_homedir_info_t **, int *num_homedirs);

void semanage_homedir_info_free(semanage_homedir_info_t *);

int semanage_boolean_set(semanage_handle_t *,

                         char *boolname, int new_bool_value, int permanent);

/* 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 */
typedef struct semanage_boolean_info semanage_boolean_info_t; int semanage_boolean_list(semanage_handle_t *,

                          semanage_boolean_info_t **, int *num_bools);

void semanage_boolean_info_free(semanage_boolean_info_t *);

int semanage_tunable_set(semanage_handle_t *,

                         char *tunablename, int new_tunable_value);
typedef struct semanage_tunable_info semanage_tunable_info_t;
int semanage_tunable_list(semanage_handle_t *,
                          semanage_tunable_info_t **, int *num_tunables);

void semanage_tunable_info_free(semanage_tunable_info_t *);

#1 lore raw

To expand on that, the plan is to make libsemanage (new name for libsemod) become the central access point for anything that manipulates the policy. It would implement things like policy access, configuration files, and transaction guarantees.

Libsepol, which currently handles access to the binary policy file, would become a static backend library for libsemanage and checkpolicy - it would supply common code to work with the policy image.

Libselinux would only contain code necessary for access decisions, and communicating with the kernel policy.

===========================

During a teleconference meeting with Tresys, and Stephen, we discussed Karl's proposal for mapping users to selinux users many-to-one (see previous discussions), and several key points were established:

1) Granularity at the Unix user level (and not just the selinux user level) is useful for implementing the categories for the MCS policy that Redhat is developing. As a result, we plan to move MLS categories from the selinux user config file into the map file (or alternative backend), where they can be associated with users, and not just selinux users. The set of accessible categories will be configured by login programs. Sensitivities would remain associated with selinux users.

2) It is desirable for the selinux libraries to have no knowledge of Unix users, and to only work with SELinux users. So, instead of changing get_ordered_context_list to accomplish the discussed mapping, all callers will be changed to pass in the sel user. API compatibility is not broken, until the fallback to the user_u default user is removed from get_ordered_context_list.

3) It is important to be able to select from multiple backends for storing the user-to-sel_user mappings, just like you can select where to store the users. The current plan is to add a "selusers" field in nsswitch.conf, and write the corresponding support in libnss_files.so. In the course of doing that, we cannot add library dependencies to libnss_files.so, so any parser and related code has to be self-contained.

4) Management of file_contexts is still a point of contention, and I am not clear exactly how the current API as proposed by Tresys will solve this problem.

5) I would also like to see single record query functions implemented by the libsemanage APIs (as opposed to iterating lists), as well as a way to modify records. I think the add methods should take a structure.

6) It is also planned to change the configuration files from being the authoritative data source, to something that's merged into the binary policy on every transaction (not every function call). What this means is, when a user is added, the modifications will be written to the binary file, and load_policy and init will no longer read the config file on startup, and risk failure. The purpose of config files is as the source to be compiled into the binary policy, not loaded on every boot. On upgrades, a utility (genpolicy) would read in all relevant files and modules (Tresys' loadable modules work), and construct the new image.

I hope this summarizes what we've been discussing off-list to some degree. Please make corrections as necessary.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#2 lore raw

I think this summarizes the dialog well Ivan, thanks.

Attached is an updated header file that uses structs for all add/remove/update functions so that arbitrary information can be added to any of them later, accessors would accompany all these structs but aren't in this header.

Joshua

Quoted 63 lines · Ivan Gyurdiev

To expand on that, the plan is to make libsemanage (new name for libsemod) become the central access point for anything that manipulates the policy. It would implement things like policy access, configuration files, and transaction guarantees.

Libsepol, which currently handles access to the binary policy file, would become a static backend library for libsemanage and checkpolicy - it would supply common code to work with the policy image.

Libselinux would only contain code necessary for access decisions, and communicating with the kernel policy.

===========================

During a teleconference meeting with Tresys, and Stephen, we discussed Karl's proposal for mapping users to selinux users many-to-one (see previous discussions), and several key points were established:

1) Granularity at the Unix user level (and not just the selinux user level) is useful for implementing the categories for the MCS policy that Redhat is developing. As a result, we plan to move MLS categories from the selinux user config file into the map file (or alternative backend), where they can be associated with users, and not just selinux users. The set of accessible categories will be configured by login programs. Sensitivities would remain associated with selinux users.

2) It is desirable for the selinux libraries to have no knowledge of Unix users, and to only work with SELinux users. So, instead of changing get_ordered_context_list to accomplish the discussed mapping, all callers will be changed to pass in the sel user. API compatibility is not broken, until the fallback to the user_u default user is removed from get_ordered_context_list.

3) It is important to be able to select from multiple backends for storing the user-to-sel_user mappings, just like you can select where to store the users. The current plan is to add a "selusers" field in nsswitch.conf, and write the corresponding support in libnss_files.so. In the course of doing that, we cannot add library dependencies to libnss_files.so, so any parser and related code has to be self-contained.

4) Management of file_contexts is still a point of contention, and I am not clear exactly how the current API as proposed by Tresys will solve this problem.

5) I would also like to see single record query functions implemented by the libsemanage APIs (as opposed to iterating lists), as well as a way to modify records. I think the add methods should take a structure.

6) It is also planned to change the configuration files from being the authoritative data source, to something that's merged into the binary policy on every transaction (not every function call). What this means is, when a user is added, the modifications will be written to the binary file, and load_policy and init will no longer read the config file on startup, and risk failure. The purpose of config files is as the source to be compiled into the binary policy, not loaded on every boot. On upgrades, a utility (genpolicy) would read in all relevant files and modules (Tresys' loadable modules work), and construct the new image.

Quoted 9 lines

I hope this summarizes what we've been discussing off-list to some degree. Please make corrections as necessary.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

/* 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_free(). */
typedef struct semanage_handle semanage_handle_t;

/* "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_free(). 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_free(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. */
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. The timeout parameter acts similarly to
* select(2).
*
* 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 with timeout set to zero (i.e.,
* return immediately if unable to obtain). */
int semanage_begin_transaction(semanage_handle_t *,

                               struct timeval *timeout);

/* 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.
*/
int semanage_commit(semanage_handle_t *);

/* META NOTES
*
* All of the below functions exepct 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. The
* particular 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.
*
* The info structs are nebulous at this time. They will have
* accessor functions from which to retrieve particular information.
* The particular accessors are unknown at this time; as design
* progresses those accessors will be decided. Two such proposed
* accessors are:

const char *semanage_module_get_name(semanage_module_info_t *); const char *semanage_module_get_version(semanage_module_info_t *);

*/

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);
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_free(semanage_module_info_t *);

typedef struct semanage_user semanage_user_t;

int semanage_user_add(semanage_handle_t *, semanage_user_t *userdata); int semanage_user_remove(semanage_handle_t *, semanage_user_t *userdata); int semanage_user_list(semanage_handle_t *, semanage_user_t **users, int *num_users); void semanage_user_free(semanage_user_t *);

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 *);

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 */
int semanage_boolean_list(semanage_handle_t *, semanage_boolean_t **, int *num_bools); void semanage_boolean_free(semanage_boolean_t *);

typedef struct semanage_tunable semanage_tunable_t;
int semanage_tunable_set(semanage_handle_t *, semanage_tunable_t *tunable); int semanage_tunable_list(semanage_handle_t *, semanage_tunable_t **list, int num_tunables); void semanage_tunable_free(semanage_tunable_t *);

#3 lore raw

int semanage_user_remove(semanage_handle_t *, semanage_user_t *userdata);

You want to remove based on name, not based on a full data structure. Similarly there should be a query function.

void semanage_user_free(semanage_user_t *);

Seems to me like the free functions should be declared with the other handlers for their corresponding opaque data structure (which are not shown here).

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#4 lore raw
Quoted 6 lines · Ivan Gyurdiev

int semanage_user_remove(semanage_handle_t *, semanage_user_t *userdata);

You want to remove based on name, not based on a full data structure. Similarly there should be a query function.

But maybe not in the future, this is meant to be future-proof

and the query functions can be added in, but those are convenience functions and have nothing to do with the design we are proposing here.

Quoted 5 lines

void semanage_user_free(semanage_user_t *);

Seems to me like the free functions should be declared with the other handlers for their corresponding opaque data structure (which are not shown here).

eh?
void semanage_module_info_free(semanage_module_info_t *); void semanage_homedir_free(semanage_homedir_t *); void semanage_boolean_free(semanage_boolean_t *); void semanage_tunable_free(semanage_tunable_t *);

all of the structures have free's

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#5 lore raw
Quoted 8 lines · Joshua Brindle
Quoted 6 lines · Ivan Gyurdiev

int semanage_user_remove(semanage_handle_t *, semanage_user_t *userdata);

You want to remove based on name, not based on a full data structure. Similarly there should be a query function.

But maybe not in the future, this is meant to be future-proof

Hmm....looks strange, but that's a good point.

Quoted 2 lines

and the query functions can be added in, but those are convenience functions and have nothing to do with the design we are proposing here.

You don't seem to like implementation details :)

I think it's all about the implementation details...
the interface is a great guideline, but in the end all of this has to be implemented, and it has to be convenient for the caller..

Quoted 6 lines
Quoted 5 lines

void semanage_user_free(semanage_user_t *);

Seems to me like the free functions should be declared with the other handlers for their corresponding opaque data structure (which are not shown here).

Quoted 7 lines

eh?
void semanage_module_info_free(semanage_module_info_t *); void semanage_homedir_free(semanage_homedir_t *); void semanage_boolean_free(semanage_boolean_t *); void semanage_tunable_free(semanage_tunable_t *);

all of the structures have free's

Yes, I think they should be moved into individual headers for each structure, where the accessors, and constructor are defined... wherever the constructor is, the free() should accompany it.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#6 lore raw
Quoted 8 lines · Ivan Gyurdiev
Quoted 7 lines · Joshua Brindle
Quoted 6 lines · Ivan Gyurdiev

int semanage_user_remove(semanage_handle_t *, semanage_user_t *userdata);

You want to remove based on name, not based on a full data structure. Similarly there should be a query function.

Quoted 9 lines
Quoted 1 line

But maybe not in the future, this is meant to be future-proof

Hmm....looks strange, but that's a good point.

Quoted 2 lines

and the query functions can be added in, but those are convenience functions and have nothing to do with the design we are proposing here.

You don't seem to like implementation details :)

not during design

Quoted 4 lines

I think it's all about the implementation details...
the interface is a great guideline, but in the end all of this has to be implemented, and it has to be convenient for the caller..

thats fine but we want a future proof, stable, scalable API, the implementation details will be handled at implementation time.

Quoted 12 lines
Quoted 12 lines
Quoted 5 lines

void semanage_user_free(semanage_user_t *);

Seems to me like the free functions should be declared with the other handlers for their corresponding opaque data structure (which are not shown here).

eh?
void semanage_module_info_free(semanage_module_info_t *); void semanage_homedir_free(semanage_homedir_t *); void semanage_boolean_free(semanage_boolean_t *); void semanage_tunable_free(semanage_tunable_t *);

Quoted 5 lines
Quoted 1 line

all of the structures have free's

Yes, I think they should be moved into individual headers for each structure, where the accessors, and constructor are defined... wherever the constructor is, the free() should accompany it.

Ah, I get what you mean now. The accessors, constructors, free's, etc will be in this header since it will be the single exported API file for libsemanage. They just weren't added to this because they are implementation details :)

Joshua

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#7 lore raw
Quoted 8 lines
Quoted 5 lines

I think it's all about the implementation details...
the interface is a great guideline, but in the end all of this has to be implemented, and it has to be convenient for the caller..

thats fine but we want a future proof, stable, scalable API, the implementation details will be handled at implementation time.

I was under the impression that you'd want me to help with the implementation... I already have code that does precisely this. With some modification, it can be made to work on libsemanage.

====

Anyway, I still don't understand how you plan to do the template expansion - you're treating that as an implementation detail, and I think you shouldn't overlook this concern, because it's not clear how it will work.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#8 lore raw
In reply to Joshua Brindle
Quoted 3 lines · Joshua Brindle

I think this summarizes the dialog well Ivan, thanks.

Attached is an updated header file that uses structs for all

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);

Is the plan to support binary or text modules for these operations? If binary modules then module_data should have type void *.

Also more liberal use of const would be good. I expect that the above functions will not change the module data so const void * would probably be the correct type. I realise that this is still in the design phase, but I think that we are ready to design which data gets modified by the library code and which doesn't.

Signature · 10 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#9 lore raw
Quoted 9 lines · Russell Coker
Quoted 5 lines · Joshua Brindle

I think this summarizes the dialog well Ivan, thanks.

Attached is an updated header file that uses structs for all

Quoted 11 lines

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);

Is the plan to support binary or text modules for these operations? If binary modules then module_data should have type void *.

Yea, I'd like to make this able to handle the monolithic policy and modules but I haven't figured out exactly how that is going to work yet.

I think that for the monolithic case you may be limited to only the special modifiers (eg., users, ports, booleans, etc) and so this would not apply to it, I'm not quite sure yet though.

Quoted 3 lines

Also more liberal use of const would be good. I expect that the above functions will not change the module data so const void * would probably be the correct type. I realise that this is still in the design phase, but I think that we are ready to design which data gets modified by the library code and which doesn't.

sure but only if it doesn't ripple throughout the rest of the library

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#10 lore raw
Quoted 7 lines · Joshua Brindle
Quoted 5 lines

Also more liberal use of const would be good. I expect that the above functions will not change the module data so const void * would probably be the correct type. I realise that this is still in the design phase, but I think that we are ready to design which data gets modified by the library code and which doesn't.

sure but only if it doesn't ripple throughout the rest of the library

It would only ripple throughout the rest of the library if necessary.

If a function has a const parameter and then passes that parameter to another function then either the second function needs a const parameter or the data must be copied. This is a feature not a bug!

When my code passes data to a library function via a const pointer then I know that (as long as there are no bugs in the library) the data will not be modified. If the pointer is not const then it may be modified and my program has to correctly manage the situation where it is changed.

If the code is designed well then using const in all the places that the design suggests it will not be difficult or complex. If the code is badly designed then it needs a better design. In either case there is no reason for not using const!

Signature · 9 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#11 lore raw
In reply to Russell Coker
Quoted 9 lines · Russell Coker

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);

Is the plan to support binary or text modules for these operations? If binary modules then module_data should have type void *.

libsemanage will handle only binary modules. The caller is assumed to have invoked checkmodule beforehand.

The reason why these pointers are 'char' is that we want byte-addressible memory. It is true that using 'char' can be misleading, but alas C is deficient here.

Signature · 7 lines
Jason Tang / [email protected]


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#12 lore raw
Quoted 9 lines · Jason Tang
Quoted 2 lines

Is the plan to support binary or text modules for these operations? If binary modules then module_data should have type void *.

libsemanage will handle only binary modules. The caller is assumed to have invoked checkmodule beforehand.

The reason why these pointers are 'char' is that we want byte-addressible memory. It is true that using 'char' can be misleading, but alas C is deficient here.

In what situations is void * not byte addressable?

System calls such as send(2) use void * on Linux (char * on Solaris), are you saying that you can't send arbitrary data down a socket?

Signature · 9 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.