PERFORCE change 110211 for review
Robert Watson
rwatson at FreeBSD.org
Tue Nov 21 17:29:05 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=110211
Change 110211 by rwatson at rwatson_fledge on 2006/11/18 11:52:56
When generating process*ex tokens and records, generate both sample
IPv4 and IPv6 files, replicating logic from subject32ex code.
Free buffers when done in subject32ex.
Affected files ...
.. //depot/projects/trustedbsd/openbsm/test/bsm/generate.c#7 edit
Differences ...
==== //depot/projects/trustedbsd/openbsm/test/bsm/generate.c#7 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $P4: //depot/projects/trustedbsd/openbsm/test/bsm/generate.c#6 $
+ * $P4: //depot/projects/trustedbsd/openbsm/test/bsm/generate.c#7 $
*/
/*
@@ -335,6 +335,7 @@
if (subject32ex_token == NULL)
err(EX_UNAVAILABLE, "au_to_subject32_ex");
write_token(directory, buf, subject32ex_token);
+ free(buf);
}
static void
@@ -361,6 +362,7 @@
if (subject32ex_token == NULL)
err(EX_UNAVAILABLE, "au_to_subject32_ex");
write_record(directory, record_filename, subject32ex_token, AUE_NULL);
+ free(buf);
}
static au_id_t process32_auid = 0x12345678;
@@ -404,28 +406,49 @@
}
static void
-generate_process32ex_token(const char *directory, const char *token_filename)
+generate_process32ex_token(const char *directory, const char *token_filename,
+ u_int32_t type)
{
token_t *process32ex_token;
+ char *buf;
- process32_tid_addr.at_addr[0] = inet_addr("127.0.0.1");
- process32_tid_addr.at_type = AU_IPv4;
+ buf = (char *)malloc(strlen(token_filename) + 6);
+ if (type == AU_IPv6) {
+ inet_pton(AF_INET6, "fe80::1", process32_tid_addr.at_addr);
+ process32_tid_addr.at_type = AU_IPv6;
+ sprintf(buf, "%s%s", token_filename, "-IPv6");
+ } else {
+ process32_tid_addr.at_addr[0] = inet_addr("127.0.0.1");
+ process32_tid_addr.at_type = AU_IPv4;
+ sprintf(buf, "%s%s", token_filename, "-IPv4");
+ }
process32ex_token = au_to_process32_ex(process32_auid, process32_euid,
process32_egid, process32_ruid, process32_rgid, process32_pid,
process32_sid, &process32_tid_addr);
if (process32ex_token == NULL)
err(EX_UNAVAILABLE, "au_to_process32_ex");
- write_token(directory, token_filename, process32ex_token);
+ write_token(directory, buf, process32ex_token);
+ free(buf);
}
static void
-generate_process32ex_record(const char *directory, const char *record_filename)
+generate_process32ex_record(const char *directory, const char *record_filename,
+ u_int32_t type)
{
token_t *process32ex_token;
+ char *buf;
- process32_tid_addr.at_addr[0] = inet_addr("127.0.0.1");
- process32_tid_addr.at_type = AU_IPv4;
+ buf = (char *)malloc(strlen(record_filename) + 6);
+ if (type == AU_IPv6) {
+ inet_pton(AF_INET6, "fe80::1", process32_tid_addr.at_addr);
+ process32_tid_addr.at_type = AU_IPv6;
+ sprintf(buf, "%s%s", record_filename, "-IPv6");
+ } else {
+ process32_tid_addr.at_addr[0] = inet_addr("127.0.0.1");
+ process32_tid_addr.at_type = AU_IPv4;
+ sprintf(buf, "%s%s", record_filename, "-IPv4");
+ }
process32ex_token = au_to_process32_ex(process32_auid, process32_euid,
process32_egid, process32_ruid, process32_rgid, process32_pid,
@@ -433,6 +456,7 @@
if (process32ex_token == NULL)
err(EX_UNAVAILABLE, "au_to_process32_ex");
write_record(directory, record_filename, process32ex_token, AUE_NULL);
+ free(buf);
}
static au_id_t process64_auid = 0x12345678;
@@ -476,12 +500,22 @@
}
static void
-generate_process64ex_token(const char *directory, const char *token_filename)
+generate_process64ex_token(const char *directory, const char *token_filename,
+ u_int32_t type)
{
token_t *process64ex_token;
+ char *buf;
- process64_tid_addr.at_addr[0] = inet_addr("127.0.0.1");
- process64_tid_addr.at_type = AU_IPv4;
+ buf = (char *)malloc(strlen(token_filename) + 6);
+ if (type == AU_IPv6) {
+ inet_pton(AF_INET6, "fe80::1", process64_tid_addr.at_addr);
+ process64_tid_addr.at_type = AU_IPv6;
+ sprintf(buf, "%s%s", token_filename, "-IPv6");
+ } else {
+ process64_tid_addr.at_addr[0] = inet_addr("127.0.0.1");
+ process64_tid_addr.at_type = AU_IPv4;
+ sprintf(buf, "%s%s", token_filename, "-IPv4");
+ }
process64ex_token = au_to_process64_ex(process64_auid, process64_euid,
process64_egid, process64_ruid, process64_rgid, process64_pid,
@@ -489,15 +523,26 @@
if (process64ex_token == NULL)
err(EX_UNAVAILABLE, "au_to_process64_ex");
write_token(directory, token_filename, process64ex_token);
+ free(buf);
}
static void
-generate_process64ex_record(const char *directory, const char *record_filename)
+generate_process64ex_record(const char *directory, const char *record_filename,
+ u_int32_t type)
{
token_t *process64ex_token;
+ char *buf;
- process64_tid_addr.at_addr[0] = inet_addr("127.0.0.1");
- process64_tid_addr.at_type = AU_IPv4;
+ buf = (char *)malloc(strlen(record_filename) + 6);
+ if (type == AU_IPv6) {
+ inet_pton(AF_INET6, "fe80::1", process64_tid_addr.at_addr);
+ process64_tid_addr.at_type = AU_IPv6;
+ sprintf(buf, "%s%s", record_filename, "-IPv6");
+ } else {
+ process64_tid_addr.at_addr[0] = inet_addr("127.0.0.1");
+ process64_tid_addr.at_type = AU_IPv4;
+ sprintf(buf, "%s%s", record_filename, "-IPv4");
+ }
process64ex_token = au_to_process64_ex(process64_auid, process64_euid,
process64_egid, process64_ruid, process64_rgid, process64_pid,
@@ -505,6 +550,7 @@
if (process64ex_token == NULL)
err(EX_UNAVAILABLE, "au_to_process64_ex");
write_record(directory, record_filename, process64ex_token, AUE_NULL);
+ free(buf);
}
static char return32_status = 0xd7;
@@ -883,12 +929,20 @@
generate_ipc_token(directory, "ipc_token");
generate_path_token(directory, "path_token");
generate_subject32_token(directory, "subject32_token");
- generate_subject32ex_token(directory, "subject32ex_token", AU_IPv4);
- generate_subject32ex_token(directory, "subject32ex_token", AU_IPv6);
+ generate_subject32ex_token(directory, "subject32ex_token",
+ AU_IPv4);
+ generate_subject32ex_token(directory, "subject32ex_token",
+ AU_IPv6);
generate_process32_token(directory, "process32_token");
- generate_process32ex_token(directory, "process32ex_token");
+ generate_process32ex_token(directory, "process32ex_token",
+ AU_IPv4);
+ generate_process32ex_token(directory, "process32ex_token",
+ AU_IPv6);
generate_process64_token(directory, "process64_token");
- generate_process64ex_token(directory, "process64ex_token");
+ generate_process64ex_token(directory, "process64ex_token",
+ AU_IPv4);
+ generate_process64ex_token(directory, "process64ex_token",
+ AU_IPv6);
generate_return32_token(directory, "return32_token");
generate_text_token(directory, "text_token");
generate_opaque_token(directory, "opaque_token");
@@ -914,9 +968,15 @@
generate_subject32ex_record(directory, "subject32ex_record",
AU_IPv6);
generate_process32_record(directory, "process32_record");
- generate_process32ex_record(directory, "process32ex_record");
+ generate_process32ex_record(directory, "process32ex_record",
+ AU_IPv4);
+ generate_process32ex_record(directory, "process32ex_record",
+ AU_IPv6);
generate_process64_record(directory, "process64_record");
- generate_process64ex_record(directory, "process64ex_record");
+ generate_process64ex_record(directory, "process64ex_record",
+ AU_IPv4);
+ generate_process64ex_record(directory, "process64ex_record",
+ AU_IPv6);
generate_return32_record(directory, "return32_record");
generate_text_record(directory, "text_record");
generate_opaque_record(directory, "opaque_record");
More information about the trustedbsd-cvs
mailing list