From: Todd K. <tod...@or...> - 2008-06-02 19:13:19
|
Hello, I am new to webmin module development and am trying to extend the "Users & Groups" module for internal purposes. What I have done is create a "Recycle User" button on the selected users "Edit Users" page that basically mimics the functionality of the delete_user.cgi (without actually deleting the user) but also extends it by showing me a list of currently selected user processes running. Once I press the "Recycle user and home directory button" it goes off and first terminates those running processes then removes the users home directory then I need to reset the users password back to some default. I am about 90% of the way there but seem to be caught up on the saving of the modified password. I am using the modify_user function. Whats actually happening is that it's leaving an incomplete line in the /etc/password and shadow file looking something like this: svctag:*LK*:6445:::::: nobody:*LK*:6445:::::: noaccess:*LK*:6445:::::: nobody4:*LK*:6445:::::: :::::::: This last line should be the entry that I recycled but it's just a bunch of empty GECOS fields. So it seems to me that it's rewriting the line but is doing it with empty values. So I think I am missing something somewhere but am unsure what other functions possibly I need to call in order for it to write out the password file. I'm assuming the modify_user function takes care of that, no? This does seem like a strange thing to do but would fit nicely into managing test accounts for may lab machines. When the lab reservation expires the admin can recycle the user with a press of the button and set it back to some default settings. Here's the snippet of code that is suppose to be resetting the password and saving it. %recycleuser = %{$ulist[$in{'num'}]}; $pass = &encrypt_password($config{'recycle_passwd'}); $recycleuser{'pass'} = $pass; # Update user details &modify_user(\%recycleuser, \%user); # Run the pre-change command $merr = &making_changes(); &error(&text('usave_emaking', "<tt>$merr</tt>")) if (defined($merr)); &unlock_user_files(); &made_changes(); So as the code runs the following is displayed in the borwser, The has info is there for debugging purposes. Deleting from other modules .. .. done Killing user processes .. done Deleting home directory .. .. done Creating Home Directory .. done new encrypted passwd=TN4xb4vuWbxc6 Contents of recycleuser Hash prior to change num => 20 inactive => max => warn => user => testuser shell => /bin/sh home => /export/home/testuser real => line => 20 pass => NNwEdL/U3qYwU sline => 20 uid => 1000 change => 14032 min => expire => gid => 10 Contents of User hash after replacing $pass but before saving num => 20 inactive => max => warn => user => testuser shell => /bin/sh home => /export/home/testuser real => line => 20 pass => TN4xb4vuWbxc6 sline => 20 uid => 1000 change => 14032 min => expire => gid => 10 Reread the %ulist has for the user "Still has the old password" num => 20 inactive => max => warn => user => testuser shell => /bin/sh home => /export/home/testuser real => line => 20 pass => NNwEdL/U3qYwU sline => 20 uid => 1000 change => 14032 min => expire => gid => 10 Any help on this would be much appriciated. |