Bug 24492 - gs -dSAFER не дает открывать файлы на чтение
Summary: gs -dSAFER не дает открывать файлы на чтение
Status: CLOSED NOTABUG
Alias: None
Product: Sisyphus
Classification: Development
Component: ghostscript (show other bugs)
Version: unstable
Hardware: all Linux
: P3 normal
Assignee: Vitaly Lipatov
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-03 13:22 MSK by Vladislav Zavjalov
Modified: 2020-09-20 22:47 MSK (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladislav Zavjalov 2010-11-03 13:22:20 MSK
На всякий случай дублирую сюда из sisyphus@ накопанное, чтоб не потерялось

$ > a.txt
$ echo "(a.txt) (r) file" > a.ps

$ gs -dBATCH -dNODISPLAY a.ps
GPL Ghostscript  9.00 (2010-09-14)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.

$ gs -dBATCH -dNODISPLAY -dSAFER a.ps
GPL Ghostscript  9.00 (2010-09-14)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /invalidfileaccess in --file--
Operand stack:
   (a.txt)   (r)
...

То есть, gs в режиме safer не дает открывать файл на чтение.
(file) run, например, тоже не работает. Хотя, казалось бы, man gs
нам говорит:

-dSAFER Disables  the  "deletefile"  and  "renamefile" operators
 and the ability to open files in any mode other than read-only.

Одно из важных следствий - gv не читает pdf-файлы (они читаются довольно хитро: скрипт pdf2dsc.ps создает некоторый временный ps-файл, который уже читает pdf), так как по дефолту в gv включен режим safer. Соответственно, в качестве временного лечения - помогает отключить кнопку Safer в меню "State/Ghostscript options"...
Comment 1 Vitaly Lipatov 2020-09-20 22:47:35 MSK
(Ответ для Vladislav Zavjalov на комментарий #0)
> На всякий случай дублирую сюда из sisyphus@ накопанное, чтоб не потерялось
> 
> $ > a.txt
> $ echo "(a.txt) (r) file" > a.ps
> 
> $ gs -dBATCH -dNODISPLAY a.ps
> GPL Ghostscript  9.00 (2010-09-14)
> Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
> This software comes with NO WARRANTY: see the file PUBLIC for details.
> 
> $ gs -dBATCH -dNODISPLAY -dSAFER a.ps
> GPL Ghostscript  9.00 (2010-09-14)
> Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
> This software comes with NO WARRANTY: see the file PUBLIC for details.
> Error: /invalidfileaccess in --file--
> Operand stack:
>    (a.txt)   (r)
> ...
> 
> То есть, gs в режиме safer не дает открывать файл на чтение.
> (file) run, например, тоже не работает. Хотя, казалось бы, man gs
> нам говорит:
Воспроизводится с -dSAFER. Этот режим нужен для того, чтобы документ ничего не стащил у вас из файловой системы.

Тут ещё есть обсуждение подобного поведения при этом ограничении:
https://bugzilla.redhat.com/show_bug.cgi?id=1632030


> 
> -dSAFER Disables  the  "deletefile"  and  "renamefile" operators
>  and the ability to open files in any mode other than read-only.
Там уже написано так:
...
       -dSAFER
              Restricts  file  operations the job can perform.  Strongly recommended for spoolers, conversion scripts or other sensitive environments where a badly
              written or malicious PostScript program code must be prevented from changing important files.