From: Daniel J Walsh <dwalsh@redhat.com>
To: Daniel J Walsh <dwalsh@redhat.com>
Cc: Stephen Smalley <sds@tycho.nsa.gov>,
James Antill <jantill@redhat.com>,
Linda Knippers <linda.knippers@hp.com>,
redhat-lspp <redhat-lspp@redhat.com>,
Klaus Weidner <klaus@atsec.com>, SE Linux <selinux@tycho.nsa.gov>,
Joshua Brindle <jbrindle@tresys.com>
Subject: Re: [redhat-lspp] Re: [PATCH 2/3] Re: MLS enforcing PTYs, sshd, and newrole
Date: Fri, 05 Jan 2007 12:05:47 -0500 [thread overview]
Message-ID: <459E856B.60800@redhat.com> (raw)
In-Reply-To: <459E7BA2.1050109@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 190 bytes --]
First libselinux-rhat patch was broken. Needs to only check the context
type.
more /etc/selinux/mls/contexts/securetty_contexts
sysadm_tty_device_t
staff_tty_device_t
user_tty_device_t
[-- Attachment #2: libselinux-rhat.patch --]
[-- Type: text/x-patch, Size: 8487 bytes --]
diff --exclude-from=exclude -N -u -r nsalibselinux/include/selinux/selinux.h libselinux-1.33.3/include/selinux/selinux.h
--- nsalibselinux/include/selinux/selinux.h 2006-11-16 17:15:18.000000000 -0500
+++ libselinux-1.33.3/include/selinux/selinux.h 2007-01-05 11:57:44.000000000 -0500
@@ -406,6 +406,7 @@
extern const char *selinux_homedir_context_path(void);
extern const char *selinux_media_context_path(void);
extern const char *selinux_contexts_path(void);
+ extern const char *selinux_securetty_context_path(void);
extern const char *selinux_booleans_path(void);
extern const char *selinux_customizable_types_path(void);
extern const char *selinux_users_path(void);
@@ -413,12 +414,14 @@
extern const char *selinux_translations_path(void);
extern const char *selinux_netfilter_context_path(void);
extern const char *selinux_path(void);
-
/* Check a permission in the passwd class.
Return 0 if granted or -1 otherwise. */
extern int selinux_check_passwd_access(access_vector_t requested);
extern int checkPasswdAccess(access_vector_t requested);
+/* Check if the tty_context is defined as a securetty
+ Return 1 if secure, 0 if not, or -1 if otherwise. */
+ extern int selinux_check_securetty_context(security_context_t tty_context);
/* Set the path to the selinuxfs mount point explicitly.
Normally, this is determined automatically during libselinux
initialization, but this is not always possible, e.g. for /sbin/init
diff --exclude-from=exclude -N -u -r nsalibselinux/man/man3/selinux_binary_policy_path.3 libselinux-1.33.3/man/man3/selinux_binary_policy_path.3
--- nsalibselinux/man/man3/selinux_binary_policy_path.3 2006-11-16 17:15:30.000000000 -0500
+++ libselinux-1.33.3/man/man3/selinux_binary_policy_path.3 2007-01-05 11:57:44.000000000 -0500
@@ -27,6 +27,8 @@
.br
extern const char *selinux_media_context_path(void);
.br
+extern const char *selinux_securetty_context_path(void);
+.br
extern const char *selinux_contexts_path(void);
.br
extern const char *selinux_booleans_path(void);
@@ -56,6 +58,8 @@
.sp
selinux_contexts_path() - directory containing all of the context configuration files
.sp
+selinux_securetty_context_path() - defines terminal contexts for securetty
+.sp
selinux_booleans_path() - initial policy boolean settings
.SH AUTHOR
diff --exclude-from=exclude -N -u -r nsalibselinux/man/man3/selinux_check_securetty_context.3 libselinux-1.33.3/man/man3/selinux_check_securetty_context.3
--- nsalibselinux/man/man3/selinux_check_securetty_context.3 1969-12-31 19:00:00.000000000 -0500
+++ libselinux-1.33.3/man/man3/selinux_check_securetty_context.3 2007-01-05 11:57:44.000000000 -0500
@@ -0,0 +1,13 @@
+.TH "selinux_check_securetty_context" "3" "1 January 2007" "dwalsh@redhat.com" "SE Linux API documentation"
+.SH "NAME"
+selinux_check_securetty_context \- check whether a tty security context is defined as a securetty context
+.SH "SYNOPSIS"
+.B #include <selinux/selinux.h>
+.sp
+.BI "int selinux_check_securetty_context(security_context_t "tty_context );
+
+.SH "DESCRIPTION"
+.B selinux_check_securetty_context
+returns 1 if tty_context is a securetty context
+returns 0 if tty_context is a not a securetty context
+returns -1 on error.
diff --exclude-from=exclude -N -u -r nsalibselinux/man/man3/selinux_securetty_context_path.3 libselinux-1.33.3/man/man3/selinux_securetty_context_path.3
--- nsalibselinux/man/man3/selinux_securetty_context_path.3 1969-12-31 19:00:00.000000000 -0500
+++ libselinux-1.33.3/man/man3/selinux_securetty_context_path.3 2007-01-05 11:57:44.000000000 -0500
@@ -0,0 +1 @@
+.so man3/selinux_binary_policy_path.3
diff --exclude-from=exclude -N -u -r nsalibselinux/src/file_path_suffixes.h libselinux-1.33.3/src/file_path_suffixes.h
--- nsalibselinux/src/file_path_suffixes.h 2006-11-16 17:15:25.000000000 -0500
+++ libselinux-1.33.3/src/file_path_suffixes.h 2007-01-05 11:57:44.000000000 -0500
@@ -7,6 +7,7 @@
S_(USER_CONTEXTS, "/contexts/users/")
S_(FAILSAFE_CONTEXT, "/contexts/failsafe_context")
S_(DEFAULT_TYPE, "/contexts/default_type")
+ S_(SECURETTY_CONTEXTS, "/contexts/securetty_contexts")
S_(BOOLEANS, "/booleans")
S_(MEDIA_CONTEXTS, "/contexts/files/media")
S_(REMOVABLE_CONTEXT, "/contexts/removable_context")
diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinux_check_securetty_context.c libselinux-1.33.3/src/selinux_check_securetty_context.c
--- nsalibselinux/src/selinux_check_securetty_context.c 1969-12-31 19:00:00.000000000 -0500
+++ libselinux-1.33.3/src/selinux_check_securetty_context.c 2007-01-05 11:57:44.000000000 -0500
@@ -0,0 +1,49 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "selinux_internal.h"
+#include "context_internal.h"
+
+int selinux_check_securetty_context(security_context_t tty_context)
+{
+ char buf[250];
+ char *ptr = "", *end;
+ size_t len;
+ int found = -1;
+ FILE *fp;
+ fp = fopen(selinux_securetty_context_path(), "r");
+ if (fp) {
+ context_t con =context_new(tty_context);
+ if (con) {
+ char *type=context_type_get(con);
+ found = 0;
+ len = strlen(type);
+ while (!feof_unlocked(fp)) {
+ if (!fgets_unlocked(buf, sizeof buf, fp))
+ break;
+
+ if (buf[strlen(buf) - 1])
+ buf[strlen(buf) - 1] = 0;
+
+ ptr = buf;
+ while (*ptr && isspace(*ptr))
+ ptr++;
+ if (!(*ptr))
+ continue;
+
+ if (!strncmp(type, ptr, len)) {
+ found = 1;
+ break;
+ }
+ }
+ context_free(con);
+ }
+ fclose(fp);
+ }
+
+ return found;
+}
+
+hidden_def(selinux_check_securetty_context)
diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinux_config.c libselinux-1.33.3/src/selinux_config.c
--- nsalibselinux/src/selinux_config.c 2006-11-16 17:15:25.000000000 -0500
+++ libselinux-1.33.3/src/selinux_config.c 2007-01-05 11:57:44.000000000 -0500
@@ -38,7 +38,8 @@
#define NETFILTER_CONTEXTS 15
#define FILE_CONTEXTS_HOMEDIR 16
#define FILE_CONTEXTS_LOCAL 17
-#define NEL 18
+#define SECURETTY_CONTEXTS 18
+#define NEL 19
/* New layout is relative to SELINUXDIR/policytype. */
static char *file_paths[NEL];
@@ -299,6 +300,12 @@
hidden_def(selinux_default_context_path)
+const char *selinux_securetty_context_path()
+{
+ return get_path(SECURETTY_CONTEXTS);
+}
+hidden_def(selinux_securetty_context_path)
+
const char *selinux_failsafe_context_path()
{
return get_path(FAILSAFE_CONTEXT);
diff --exclude-from=exclude -N -u -r nsalibselinux/src/selinux_internal.h libselinux-1.33.3/src/selinux_internal.h
--- nsalibselinux/src/selinux_internal.h 2006-11-16 17:15:25.000000000 -0500
+++ libselinux-1.33.3/src/selinux_internal.h 2007-01-05 11:57:44.000000000 -0500
@@ -53,6 +53,7 @@
hidden_proto(security_setenforce)
hidden_proto(selinux_binary_policy_path)
hidden_proto(selinux_default_context_path)
+ hidden_proto(selinux_securetty_context_path)
hidden_proto(selinux_failsafe_context_path)
hidden_proto(selinux_removable_context_path)
hidden_proto(selinux_file_context_path)
@@ -66,6 +67,7 @@
hidden_proto(selinux_media_context_path)
hidden_proto(selinux_path)
hidden_proto(selinux_check_passwd_access)
+ hidden_proto(selinux_check_securetty_context)
hidden_proto(matchpathcon_init_prefix)
hidden_proto(selinux_users_path)
hidden_proto(selinux_usersconf_path);
diff --exclude-from=exclude -N -u -r nsalibselinux/utils/selinux_check_securetty_context.c libselinux-1.33.3/utils/selinux_check_securetty_context.c
--- nsalibselinux/utils/selinux_check_securetty_context.c 1969-12-31 19:00:00.000000000 -0500
+++ libselinux-1.33.3/utils/selinux_check_securetty_context.c 2007-01-05 11:57:44.000000000 -0500
@@ -0,0 +1,40 @@
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/errno.h>
+#include <selinux/selinux.h>
+
+void usage(const char *progname)
+{
+ fprintf(stderr,
+ "usage: %s tty_context...\n",
+ progname);
+ exit(1);
+}
+
+int main(int argc, char **argv)
+{
+ int i;
+ if (argc < 2)
+ usage(argv[0]);
+
+ for (i = 1; i < argc; i++) {
+ switch (selinux_check_securetty_context(argv[i])) {
+ case 1:
+ printf("%s securetty.\n", argv[i]);
+ break;
+ case 0:
+ printf("%s not securetty.\n", argv[i]);
+ break;
+ case -1:
+ perror("Failed on check if securetty");
+ return -1;
+ }
+ }
+ return 0;
+}
next prev parent reply other threads:[~2007-01-05 17:05 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-12 7:33 MLS enforcing PTYs, sshd, and newrole Klaus Weidner
2006-10-12 10:25 ` Russell Coker
2006-10-12 14:48 ` Klaus Weidner
2006-10-12 15:16 ` Michael C Thompson
2006-10-12 16:54 ` [redhat-lspp] " Casey Schaufler
2006-10-12 15:37 ` Casey Schaufler
2006-10-19 13:21 ` [redhat-lspp] " Daniel J Walsh
2006-10-19 13:30 ` Stephen Smalley
2006-10-19 14:06 ` Daniel J Walsh
2006-10-19 14:32 ` Stephen Smalley
2006-10-21 4:37 ` Casey Schaufler
2006-10-23 16:14 ` James Antill
2006-10-23 16:39 ` Casey Schaufler
2006-10-23 16:45 ` Paul Moore
2006-10-23 18:41 ` Casey Schaufler
2006-10-24 20:37 ` James Antill
2006-10-25 0:19 ` George C. Wilson
2006-10-25 11:48 ` Stephen Smalley
2006-10-25 12:22 ` Stephen Smalley
2006-10-25 13:50 ` James Antill
2006-10-25 13:59 ` Stephen Smalley
2006-10-25 19:15 ` James Antill
2006-10-25 19:24 ` Stephen Smalley
[not found] ` <1161970810.29689.88.camel@code.and.org>
[not found] ` <1161974293.1306.167.camel@moss-spartans.epoch.ncsc.mil>
2006-10-30 20:03 ` [PATCH 1/3] " James Antill
2006-10-30 20:16 ` [PATCH 2/3] " James Antill
2006-10-30 20:22 ` [PATCH 3/3] " James Antill
2006-10-31 14:23 ` [PATCH 2/3] " Stephen Smalley
2006-10-31 14:24 ` Stephen Smalley
2006-10-31 15:00 ` James Antill
2006-10-31 15:11 ` Stephen Smalley
2006-10-31 16:04 ` James Antill
2006-10-31 16:21 ` Stephen Smalley
2006-10-31 18:33 ` James Antill
2006-11-01 12:36 ` Stephen Smalley
2007-01-04 21:34 ` [redhat-lspp] " Daniel J Walsh
2007-01-04 21:57 ` Linda Knippers
2007-01-04 22:19 ` Daniel J Walsh
2007-01-04 23:19 ` Linda Knippers
2007-01-05 1:07 ` Klaus Weidner
2007-01-05 3:05 ` Joshua Brindle
2007-01-05 3:33 ` Klaus Weidner
2007-01-05 3:35 ` Joshua Brindle
2007-01-05 4:01 ` Klaus Weidner
2007-01-05 15:56 ` Stephen Smalley
2007-01-05 16:23 ` Daniel J Walsh
2007-01-05 16:24 ` Daniel J Walsh
2007-01-05 17:05 ` Daniel J Walsh [this message]
2007-01-05 18:34 ` Stephen Smalley
2007-01-05 18:43 ` Stephen Smalley
2007-01-05 15:55 ` Stephen Smalley
2007-01-04 22:13 ` Casey Schaufler
2007-01-04 22:20 ` Daniel J Walsh
2006-10-31 14:20 ` [PATCH 1/3] " Stephen Smalley
2006-10-25 21:36 ` [redhat-lspp] " Stephen Smalley
2006-10-26 14:09 ` Daniel J Walsh
2006-10-19 13:32 ` Steve Grubb
2006-10-19 13:39 ` Stephen Smalley
2006-10-20 7:00 ` Russell Coker
2006-10-27 15:36 ` Valdis.Kletnieks
2006-10-27 23:04 ` Russell Coker
2006-10-31 14:29 ` Stephen Smalley
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=459E856B.60800@redhat.com \
--to=dwalsh@redhat.com \
--cc=jantill@redhat.com \
--cc=jbrindle@tresys.com \
--cc=klaus@atsec.com \
--cc=linda.knippers@hp.com \
--cc=redhat-lspp@redhat.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.