[Spice-devel] [phodav PATCH RFC] webdavd: Automount shared folder on Windows

Lukas Venhoda lvenhoda at redhat.com
Tue Aug 11 03:38:56 PDT 2015


Hi,

----- Original Message -----
> From: "Marc-André Lureau" <mlureau at redhat.com>
> To: "Lukas Venhoda" <lvenhoda at redhat.com>
> Cc: spice-devel at lists.freedesktop.org
> Sent: Friday, July 31, 2015 7:21:19 PM
> Subject: Re: [Spice-devel] [phodav PATCH RFC] webdavd: Automount shared folder	on Windows
> 
> Hi Lukas
> 
> ----- Original Message -----
> > Start a new thread, that tries to connect to the shared folder.
> > Sleeps for 1 second between every try.
> 
> Why not assume that the webdav connection is present when entering the main
> loop (after a few seconds perhaps just in case the read returns an error)?

Yes, this could be better. As long as the main loop is polling, I can just try to connect once every time.
I still need to sleep, maybe for a few more seconds (3-5), to be sure, that the read is blocked.
(Only then is the connection to shared folders succesful)

> > Thread exits on succesful connect, or if the drive letter was already
> > asigned.
> > ---
> > https://bugs.freedesktop.org/show_bug.cgi?id=90477
> > 
> > This is just RFC
> > 
> >  - The function needs a way to connect to proper drive letter
> >     - NetUseAdd, or GetLogicalDrives()
> 
> It is assigned dynamically, no?

Only when using NetUseAdd(). WNetAddConnection2() Requires specific drive letter.

> >  - I tried calling this function in callback, in g_task, but it seems, that
> >    Windows can only succesfully map the drive, if the function is called
> >    AFTER the first read (which blocks), that's why I decided to use a new
> >    thread.
> >      - This seems to be the only way to mount the drive in webdavd itself.
> > 
> >  - Currently, if the service maps the drive, the user can't disconnect it.
> >     - This is most likely because service has SYSTEM privileges.
> >     - Need a way to map the drive with user privileges
> 
> I am not sure this is a real problem.

As long as people don't want to disconnect the drive manually, it's ok to leave it as is.

> > 
> >  - Webdavd service on Windows doesn't notice, when the sharing is disabled.
> >     - This could be fixed, if vd_agent handled the start and stop of
> >       webdavd according to state of the Share Folder button in viewer.
> 
> Well, it should notice that connection is gone, the read returns an error.
> There might be a better way to wait until the connection is up instead (I
> remember I couldn't find one, but it should be doable).

When I disabled the sharing, the reads stays blocked for some reason.
I'll keep looking for a solution for this. It's really weird, that it doesn't notice it.

> >     - This would also fix unmapping folder when sharing is disable.
> >        - We could just unmap the drive in webdavd when we stop it.
> 
> yes
> 
> >     - vd_agent could even tell if the webdavd is installed, and grey out
> >     the
> >       Share Folder button accordingaly.
> 
> That would need some more thoughts indeed (I am not sure it's worth the
> effort).

It shouldn't be that much work. There is API to see whether the service is installed and/or running.

> >  - I tried calling this function in callback, in g_task, but it seems, that
> >    Windows can only succesfully map the drive, if the function is called
> >    AFTER the first read (which blocks), that's why I decided to use a new
> >    thread.
> >      - This seems to be the only way to mount the drive in webdavd itself.

> When mounting, Windows will try to populate the folder, so the connection must be up before that. (I don't think a thread helps).

Yes. The thread doesn't help in that the connection must be running, The problem is, that the read blocks when connected,
and I have no way to connect after that. The thread just makes sure, that I can call connect function even when the read is blocked.
There might be a better approach to this, but I couldn't find any that would work and/or wouldn't need significant refactoring.

All in all, I'll clean up the thread, so it doesn't use a while loop and uses the polling, that is currently implemented
(though this will spawn and join a thread with every poll). I'll also clean up the connection, so that the letter is dynamic,
and it doesn't connect when the drive is already mapped.

Then I'll look more into the disconnecting, when sharing is disabled.

Lukas


More information about the Spice-devel mailing list