X-Git-Url: https://git.cameronkatri.com/pw-darwin.git/blobdiff_plain/d8f99db12f55e1f07f7eb60a408904a29aa56d65..b0c53286ae634ab410a90cd6ec0372e9961ab406:/adduser/adduser.perl?ds=inline diff --git a/adduser/adduser.perl b/adduser/adduser.perl index 42a1c5e..dec26df 100644 --- a/adduser/adduser.perl +++ b/adduser/adduser.perl @@ -24,7 +24,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $Id: adduser.perl,v 1.24 1996/12/29 15:06:52 wosch Exp $ +# $Id: adduser.perl,v 1.30 1997/05/01 23:23:06 ache Exp $ # read variables @@ -33,7 +33,7 @@ sub variables { $defaultpasswd = "yes"; # use password for new users $dotdir = "/usr/share/skel"; # copy dotfiles from this dir $dotdir_bak = $dotdir; - $send_message = "no"; # send message to new user + $send_message = "/etc/adduser.message"; # send message to new user $send_message_bak = '/etc/adduser.message'; $config = "/etc/adduser.conf"; # config file for adduser $config_read = 1; # read config file @@ -53,6 +53,7 @@ sub variables { $defaultshell = 'sh'; # defaultshell if not empty $group_uniq = 'USER'; $defaultgroup = $group_uniq;# login groupname, $group_uniq means username + $defaultclass = ''; $uid_start = 1000; # new users get this uid $uid_end = 32000; # max. uid @@ -245,6 +246,10 @@ sub passwd_read { while(

) { chop; push(@passwd_backup, $_); + # ignore comments + next if /^\s*$/; + next if /^\s*#/; + ($p_username, $pw, $p_uid, $p_gid, $sh) = (split(/:/, $_))[0..3,9]; print "$p_username already exists with uid: $username{$p_username}!\n" @@ -272,6 +277,10 @@ sub group_read { while() { chop; push(@group_backup, $_); + # ignore comments + next if /^\s*$/; + next if /^\s*#/; + ($g_groupname, $pw, $g_gid, $memb) = (split(/:/, $_))[0..3]; $groupmembers{$g_gid} = $memb; @@ -383,6 +392,16 @@ sub new_users_id { return &next_id($name); } +# return login class for user +sub new_users_class { + local($def) = @_; + local($class); + + $class = &confirm_list("Enter login class:", 1, $def, ($def, "default")); + $class = "" if $class eq "default"; + return $class; +} + # add user to group sub add_group { local($gid, $name) = @_; @@ -524,6 +543,7 @@ Password: **** Fullname: $fullname Uid: $u_id Gid: $g_id ($group_login) +Class: $class Groups: $group_login $new_groups HOME: $home/$name Shell: $sh @@ -668,9 +688,10 @@ sub new_users { # sh: shell # u_id: user id # g_id: group id + # class: login class # group_login: groupname of g_id # new_groups: some other groups - local($name, $group_login, $fullname, $sh, $u_id, $g_id, $new_groups); + local($name, $group_login, $fullname, $sh, $u_id, $g_id, $class, $new_groups); local($groupmembers_bak, $cryptpwd); local($new_users_ok) = 1; @@ -683,6 +704,7 @@ sub new_users { $fullname = &new_users_fullname($name); $sh = &new_users_shell; ($u_id, $g_id) = &new_users_id($name); + $class = &new_users_class($defaultclass); ($group_login, $defaultgroup) = &new_users_grplogin($name, $defaultgroup, $new_users_ok); # do not use uniq username and login group @@ -699,7 +721,7 @@ sub new_users { $cryptpwd = crypt($password, &salt) if $password ne ""; # obscure perl bug $new_entry = "$name\:" . "$cryptpwd" . - "\:$u_id\:$g_id\::0:0:$fullname:$home/$name:$sh"; + "\:$u_id\:$g_id\:$class\:0:0:$fullname:$home/$name:$sh"; &append_file($etc_passwd, "$new_entry"); &new_users_pwdmkdb("$new_entry"); &new_users_group_update; @@ -719,7 +741,7 @@ sub new_users { } sub batch { - local($name, $groups, $fullname, $password) = @_; + local($name, $groups, $class, $fullname, $password) = @_; local($sh); $defaultshell = &shell_default_valid($defaultshell); @@ -736,11 +758,12 @@ sub batch { ($flag, $new_groups) = &new_users_groups_valid($groups); return 0 if $flag; + $class = $defaultclass if $class eq ""; $cryptpwd = ""; $cryptpwd = crypt($password, &salt) if $password ne ""; # obscure perl bug $new_entry = "$name\:" . "$cryptpwd" . - "\:$u_id\:$g_id\::0:0:$fullname:$home/$name:$sh"; + "\:$u_id\:$g_id\:$class\:0:0:$fullname:$home/$name:$sh"; &append_file($etc_passwd, "$new_entry"); &new_users_pwdmkdb("$new_entry"); &new_users_group_update; @@ -770,8 +793,9 @@ sub check_root { sub usage { warn <