Re: TrustedPath
- To: mathgroup at smc.vnet.net
- Subject: [mg123501] Re: TrustedPath
- From: David Reiss <dbreiss at gmail.com>
- Date: Fri, 9 Dec 2011 05:56:02 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jbq47t$it1$1@smc.vnet.net>
Trusting is set for directories rather than particular files. One thing to do is to create a button that cause the trust for a notebook's directory to be set. Or alternatively, execute the needed code automatically when some action is taken on a notebook -- e.g., via some event handler -- to execute the code. A dialog will always appear when that code is executed -- otherwise someone could insert that code to subvert the trust process. But, once it has run once on a given machine, the trust will be set for all future uses of that directory. So, with that said, here is a bit of code from deep within http://scientificarts.com/worklife that will add a notebook's directory to the set of trusted directory paths. Catch@Module[{securityOptions, dir, trustedPaths, unTrustedPaths, unTrustedPathsAsStrings, trustByDefault}, General::WorkLifenottrusted = "The directory `1` is currently contained in the list of Untrusted \ directories. Please remove it from this list first before adding it \ to the list of Trusted directories."; General::WorkLifenodir = "The directory `1` does not exist."; dir = ToFileName[{CurrentValue["NotebookDirectory"]}]; If[FileType[dir] =!= Directory, Throw[Message[General::WorkLifenodir, dir]; $Failed]]; trustedPaths = CurrentValue[$FrontEnd, {"NotebookSecurityOptions", "TrustedPath"}]; unTrustedPaths = CurrentValue[$FrontEnd, {"NotebookSecurityOptions", "UntrustedPath"}]; unTrustedPathsAsStrings = ToFileName[{#}] & /@ unTrustedPaths; trustByDefault = CurrentValue[$FrontEnd, {"NotebookSecurityOptions", "TrustByDefault"}]; If[MemberQ[unTrustedPathsAsStrings, dir], Throw[Message[General::WorkLifenottrusted, dir]; (SetOptions[$FrontEnd, "PreferencesSettings" -> {"Page" -> "System"}]; FrontEndTokenExecute["PreferencesDialog"])]]; trustedPaths = Union@Flatten[{trustedPaths, FrontEnd`FileName[{#}] &[dir]}]; securityOptions = { "TrustedPath" -> trustedPaths, "UntrustedPath" -> unTrustedPaths, "TrustByDefault" -> trustByDefault}; SetOptions[$FrontEnd, "NotebookSecurityOptions" -> securityOptions]; securityOptions ] On the question of whether to place things on the Mac in the application package.... if I understand this correctly this is the CDFPlayer application itself. If you add things there, then they will be overwritten for each time you update the CDFPlayer. I hope that this helps... --David On Dec 8, 5:41 am, Tom De Vries <tidetable... at gmail.com> wrote: > Hello! > > I am wondering if someone can help with an obscure question. > > I am bundling together a large group of files using the CDF format. > > My students don't have Mathematica so I save the files in CDF format > and the students use CDFPlayer to view them. > > I've found that the things that trigger the "This file contains > potentially unsafe dynamic content" can be really simple. > Linking to a Quicktime movie, using File operations to open another > notebook, etc. > > I completely understand the need for security, so I am happy Wolfram > is making sure bad things don't happen. > > However... this is going to drive my students crazy. > The index I've created links many notebooks, and this message gets > triggered often, and it becomes a pain. > > Since there are going to be many sets of notes, it won't be like > saying "Enable" once and then good to go. > > Each new time a file gets opened, it's the same routine... > > I'm sorry that there isn't a setting in CDFPlayer that allows for a > global.... "yes , I trust this collection of files". > > Fumbling around as I often do...., I found a solution that works on a > Mac, and wondering if PC users can chime in with something > similar..... > > While running the CDFPlayer I found you could go to "About CDFPlayer", > ask for System Information, and digging around gave me some > directories CDFPlayer trusts... > > One of those was the "application package". > > So, on a Mac, I could open this package, give my permission to move > in my set of lesson files, and bliss.... > > Is this a reasonable solution? > > Can PC users do something similar? I.E. is there a simple place to > put a set of TRUSTED FILES, where they could be opened and worked > with without getting a warning all the time. > > And finally, is there an easier way to do this? I suspect, reading > about textbook publishers and developers using CDF, there must be > some way to deal with this issue? > > Sorry for the obscure questions, I'm hoping some other users have > some advice about this. > > Sincerely, > > Tom