home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / lib / user-setup / functions.sh next >
Encoding:
Text File  |  2010-07-27  |  1.2 KB  |  45 lines

  1. # Returns a true value if there seems to be a system user account.
  2. is_system_user () {
  3.     if ! [ -e $ROOT/etc/passwd ]; then
  4.         return 1
  5.     fi
  6.     
  7.         # Assume NIS, or any uid from 1000 to 59999,  means there is a user.
  8.         if grep -q '^+:' $ROOT/etc/passwd || \
  9.            grep -q '^[^:]*:[^:]*:[1-9][0-9][0-9][0-9]:' $ROOT/etc/passwd || \
  10.            grep -q '^[^:]*:[^:]*:[1-5][0-9][0-9][0-9][0-9]:' $ROOT/etc/passwd; then
  11.                 return 0
  12.         else
  13.                 return 1
  14.         fi
  15. }
  16.  
  17. # Returns a true value if root already has a password.
  18. root_password () {
  19.     if ! [ -e $ROOT/etc/passwd ]; then
  20.         return 1
  21.     fi
  22.     
  23.     # Assume there is a root password if NIS is being used.
  24.     if grep -q '^+:' $ROOT/etc/passwd; then
  25.         return 0
  26.     fi
  27.  
  28.     # Be more careful than usual about test arguments in the following,
  29.     # just in case (for example) the encrypted password string is "!".
  30.  
  31.     if [ -e $ROOT/etc/shadow ] && \
  32.        [ -n "`grep ^root: $ROOT/etc/shadow | cut -d : -f 2`" ] && \
  33.        [ "x`grep ^root: $ROOT/etc/shadow | cut -d : -f 2`" != 'x*' ]; then
  34.         return 0
  35.     fi
  36.     
  37.     if [ -e $ROOT/etc/passwd ] && \
  38.         [ -n "`grep ^root: $ROOT/etc/passwd | cut -d : -f 2`" ] && \
  39.         [ "x`grep ^root: $ROOT/etc/passwd | cut -d : -f 2`" != 'xx' ]; then
  40.             return 0
  41.     fi
  42.  
  43.     return 1
  44. }
  45.