From: Michael C Thompson <thompsmc@us.ibm.com>
To: Michael C Thompson <thompsmc@us.ibm.com>
Cc: lspp-list <redhat-lspp@redhat.com>,
Linux Audit <linux-audit@redhat.com>,
SE Linux <selinux@tycho.nsa.gov>, Steve Grubb <sgrubb@redhat.com>
Subject: Re: [PATCH] newrole auditing of failures due to user actions
Date: Thu, 28 Sep 2006 15:05:23 -0500 [thread overview]
Message-ID: <451C2B03.1060300@us.ibm.com> (raw)
In-Reply-To: <451C2473.7050102@us.ibm.com>
Michael C Thompson wrote:
> This patch introduces two new point in the code where audit records are
> generated for newrole. Both points are when the attempt to newrole fails.
Forgot to copy the SELinux mailing list.
> The first point is when the default type could not be determine for the
> specified role - this is audited because, as sgrubb pointed out, it is
> currently non-tracked path to probe the policy.
>
> The second point is when the desired context to change to is invalid.
>
> There record format remains unchanged. Failing to validate the desired
> context will result in the old and new contexts being recorded intact to
> the log. For the default type, the old and new contexts have not yet
> been obtained, so they are recorded in the log as XXX_context=?
>
> Signed-off-by: Michael Thompson <thompsmc@us.ibm.com>
>
> ----
>
>
>
> ------------------------------------------------------------------------
>
> --- policycoreutils-1.30.29/newrole/newrole.c 2006-09-14 07:07:26.000000000 -0500
> +++ policycoreutils-1.30.29.orig.dev/newrole/newrole.c 2006-09-28 14:21:27.000000000 -0500
> @@ -47,7 +47,9 @@
> *
> *************************************************************************/
>
> +#ifndef _GNU_SOURCE
> #define _GNU_SOURCE
> +#endif
> #include <stdio.h>
> #include <stdlib.h> /* for malloc(), realloc(), free() */
> #include <pwd.h> /* for getpwuid() */
> @@ -394,6 +396,41 @@
> cap_free(new_caps);
> }
> }
> +
> +/* Send audit message */
> +int send_audit_message(int success, security_context_t old_context,
> + security_context_t new_context, const char *ttyn)
> +{
> + char *msg = NULL;
> + int rc;
> + int audit_fd = audit_open();
> +
> + if (audit_fd < 0) {
> + fprintf(stderr, _("Error connecting to audit system.\n"));
> + rc = -1;
> + goto out;
> + }
> + if (asprintf(&msg, "newrole: old-context=%s new-context=%s",
> + old_context ? old_context : "?",
> + new_context ? new_context : "?") < 0) {
> + fprintf(stderr, _("Error allocating memory.\n"));
> + rc = -1;
> + goto out;
> + }
> + rc = audit_log_user_message(audit_fd, AUDIT_USER_ROLE_CHANGE,
> + msg, NULL, NULL, ttyn, success);
> + if (rc <= 0) {
> + fprintf(stderr, _("Error sending audit message.\n"));
> + rc = -1;
> + goto out;
> + }
> + rc = 0;
> +out:
> + free(msg);
> + close(audit_fd);
> + return rc;
> +}
> +
> #endif
>
> /************************************************************************
> @@ -536,6 +573,9 @@
> if (role_s && !type_s) {
> if (get_default_type(role_s, &type_s)) {
> fprintf(stderr, _("Couldn't get default type.\n"));
> +#ifdef LOG_AUDIT_PRIV
> + send_audit_message(0, old_context, new_context, ttyn);
> +#endif
> exit(-1);
> }
> #ifdef CANTSPELLGDB
> @@ -715,6 +755,9 @@
>
> if (security_check_context(new_context) < 0) {
> fprintf(stderr, _("%s is not a valid context\n"), new_context);
> +#ifdef LOG_AUDIT_PRIV
> + send_audit_message(0, old_context, new_context, ttyn);
> +#endif
> exit(-1);
> }
>
> @@ -874,30 +917,8 @@
> exit(-1);
> }
> #ifdef LOG_AUDIT_PRIV
> - /* Send audit message */
> - {
> - char *msg;
> - int rc;
> - int audit_fd = audit_open();
> - if (audit_fd < 0) {
> - fprintf(stderr,
> - _("Error connecting to audit system.\n"));
> - exit(-1);
> - }
> - if (asprintf(&msg, "newrole: old-context=%s new-context=%s",
> - old_context, new_context) < 0) {
> - fprintf(stderr, _("Error allocating memory.\n"));
> - exit(-1);
> - }
> - rc = audit_log_user_message(audit_fd, AUDIT_USER_ROLE_CHANGE,
> - msg, NULL, NULL, ttyn, 1);
> - if (rc <= 0) {
> - fprintf(stderr, _("Error sending audit message.\n"));
> - exit(-1);
> - }
> - free(msg);
> - close(audit_fd);
> - }
> + if (send_audit_message(1, old_context, new_context, ttyn))
> + exit(-1);
> #endif
> freecon(old_context);
> execv(pw->pw_shell, argv + optind - 1);
>
>
> ------------------------------------------------------------------------
>
> --
> Linux-audit mailing list
> Linux-audit@redhat.com
> https://www.redhat.com/mailman/listinfo/linux-audit
WARNING: multiple messages have this Message-ID (diff)
From: Michael C Thompson <thompsmc@us.ibm.com>
To: Michael C Thompson <thompsmc@us.ibm.com>
Cc: Linux Audit <linux-audit@redhat.com>,
lspp-list <redhat-lspp@redhat.com>,
Steve Grubb <sgrubb@redhat.com>, SE Linux <selinux@tycho.nsa.gov>
Subject: Re: [PATCH] newrole auditing of failures due to user actions
Date: Thu, 28 Sep 2006 15:05:23 -0500 [thread overview]
Message-ID: <451C2B03.1060300@us.ibm.com> (raw)
In-Reply-To: <451C2473.7050102@us.ibm.com>
Michael C Thompson wrote:
> This patch introduces two new point in the code where audit records are
> generated for newrole. Both points are when the attempt to newrole fails.
Forgot to copy the SELinux mailing list.
> The first point is when the default type could not be determine for the
> specified role - this is audited because, as sgrubb pointed out, it is
> currently non-tracked path to probe the policy.
>
> The second point is when the desired context to change to is invalid.
>
> There record format remains unchanged. Failing to validate the desired
> context will result in the old and new contexts being recorded intact to
> the log. For the default type, the old and new contexts have not yet
> been obtained, so they are recorded in the log as XXX_context=?
>
> Signed-off-by: Michael Thompson <thompsmc@us.ibm.com>
>
> ----
>
>
>
> ------------------------------------------------------------------------
>
> --- policycoreutils-1.30.29/newrole/newrole.c 2006-09-14 07:07:26.000000000 -0500
> +++ policycoreutils-1.30.29.orig.dev/newrole/newrole.c 2006-09-28 14:21:27.000000000 -0500
> @@ -47,7 +47,9 @@
> *
> *************************************************************************/
>
> +#ifndef _GNU_SOURCE
> #define _GNU_SOURCE
> +#endif
> #include <stdio.h>
> #include <stdlib.h> /* for malloc(), realloc(), free() */
> #include <pwd.h> /* for getpwuid() */
> @@ -394,6 +396,41 @@
> cap_free(new_caps);
> }
> }
> +
> +/* Send audit message */
> +int send_audit_message(int success, security_context_t old_context,
> + security_context_t new_context, const char *ttyn)
> +{
> + char *msg = NULL;
> + int rc;
> + int audit_fd = audit_open();
> +
> + if (audit_fd < 0) {
> + fprintf(stderr, _("Error connecting to audit system.\n"));
> + rc = -1;
> + goto out;
> + }
> + if (asprintf(&msg, "newrole: old-context=%s new-context=%s",
> + old_context ? old_context : "?",
> + new_context ? new_context : "?") < 0) {
> + fprintf(stderr, _("Error allocating memory.\n"));
> + rc = -1;
> + goto out;
> + }
> + rc = audit_log_user_message(audit_fd, AUDIT_USER_ROLE_CHANGE,
> + msg, NULL, NULL, ttyn, success);
> + if (rc <= 0) {
> + fprintf(stderr, _("Error sending audit message.\n"));
> + rc = -1;
> + goto out;
> + }
> + rc = 0;
> +out:
> + free(msg);
> + close(audit_fd);
> + return rc;
> +}
> +
> #endif
>
> /************************************************************************
> @@ -536,6 +573,9 @@
> if (role_s && !type_s) {
> if (get_default_type(role_s, &type_s)) {
> fprintf(stderr, _("Couldn't get default type.\n"));
> +#ifdef LOG_AUDIT_PRIV
> + send_audit_message(0, old_context, new_context, ttyn);
> +#endif
> exit(-1);
> }
> #ifdef CANTSPELLGDB
> @@ -715,6 +755,9 @@
>
> if (security_check_context(new_context) < 0) {
> fprintf(stderr, _("%s is not a valid context\n"), new_context);
> +#ifdef LOG_AUDIT_PRIV
> + send_audit_message(0, old_context, new_context, ttyn);
> +#endif
> exit(-1);
> }
>
> @@ -874,30 +917,8 @@
> exit(-1);
> }
> #ifdef LOG_AUDIT_PRIV
> - /* Send audit message */
> - {
> - char *msg;
> - int rc;
> - int audit_fd = audit_open();
> - if (audit_fd < 0) {
> - fprintf(stderr,
> - _("Error connecting to audit system.\n"));
> - exit(-1);
> - }
> - if (asprintf(&msg, "newrole: old-context=%s new-context=%s",
> - old_context, new_context) < 0) {
> - fprintf(stderr, _("Error allocating memory.\n"));
> - exit(-1);
> - }
> - rc = audit_log_user_message(audit_fd, AUDIT_USER_ROLE_CHANGE,
> - msg, NULL, NULL, ttyn, 1);
> - if (rc <= 0) {
> - fprintf(stderr, _("Error sending audit message.\n"));
> - exit(-1);
> - }
> - free(msg);
> - close(audit_fd);
> - }
> + if (send_audit_message(1, old_context, new_context, ttyn))
> + exit(-1);
> #endif
> freecon(old_context);
> execv(pw->pw_shell, argv + optind - 1);
>
>
> ------------------------------------------------------------------------
>
> --
> Linux-audit mailing list
> Linux-audit@redhat.com
> https://www.redhat.com/mailman/listinfo/linux-audit
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
next prev parent reply other threads:[~2006-09-28 20:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-28 19:37 [PATCH] newrole auditing of failures due to user actions Michael C Thompson
2006-09-28 20:05 ` Michael C Thompson [this message]
2006-09-28 20:05 ` Michael C Thompson
2006-09-28 20:15 ` Steve Grubb
2006-09-28 20:15 ` Steve Grubb
2006-09-28 20:29 ` Stephen Smalley
2006-09-28 20:36 ` Michael C Thompson
2006-09-28 20:10 ` Stephen Smalley
2006-09-28 20:38 ` Michael C Thompson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=451C2B03.1060300@us.ibm.com \
--to=thompsmc@us.ibm.com \
--cc=linux-audit@redhat.com \
--cc=redhat-lspp@redhat.com \
--cc=selinux@tycho.nsa.gov \
--cc=sgrubb@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.