You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by vwguac <hw...@rcs.de> on 2020/03/27 19:28:31 UTC

Guacamole RDP Printing not work

A print job is created in the rdp session, but is not issued as a pdf to the
client.

guacd[839]: DEBUG: Ignoring printer cached configuration data
guacd[839]: INFO: Print job created
guacd[839]: INFO: Created PDF filter process PID=862
guacd[839]: DEBUG: Reading output from filter process...
guacd[862]: INFO: Running gs
guacd[839]: ERROR: Unknown printer I/O request function: 0x3/0x0



--
Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: Guacamole RDP Printing not work

Posted by Mike Jumper <mj...@apache.org>.
Thanks - I'll reopen the issue in JIRA.

I expect we just need to respond to the I/O request with
STATUS_NOT_SUPPORTED.

- Mike


On Fri, Apr 3, 2020, 11:43 vwguac <hw...@rcs.de> wrote:

> I have adjusted the guacd code.
> Now I answer the read request with a dummy string and it works. :-)
> Windows doesn't seem to care what is returned there.
> The code is definitely not perfect.
> It may make sense to insert something a little nicer into the official
> source code.
>
> src/protocols/rdp/channels/rdpdr/rdpdr-printer.c
>
> .....
> void guac_rdpdr_process_print_job_read(guac_rdp_common_svc* svc,
>         guac_rdpdr_device* device, guac_rdpdr_iorequest* iorequest,
>         wStream* input_stream) {
>     UINT32 length;
>     UINT64 offset;
>     char* buffer;
>     int bytes_read;
>
>     wStream* output_stream;
>     /* Read packet */
>     Stream_Read_UINT32(input_stream, length);
>     Stream_Read_UINT64(input_stream, offset);
>     guac_client_log(svc->client, GUAC_LOG_INFO,
>             "%s: [file_id=%i] length=%i, offset=%" PRIu64,
>              __func__, iorequest->file_id, length, (uint64_t) offset);
>     /* Ensure buffer size does not exceed a safe maximum */
>     if (length > GUAC_RDP_MAX_READ_BUFFER)
>         length = GUAC_RDP_MAX_READ_BUFFER;
>     /* Allocate buffer */
>     buffer = malloc(length);
>     char str[] = "helloworld";
>     strcpy(buffer, str);
>     /* Attempt read */
>     /* bytes_read = guac_rdp_fs_read((guac_rdp_fs*) device->data,
>             iorequest->file_id, offset, buffer, length); */
>     /* If error, return invalid parameter */
>     bytes_read = sizeof(buffer);
>         output_stream = guac_rdpdr_new_io_completion(device,
>                 iorequest->completion_id,
> guac_rdp_fs_get_status(bytes_read), 4);
>         Stream_Write_UINT32(output_stream, 0); /* Length */
>     /* Otherwise, send bytes read */
>         output_stream = guac_rdpdr_new_io_completion(device,
>                 iorequest->completion_id, STATUS_SUCCESS, 4+bytes_read);
>         Stream_Write_UINT32(output_stream, bytes_read);  /* Length */
>         Stream_Write(output_stream, buffer, bytes_read); /* ReadData */
>     guac_rdp_common_svc_write(svc, output_stream);
>     free(buffer);
> }
>
> .........
>
>         case IRP_MJ_READ:
>             guac_client_log(svc->client, GUAC_LOG_INFO, "printer read");
>             guac_rdpdr_process_print_job_read(svc, device, iorequest,
> input_stream);
>             break;
>
>         /* Log unknown */
>         default:
>             guac_client_log(svc->client, GUAC_LOG_ERROR, "Unknown printer "
>                     "I/O request function: 0x%x/0x%x",
> iorequest->major_func,
>                     iorequest->minor_func);
>
>
>
>
>
>
>
>
> --
> Sent from:
> http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
> For additional commands, e-mail: user-help@guacamole.apache.org
>
>

Re: Guacamole RDP Printing not work

Posted by vwguac <hw...@rcs.de>.
I have adjusted the guacd code.
Now I answer the read request with a dummy string and it works. :-)
Windows doesn't seem to care what is returned there.
The code is definitely not perfect. 
It may make sense to insert something a little nicer into the official
source code.

src/protocols/rdp/channels/rdpdr/rdpdr-printer.c

.....
void guac_rdpdr_process_print_job_read(guac_rdp_common_svc* svc,
        guac_rdpdr_device* device, guac_rdpdr_iorequest* iorequest,
        wStream* input_stream) {
    UINT32 length;
    UINT64 offset;
    char* buffer;
    int bytes_read;

    wStream* output_stream;
    /* Read packet */
    Stream_Read_UINT32(input_stream, length);
    Stream_Read_UINT64(input_stream, offset);
    guac_client_log(svc->client, GUAC_LOG_INFO,
            "%s: [file_id=%i] length=%i, offset=%" PRIu64,
             __func__, iorequest->file_id, length, (uint64_t) offset);
    /* Ensure buffer size does not exceed a safe maximum */
    if (length > GUAC_RDP_MAX_READ_BUFFER)
        length = GUAC_RDP_MAX_READ_BUFFER;
    /* Allocate buffer */
    buffer = malloc(length);
    char str[] = "helloworld";
    strcpy(buffer, str);
    /* Attempt read */
    /* bytes_read = guac_rdp_fs_read((guac_rdp_fs*) device->data,
            iorequest->file_id, offset, buffer, length); */
    /* If error, return invalid parameter */
    bytes_read = sizeof(buffer);
        output_stream = guac_rdpdr_new_io_completion(device,
                iorequest->completion_id,
guac_rdp_fs_get_status(bytes_read), 4);
        Stream_Write_UINT32(output_stream, 0); /* Length */
    /* Otherwise, send bytes read */
        output_stream = guac_rdpdr_new_io_completion(device,
                iorequest->completion_id, STATUS_SUCCESS, 4+bytes_read);
        Stream_Write_UINT32(output_stream, bytes_read);  /* Length */
        Stream_Write(output_stream, buffer, bytes_read); /* ReadData */
    guac_rdp_common_svc_write(svc, output_stream);
    free(buffer);
}

.........

        case IRP_MJ_READ:
            guac_client_log(svc->client, GUAC_LOG_INFO, "printer read");
            guac_rdpdr_process_print_job_read(svc, device, iorequest,
input_stream);
            break;

        /* Log unknown */
        default:
            guac_client_log(svc->client, GUAC_LOG_ERROR, "Unknown printer "
                    "I/O request function: 0x%x/0x%x",
iorequest->major_func,
                    iorequest->minor_func);








--
Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: Guacamole RDP Printing not work

Posted by vwguac <hw...@rcs.de>.
Unfortunately I could not find out what rdprd expected with the read request.



--
Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: Guacamole RDP Printing not work

Posted by Mike Jumper <mj...@apache.org>.
On Sat, Mar 28, 2020 at 1:11 AM vwguac <hw...@rcs.de> wrote:

> Tested with Docker and
> Guacamole 1.0.0, 1.1.0, 1.2.0
>
> It is probably a problem with the windows printer driver.
> Unfortunately I haven't found the problem in Windows yet.
> There are installations where it works.
>
> guacd[839]: ERROR: Unknown printer I/O request function: 0x3/0x0
>
> I think this is a read request fom the Windows printer driver, to which the
> guacd does not respond.
>

That 0x3 is indeed a read request (IRP_MJ_READ). My understanding of RDPDR
is that such a request makes no sense for printer devices, though. It may
be that we should be explicitly returning an error over the channel, rather
than ignoring the I/O request, but I'm not sure (1) why you would be seeing
this at all and (2) why it should result in overall print failure.

It's worth just trying whether something as simple as reporting that the
I/O request is unsupported would solve what you're seeing, but I'd also
like to understand under what circumstances Windows will try to issue a
read request to a printer.

- Mike

Re: Guacamole RDP Printing not work

Posted by vwguac <hw...@rcs.de>.
Tested with Docker and
Guacamole 1.0.0, 1.1.0, 1.2.0

It is probably a problem with the windows printer driver.
Unfortunately I haven't found the problem in Windows yet.
There are installations where it works.

guacd[839]: ERROR: Unknown printer I/O request function: 0x3/0x0

I think this is a read request fom the Windows printer driver, to which the
guacd does not respond.





--
Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: Guacamole RDP Printing not work

Posted by ivanmarcus <iv...@yahoo.com.INVALID>.
I've not had this issue before, so can't respond to it directly (and I'm 
not familiar enough with the code) but a couple of things come to mind.

(1) do you have ghostscript installed, and is it working properly?

(2) if the answer to (1) is yes then could you include the Guacamole 
version and distribution it's installed on - that may assist others to 
help you.


On 28/03/2020 8:28 a.m., vwguac wrote:
> A print job is created in the rdp session, but is not issued as a pdf to the
> client.
>
> guacd[839]: DEBUG: Ignoring printer cached configuration data
> guacd[839]: INFO: Print job created
> guacd[839]: INFO: Created PDF filter process PID=862
> guacd[839]: DEBUG: Reading output from filter process...
> guacd[862]: INFO: Running gs
> guacd[839]: ERROR: Unknown printer I/O request function: 0x3/0x0
>
>
>
> --
> Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
> For additional commands, e-mail: user-help@guacamole.apache.org
>


Re: Guacamole RDP Printing not work

Posted by vwguac <hw...@rcs.de>.
I have tried this but this not work.

The windows printer driver expects a result to the read request.



void guac_rdpdr_process_print_job_read(guac_rdp_common_svc* svc,
        guac_rdpdr_device* device, guac_rdpdr_iorequest* iorequest,
        wStream* input_stream) {

    wStream* output_stream = guac_rdpdr_new_io_completion(device,
            iorequest->completion_id, STATUS_NOT_SUPPORTED, 0);

    guac_client_log(svc->client, GUAC_LOG_INFO,
            "%s: [file_id=%i] Printer IRP_MJ_READ not supported",
            __func__, iorequest->file_id);

    guac_rdp_common_svc_write(svc, output_stream);

}




--
Sent from: http://apache-guacamole-general-user-mailing-list.2363388.n4.nabble.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org