|
From: Todd K. <tod...@gm...> - 2008-06-13 17:26:17
|
I figured it out.
I was passing the hashes in the wrong order.
I had this:
&modify_user(\%recycleuser, \%user);
but it should be this:
>> &modify_user(\%user, \%recycleuser);
A small over site on my part. Thats for taking the time to look at it.
Now that I have some Webmin coding under my belt I might try some other stuff
like writing a module for Solaris Jumpstart "JET"
Thanks for the help.
On Fri, Jun 13, 2008 at 1:13 PM, Jamie Cameron <jca...@we...> wrote:
> That code looks fine to me - is it doing what you expect?
>
> - Jamie
>
>
> On Jun 13, 2008, at 10:01 AM, "Todd Kennedy" <tod...@gm...> wrote:
>
>> 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
>>>
>>
>> ---
>> ----------------------------------------------------------------------
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services for
>> just about anything Open Source.
>> http://sourceforge.net/services/buy/index.php
>> -
>> 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
>>
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> -
> 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
>
|