librpc/spoolss fixes for Samba 4

Jelmer Vernooij jelmer at samba.org
Wed Dec 28 16:17:10 MST 2011


Am 29/12/11 00:08, schrieb Fábio Ramon:
> On 27 December 2011 22:41, Jelmer Vernooij<jelmer at samba.org>  wrote:
>
>> Am 27/12/11 18:43, schrieb Fábio Ramon:
>>
>> def enumPrinterDrivers(server, arch):
>>>      cs = 'ncacn_np:%s' % server
>>>      creds = makeCredentials()
>>>      sp = spoolss.spoolss(cs, credentials=creds)
>>>
>>>      try:
>>>          result = sp.EnumPrinterDrivers(server, arch, 1, 0, 0)
>>>      except Exception, e:
>>>          errno, errstr, result = e
>>>          if errno != constants.SAMBA_WERR_**INSUFFICIENT_BUFFER:
>>>              raise
>>>
>>>      needed = result[2]
>>>      result = sp.EnumPrinterDrivers(server, arch, 1, needed, needed)[1]
>>>
>> I think the API should actually abstract this bit away for you, and just
>> let you do a EnumPrinterDrivers call without having to pass in a length.
>> /it/ should take care of passing in a buffer of the right size and not
>> returning anything to you until it actually has the printer data.
>>
>> The spoolss interface already adds in a lot of code that is not strictly
>> DCE/RPC code, so I think this is a reasonable thing to do.
>>
>> Cheers,
>>
>> Jelmer
>>
>
> I am not familiar with Samba 4 design, so I thought there was a effort to
> maintain a single interface definition (I mean function name and
> parameters) between Python and C RPC clients. Is there any code generated
> from IDL to be directly used by client program written in C at this
> version? I think no.
>
> As Pyhton is a high-level scripting programming language, whose philosophy
> is easy to develop, I and other colleague agree this is a right thing to do.
>
> Do you mean the PIDL parse Python.pm must be modified and Python interfaces
> that has a buffer parameter will be changed to accomplish this? Or at what
> level must this be done?
The spoolss IDL file in Samba 4 is a bit unusual in that it combines 
both the actual interface definition and the layer that lives on top of 
that - which serializes several of the buffers that are a part of spoolss.

This sort of change should be done somewhere in the spoolss IDL file or 
those accompanying helpers. Yes, those changes will affect both the 
Python API and the C API - but that's fine, they both need this 
functionality.

An alternative would be to not have pidl generate python bindings from 
the IDL interface, but to instead have manually written python bindings 
for the thin layer of C helpers that wraps around the spoolss 
marshalling code that is generated by pidl. Personally, I think that 
approach would make the most sense and result in the best Python API 
given the nature of spoolss, but it would probably also be the most work.

Cheers,

jelmer


More information about the samba-technical mailing list