claukiller

Untitled

May 4th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Juan Francisco Piñera Ovejero - UO244707
  4. ALUMNO1=$1
  5. ALUMNO2=$2
  6. MICLAVE=$3
  7. GRUPO="pringaos"
  8. HOME_DIR="/home/pringaos"
  9. SHELL1="/bin/bash"
  10. SHELL2="/bin/sh"
  11.  
  12. CIFRADO1=`python -c '\\
  13. import random
  14. pos_char= "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
  15. num_car = 8
  16. salt ="$1$"
  17. for c in range(num_car):
  18. salt = salt + pos_char[random.randint(0,len(pos_char)-1)]
  19. salt += "$"
  20. print salt'`
  21.  
  22.  
  23. CIFRADO2=`python -c '\\
  24. import random
  25. pos_char= "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
  26. num_car = 8
  27. salt ="$5$"
  28. for c in range(num_car):
  29. salt = salt + pos_char[random.randint(0,len(pos_char)-1)]
  30. salt += "$"
  31. print salt'`
  32.  
  33. # Crea el directorio del grupo si es que no existe
  34. # para ello debes buscar como comprobar si existe a no un directorio
  35. # y en caso de existir generar un mensaje que digo auq ya existe
  36. # y si no crearlo.
  37. if [ -d $HOME_DIR];
  38. then
  39. echo "ya existe el directorio"
  40. else
  41. mkdir $HOME_DIR
  42. fi
  43. # Crea el grupo al que van a pertenecer los usuarios utilizando la
  44. # variable GRUPO
  45. groupadd $GRUPO
  46.  
  47. PASSWORD1=`python -c "import crypt;print crypt.crypt('$MICLAVE','$CIFRADO1')"`
  48. PASSWORD2=`python -c "import crypt;print crypt.crypt('$MICLAVE','$CIFRADO2')"`
  49.  
  50. # Creo el usuario1
  51. useradd -d $HOME_DIR/$ALUMNO1 -m $ALUMNO1 -s $SHELL1 -g $GRUPO -p $PASSWORD1
  52.  
  53. # Creo el usuario2
  54. useradd -d $HOME_DIR/$ALUMNO2 -m $ALUMNO2 -s $SHELL2 -g $GRUPO -p $PASSWORD2
  55.  
  56. done
Add Comment
Please, Sign In to add comment