Last attempt at upstreaming semodule_disable patch.
This patch allows you to disable/Enable policy modules.
It never seems to get upstreamed. :^(
libsemanage/include/semanage/modules.h +4 -1
@@ -40,10 +40,12 @@ int semanage_module_install_base(semanage_handle_t *, char *module_data, size_t data_len);int semanage_module_install_base_file (semanage_handle_t *,const char *module_name); +int semanage_module_enable (semanage_handle_t *,char *module_name); +int semanage_module_disable (semanage_handle_t *,char *module_name);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 */ +modules, only name and version, and enabled/disabled flag at this time */ typedef struct semanage_module_info semanage_module_info_t ; int semanage_module_list(semanage_handle_t *,
@@ -53,5 +55,6 @@ 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 *); +int semanage_module_get_enabled (semanage_module_info_t *);#endif
libsemanage/src/direct_api.c +116 -3
164 lines not on this page · raw message
libsemanage/src/libsemanage.map +3 -0
@@ -6,10 +6,13 @@ LIBSEMANAGE_1.0 { semanage_module_install; semanage_module_install_file; semanage_module_upgrade; semanage_module_upgrade_file; semanage_module_install_base; semanage_module_install_base_file; + semanage_module_enable; + semanage_module_disable; semanage_module_remove; semanage_module_list; semanage_module_info_datum_destroy; semanage_module_list_nth; semanage_module_get_name; semanage_module_get_version; semanage_select_store; + semanage_module_get_enabled; semanage_reload_policy; semanage_set_reload; semanage_set_rebuild; semanage_user_*; semanage_bool_*; semanage_seuser_*; semanage_iface_*; semanage_port_*; semanage_context_*;
libsemanage/src/module_internal.h +1 -0
@@ -6,6 +6,7 @@ hidden_proto(semanage_module_get_name) hidden_proto(semanage_module_get_version) + hidden_proto(semanage_module_get_enabled) hidden_proto(semanage_module_info_datum_destroy) hidden_proto(semanage_module_list_nth)#endif
libsemanage/src/modules.c +41 -0
53 lines not on this page · raw message
libsemanage/src/modules.h +1 -0
@@ -26,6 +26,7 @@struct semanage_module_info {char *name;/* Key */ char *version; +int enabled; };#endif
libsemanage/src/policy.h +6 -0
@@ -58,6 +58,12 @@ struct semanage_policy_table {/* Upgrade a policy module */ int (*upgrade_file) (struct semanage_handle *,const char *); +/* Enable a policy module */ +int (*enable) (struct semanage_handle *,char *); + +/* Disable a policy module */ +int (*disable) (struct semanage_handle *,char *); +/* Remove a policy module */ int (*remove) (struct semanage_handle *,char *);
libsemanage/src/semanage_store.c +49 -11
96 lines not on this page · raw message
libsemanage/src/semanage_store.h +2 -0
@@ -128,4 +128,6 @@ int semanage_nc_sort(semanage_handle_t * sh,size_t buf_len, char **sorted_buf, size_t * sorted_buf_len); +extern const char *DISABLESTR ; +#endif
policycoreutils/semodule/semodule.8 +6 -0
@@ -35,6 +35,12 @@ upgrade an existing module package, or install if the module does not exist .B \-b,\-\-base=MODULE_PKG install/replace base module package .TP +.B \-d,\-\-disable=MODULE_NAME +disable existing module +.TP +.B \-e,\-\-enable=MODULE_NAME +enable existing module +.TP .B \-r,\-\-remove=MODULE_NAME remove existing module .TP
policycoreutils/semodule/semodule.c +46 -7
109 lines not on this page · raw message
Quoted 3 lines · Daniel J Walsh
This patch allows you to disable/Enable policy modules.
It never seems to get upstreamed. :^(
This is a wonderful feature. It allows me to replace existing modules and to easily modify existing policy.
Quoted 3 lines · Daniel J Walsh
This patch allows you to disable/Enable policy modules.
It never seems to get upstreamed. :^(
Caleb's patch set in December not only moves the policy store and adds priority support, it also allows modules to be enabled and disabled.
The hope is that that patch set as well as the one adding support for source policy modules can be upstreamed sometime in the near future.
Signature · 8 lines
James Carter <[email protected]> National Security Agency -- 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.
Quoted 4 lines · James Carter
Quoted 2 lines · Daniel J Walsh
This patch allows you to disable/Enable policy modules.
Quoted 9 lines
Quoted 2 lines
It never seems to get upstreamed. :^(
Caleb's patch set in December not only moves the policy store and adds priority support, it also allows modules to be enabled and disabled.
The hope is that that patch set as well as the one adding support for source policy modules can be upstreamed sometime in the near future.
Yes I look forward to that patch but that is not going to be used until Fedora 14 at the earliest. Anyone distros working off the current code, could use this patch. But if it is not wanted, I can leave it as a patch for the next 7 years. :^)
--
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.
Quoted 4 lines · James Carter
Quoted 2 lines · Daniel J Walsh
This patch allows you to disable/Enable policy modules.
Quoted 10 lines
Quoted 2 lines
It never seems to get upstreamed. :^(
Caleb's patch set in December not only moves the policy store and adds priority support, it also allows modules to be enabled and disabled.
The hope is that that patch set as well as the one adding support for source policy modules can be upstreamed sometime in the near future.
As long as the user interface stays the same I'm fine with the concept of this patch (the stuff under the covers will change but that is not a problem).
I'll review it and ack or give feedback soon.
Joshua Brindle
Acked-byQuoted 3 lines · Daniel J Walsh
This patch allows you to disable/Enable policy modules.
It never seems to get upstreamed. :^(
Applied the attached patch on top of it, it fixes an implicit declaration warning, makes the errors for disabling or enabling an already disabled or enabled module nicer and fixes a comment.
libsemanage/src/direct_api.c +28 -17
@@ -1304,8 +1304,14 @@ static int semanage_direct_enable(semanage_handle_t * sh, char *module_name) goto cleanup; } base++; -if (memcmp (module_name, base, name_len) ==0 && -strcmp (base + name_len +3 ,DISABLESTR ) ==0 ) { +if (memcmp (module_name, base, name_len) ==0 ) { + +if (strcmp (base + name_len +3 ,DISABLESTR ) !=0 ) { +ERR (sh,"Module %s is already enabled." , module_name); + retval =-2 ; + goto cleanup; + } +int len =strlen (module_filenames[i]) -strlen (DISABLESTR );char *enabled_name =calloc (1 , len+1 );if (!enabled_name) {
@@ -1336,7 +1342,7 @@ static int semanage_direct_enable(semanage_handle_t * sh, char *module_name)return retval; } -/* Enables a module from the sandbox. Returns 0 on success, -1 if out +/* Disables a module from the sandbox. Returns 0 on success, -1 if out * of memory, -2 if module not found or could not be enabled. */ static int semanage_direct_disable (semanage_handle_t * sh,char *module_name) {
@@ -1356,23 +1362,28 @@ static int semanage_direct_disable(semanage_handle_t * sh, char *module_name) goto cleanup; } base++; -if (memcmp (module_name, base, name_len) ==0 && -strcmp (base + name_len,".pp" ) ==0 ) { -char disabled_name[PATH_MAX ]; -if (snprintf (disabled_name,PATH_MAX ,"%s%s" , - module_filenames[i],DISABLESTR ) ==PATH_MAX ) { -ERR (sh,"Could not disable module file %s." , - module_filenames[i]); +if (memcmp (module_name, base, name_len) ==0 ) { +if (strcmp (base + name_len +3 ,DISABLESTR ) ==0 ) { +ERR (sh,"Module %s is already disabled." , module_name); retval =-2 ; goto cleanup; + }else if (strcmp (base + name_len,".pp" ) ==0 ) { +char disabled_name[PATH_MAX ]; +if (snprintf (disabled_name,PATH_MAX ,"%s%s" , + module_filenames[i],DISABLESTR ) ==PATH_MAX ) { +ERR (sh,"Could not disable module file %s." , + module_filenames[i]); + retval =-2 ; + goto cleanup; + } +if (rename (module_filenames[i], disabled_name) ==-1 ) { +ERR (sh,"Could not disable module file %s." , + module_filenames[i]); + retval =-2 ; + } + retval =0 ; + goto cleanup; } -if (rename (module_filenames[i], disabled_name) ==-1 ) { -ERR (sh,"Could not disable module file %s." , - module_filenames[i]); - retval =-2 ; - } - retval =0 ; - goto cleanup; } }ERR (sh,"Module %s was not found." , module_name);
libsemanage/src/semanage_store.h +1 -0
@@ -84,6 +84,7 @@ int semanage_make_sandbox(semanage_handle_t * sh);int semanage_get_modules_names (semanage_handle_t * sh,char ***filenames,int *len); +int semanage_module_enabled (const char *file);/* lock file routines */ int semanage_get_trans_lock (semanage_handle_t * sh);int semanage_get_active_lock (semanage_handle_t * sh);
Quoted 11 lines · Joshua Brindle
Quoted 3 lines · Daniel J Walsh
This patch allows you to disable/Enable policy modules.
It never seems to get upstreamed. :^(
Acked-by Joshua Brindle <[email protected]>Applied the attached patch on top of it, it fixes an implicit declaration warning, makes the errors for disabling or enabling an already disabled or enabled module nicer and fixes a comment.
Merged in libsemanage 2.0.45
--
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.