[BusyBox-cvs] busybox/loginutils login.c,1.10,1.11 su.c,1.3,1.4
Erik Andersen
andersen at busybox.net
Thu Jul 3 10:07:06 UTC 2003
Update of /var/cvs/busybox/loginutils
In directory winder:/tmp/cvs-serv27387/loginutils
Modified Files:
login.c su.c
Log Message:
Patch from Russell Coker:
I've attached my latest SE Linux patch for busybox against the latest CVS
version of busybox.
Index: login.c
===================================================================
RCS file: /var/cvs/busybox/loginutils/login.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- login.c 19 Mar 2003 09:12:20 -0000 1.10
+++ login.c 3 Jul 2003 10:07:02 -0000 1.11
@@ -16,7 +16,12 @@
#include <time.h>
#include "busybox.h"
-
+#ifdef CONFIG_SELINUX
+#include <flask_util.h>
+#include <get_sid_list.h>
+#include <proc_secure.h>
+#include <fs_secure.h>
+#endif
#ifdef CONFIG_FEATURE_U_W_TMP
// import from utmp.c
@@ -73,6 +78,10 @@
int opt_fflag = 0;
char *opt_host = 0;
int alarmstarted = 0;
+#ifdef CONFIG_SELINUX
+ int flask_enabled = is_flask_enabled();
+ security_id_t sid = 0, old_tty_sid, new_tty_sid;
+#endif
username[0]=0;
amroot = ( getuid ( ) == 0 );
@@ -217,6 +226,36 @@
#ifdef CONFIG_FEATURE_U_W_TMP
setutmp ( username, tty );
#endif
+#ifdef CONFIG_SELINUX
+ if (flask_enabled)
+ {
+ struct stat st;
+
+ if (get_default_sid(username, 0, &sid))
+ {
+ fprintf(stderr, "Unable to get SID for %s\n", username);
+ exit(1);
+ }
+ if (stat_secure(tty, &st, &old_tty_sid))
+ {
+ fprintf(stderr, "stat_secure(%.100s) failed: %.100s\n", tty, strerror(errno));
+ return EXIT_FAILURE;
+ }
+ if (security_change_sid (sid, old_tty_sid, SECCLASS_CHR_FILE, &new_tty_sid) != 0)
+ {
+ fprintf(stderr, "security_change_sid(%.100s) failed: %.100s\n", tty, strerror(errno));
+ return EXIT_FAILURE;
+ }
+ if(chsid(tty, new_tty_sid) != 0)
+ {
+ fprintf(stderr, "chsid(%.100s, %d) failed: %.100s\n", tty, new_tty_sid, strerror(errno));
+ return EXIT_FAILURE;
+ }
+ }
+ else
+ sid = 0;
+#endif
+
if ( *tty != '/' )
snprintf ( full_tty, sizeof( full_tty ) - 1, "/dev/%s", tty);
else
@@ -239,7 +278,11 @@
if ( pw-> pw_uid == 0 )
syslog ( LOG_INFO, "root login %s\n", fromhost );
- run_shell ( pw-> pw_shell, 1, 0, 0 ); /* exec the shell finally. */
+ run_shell ( pw-> pw_shell, 1, 0, 0
+#ifdef CONFIG_SELINUX
+ , sid
+#endif
+ ); /* exec the shell finally. */
return EXIT_FAILURE;
}
Index: su.c
===================================================================
RCS file: /var/cvs/busybox/loginutils/su.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- su.c 19 Mar 2003 09:12:20 -0000 1.3
+++ su.c 3 Jul 2003 10:07:02 -0000 1.4
@@ -156,7 +156,11 @@
change_identity ( pw );
setup_environment ( opt_shell, opt_loginshell, !opt_preserve, pw );
- run_shell ( opt_shell, opt_loginshell, opt_command, (const char**)opt_args );
+ run_shell ( opt_shell, opt_loginshell, opt_command, (const char**)opt_args
+#ifdef CONFIG_SELINUX
+ , 0
+#endif
+ );
return EXIT_FAILURE;
}
More information about the busybox-cvs
mailing list