From: Todd K. <tod...@gm...> - 2008-06-13 17:01:29
|
Hi Jamie, One question. If I am resetting the password and I am encrypting it like so: $pass = &encrypt_password($config{'recycle_passwd'}); $recycleuser{'pass'} = $pass; and then I am calling modify_user like so &modify_user(\%recycleuser, \%user); Is the hash key 'pass' what I should be using to reset the password if I'm doing the encryption outside of the modify_user function or should I be using something else? On Mon, Jun 2, 2008 at 5:04 PM, Jamie Cameron <jca...@we...> wrote: > Hi Todd, > > Make sure that in your code, you aren't calling modify_user with an > empty user hash. It looks like that is the case, as this would cause > an 'empty' line like that to be inserted into /etc/passwd. > > I'd have to see all your code to comment further though.. > > - Jamie > > On 02/Jun/2008 12:11 Todd Kennedy wrote .. >> 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. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > - > Forwarded by the Webmin development list at web...@we... > To remove yourself from this list, go to > http://lists.sourceforge.net/lists/listinfo/webadmin-devel > |