From: Michael C Thompson <thompsmc@us.ibm.com>
To: Daniel J Walsh <dwalsh@redhat.com>
Cc: SE Linux <selinux@tycho.nsa.gov>,
Stephen Smalley <sds@tycho.nsa.gov>,
jdesai@us.ibm.com
Subject: Re: [RFC PATCH] newrole suid breakdown
Date: Thu, 05 Oct 2006 10:46:08 -0500 [thread overview]
Message-ID: <452528C0.1050907@us.ibm.com> (raw)
In-Reply-To: <45251C15.6020506@redhat.com>
Daniel J Walsh wrote:
> Michael C Thompson wrote:
>> Daniel J Walsh wrote:
>>> Michael C Thompson wrote:
<snip>
>> diff -Naur policycoreutils-1.30.30.dev/newrole/newrole.c
>> policycoreutils-1.30.30.dev.rh/newrole/newrole.c
>> --- policycoreutils-1.30.30.dev/newrole/newrole.c 2006-10-04
>> 17:01:17.000000000 -0500
>> +++ policycoreutils-1.30.30.dev.rh/newrole/newrole.c 2006-10-05
>> 09:39:14.000000000 -0500
>> @@ -548,6 +548,7 @@
>> uid_t uid;
>> int fd;
>> int enforcing;
>> + int ignore_privilage_actions = 0;
>> sigset_t empty;
>> #ifdef USE_PAM
>> int rc; /* pam return code */
>> @@ -562,8 +563,11 @@
>> };
>> #endif
>>
>> - if (drop_capabilities())
>> - return -1;
>> + if (geteuid())
>> + ignore_privilage_actions = 1;
>> + else
>> + if (drop_capabilities())
>> + return -1;
>>
>>
> I think this is all you need. Audit can handle the fact that it can't
> send a message by sending it to /var/log/messages. And if You use
> pam_namespace.so you should fail if you are not setuid and you are not
> root.
True, but right now we are set to abort newrole if those actions are
expected to succeed (we have compiled with the respective _PRIV). Should
that behavior be changed?
>> /* Empty the signal mask in case someone is blocking a signal */
>> sigemptyset(&empty);
>> @@ -662,7 +666,9 @@
>> if (role_s && !type_s) {
>> if (get_default_type(role_s, &type_s)) {
>> fprintf(stderr, _("Couldn't get default type.\n"));
>> - send_audit_message(0, old_context, new_context, ttyn);
>> + if (!ignore_privilage_actions)
>> + send_audit_message(0, old_context, new_context,
>> + ttyn);
>> exit(-1);
>> }
>> #ifdef CANTSPELLGDB
>> @@ -851,7 +857,8 @@
>>
>> if (security_check_context(new_context) < 0) {
>> fprintf(stderr, _("%s is not a valid context\n"), new_context);
>> - send_audit_message(0, old_context, new_context, ttyn);
>> + if (!ignore_privilage_actions)
>> + send_audit_message(0, old_context, new_context, ttyn);
>> exit(-1);
>> }
>>
>> @@ -960,12 +967,15 @@
>>
>> #ifdef USE_PAM
>> #ifdef NAMESPACE_PRIV
>> - rc = pam_close_session(pam_handle,0);
>> - if(rc != PAM_SUCCESS) {
>> - fprintf(stderr, "pam_close_session failed with %s\n",
>> - pam_strerror(pam_handle, rc));
>> - pam_end(pam_handle, rc);
>> - exit(-1);
>> + if (!ignore_privilage_actions) {
>> + rc = pam_close_session(pam_handle,0);
>> + if(rc != PAM_SUCCESS) {
>> + fprintf(stderr,
>> + "pam_close_session failed with %s\n",
>> + pam_strerror(pam_handle, rc));
>> + pam_end(pam_handle, rc);
>> + exit(-1);
>> + }
>> }
>> #endif
>>
>> @@ -1026,21 +1036,24 @@
>> exit(-1);
>> }
>> #ifdef NAMESPACE_PRIV
>> - /* Ask PAM to setup session for user running this program */
>> - rc = pam_open_session(pam_handle,0);
>> - if(rc != PAM_SUCCESS) {
>> - fprintf(stderr, "pam_open_session failed with %s\n",
>> - pam_strerror(pam_handle, rc));
>> - exit(-1);
>> + if (!ignore_privilage_actions) {
>> + /* Ask PAM to setup session for user running this program */
>> + rc = pam_open_session(pam_handle,0);
>> + if(rc != PAM_SUCCESS) {
>> + fprintf(stderr, "pam_open_session failed with %s\n",
>> + pam_strerror(pam_handle, rc));
>> + exit(-1);
>> + }
>> }
>> #endif
>> -
>> - if (send_audit_message(1, old_context, new_context, ttyn))
>> - exit(-1);
>> + if (!ignore_privilage_actions)
>> + if (send_audit_message(1, old_context, new_context, ttyn))
>> + exit(-1);
>> freecon(old_context);
>> #ifdef NAMESPACE_PRIV
>> - if (transition_to_caller_uid())
>> - exit(-1);
>> + if (!ignore_privilage_actions)
>> + if (transition_to_caller_uid())
>> + exit(-1);
>> #endif
>> execv(pw->pw_shell, argv + optind - 1);
>>
>>
>
>
> --
> 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.
--
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-10-05 15:46 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-04 22:17 [RFC PATCH] newrole suid breakdown Michael C Thompson
2006-10-05 13:57 ` Daniel J Walsh
2006-10-05 14:42 ` Michael C Thompson
2006-10-05 14:52 ` Daniel J Walsh
2006-10-05 15:46 ` Michael C Thompson [this message]
2006-10-05 17:56 ` Stephen Smalley
2006-10-05 14:58 ` Stephen Smalley
2006-10-05 15:55 ` Michael C Thompson
2006-10-05 18:39 ` Stephen Smalley
2006-10-05 19:53 ` Michael C Thompson
2006-10-05 20:12 ` Stephen Smalley
2006-10-05 20:47 ` Michael C Thompson
2006-10-05 21:48 ` Steve Grubb
2006-10-06 14:52 ` Stephen Smalley
2006-10-06 15:16 ` Russell Coker
2006-10-06 15:22 ` Linda Knippers
2006-10-06 15:22 ` Michael C Thompson
2006-10-06 15:36 ` Steve Grubb
2006-10-06 15:49 ` Stephen Smalley
2006-10-06 15:34 ` Steve Grubb
2006-10-06 16:14 ` Stephen Smalley
2006-10-06 17:08 ` Daniel J Walsh
2006-10-06 17:13 ` Stephen Smalley
2006-10-05 23:15 ` Russell Coker
2006-10-06 17:01 ` Daniel J Walsh
2006-10-06 17:37 ` Russell Coker
2006-10-06 18:50 ` Daniel J Walsh
2006-10-06 18:54 ` Stephen Smalley
2006-10-06 19:03 ` Russell Coker
2006-10-06 21:36 ` Michael C Thompson
2006-10-06 21:50 ` Stephen Smalley
2006-10-05 14:40 ` Stephen Smalley
2006-10-05 16:07 ` Michael C Thompson
2006-10-05 17:40 ` Stephen Smalley
2006-10-05 20:10 ` Michael C Thompson
2006-10-05 20:24 ` Stephen Smalley
2006-10-05 20:42 ` 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=452528C0.1050907@us.ibm.com \
--to=thompsmc@us.ibm.com \
--cc=dwalsh@redhat.com \
--cc=jdesai@us.ibm.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
/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.