info/man.command stopped by gatekeeper

Joshua Pettus <[email protected]>
Newsgroups gmane.comp.gnu.xboard.devel
Message-ID <[email protected]>
Hello Everyone,

As had explained before,  OSX’s terminal app couldn’t take arguments from the command line.  So to counter that, I came up with the solution of using the OS’s feature of automatically opening terminal when opening a .command script.  This was in order to pass the arguments to load the man/info pages.

There is one major flaw to this though.  Gatekeeper by default blocks executables not codesigned until the user gives the go ahead.  Apparently .command scripts count. :-(  Normally this is done by right clicking on the executable, selecting open, and press open in the popup dialog (only needs to be done once).  But in the case of xboard launching those scripts, the user doesn’t have that option. So they have to go into system preferences and allow the last item blocked, or disable gatekeeper.  Hardly an Ideal situation.

The other option of telling the terminal app to run a shellscript is through applescript, which until now I didn’t believe could be put into our source.  Thankfully I came across a very useful shell command called osascript that does this, and the multiple lines, typical of applescript, could be put into one line with -e between commands.

As such I removed the launching scripts and put applescript into manproc and infoproc to do the job. I fear this meant I had to move infoproc to gtk/xboard.c (and xaw/xboard.c) in order to take advantage of the dataDir function in place.  (Thanks Harm, you are teaching me well XD.)

Here is a patch file making all the changes plus modifying our app build script.



I think i should put out a xboard 4.8.0c with these changes, if you all agree with them.

Best Regards,
Josh
xboard.patch (application/octet-stream, 4 KB)
diff -uprN ./xboard-a/Makefile.am ./xboard-b/Makefile.am
--- ./xboard-a/Makefile.am	2014-10-28 17:37:22.000000000 -0400
+++ ./xboard-b/Makefile.am	2014-11-04 14:10:08.000000000 -0500
@@ -255,8 +255,6 @@ osxapp: all-recursive install install-re
 	$(INSTALL) ./osxapp/XBoard.gtklauncher $(bindir)/XBoard
 	$(INSTALL) ./xboard $(bindir)/xboard-bin
 	cp -R ./osxapp/icons/. $(datarootdir)
-	$(INSTALL) ./osxapp/man.command    $(datarootdir)/bin/man.command
-	$(INSTALL) ./osxapp/info.command   $(datarootdir)/bin/info.command
 	sed -e 's?-soundProgram "aplay -q"?-soundProgram "afplay"?'\
             -e 's?-firstChessProgram fairymax?-firstChessProgram "./fairymax"?'\
 	    -e 's?-firstChessProgramNames {fairymax?-firstChessProgramNames {"fairymax" -fcp "./fairymax" -fd "~~/../../bin/fairymax"?'\
@@ -280,7 +278,7 @@ osxapp: all-recursive install install-re
 	echo '-autoLogo true' >>$(sysconfdir)/xboard.conf
 	echo '-logoDir "~~/logos"' >>$(sysconfdir)/xboard.conf
 	echo '-logoSize 100' >>$(sysconfdir)/xboard.conf
-	echo '-openCommand "cd %s/../../bin; open"' >>$(sysconfdir)/xboard.conf
+	echo '-openCommand "open"' >>$(sysconfdir)/xboard.conf
 	echo '-firstDirectory "~~/../../bin/fairymax"' >>$(sysconfdir)/xboard.conf
 	echo '-secondDirectory "~~/../../bin/fairymax"' >>$(sysconfdir)/xboard.conf
 	echo '-secondChessProgram "./fairymax"' >>$(sysconfdir)/xboard.conf
diff -uprN ./xboard-a/gtk/xboard.c ./xboard-b/gtk/xboard.c
--- ./xboard-a/gtk/xboard.c	2014-10-28 17:37:22.000000000 -0400
+++ ./xboard-b/gtk/xboard.c	2014-11-04 14:04:16.000000000 -0500
@@ -1965,7 +1966,7 @@ ManProc ()
 {   // called from menu
 #ifdef OSXAPP
     char buf[MSG_SIZ];
-    snprintf(buf, MSG_SIZ, "%s ./man.command", appData.sysOpen);
+    snprintf(buf, MSG_SIZ, "osascript -e 'tell application \"Terminal\"' -e 'activate' -e 'do script \"man %s/../man/man6/xboard.6\"' -e 'end tell'", dataDir);
     system(buf);
 #else
     system("xterm -e man xboard &");
@@ -1973,6 +1974,20 @@ ManProc ()
 }
 
 void
+InfoProc ()
+{
+    char buf[MSG_SIZ];
+#ifdef OSXAPP
+    snprintf(buf, MSG_SIZ, "osascript -e 'tell application \"Terminal\"' -e 'activate' -e 'do script \"info -d %s/../info -f xboard.info\"' -e 'end tell'", dataDir);
+#else
+        snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &",
+                 INFODIR, INFOFILE);
+#endif
+    system(buf);
+}
+
+
+void
 SetWindowTitle (char *text, char *title, char *icon)
 {
 #ifdef TODO_GTK
diff -uprN ./xboard-a/menus.c ./xboard-b/menus.c
--- ./xboard-a/menus.c	2014-10-28 17:37:22.000000000 -0400
+++ ./xboard-b/menus.c	2014-11-04 14:14:33.000000000 -0500
@@ -310,19 +310,6 @@ SaveSettingsProc ()
 }
 
 void
-InfoProc ()
-{
-    char buf[MSG_SIZ];
-#ifdef OSXAPP
-    snprintf(buf, MSG_SIZ, "%s ./info.command", appData.sysOpen);
-#else
-    snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &",
-	    INFODIR, INFOFILE);
-#endif
-    system(buf);
-}
-
-void
 BugReportProc ()
 {
     char buf[MSG_SIZ];
diff -uprN ./xboard-a/osxapp/info.command ./xboard-b/osxapp/info.command
--- ./xboard-a/osxapp/info.command	2014-10-28 17:37:22.000000000 -0400
+++ ./xboard-b/osxapp/info.command	1969-12-31 19:00:00.000000000 -0500
@@ -1,2 +0,0 @@
-cd "${0%/*}"
-info -d ../share/info -f xboard.info
diff -uprN ./xboard-a/osxapp/man.command ./xboard-b/osxapp/man.command
--- ./xboard-a/osxapp/man.command	2014-10-28 17:37:22.000000000 -0400
+++ ./xboard-b/osxapp/man.command	1969-12-31 19:00:00.000000000 -0500
@@ -1,2 +0,0 @@
-cd "${0%/*}"
-man ../share/man/man6/xboard.6
diff -uprN ./xboard-a/xaw/xboard.c ./xboard-b/xaw/xboard.c
--- ./xboard-a/xaw/xboard.c	2014-10-28 17:37:22.000000000 -0400
+++ ./xboard-b/xaw/xboard.c	2014-11-04 14:14:16.000000000 -0500
@@ -2123,6 +2123,15 @@ ManProc ()
 }
 
 void
+InfoProc ()
+{
+    char buf[MSG_SIZ];
+    snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &",
+             INFODIR, INFOFILE);
+    system(buf);
+}
+
+void
 SetWindowTitle (char *text, char *title, char *icon)
 {
     Arg args[16];
smime.p7s (application/pkcs7-signature, 1.4 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.