From: <ssm...@us...> - 2007-02-20 13:53:18
|
Revision: 2240 http://svn.sourceforge.net/selinux/?rev=2240&view=rev Author: ssmalley Date: 2007-02-20 05:53:16 -0800 (Tue, 20 Feb 2007) Log Message: ----------- ported r2232 through r2239 from trunk. Modified Paths: -------------- branches/stable/1_0/checkpolicy/policy_parse.y branches/stable/1_0/libselinux/include/selinux/avc.h branches/stable/1_0/libselinux/man/man3/avc_add_callback.3 branches/stable/1_0/libselinux/src/avc.c branches/stable/1_0/libselinux/src/avc_internal.c branches/stable/1_0/libselinux/src/avc_internal.h branches/stable/1_0/libselinux/src/avc_sidtab.c branches/stable/1_0/libselinux/src/selinux_netlink.h branches/stable/1_0/libsemanage/Makefile branches/stable/1_0/libsemanage/src/direct_api.c branches/stable/1_0/libsemanage/src/semanage_store.c branches/stable/1_0/libsemanage/src/semanage_store.h branches/stable/1_0/policycoreutils/semanage/seobject.py branches/stable/1_0/policycoreutils/setfiles/setfiles.c Modified: branches/stable/1_0/checkpolicy/policy_parse.y =================================================================== --- branches/stable/1_0/checkpolicy/policy_parse.y 2007-02-20 13:43:22 UTC (rev 2239) +++ branches/stable/1_0/checkpolicy/policy_parse.y 2007-02-20 13:53:16 UTC (rev 2240) @@ -929,11 +929,6 @@ yyerror("no class name for class definition?"); return -1; } - if (id_has_dot(id)) { - free(id); - yyerror("class identifiers may not contain periods"); - return -1; - } datum = (class_datum_t *) malloc(sizeof(class_datum_t)); if (!datum) { yyerror("out of memory"); Modified: branches/stable/1_0/libselinux/include/selinux/avc.h =================================================================== --- branches/stable/1_0/libselinux/include/selinux/avc.h 2007-02-20 13:43:22 UTC (rev 2239) +++ branches/stable/1_0/libselinux/include/selinux/avc.h 2007-02-20 13:53:16 UTC (rev 2240) @@ -304,11 +304,11 @@ * -%1 if insufficient memory exists to add the callback. */ int avc_add_callback(int (*callback) - (u_int32_t event, security_id_t ssid, + (uint32_t event, security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms, access_vector_t * out_retained), - u_int32_t events, security_id_t ssid, + uint32_t events, security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms); Modified: branches/stable/1_0/libselinux/man/man3/avc_add_callback.3 =================================================================== --- branches/stable/1_0/libselinux/man/man3/avc_add_callback.3 2007-02-20 13:43:22 UTC (rev 2239) +++ branches/stable/1_0/libselinux/man/man3/avc_add_callback.3 2007-02-20 13:53:16 UTC (rev 2240) @@ -9,7 +9,7 @@ .br .B #include <selinux/avc.h> .sp -.BI "int avc_add_callback(int (*" callback ")(u_int32_t " event , +.BI "int avc_add_callback(int (*" callback ")(uint32_t " event , .in +\w'int avc_add_callback(int (*callback)('u .BI "security_id_t " ssid , .br @@ -22,7 +22,7 @@ .BI "access_vector_t *" out_retained ")," .in .in +\w'int avc_add_callback('u -.BI "u_int32_t " events ", security_id_t " ssid , +.BI "uint32_t " events ", security_id_t " ssid , .br .BI "security_id_t " tsid ", security_class_t " tclass , .br Modified: branches/stable/1_0/libselinux/src/avc.c =================================================================== --- branches/stable/1_0/libselinux/src/avc.c 2007-02-20 13:43:22 UTC (rev 2239) +++ branches/stable/1_0/libselinux/src/avc.c 2007-02-20 13:53:16 UTC (rev 2240) @@ -49,9 +49,9 @@ } }; static const struct av_perm_to_string { - u16 tclass; - u16 nameidx; - u32 value; + uint16_t tclass; + uint16_t nameidx; + uint32_t value; } av_perm_to_string[] = { #define S_(c, v, s) { c, offsetof(union av_perm_to_string_data, L1(__LINE__)), v }, #include "av_perm_to_string.h" @@ -77,7 +77,7 @@ #undef S_ } }; -static const u16 class_to_string[] = { +static const uint16_t class_to_string[] = { #define S_(s) offsetof(union class_to_string_data, L1(__LINE__)), #include "class_to_string.h" #undef S_ @@ -112,7 +112,7 @@ struct { #define TB_(s) struct { #define TE_(s) } s##_part; -#define S_(s) u16 L1(__LINE__) +#define S_(s) uint16_t L1(__LINE__) #define L1(l) L2(l) #define L2(l) field_##l; #include "common_perm_to_string.h" @@ -122,7 +122,7 @@ #undef L1 #undef L2 }; - u16 data[0]; + uint16_t data[0]; } common_perm_to_string = { { #define TB_(s) { @@ -140,11 +140,11 @@ }; static const struct av_inherit { - u16 tclass; - u16 common_pts_idx; - u32 common_base; + uint16_t tclass; + uint16_t common_pts_idx; + uint32_t common_base; } av_inherit[] = { -#define S_(c, i, b) { c, offsetof(union common_perm_to_string, common_##i##_perm_to_string_part)/sizeof(u16), b }, +#define S_(c, i, b) { c, offsetof(union common_perm_to_string, common_##i##_perm_to_string_part)/sizeof(uint16_t), b }, #include "av_inherit.h" #undef S_ }; @@ -168,17 +168,17 @@ struct avc_cache { struct avc_node *slots[AVC_CACHE_SLOTS]; - u_int32_t lru_hint; /* LRU hint for reclaim scan */ - u_int32_t active_nodes; - u_int32_t latest_notif; /* latest revocation notification */ + uint32_t lru_hint; /* LRU hint for reclaim scan */ + uint32_t active_nodes; + uint32_t latest_notif; /* latest revocation notification */ }; struct avc_callback_node { - int (*callback) (u_int32_t event, security_id_t ssid, + int (*callback) (uint32_t event, security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms, access_vector_t * out_retained); - u_int32_t events; + uint32_t events; security_id_t ssid; security_id_t tsid; security_class_t tclass; @@ -402,7 +402,7 @@ { struct avc_node *prev, *cur; int try; - u_int32_t hvalue; + uint32_t hvalue; hvalue = avc_cache.lru_hint; for (try = 0; try < 2; try++) { @@ -795,8 +795,8 @@ */ static void avc_dump_av(security_class_t tclass, access_vector_t av) { - const u16 *common_pts_idx = 0; - u_int32_t common_base = 0, perm; + const uint16_t *common_pts_idx = 0; + uint32_t common_base = 0, perm; unsigned int i, i2; if (av == 0) { @@ -1006,12 +1006,12 @@ return rc; } -int avc_add_callback(int (*callback) (u_int32_t event, security_id_t ssid, +int avc_add_callback(int (*callback) (uint32_t event, security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms, access_vector_t * out_retained), - u_int32_t events, security_id_t ssid, + uint32_t events, security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms) { @@ -1041,7 +1041,7 @@ return (x == y || x == SECSID_WILD || y == SECSID_WILD); } -static inline void avc_update_node(u_int32_t event, struct avc_node *node, +static inline void avc_update_node(uint32_t event, struct avc_node *node, access_vector_t perms) { switch (event) { @@ -1067,7 +1067,7 @@ } } -static int avc_update_cache(u_int32_t event, security_id_t ssid, +static int avc_update_cache(uint32_t event, security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms) { @@ -1105,10 +1105,10 @@ * This should not be called directly; use the individual event * functions instead. */ -static int avc_control(u_int32_t event, security_id_t ssid, +static int avc_control(uint32_t event, security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms, - u_int32_t seqno, access_vector_t * out_retained) + uint32_t seqno, access_vector_t * out_retained) { struct avc_callback_node *c; access_vector_t tretained = 0, cretained = 0; @@ -1167,7 +1167,7 @@ */ int avc_ss_grant(security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms, - u_int32_t seqno) + uint32_t seqno) { return avc_control(AVC_CALLBACK_GRANT, ssid, tsid, tclass, perms, seqno, 0); @@ -1188,7 +1188,7 @@ */ int avc_ss_try_revoke(security_id_t ssid, security_id_t tsid, security_class_t tclass, - access_vector_t perms, u_int32_t seqno, + access_vector_t perms, uint32_t seqno, access_vector_t * out_retained) { return avc_control(AVC_CALLBACK_TRY_REVOKE, @@ -1208,7 +1208,7 @@ */ int avc_ss_revoke(security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms, - u_int32_t seqno) + uint32_t seqno) { return avc_control(AVC_CALLBACK_REVOKE, ssid, tsid, tclass, perms, seqno, 0); @@ -1218,7 +1218,7 @@ * avc_ss_reset - Flush the cache and revalidate migrated permissions. * @seqno: policy sequence number */ -int avc_ss_reset(u_int32_t seqno) +int avc_ss_reset(uint32_t seqno) { int rc; @@ -1243,7 +1243,7 @@ */ int avc_ss_set_auditallow(security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms, - u_int32_t seqno, u_int32_t enable) + uint32_t seqno, uint32_t enable) { if (enable) return avc_control(AVC_CALLBACK_AUDITALLOW_ENABLE, @@ -1264,7 +1264,7 @@ */ int avc_ss_set_auditdeny(security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms, - u_int32_t seqno, u_int32_t enable) + uint32_t seqno, uint32_t enable) { if (enable) return avc_control(AVC_CALLBACK_AUDITDENY_ENABLE, @@ -1303,7 +1303,7 @@ access_vector_t string_to_av_perm(security_class_t tclass, const char *s) { - const u16 *common_pts_idx = 0; + const uint16_t *common_pts_idx = 0; access_vector_t perm, common_base = 0; unsigned int i; @@ -1340,7 +1340,7 @@ void print_access_vector(security_class_t tclass, access_vector_t av) { - const u16 *common_pts_idx = 0; + const uint16_t *common_pts_idx = 0; access_vector_t common_base = 0; unsigned int i, i2, perm; Modified: branches/stable/1_0/libselinux/src/avc_internal.c =================================================================== --- branches/stable/1_0/libselinux/src/avc_internal.c 2007-02-20 13:43:22 UTC (rev 2239) +++ branches/stable/1_0/libselinux/src/avc_internal.c 2007-02-20 13:53:16 UTC (rev 2240) @@ -11,12 +11,12 @@ #include <errno.h> #include <stdio.h> #include <stdlib.h> +#include <stdint.h> #include <unistd.h> #include <fcntl.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> -#include <asm/types.h> #include <linux/netlink.h> #include "selinux_netlink.h" #include "avc_internal.h" Modified: branches/stable/1_0/libselinux/src/avc_internal.h =================================================================== --- branches/stable/1_0/libselinux/src/avc_internal.h 2007-02-20 13:43:22 UTC (rev 2239) +++ branches/stable/1_0/libselinux/src/avc_internal.h 2007-02-20 13:53:16 UTC (rev 2240) @@ -15,10 +15,6 @@ #include <selinux/avc.h> #include "dso.h" -typedef u_int32_t u32; -typedef u_int16_t u16; -typedef u_int8_t u8; - /* SID reference counter manipulation */ static inline int sid_inc_refcnt(security_id_t sid) { @@ -164,21 +160,21 @@ /* internal callbacks */ int avc_ss_grant(security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms, - u_int32_t seqno) hidden; + uint32_t seqno) hidden; int avc_ss_try_revoke(security_id_t ssid, security_id_t tsid, security_class_t tclass, - access_vector_t perms, u_int32_t seqno, + access_vector_t perms, uint32_t seqno, access_vector_t * out_retained) hidden; int avc_ss_revoke(security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms, - u_int32_t seqno) hidden; -int avc_ss_reset(u_int32_t seqno) hidden; + uint32_t seqno) hidden; +int avc_ss_reset(uint32_t seqno) hidden; int avc_ss_set_auditallow(security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms, - u_int32_t seqno, u_int32_t enable) hidden; + uint32_t seqno, uint32_t enable) hidden; int avc_ss_set_auditdeny(security_id_t ssid, security_id_t tsid, security_class_t tclass, access_vector_t perms, - u_int32_t seqno, u_int32_t enable) hidden; + uint32_t seqno, uint32_t enable) hidden; /* netlink kernel message code */ extern int avc_netlink_trouble hidden; Modified: branches/stable/1_0/libselinux/src/avc_sidtab.c =================================================================== --- branches/stable/1_0/libselinux/src/avc_sidtab.c 2007-02-20 13:43:22 UTC (rev 2239) +++ branches/stable/1_0/libselinux/src/avc_sidtab.c 2007-02-20 13:53:16 UTC (rev 2240) @@ -6,6 +6,7 @@ #include <errno.h> #include <stdio.h> #include <stdlib.h> +#include <stdint.h> #include <string.h> #include "selinux_internal.h" #include <selinux/avc.h> Modified: branches/stable/1_0/libselinux/src/selinux_netlink.h =================================================================== --- branches/stable/1_0/libselinux/src/selinux_netlink.h 2007-02-20 13:43:22 UTC (rev 2239) +++ branches/stable/1_0/libselinux/src/selinux_netlink.h 2007-02-20 13:53:16 UTC (rev 2240) @@ -25,7 +25,7 @@ }; struct selnl_msg_policyload { - u_int32_t seqno; + uint32_t seqno; }; #endif /* _LINUX_SELINUX_NETLINK_H */ Modified: branches/stable/1_0/libsemanage/Makefile =================================================================== --- branches/stable/1_0/libsemanage/Makefile 2007-02-20 13:43:22 UTC (rev 2239) +++ branches/stable/1_0/libsemanage/Makefile 2007-02-20 13:53:16 UTC (rev 2240) @@ -23,4 +23,5 @@ $(MAKE) -C src $@ $(MAKE) -C include $@ -test: +test: all + $(MAKE) -C tests test Modified: branches/stable/1_0/libsemanage/src/direct_api.c =================================================================== --- branches/stable/1_0/libsemanage/src/direct_api.c 2007-02-20 13:43:22 UTC (rev 2239) +++ branches/stable/1_0/libsemanage/src/direct_api.c 2007-02-20 13:53:16 UTC (rev 2240) @@ -65,7 +65,7 @@ int *num_modules); static struct semanage_policy_table direct_funcs = { - .get_serial = semanage_get_commit_number, + .get_serial = semanage_direct_get_serial, .destroy = semanage_direct_destroy, .disconnect = semanage_direct_disconnect, .begin_trans = semanage_direct_begintrans, @@ -911,7 +911,7 @@ goto cleanup; } if (num_mod_files == 0) { - retval = semanage_get_commit_number(sh); + retval = semanage_direct_get_serial(sh); goto cleanup; } @@ -954,7 +954,7 @@ free(version); } } - retval = semanage_get_commit_number(sh); + retval = semanage_direct_get_serial(sh); cleanup: sepol_policy_file_free(pf); Modified: branches/stable/1_0/libsemanage/src/semanage_store.c =================================================================== --- branches/stable/1_0/libsemanage/src/semanage_store.c 2007-02-20 13:43:22 UTC (rev 2239) +++ branches/stable/1_0/libsemanage/src/semanage_store.c 2007-02-20 13:53:16 UTC (rev 2240) @@ -968,14 +968,14 @@ if (!strncmp(buf, "HOME_DIR", 8) || !strncmp(buf, "HOME_ROOT", 9) || strstr(buf, "ROLE")) { /* This contains one of the template variables, write it to homedir.template */ - if (write(hd, buf, strnlen(buf, PATH_MAX)) == 0) { + if (write(hd, buf, strlen(buf)) == 0) { ERR(sh, "Write to %s failed.", semanage_path(SEMANAGE_TMP, SEMANAGE_HOMEDIR_TMPL)); goto cleanup; } } else { - if (write(fc, buf, strnlen(buf, PATH_MAX)) == 0) { + if (write(fc, buf, strlen(buf)) == 0) { ERR(sh, "Write to %s failed.", semanage_path(SEMANAGE_TMP, SEMANAGE_FC)); goto cleanup; @@ -1151,7 +1151,7 @@ struct stat buf; /* update the commit number */ - if ((commit_number = semanage_get_commit_number(sh)) < 0) { + if ((commit_number = semanage_direct_get_serial(sh)) < 0) { return -1; } commit_number++; @@ -1412,7 +1412,7 @@ /* Read the current commit number from the commit number file which * the handle is pointing, resetting the file pointer afterwards. * Return it (a non-negative number), or -1 on error. */ -int semanage_get_commit_number(semanage_handle_t * sh) +int semanage_direct_get_serial(semanage_handle_t * sh) { char buf[32]; int fd, commit_number; Modified: branches/stable/1_0/libsemanage/src/semanage_store.h =================================================================== --- branches/stable/1_0/libsemanage/src/semanage_store.h 2007-02-20 13:43:22 UTC (rev 2239) +++ branches/stable/1_0/libsemanage/src/semanage_store.h 2007-02-20 13:53:16 UTC (rev 2240) @@ -89,7 +89,7 @@ int semanage_get_active_lock(semanage_handle_t * sh); void semanage_release_trans_lock(semanage_handle_t * sh); void semanage_release_active_lock(semanage_handle_t * sh); -int semanage_get_commit_number(semanage_handle_t * sh); +int semanage_direct_get_serial(semanage_handle_t * sh); int semanage_link_sandbox(semanage_handle_t * sh, sepol_module_package_t ** base); Modified: branches/stable/1_0/policycoreutils/semanage/seobject.py =================================================================== --- branches/stable/1_0/policycoreutils/semanage/seobject.py 2007-02-20 13:43:22 UTC (rev 2239) +++ branches/stable/1_0/policycoreutils/semanage/seobject.py 2007-02-20 13:53:16 UTC (rev 2240) @@ -139,7 +139,7 @@ translations = fd.readlines() fd.close() except IOError, e: - raise ValueError(_("Unable to open %s: translations not supported on non-MLS machines") % (self.filename, e) ) + raise ValueError(_("Unable to open %s: translations not supported on non-MLS machines") % (self.filename) ) self.ddict = {} self.comments = [] Modified: branches/stable/1_0/policycoreutils/setfiles/setfiles.c =================================================================== --- branches/stable/1_0/policycoreutils/setfiles/setfiles.c 2007-02-20 13:43:22 UTC (rev 2239) +++ branches/stable/1_0/policycoreutils/setfiles/setfiles.c 2007-02-20 13:53:16 UTC (rev 2240) @@ -357,6 +357,7 @@ "%s: %s not reset customized by admin to %s\n", progname, my_file, context); } + freecon(context); goto out; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |