Re: [Spice-devel] [spice-gtk] smartcard: Warn if multiple readers are detected

2019-02-21 Thread Frediano Ziglio
> 
> Hi
> 
> On Thu, Feb 21, 2019 at 4:21 PM Christophe Fergeau 
> wrote:
> >
> > On Thu, Feb 21, 2019 at 03:59:00PM +0100, Marc-André Lureau wrote:
> > > Hi
> > >
> > > On Wed, Feb 20, 2019 at 5:17 PM Christophe Fergeau 
> > > wrote:
> > > >
> > > > spice-server does not deal properly with multiple smartcard readers,
> > > > only the first one will be working. Add a warning when this happens to
> > > > make it easier to diagnose such issues.
> > > >
> > > > Signed-off-by: Christophe Fergeau 
> > > > ---
> > > >  src/smartcard-manager.c | 20 
> > > >  1 file changed, 20 insertions(+)
> > > >
> > > > diff --git a/src/smartcard-manager.c b/src/smartcard-manager.c
> > > > index ceecfdc7..456c3c2e 100644
> > > > --- a/src/smartcard-manager.c
> > > > +++ b/src/smartcard-manager.c
> > > > @@ -389,6 +389,25 @@ typedef struct {
> > > >  GError *err;
> > > >  } SmartcardManagerInitArgs;
> > > >
> > > > +/* spice-server only supports one smartcard reader being in use */
> > > > +static void smartcard_check_reader_count(void)
> > > > +{
> > > > +unsigned int reader_count = 0;
> > > > +GList *readers;
> > > > +GList *it;
> > > > +
> > > > +readers =
> > > > spice_smartcard_manager_get_readers(spice_smartcard_manager_get());
> > > > +
> > > > +for (it = readers; it != NULL; it = it->next) {
> > > > +reader_count++;
> > > > +g_boxed_free(SPICE_TYPE_SMARTCARD_READER, it->data);
> > > > +}
> > > > +if (reader_count > 1) {
> > > > +g_warning("Multiple smartcard readers are plugged in, only the
> > > > first one will be shared with the VM");
> > > > +}
> > > > +g_list_free(readers);
> > >
> > >
> > > looks ok, ack
> > >
> > > it could eventually be simplified with g_list_count() &
> > > g_list_free_full() (that would require wrapping the boxed_free with a
> > > helper)
> >
> > I thought about it, given the need for a wrapper, it felt better to do
> > it this way.
> >
> 
> The wrapper could potentially simplify other parts of the code, your call.
> 

Why not using vreader_get_reader_list directly? It has a simple 
vreader_list_delete.

Frediano
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Re: [Spice-devel] [spice-gtk] smartcard: Warn if multiple readers are detected

2019-02-21 Thread Marc-André Lureau
Hi

On Thu, Feb 21, 2019 at 4:21 PM Christophe Fergeau  wrote:
>
> On Thu, Feb 21, 2019 at 03:59:00PM +0100, Marc-André Lureau wrote:
> > Hi
> >
> > On Wed, Feb 20, 2019 at 5:17 PM Christophe Fergeau  
> > wrote:
> > >
> > > spice-server does not deal properly with multiple smartcard readers,
> > > only the first one will be working. Add a warning when this happens to
> > > make it easier to diagnose such issues.
> > >
> > > Signed-off-by: Christophe Fergeau 
> > > ---
> > >  src/smartcard-manager.c | 20 
> > >  1 file changed, 20 insertions(+)
> > >
> > > diff --git a/src/smartcard-manager.c b/src/smartcard-manager.c
> > > index ceecfdc7..456c3c2e 100644
> > > --- a/src/smartcard-manager.c
> > > +++ b/src/smartcard-manager.c
> > > @@ -389,6 +389,25 @@ typedef struct {
> > >  GError *err;
> > >  } SmartcardManagerInitArgs;
> > >
> > > +/* spice-server only supports one smartcard reader being in use */
> > > +static void smartcard_check_reader_count(void)
> > > +{
> > > +unsigned int reader_count = 0;
> > > +GList *readers;
> > > +GList *it;
> > > +
> > > +readers = 
> > > spice_smartcard_manager_get_readers(spice_smartcard_manager_get());
> > > +
> > > +for (it = readers; it != NULL; it = it->next) {
> > > +reader_count++;
> > > +g_boxed_free(SPICE_TYPE_SMARTCARD_READER, it->data);
> > > +}
> > > +if (reader_count > 1) {
> > > +g_warning("Multiple smartcard readers are plugged in, only the 
> > > first one will be shared with the VM");
> > > +}
> > > +g_list_free(readers);
> >
> >
> > looks ok, ack
> >
> > it could eventually be simplified with g_list_count() &
> > g_list_free_full() (that would require wrapping the boxed_free with a
> > helper)
>
> I thought about it, given the need for a wrapper, it felt better to do
> it this way.
>

The wrapper could potentially simplify other parts of the code, your call.


-- 
Marc-André Lureau
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Re: [Spice-devel] [spice-gtk] smartcard: Warn if multiple readers are detected

2019-02-21 Thread Christophe Fergeau
On Thu, Feb 21, 2019 at 03:59:00PM +0100, Marc-André Lureau wrote:
> Hi
> 
> On Wed, Feb 20, 2019 at 5:17 PM Christophe Fergeau  
> wrote:
> >
> > spice-server does not deal properly with multiple smartcard readers,
> > only the first one will be working. Add a warning when this happens to
> > make it easier to diagnose such issues.
> >
> > Signed-off-by: Christophe Fergeau 
> > ---
> >  src/smartcard-manager.c | 20 
> >  1 file changed, 20 insertions(+)
> >
> > diff --git a/src/smartcard-manager.c b/src/smartcard-manager.c
> > index ceecfdc7..456c3c2e 100644
> > --- a/src/smartcard-manager.c
> > +++ b/src/smartcard-manager.c
> > @@ -389,6 +389,25 @@ typedef struct {
> >  GError *err;
> >  } SmartcardManagerInitArgs;
> >
> > +/* spice-server only supports one smartcard reader being in use */
> > +static void smartcard_check_reader_count(void)
> > +{
> > +unsigned int reader_count = 0;
> > +GList *readers;
> > +GList *it;
> > +
> > +readers = 
> > spice_smartcard_manager_get_readers(spice_smartcard_manager_get());
> > +
> > +for (it = readers; it != NULL; it = it->next) {
> > +reader_count++;
> > +g_boxed_free(SPICE_TYPE_SMARTCARD_READER, it->data);
> > +}
> > +if (reader_count > 1) {
> > +g_warning("Multiple smartcard readers are plugged in, only the 
> > first one will be shared with the VM");
> > +}
> > +g_list_free(readers);
> 
> 
> looks ok, ack
> 
> it could eventually be simplified with g_list_count() &
> g_list_free_full() (that would require wrapping the boxed_free with a
> helper)

I thought about it, given the need for a wrapper, it felt better to do
it this way.

Christophe


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Re: [Spice-devel] [spice-gtk] smartcard: Warn if multiple readers are detected

2019-02-21 Thread Marc-André Lureau
Hi

On Wed, Feb 20, 2019 at 5:17 PM Christophe Fergeau  wrote:
>
> spice-server does not deal properly with multiple smartcard readers,
> only the first one will be working. Add a warning when this happens to
> make it easier to diagnose such issues.
>
> Signed-off-by: Christophe Fergeau 
> ---
>  src/smartcard-manager.c | 20 
>  1 file changed, 20 insertions(+)
>
> diff --git a/src/smartcard-manager.c b/src/smartcard-manager.c
> index ceecfdc7..456c3c2e 100644
> --- a/src/smartcard-manager.c
> +++ b/src/smartcard-manager.c
> @@ -389,6 +389,25 @@ typedef struct {
>  GError *err;
>  } SmartcardManagerInitArgs;
>
> +/* spice-server only supports one smartcard reader being in use */
> +static void smartcard_check_reader_count(void)
> +{
> +unsigned int reader_count = 0;
> +GList *readers;
> +GList *it;
> +
> +readers = 
> spice_smartcard_manager_get_readers(spice_smartcard_manager_get());
> +
> +for (it = readers; it != NULL; it = it->next) {
> +reader_count++;
> +g_boxed_free(SPICE_TYPE_SMARTCARD_READER, it->data);
> +}
> +if (reader_count > 1) {
> +g_warning("Multiple smartcard readers are plugged in, only the first 
> one will be shared with the VM");
> +}
> +g_list_free(readers);


looks ok, ack

it could eventually be simplified with g_list_count() &
g_list_free_full() (that would require wrapping the boxed_free with a
helper)

> +}
> +
>  static gboolean smartcard_manager_init(SmartcardManagerInitArgs *args)
>  {
>  gchar *emul_args = NULL;
> @@ -442,6 +461,7 @@ init:
>  "Failed to initialize smartcard");
>  goto end;
>  }
> +smartcard_check_reader_count();
>
>  retval = TRUE;
>
> --
> 2.20.1
>
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Spice-devel] [spice-gtk] smartcard: Warn if multiple readers are detected

2019-02-20 Thread Christophe Fergeau
spice-server does not deal properly with multiple smartcard readers,
only the first one will be working. Add a warning when this happens to
make it easier to diagnose such issues.

Signed-off-by: Christophe Fergeau 
---
 src/smartcard-manager.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/smartcard-manager.c b/src/smartcard-manager.c
index ceecfdc7..456c3c2e 100644
--- a/src/smartcard-manager.c
+++ b/src/smartcard-manager.c
@@ -389,6 +389,25 @@ typedef struct {
 GError *err;
 } SmartcardManagerInitArgs;
 
+/* spice-server only supports one smartcard reader being in use */
+static void smartcard_check_reader_count(void)
+{
+unsigned int reader_count = 0;
+GList *readers;
+GList *it;
+
+readers = 
spice_smartcard_manager_get_readers(spice_smartcard_manager_get());
+
+for (it = readers; it != NULL; it = it->next) {
+reader_count++;
+g_boxed_free(SPICE_TYPE_SMARTCARD_READER, it->data);
+}
+if (reader_count > 1) {
+g_warning("Multiple smartcard readers are plugged in, only the first 
one will be shared with the VM");
+}
+g_list_free(readers);
+}
+
 static gboolean smartcard_manager_init(SmartcardManagerInitArgs *args)
 {
 gchar *emul_args = NULL;
@@ -442,6 +461,7 @@ init:
 "Failed to initialize smartcard");
 goto end;
 }
+smartcard_check_reader_count();
 
 retval = TRUE;
 
-- 
2.20.1

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel