svn commit: trunk/busybox: include loginutils

aldot at busybox.net aldot at busybox.net
Thu Jan 19 18:04:17 UTC 2006


Author: aldot
Date: 2006-01-19 10:04:15 -0800 (Thu, 19 Jan 2006)
New Revision: 13433

Log:
- Document -m, -c, -s and provide a default shell for standalone build.
- Wrap overlong lines plus a few whitespace fixes.
- add GPL header.


Modified:
   trunk/busybox/include/usage.h
   trunk/busybox/loginutils/su.c


Changeset:
Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h	2006-01-19 17:50:23 UTC (rev 13432)
+++ trunk/busybox/include/usage.h	2006-01-19 18:04:15 UTC (rev 13433)
@@ -2814,7 +2814,9 @@
 #define su_full_usage \
 	"Change user id or become root.\n" \
 	"Options:\n" \
-	"\t-p\tPreserve environment"
+	"\t-p, -m\tPreserve environment" \
+	"\n\t-c\tCommand to pass to 'sh -c'" \
+	"\n\t-s\tShell to use instead of default shell"
 
 #define sulogin_trivial_usage \
 	"[OPTION]... [tty-device]"

Modified: trunk/busybox/loginutils/su.c
===================================================================
--- trunk/busybox/loginutils/su.c	2006-01-19 17:50:23 UTC (rev 13432)
+++ trunk/busybox/loginutils/su.c	2006-01-19 18:04:15 UTC (rev 13433)
@@ -1,4 +1,7 @@
 /* vi: set sw=4 ts=4: */
+/*
+   Licensed under the GPL v2, see the file LICENSE in this tarball.
+*/
 
 #include <fcntl.h>
 #include <signal.h>
@@ -18,12 +21,15 @@
 
 #include "busybox.h"
 
+/* The shell to run if none is given in the user's passwd entry.  */
+#ifndef DEFAULT_SHELL
+#define DEFAULT_SHELL "/bin/sh"
+#endif
 
-
-/* The shell to run if none is given in the user's passwd entry.  */
+/* Default user.  */
 #define DEFAULT_USER  "root"
 
-//#define SYSLOG_SUCCESS
+/* #define SYSLOG_SUCCESS */
 #define SYSLOG_FAILURE
 
 
@@ -31,7 +37,8 @@
 /* Log the fact that someone has run su */
 
 # if defined( SYSLOG_SUCCESS ) && defined( SYSLOG_FAILURE )
-static void log_su (const char *successful, const char *old_user, const char *tty)
+static void log_su (const char *successful, const char *old_user,
+					const char *tty)
 {
 	syslog ( LOG_NOTICE, "%s%s on %s", successful, old_user, tty);
 }
@@ -98,7 +105,8 @@
 	if ( !old_user )
 #endif
 		{
-		/* getlogin can fail -- usually due to lack of utmp entry. Resort to getpwuid.  */
+		/* getlogin can fail -- usually due to lack of utmp entry.
+		   Resort to getpwuid.  */
 		pw = getpwuid ( cur_uid );
 		old_user = ( pw ? pw->pw_name : "" );
 	}
@@ -116,8 +124,8 @@
 	/* Make sure pw->pw_shell is non-NULL.  It may be NULL when NEW_USER
 	   is a username that is retrieved via NIS (YP), but that doesn't have
 	   a default shell listed.  */
-	if ( !pw-> pw_shell || !pw->pw_shell [0] )
-		pw-> pw_shell = (char *) DEFAULT_SHELL;
+	if ( !pw->pw_shell || !pw->pw_shell [0] )
+		pw->pw_shell = (char *) DEFAULT_SHELL;
 
 	if ((( cur_uid == 0 ) || correct_password ( pw ))) {
 		log_su_successful(pw->pw_uid, old_user, tty );
@@ -133,7 +141,7 @@
 	if ( !opt_shell && opt_preserve )
 		opt_shell = getenv ( "SHELL" );
 
-	if ( opt_shell && cur_uid && restricted_shell ( pw-> pw_shell )) {
+	if ( opt_shell && cur_uid && restricted_shell ( pw->pw_shell )) {
 		/* The user being su'd to has a nonstandard shell, and so is
 		   probably a uucp account or has restricted access.  Don't
 		   compromise the account by allowing access with a standard
@@ -147,7 +155,7 @@
 
 	change_identity ( pw );
 	setup_environment ( opt_shell, opt_loginshell, !opt_preserve, pw );
-#ifdef CONFIG_SELINUX
+#if ENABLE_SELINUX
        set_current_security_context(NULL);
 #endif
 	run_shell ( opt_shell, opt_loginshell, opt_command, (const char**)opt_args);




More information about the busybox-cvs mailing list