[Freeipa-devel] [PATCH] Change the behaviour of addattr/setattr parameters

Adam Young ayoung at redhat.com
Fri Aug 13 20:24:54 UTC 2010


On 08/12/2010 09:35 AM, Pavel Zůna wrote:
> On 2010-08-12 14:38, Rob Crittenden wrote:
>> Pavel Zůna wrote:
>>> On 2010-08-12 04:46, Rob Crittenden wrote:
>>>> Pavel Zůna wrote:
>>>>> setattr and addattr can now be used both to set all values of
>>>>> ANY attribute. the last setattr always resets the attribute to
>>>>> the specified value and all addattr append to it.
>>>>>
>>>>> Examples:
>>>>> user-mod testuser --setattr=title=msc
>>>>> title: msc
>>>>> user-mod testuser --setattr=title=msb
>>>>> title: msb
>>>>> user-mod testuser --addattr=title=msc
>>>>> title: msb, msc
>>>>> user-mod testuser --setattr=title=
>>>>> title:
>>>>> user-mod testuser --setattr=title=msc --addattr=msb
>>>>> title: msc, msb
>>>>> user-mod testuser --setattr=title=ing --addattr=bc
>>>>> title: ing, bc
>>>>> user-mod testuser --setattr=title=doc
>>>>> title: doc
>>>>>
>>>>> It's not very user friendly, but it's going to be used very very
>>>>> rarely in special conditions in the CLI and we can use it to save
>>>>> lots of JSON-RPC roundtrips in the webUI.
>>>>>
>>>>> Pavel
>>>>
>>>> It was my intention when I added addattr and setattr that one couldn't
>>>> set already-defined params this way. They were silently ignored. So 
>>>> you
>>>> couldn't do:
>>>>
>>>> user-mod testuser --setattr=givenname=Jeff
>>>>
>>>> This would be possible with this patch. Was that intentional?
>>>>
>>>> BTW I have the start of a test suite for this functionality.
>>>>
>>>> rob
>>>
>>> Yes, it is intentional. I forgot to mention it in the description. I'm
>>> using setattr/addattr for everything in the webUI - it makes the code a
>>> lot simpler.
>>
>> Doesn't that invalidate all the validators we have in the plugins? This
>> is why I disallowed it.
>>
>> rob
>
> It does, but I see these options as something only experienced users, 
> who need to set something we don't support directly, will use. 
> Sometimes they might want to disable the validators, if they know what 
> they're doing. We could also make the setattr/addattr handler in 
> frontend.py detect if a there's a validator available and use it.
>
> Validators in the webUI is still something we need to figure out. Adam 
> was proposing having validators in the form of regex strings, which is 
> not a bad idea as it's easy to implement on any platform/language. On 
> the other hand, I don't know if it's good enough for all parameters we 
> have.
>
> Hmm. There's a lot to think about here actually. I'll make it my 
> homework for the weekend. :)
>
> Pavel
>
> _______________________________________________
> Freeipa-devel mailing list
> Freeipa-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/freeipa-devel


Here's my version, that just calls the parameter prior to updating the 
attr.  I tested it with:

[root at ipa ~]# ipa user-mod --setattr uidnumber=555 kfrog
---------------------
Modified user "kfrog"
---------------------
   User login: kfrog
   First name: Kermit
   Last name: Frog
   Home directory: /home/kfrog
   Login shell: /bin/sh
   UID: 555
   Groups: ipausers
[root at ipa ~]# ipa user-mod --setattr uidnumber=frog kfrog
ipa: ERROR: invalid 'uidnumber': must be an integer



-------------- next part --------------
A non-text attachment was scrubbed...
Name: admiyo-freeipa-0007-setaddattr.patch
Type: text/x-patch
Size: 5973 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20100813/917623c8/attachment.bin>


More information about the Freeipa-devel mailing list