<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>24492</bug_id>
          
          <creation_ts>2010-11-03 13:22:20 +0300</creation_ts>
          <short_desc>gs -dSAFER не дает открывать файлы на чтение</short_desc>
          <delta_ts>2020-09-20 22:47:35 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>ghostscript</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>NOTABUG</resolution>
          
          <see_also>https://bugzilla.redhat.com/show_bug.cgi?id=1632030</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Vladislav Zavjalov">slazav</reporter>
          <assigned_to name="Vitaly Lipatov">lav</assigned_to>
          <cc>admsasha</cc>
    
    <cc>george</cc>
    
    <cc>kirill</cc>
    
    <cc>lav</cc>
    
    <cc>vitty</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>114774</commentid>
    <comment_count>0</comment_count>
    <who name="Vladislav Zavjalov">slazav</who>
    <bug_when>2010-11-03 13:22:20 +0300</bug_when>
    <thetext>На всякий случай дублирую сюда из sisyphus@ накопанное, чтоб не потерялось

$ &gt; a.txt
$ echo &quot;(a.txt) (r) file&quot; &gt; 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  &quot;deletefile&quot;  and  &quot;renamefile&quot; operators
 and the ability to open files in any mode other than read-only.

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

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


&gt; 
&gt; -dSAFER Disables  the  &quot;deletefile&quot;  and  &quot;renamefile&quot; operators
&gt;  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.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>