home *** CD-ROM | disk | FTP | other *** search
/ Caldera Network Desktop 1.0 / caldera-network-desktop-1.0.bin / images / ramdisk2-beta.img / usr / lib / perl / users < prev    next >
Text File  |  1995-12-04  |  2KB  |  117 lines

  1. # add users -*-perl-*-
  2.  
  3. sub root_password {
  4.  
  5.     local ( $pid );
  6.  
  7.     &rhs_msgbox("Root Password",
  8. <<EOM
  9. >
  10. You will now enter a password for the root user (super-user).
  11. If you forget this password, you must re-install the system!
  12. >
  13. EOM
  14.         , 60);
  15.  
  16.     if (! $rh_testing) {
  17.     system("cp -f $fsmount/etc/passwd /etc");
  18.     symlink("$fsmount/etc/npasswd.conf", "/etc/npasswd.conf");
  19.     # clear the screen - it looks better that way"
  20.     print "H";
  21.     system("passwd");
  22.     system("cp -f /etc/passwd $fsmount/etc");
  23.     }
  24.  
  25. #    if ($pid = fork) {
  26. #    waitpid($pid, 0);
  27. #    } else {
  28. #    chroot $fsmount;
  29. #    system("passwd");
  30. #    exit 0;
  31. #    }
  32.     
  33.     return 1;
  34. }
  35.  
  36. sub add_users {
  37.  
  38.     local ( $prompt, $username, $pid, $command );
  39.  
  40.     $prompt = 
  41. <<EOM
  42. >
  43. Do you want to create a user account?
  44. >
  45. EOM
  46.     ;
  47.  
  48.     while (1) {
  49.     if (! &rhs_yesno("Create User", $prompt, 50)) {
  50.         return 1;
  51.     }
  52.     $prompt =
  53. <<EOM
  54. >
  55. Do you want to create another user account?
  56. >
  57. EOM
  58.     ;
  59.  
  60.     if (! &rhs_inputbox("User Name",
  61. <<EOM
  62. >
  63. Enter a name for the user account, up to 8 characters.
  64. >
  65. EOM
  66.                 , 60, "")) {
  67.         return 1;
  68.     }
  69.  
  70.     $username = $dialog_result;
  71.  
  72.     if (&rhs_yesno("Home Directory",
  73. <<EOM
  74. >
  75. If your home directories will be mounted via NFS, you can
  76. skip this step. Otherwise, create a home directory.
  77. >
  78. Do you want to create a home directory for $username?
  79. >
  80. EOM
  81.                , 60)) {
  82.         $command = "adduser $username";
  83.     } else {
  84.         $command = "adduser $username NOHOME";
  85.     }
  86.  
  87.     &rhs_infobox("Create User",
  88. <<EOM
  89. >
  90. Creating user account...
  91. >
  92. EOM
  93.              , 60);
  94.  
  95.     if ($pid = fork) {
  96.         waitpid($pid, 0);
  97.     } else {
  98.         if (! $rh_testing) {
  99.         chroot $fsmount;
  100.         open(SAVEOUT, ">&STDOUT");
  101.         open(SAVEERR, ">&STDERR");
  102.         open(STDOUT, ">/dev/null");
  103.         open(STDERR, ">/dev/null");
  104.         system($command);
  105.         open(STDOUT, ">&SAVEOUT");
  106.         open(STDERR, ">&SAVEERR");
  107.         }
  108.  
  109.         exit 0;
  110.     }
  111.     }
  112. }
  113.  
  114.  
  115. ###########################
  116. 1;
  117.