Changeset 22282


Ignore:
Timestamp:
2010-07-18T20:36:12+02:00 (8 years ago)
Author:
jow
Message:

[package] base-files, busybox: fix 22279, simplify code and get rid of awk

Location:
trunk/package
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/base-files/files/bin/login.sh

    r22279 r22282  
    11#!/bin/sh 
    2 # Copyright (C) 2006 OpenWrt.org 
     2# Copyright (C) 2006-2010 OpenWrt.org 
    33 
    4  
    5 regpassresult="0" 
    6 grep '^root:[^!]' /etc/passwd >&- 2>&- 
    7 regpassresult="$?" 
    8 shadowresult="0" 
    9 if [ -e "/etc/shadow" ]; then 
    10         grep '^root:[^!]' /etc/shadow >&- 2>&- 
    11         shadowresult="$?" 
    12 fi 
    13 [ "$regpassresult" = "0" ] && [ "$shadowresult" = "0" ] && [ -z "$FAILSAFE" ] && { 
    14     echo "Login failed." 
    15     exit 0 
    16 } || { 
     4if grep -qs '^root:[^!]' /etc/passwd /etc/shadow && [ -z "$FAILSAFE" ]; then 
     5        echo "Login failed." 
     6        exit 0 
     7else 
    178cat << EOF 
    189 === IMPORTANT ============================ 
     
    2112 ------------------------------------------ 
    2213EOF 
    23 } 
     14fi 
    2415 
    2516exec /bin/ash --login 
  • trunk/package/busybox/files/telnet

    r22279 r22282  
    11#!/bin/sh /etc/rc.common 
    2 # Copyright (C) 2006 OpenWrt.org 
     2# Copyright (C) 2006-2010 OpenWrt.org 
    33START=50 
    44 
     5has_root_pwd() { 
     6        local pwd=$([ -f "$1" ] && cat "$1") 
     7              pwd="${pwd#*root:}" 
     8              pwd="${pwd%%:*}" 
     9 
     10        test -n "${pwd#!}" 
     11} 
     12 
    513start() { 
    6         if      [ \! -f /etc/passwd ] || \ 
    7                 ( awk -F: '/^root:/ && ($2 != "") && ($2 !~ /\!/) {exit 1}' /etc/passwd 2>/dev/null && \ 
    8                 awk -F: '/^root:/ && ($2 != "") && ($2 !~ /\!/) {exit 1}' /etc/shadow 2>/dev/null ) || \ 
    9                 ( [ \! -x /usr/sbin/dropbear ] && [ \! -x /usr/sbin/sshd ] ) 
    10         then \ 
     14        if ( ! has_root_pwd /etc/passwd && ! has_root_pwd /etc/shadow ) || \ 
     15           ( [ ! -x /usr/sbin/dropbear ] && [ ! -x /usr/sbin/sshd ] ); 
     16        then 
    1117                telnetd -l /bin/login.sh 
    1218        fi 
     
    1420 
    1521stop() { 
    16         killall telnetd 
     22        killall telnetd 2>/dev/null 
    1723} 
     24 
Note: See TracChangeset for help on using the changeset viewer.