On Mon, May 23, 2011 at 02:12:58PM +0200, Rene Nussbaumer wrote:
> On Fri, May 20, 2011 at 3:48 PM, Iustin Pop <[email protected]> wrote:
> > On Fri, May 20, 2011 at 02:32:25PM +0200, Rene Nussbaumer wrote:
> >> On Fri, May 20, 2011 at 11:31 AM, Iustin Pop <[email protected]> wrote:
> >> > On Fri, May 20, 2011 at 10:50:25AM +0200, René Nussbaumer wrote:
> >> >> ---
> >> >> lib/backend.py | 6 ++++++
> >> >> lib/rpc.py | 6 ++++--
> >> >> 2 files changed, 10 insertions(+), 2 deletions(-)
> >> >>
> >> >> diff --git a/lib/backend.py b/lib/backend.py
> >> >> index 339440b..13803f7 100644
> >> >> --- a/lib/backend.py
> >> >> +++ b/lib/backend.py
> >> >> @@ -1821,6 +1821,12 @@ def UploadFile(file_name, data, mode, uid, gid,
> >> >> atime, mtime):
> >> >>
> >> >> raw_data = _Decompress(data)
> >> >>
> >> >> + getents = runtime.GetEnts()
> >> >> + if isinstance(uid, str):
> >> >> + uid = getents.LookupUser(uid)
> >> >> + if isinstance(gid, str):
> >> >> + gid = getents.LookupGroup(gid)
> >> >
> >> > I wonder if we shouldn't make it so that it's always using names, i.e.
> >> > abort if we get integers. Otherwise it could be that someone adds a new
> >> > call to this RPC with IDs that are not synced. What do you think?
> >>
> >> Good point, changed and put in assert for that.
> >
> > Mmm. Since these are parameters received over the network, I don't think
> > an assert is right. Could you please change it into if not
> > isinstance(uid, str) and …: _Fail("Invalid username/groupname type")?
> > That will be reported much better to the master daemon.
[+list]
> diff --git a/lib/backend.py b/lib/backend.py
> index de69397..da91cea 100644
> --- a/lib/backend.py
> +++ b/lib/backend.py
> @@ -1801,10 +1801,10 @@ def UploadFile(file_name, data, mode, uid,
> gid, atime, mtime):
> @param data: the new contents of the file
> @type mode: int
> @param mode: the mode to give the file (can be None)
> - @type uid: int
> - @param uid: the owner of the file (can be -1 for default)
> - @type gid: int
> - @param gid: the group of the file (can be -1 for default)
> + @type uid: string
> + @param uid: the owner of the file
> + @type gid: string
> + @param gid: the group of the file
> @type atime: float
> @param atime: the atime to set on the file (can be None)
> @type mtime: float
> @@ -1821,8 +1821,8 @@ def UploadFile(file_name, data, mode, uid, gid,
> atime, mtime):
>
> raw_data = _Decompress(data)
>
> - assert isinstance(uid, str)
> - assert isinstance(gid, str)
> + if not (isinstance(uid, basestring) or isinstance(gid, basestring)):
> + _Fail("Invalid username/groupname type")
This has to be "and". Then LGTM.
iustin