title: How to create a login script based on the root password in Linux Distro Openwrt?
body: <p>&nbsp;&nbsp;&nbsp;&nbsp; I have a web application in Linux Distro Openwrt ,  where I am using the root password for login by user.  I was able to change the root password from a 'password change' html page using a cgi program in c by calling the system command to change the root password.  </p>
  
  <p><code>system("(echo 'newpassword'; sleep 1; echo 'newpassword') | passwd root");</code></p>
  
  <p>&nbsp;&nbsp; &nbsp;&nbsp; Now the problem I am facing is that , I am not getting how to make the login page functional.. ( how to login with the root password? what sort of cgi should I use there? or should I call a script which may be already there in openwrt?) . I found a script login.sh in /bin folder, but Is that a login script (script given below)? </p>
  
  <pre><code>#!/bin/sh
  if ( ! grep -qs '^root:[!x]\?:' /etc/shadow || \
  
   ! grep -qs '^root:[!x]\?:' /etc/passwd ) &amp;&amp; \
  [ -z "$FAILSAFE" ]
  
  then
  
      echo "Login failed."
      exit 0
  
  
  else
  
  cat &lt;&lt; EOF
  
  
  
  === IMPORTANT ============================
    Use 'passwd' to set your login password
    this will disable telnet and enable SSH
   ------------------------------------------
  
  EOF
  fi
  exec /bin/ash --login
  </code></pre>
  
  <p>How is LuCI doing that?..</p>
  
  <p>I hope the question is clear.</p>
  
  <p>Thanks.</p>