[BusyBox] Re: check_login in loginutils/login.c

Friedrich Lobenstock fl at fl.priv.at
Wed Jan 7 10:57:26 UTC 2004


Tito wrote on 07.01.2004 12:31 MET:
> On Tuesday 06 January 2004 23:19, Friedrich Lobenstock wrote:
>
>>How about the patch below? It calls check_nologin for a user-id
>>which I think is more clear and let me show you that we even
>>reduce code size:
>>
>>[...]
>>
>>Difference: 32 Bytes (because we do one comparision less than before)
>>[ note: result valid for the CRIS architecture, numbers might differ on
>>other arch ]
>>
>>--- busybox-1.00-pre5/loginutils/login.c.org
>>+++ busybox-1.00-pre5/loginutils/login.c	2004-01-06
>>[...]
> 
> At this point to be coherent rather than writing a comment do
> 		if(uid!=0)
> 
>>+		if ( uid ) /* !root */
>>  			return 1;
> 
> Looks easier to understand at the first glance...........

Ok you are right. For the compile it's the same, so here's the updated patch:

--- busybox-1.00-pre5/loginutils/login.c.org	2004-01-06 23:33:24.000000000 +0100
+++ busybox-1.00-pre5/loginutils/login.c	2004-01-07 11:53:30.000000000 +0100
@@ -37,7 +37,7 @@
  #define USERNAME_SIZE 32


-static int check_nologin ( int amroot );
+static int check_nologin ( int uid );

  #if defined CONFIG_FEATURE_SECURETTY
  static int check_tty ( const char *tty );
@@ -217,7 +217,7 @@
  	}
  		
  	alarm ( 0 );
-	if ( check_nologin ( pw-> pw_uid == 0 ))
+	if ( check_nologin ( pw-> pw_uid ))
  		return EXIT_FAILURE;

  #ifdef CONFIG_FEATURE_U_W_TMP
@@ -315,7 +315,7 @@
  }


-static int check_nologin ( int amroot )
+static int check_nologin ( int uid )
  {
  	if ( access ( bb_path_nologin_file, F_OK ) == 0 ) {
  		FILE *fp;
@@ -330,7 +330,7 @@
  		} else {
  			puts ( "\r\nSystem closed for routine maintenance.\r" );
  		}
-		if ( !amroot )
+		if ( uid!=0 )
  			return 1;
  			
  		puts ( "\r\n[Disconnect bypassed -- root login allowed.]\r" );


-- 
MfG / Regards
Friedrich Lobenstock




More information about the busybox mailing list