]> git.donarmstrong.com Git - lilypond.git/commitdiff
* input/no-notation/safe-include.ly:
authorJan Nieuwenhuizen <janneke@gnu.org>
Wed, 28 Jan 2004 21:02:12 +0000 (21:02 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Wed, 28 Jan 2004 21:02:12 +0000 (21:02 +0000)
* input/no-notation/safe-guile.ly:
* input/no-notation/safe-ps.ly:
* input/no-notation/safe-tex.ly: New file.

* scripts/lilypond.py (global_latex_preamble): Add \nofiles for
safe mode Add -s,--safe-mode option.  Use -S,--set for setting
options now.
(run_lilypond): When in --safe-mode, pass option to lilypond-bin.
When in --safe-mode, set environment openout_any=p[aranoid].

* tex/ltest.tex:
* tex/lilyponddefs.tex: Add \nofiles.

* Documentation/topdocs/NEWS.texi: Add note about safe mode.

ChangeLog
Documentation/topdocs/NEWS.texi
input/no-notation/safe-guile.ly [new file with mode: 0644]
input/no-notation/safe-include.ly [new file with mode: 0644]
input/no-notation/safe-ps.ly [new file with mode: 0644]
input/no-notation/safe-tex.ly [new file with mode: 0644]
scripts/lilypond.py
tex/lilyponddefs.tex
tex/ltest.tex

index 378ec3eef8584f1d1fe70e8206b5ba83f2126254..8dcb7b0edafc4db806ed67d43f1bac3d7ff56813 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
 2004-01-28  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+       * input/no-notation/safe-include.ly:
+       * input/no-notation/safe-guile.ly:
+       * input/no-notation/safe-ps.ly: 
+       * input/no-notation/safe-tex.ly: New file.
+
+       * scripts/lilypond.py (global_latex_preamble): Add \nofiles for
+       safe mode Add -s,--safe-mode option.  Use -S,--set for setting
+       options now.
+       (run_lilypond): When in --safe-mode, pass option to lilypond-bin.
+       When in --safe-mode, set environment openout_any=p[aranoid].
+
+       * tex/ltest.tex: 
+       * tex/lilyponddefs.tex: Add \nofiles.
+
+       * python/lilylib.py (get_bbox, make_ps_images): Add -dSAFER to gs
+       options.
+
        * Documentation/topdocs/NEWS.texi: Add note about safe mode.
 
        * mf/GNUmakefile (FETA_LIST_FILES): Install feta*list.lys too.
index 5c19902c476614da8030ffd5ebdafc3ca99e28ac..030a9077bfe4b453f02b61cc69c1f21fdba03305 100644 (file)
@@ -18,9 +18,11 @@ Version 2.1.13
 
 @itemize @bullet
 
-@item Safe mode has been reinstated for lilypond-bin.  When lilypond-bin
-is invoked with @code{--safe-mode}, the user's Guile expressions are
-evaluated in a safe environment and file inclusion is not allowed.
+@item Safe mode has been reinstated for lilypond.
+When lilypond is invoked with @{--safe-mode}, @TeX{} and PostScript
+file output is disallowed, and lilypond-bin is invoked with
+@code{--safe-mode}, the user's Guile expressions are evaluated in a
+safe environment and file inclusion is not allowed.
 (This feature is still experimental.)
 
 @item There is now a Scheme macro for defining markup
diff --git a/input/no-notation/safe-guile.ly b/input/no-notation/safe-guile.ly
new file mode 100644 (file)
index 0000000..a9a97ca
--- /dev/null
@@ -0,0 +1,14 @@
+\version "2.1.16"
+
+\header{
+    
+    texidoc = "This should not survive lilypond --safe-mode, and
+    certainly not write /tmp/safe-guile.scm"
+    
+}
+
+#(write "hallo" (open-file "/tmp/safe-guile.scm" "w"))
+
+\score{
+    \notes c''
+}
\ No newline at end of file
diff --git a/input/no-notation/safe-include.ly b/input/no-notation/safe-include.ly
new file mode 100644 (file)
index 0000000..08cdfce
--- /dev/null
@@ -0,0 +1,13 @@
+\version "2.1.16"
+
+\header{
+    
+    texidoc = "This should not survive lilypond --safe-mode"
+    
+}
+
+\include "safe-ps.ly"
+
+\score{
+    \notes c''
+}
\ No newline at end of file
diff --git a/input/no-notation/safe-ps.ly b/input/no-notation/safe-ps.ly
new file mode 100644 (file)
index 0000000..aeee4ae
--- /dev/null
@@ -0,0 +1,11 @@
+\version "2.1.16"
+
+\header{
+    texidoc = "This should not survive lilypond run, and certainly not
+    write /tmp/safe-ps.ps"
+}
+
+\score{
+    \notes c''-"\\embeddedps{ (/tmp/safe-ps.ps) (w) file (hallo) writestring }"
+   
+}
diff --git a/input/no-notation/safe-tex.ly b/input/no-notation/safe-tex.ly
new file mode 100644 (file)
index 0000000..a407512
--- /dev/null
@@ -0,0 +1,16 @@
+\version "2.1.16"
+
+\header{
+    
+    texidoc = "This should not survive lilypond --safe-mode --no-pdf --png
+    run, and certainly not write /tmp/safe-tex.tex"
+
+    % beware
+    % openout_any=y lilypond --keep --safe-mode -S latexoptions=']{article}
+    % \let\nofiles\relax%' input/no-notation/safe-tex.ly
+
+}
+
+\score{
+    \notes c''-"\\newwrite\\barf\\immediate\\openout\\barf=/tmp/safe-tex.tex\\immediate\\write\\barf{hallo}"
+}
index 15af60e526198f5af795c7bb72b7898c74a16f4f..96dd3b4cd0c241df4e189a8cdb3ac99d9443a9d6 100644 (file)
@@ -126,30 +126,33 @@ option_definitions = [
         _ ("write Makefile dependencies for every input file")),
        ('', 'h', 'help', _ ("print this help")),
        ('', '', 'debug', _ ("print even more output")),
+       (_ ("FILE"), 'f', 'find-pfa', _ ("find pfa fonts used in FILE")),
+       ('','', 'html', _("make HTML file with links to all output")),
        (_ ("DIR"), 'I', 'include', _ ("add DIR to LilyPond's search path")),
        ('', 'k', 'keep',
         _ ("keep all output, output to directory %s.dir") % program_name),
        ('', '', 'no-lily', _ ("don't run LilyPond")),
        ('', 'm', 'no-paper', _ ("produce MIDI output only")),
        (_ ("FILE"), 'o', 'output', _ ("write output to FILE")),
-       (_ ("FILE"), 'f', 'find-pfa', _ ("find pfa fonts used in FILE")),
        (_ ('RES'), '', 'preview-resolution',
         _ ("set the resolution of the preview to RES")),
+       ('', '', 'no-pdf', _ ("do not generate PDF output")),
+       ('', '', 'no-ps', _ ("do not generate PostScript outpug")),
+       ('', 'p', 'pdf', _ ("generate PDF output")),
        ('', 'P', 'postscript', _ ("generate PostScript output")),
-       ('', '', 'png', _("generate PNG page images")),
-       ('', '', 'psgz', _("generate PS.GZ")),
-       # separate options for PDF  / PS / DVI ?  
        ('', '', 'pdftex', _ ("use pdflatex to generate a PDF output")),
-       # FIXME: preview, picture; to indicate creation of a PNG?
+       ('', '', 'png', _("generate PNG page images")),
        ('', '', 'preview', _ ("make a picture of the first system")),
-       ('','', 'html', _("make HTML file with links to all output")),
-       (_ ("KEY=VAL"), 's', 'set', _ ("change global setting KEY to VAL")),
+       ('', '', 'psgz', _ ("generate PS.GZ")),
+       ('', 's', 'safe-mode', _ ("run in safe-mode")),
+       (_ ("KEY=VAL"), 'S', 'set', _ ("change global setting KEY to VAL")),
        ('', 'V', 'verbose', _ ("be verbose")),
        ('', 'v', 'version', _ ("print version number")),
        ('', 'w', 'warranty', _ ("show warranty and copyright")),
        ]
 
 # other globals
+safe_mode_p = 0
 preview_p = 0
 page_images_p = 0
 lilypond_error_p = 0
@@ -253,6 +256,9 @@ def run_lilypond (files, dep_prefix):
        if pdftex_p:
                opts = opts + ' -f pdftex'              
 
+       if safe_mode_p:
+               opts = opts + ' --safe-mode'
+
        if track_dependencies_p:
                opts = opts + " --dependencies"
                if dep_prefix:
@@ -395,15 +401,17 @@ def global_latex_preamble (extra):
 
        options = ''
 
-
        if extra['latexoptions']:
                options = options + ',' + extra['latexoptions'][-1]
 
        s = s + '\\documentclass[%s]{article}\n' % options
 
-       if extra['language']:
-               s = s + r'\usepackage[%s]{babel}' % extra['language'][-1] + '\n'
+       if safe_mode_p:
+               s = s + '\\nofiles\n'
 
+       if extra['language']:
+               s = s + r'\usepackage[%s]{babel}' \
+                   % extra['language'][-1] + '\n'
 
        s = s + '\\usepackage{%s}\n' \
                % string.join (extra['latexpackages'], ',')
@@ -704,10 +712,21 @@ for opt in options:
        elif o == '--include' or o == '-I':
                include_path.append (a)
        elif o == '--postscript' or o == '-P':
-               targets.append ('PS')
+               if 'PDF' in targets:
+                       targets.remove ('PDF')
+               if 'PS' not in targets:
+                       targets.append ('PS')
+       elif o == '--pdf' or o == '-p':
+               if 'PDF' not in targets:
+                       targets.append ('PDF')
+       elif o == '--no-pdf':
+               if 'PDF' in targets:
+                       targets.remove ('PDF')
        elif o == '--no-ps':
-               targets.remove ('PS')
-               targets.remove ('PDF')
+               if 'PS' in targets:
+                       targets.remove ('PS')
+               if 'PDF' in targets:
+                       targets.remove ('PDF')
        elif o == '--keep' or o == '-k':
                keep_temp_dir_p = 1
        elif o == '--debug':
@@ -726,7 +745,9 @@ for opt in options:
                paper_p = 0
        elif o == '--output' or o == '-o':
                output_name = a
-       elif o == '--set' or o == '-s':
+       elif o == '--safe-mode' or o == '-s':
+               safe_mode_p = 1
+       elif o == '--set' or o == '-S':
                ss = string.split (a, '=')
                set_setting (extra_init, ss[0], ss[1])
        elif o == '--dependencies' or o == '-d':
@@ -738,8 +759,8 @@ for opt in options:
                sys.exit (0)
        elif o == '--pdftex':
                latex_cmd = 'pdflatex'
-               targets.remove('DVI')
-               targets.append('PDFTEX')
+               targets.remove ('DVI')
+               targets.append ('PDFTEX')
                pdftex_p = 1
                tex_extension = '.pdftex'
        elif o == '--warranty' or o == '-w':
@@ -755,6 +776,8 @@ for opt in options:
                        targets.append ('PNG')
        elif o == '--psgz':
                targets.append ('PS.GZ')
+               if 'PS' not in targets:
+                       targets.append ('PS')
        else:
                unimplemented_option () # signal programming error
 
@@ -830,6 +853,8 @@ if 1:
 
        tmpdir = ly.setup_temp ()
        ly.setup_environment ()
+       if safe_mode_p:
+               os.environ['openout_any'] = 'p'
 
        # to be sure, add tmpdir *in front* of inclusion path.
        #os.environ['TEXINPUTS'] =  tmpdir + ':' + os.environ['TEXINPUTS']
index 515e8811ec8f9e00b559ffed4799832e5abccd96..5cc6d4ffcf95e3b7b6172efe765fad235816cfaa 100644 (file)
@@ -55,6 +55,7 @@
         \endgroup
         \def\lilyponddocument{}
         \documentclass[a4paper]{article}
+       \nofiles
         \pagestyle{empty}
         % \begin is defined as \outer in texinfo, thus we use \csname
         \csname begin\endcsname{document}
index ce39b7c222fde9d2acd561d26985dcf8df03c606..0425d88072ff7e019871a5a7744040576037000a 100644 (file)
@@ -1,5 +1,6 @@
 % Mats Bengtsson
 \documentclass[a4paper, 10pt]{article}
+\nofiles
 
 % Allow for 8-bit characters:
 \usepackage[latin1]{inputenc}