From 45cdceb023897ee25d4d82434f570d63ccf43df8 Mon Sep 17 00:00:00 2001
From: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat, 2 Jan 2016 19:59:16 -0800
Subject: [PATCH] Solaris paths
Various fixes to deal with where we install things on Solaris:
- Only run hacks from the hacks dir, not $PATH
- Find helper programs even though they are not in $PATH
- Show author names when reading RSS feeds from sites like blogs.sun.com
- Show Solaris package names in demo app when hacks are not installed
- Use gnome-help to display man pages nicely, without requiring internet
access (which some customers at secure sites won't have configured),
instead of opening a web browser to view the man page at jwz.org or
opening a gnome-terminal to run the man command.
Mostly not acceptable upstream.
Backport notes: this change relies on the gnome-help version delivered in
Solaris 11 that supports "man:xscreensaver" style URL's to display man pages.
When backporting to Solaris 10 you will probably want to uncomment the
lines shown for GNOME 2.4/2.6.
Also, you'll need to fix the package names shown when the hacks are not
installed to be the older SUNWxscreensaver-* for Solaris 10.
---
driver/Makefile.in | 9 ++++---
driver/XScreenSaver.ad.in | 14 +++++++---
driver/demo-Gtk.c | 4 +--
driver/subprocs.c | 54 ++++++++++++++++++++++++++++++++++++--
driver/xscreensaver-demo.glade2.in | 4 +--
driver/xscreensaver-text | 6 ++++-
driver/xscreensaver.man | 5 ++--
hacks/glx/Makefile.in | 4 +--
8 files changed, 81 insertions(+), 19 deletions(-)
diff --git a/driver/Makefile.in b/driver/Makefile.in
index c132304..a5b94bf 100644
--- a/driver/Makefile.in
+++ b/driver/Makefile.in
@@ -27,7 +27,7 @@ INTLTOOL_MERGE = @INTLTOOL_MERGE@
GTK_DATADIR = @GTK_DATADIR@
GTK_APPDIR = $(GTK_DATADIR)/applications
GTK_ICONDIR = $(GTK_DATADIR)/pixmaps
-GTK_GLADEDIR = $(GTK_DATADIR)/xscreensaver/glade
+GTK_GLADEDIR = $(prefix)/lib/xscreensaver/config
HACK_CONF_DIR = @HACK_CONF_DIR@
CC = @CC@
@@ -36,8 +36,11 @@ CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
DEFS = @DEFS@
INTL_DEFS = -DLOCALEDIR=\"$(localedir)\"
-SUBP_DEFS = $(DEFS) -DDEFAULT_PATH_PREFIX='"@HACKDIR@"'
-GTK_DEFS = $(DEFS) -DDEFAULT_ICONDIR='"$(GTK_GLADEDIR)"'
+SUBP_DEFS = $(DEFS) -DHACK_PATH='"@HACKDIR@"' \
+ -DDEFAULT_PATH_PREFIX='"@HACKDIR@:$(libexecdir)"' \
+ -DHELPER_PATH='"$(libexecdir)"'
+GTK_DEFS = $(DEFS) -DDEFAULT_ICONDIR='"$(GTK_GLADEDIR)"' \
+ -DBINDIR='"$(bindir)"'
CONF_DEFS = -DHACK_CONFIGURATION_PATH='"$(HACK_CONF_DIR)"'
LIBS = @LIBS@
diff --git a/driver/XScreenSaver.ad.in b/driver/XScreenSaver.ad.in
index 22d5bcb..3e1ff8a 100644
--- a/driver/XScreenSaver.ad.in
+++ b/driver/XScreenSaver.ad.in
@@ -91,18 +91,24 @@ GetViewPortIsFullOfLies: False
! This is the URL loaded by the "Help" button on the splash screen,
! and by the "Documentation" menu item in xscreensaver-demo.
-*helpURL: http://www.jwz.org/xscreensaver/man.html
+*helpURL: man:xscreensaver
! loadURL -- how the "Help" buttons load the helpURL (/bin/sh syntax.)
! manualCommand -- how the "Documentation" buttons display man pages.
!
! And there are so very many options to choose from!
!
+! Modern GNOME:
+!
+*loadURL: gnome-help '%s'
+*manualCommand: gnome-help 'man:%s'
+!
! Gnome 2.4, 2.6: (yelp can't display man pages, as of 2.6.3)
!
-@GNOME24@*loadURL: @WITH_BROWSER@ '%s'
-@GNOME24@*manualCommand: gnome-terminal --title '%s manual' \
-@GNOME24@ --command '/bin/sh -c "man %s; read foo"'
+!*loadURL: gnome-terminal --title 'xscreensaver manual' \
+! --command '/bin/ksh -c "man xscreensaver; read foo"'
+!*manualCommand: gnome-terminal --title '%s manual' \
+! --command '/bin/ksh -c "man %s; read foo"'
!
! Gnome 2.2:
!
diff --git a/driver/demo-Gtk.c b/driver/demo-Gtk.c
index 27d2316..6c449f2 100644
--- a/driver/demo-Gtk.c
+++ b/driver/demo-Gtk.c
@@ -994,7 +994,7 @@ restart_menu_cb (GtkWidget *widget, gpointer user_data)
flush_dialog_changes_and_save (s);
xscreensaver_command (GDK_DISPLAY(), XA_EXIT, 0, False, NULL);
sleep (1);
- if (system ("xscreensaver -nosplash &") < 0)
+ if (system (BINDIR "/xscreensaver -nosplash &") < 0)
fprintf (stderr, "%s: fork error\n", blurb());
await_xscreensaver (s);
@@ -4969,7 +4969,7 @@ main (int argc, char **argv)
if (init_results == 1)
{
- system ("xscreensaver -nosplash &");
+ system (BINDIR "/xscreensaver -nosplash &");
return 0;
}
diff --git a/driver/subprocs.c b/driver/subprocs.c
index ecbaeb2..9414df1 100644
--- a/driver/subprocs.c
+++ b/driver/subprocs.c
@@ -14,6 +14,7 @@
# include "config.h"
#endif
+#include <sys/stat.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
@@ -799,6 +800,8 @@ print_path_error (const char *program)
free (cmd);
perror (buf);
+/* mali - security issue do not want to display user's path */
+#ifdef EXPOSE_USER_PATH
if (errno == ENOENT &&
(token = getenv("PATH")))
{
@@ -829,6 +832,7 @@ print_path_error (const char *program)
}
fprintf (stderr, "\n");
}
+#endif
}
@@ -885,12 +889,42 @@ fork_and_exec (saver_screen_info *ssi, const char *command)
return forked;
}
+static Bool
+check_if_hacks_dir_exists(Bool verbose_p)
+{
+ const char hackdir[] = HACK_PATH;
+
+ int status;
+ struct stat st;
+
+ status = stat (hackdir, &st);
+
+ if (status == 0 && S_ISDIR(st.st_mode))
+ {
+ return True;
+ }
+ else
+ {
+ if (verbose_p)
+ {
+ fprintf(stderr,
+ "%s: Warning: dir: %s missing. Will not run hacks\n",
+ blurb(), hackdir);
+ }
+ return False;
+ }
+}
void
spawn_screenhack (saver_screen_info *ssi)
{
saver_info *si = ssi->global;
saver_preferences *p = &si->prefs;
+ char* complete_hack_command;
+
+ if (si->prefs.verbose_p)
+ fprintf(stderr, "--> spawn_screenhack()\n");
+
XFlush (si->dpy);
if (!monitor_powered_on_p (si))
@@ -970,6 +1004,12 @@ spawn_screenhack (saver_screen_info *ssi)
;
}
+ if ((new_hack >= 0) &&
+ (check_if_hacks_dir_exists(p->verbose_p) == False))
+ {
+ new_hack = -1;
+ }
+
if (new_hack < 0) /* don't run a hack */
{
ssi->current_hack = -1;
@@ -1017,7 +1057,17 @@ spawn_screenhack (saver_screen_info *ssi)
if (si->selection_mode < 0)
si->selection_mode = 0;
- forked = fork_and_exec (ssi, hack->command);
+ /* We need complete path to hack command else any executable
+ * with the same name in the path gets executed.
+ */
+ complete_hack_command = malloc (10 + strlen(hack->command) +
+ strlen (HACK_PATH));
+ sprintf(complete_hack_command, HACK_PATH"/%s", hack->command);
+
+
+ forked = fork_and_exec (ssi, complete_hack_command);
+ free (complete_hack_command);
+
switch ((int) forked)
{
case -1: /* fork failed */
@@ -1196,7 +1246,7 @@ get_best_gl_visual (saver_info *si, Screen *screen)
char *av[10];
int ac = 0;
- av[ac++] = "xscreensaver-gl-helper";
+ av[ac++] = HELPER_PATH "/xscreensaver-gl-helper";
av[ac] = 0;
if (pipe (fds))
diff --git a/driver/xscreensaver-demo.glade2.in b/driver/xscreensaver-demo.glade2.in
index ad0095d..40e47f6 100644
--- a/driver/xscreensaver-demo.glade2.in
+++ b/driver/xscreensaver-demo.glade2.in
@@ -927,8 +927,8 @@ Installed</property>
<property name="visible">True</property>
<property name="label" translatable="yes">Very few (or no) screen savers appear to be available.
-This probably means that the &quot;xscreensaver-extras&quot; and
-&quot;xscreensaver-gl-extras&quot; packages are not installed.</property>
+This probably means that the “desktop/xscreensaver/hacks” and
+“desktop/xscreensaver/hacks/hacks-gl” packages are not installed.</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
diff --git a/driver/xscreensaver-text b/driver/xscreensaver-text
index 8199829..921d5c7 100755
--- a/driver/xscreensaver-text
+++ b/driver/xscreensaver-text
@@ -569,12 +569,15 @@ sub reformat_rss($) {
$i++;
my ($title, $body1, $body2, $body3);
+ my $author;
$title = $3 if (m@<((TITLE) [^<>\s]*)[^<>]*>\s*(.*?)\s*</\1>@xsi);
$body1 = $3 if (m@<((DESCRIPTION) [^<>\s]*)[^<>]*>\s*(.*?)\s*</\1>@xsi);
$body2 = $3 if (m@<((CONTENT) [^<>\s]*)[^<>]*>\s*(.*?)\s*</\1>@xsi);
$body3 = $3 if (m@<((SUMMARY) [^<>\s]*)[^<>]*>\s*(.*?)\s*</\1>@xsi);
+ $author = $3 if (m@<((DC:CREATOR) [^<>\s]*)[^<>]*>\s*(.*?)\s*</\1>@xsi);
+
# If there are both <description> and <content> or <content:encoded>,
# use whichever one contains more text.
#
@@ -598,10 +601,11 @@ sub reformat_rss($) {
$title = rss_field_to_html ($title || '');
$body1 = rss_field_to_html ($body1 || '');
+ $author = rss_field_to_html ($author || '');
$title = '' if ($body1 eq $title); # Identical in Twitter's atom feed.
- $out .= reformat_html ("$title<P>$body1", $wiki_p ? 'wiki' : 'rss');
+ $out .= reformat_html ("$title<BR>$author<P>$body1", $wiki_p ? 'wiki' : 'rss');
$out .= "\n";
}
diff --git a/driver/xscreensaver.man b/driver/xscreensaver.man
index 11f5b02..9ad7509 100644
--- a/driver/xscreensaver.man
+++ b/driver/xscreensaver.man
@@ -97,9 +97,8 @@ xscreensaver-command -restart
If you want to set the system-wide defaults, then make your edits to
the xscreensaver app-defaults file, which should have been installed
when xscreensaver itself was installed. The app-defaults file will
-usually be named /usr/lib/X11/app-defaults/XScreenSaver, but different
-systems might keep it in a different place (for example,
-/usr/openwin/lib/app-defaults/XScreenSaver on Solaris.)
+usually be named /usr/share/X11/app-defaults/XScreenSaver, but different
+systems might keep it in a different place.
When settings are changed in the Preferences dialog box (see above)
the current settings will be written to the \fI.xscreensaver\fP file.
diff --git a/hacks/glx/Makefile.in b/hacks/glx/Makefile.in
index 211d356..23c68d4 100644
--- a/hacks/glx/Makefile.in
+++ b/hacks/glx/Makefile.in
@@ -303,7 +303,7 @@ install-program:: $(EXES)
# the xscreensaver-gl-helper program, in $bindir
install-program:: $(EXES)
@exes="@GL_UTIL_EXES@" ; \
- idir="$(install_prefix)$(bindir)" ; \
+ idir="$(install_prefix)$(libexecdir)" ; \
if [ "$$exes" != "" ]; then \
if [ ! -d $$idir ]; then \
$(INSTALL_DIRS) $$idir ; \
@@ -372,7 +372,7 @@ uninstall-program::
# the xscreensaver-gl-helper program, in $bindir
uninstall-program::
@exes="$(GL_UTIL_EXES)" ; \
- idir="$(install_prefix)$(bindir)" ; \
+ idir="$(install_prefix)$(libexecdir)" ; \
for program in $$exes; do \
echo rm -f $$idir/$$program ; \
rm -f $$idir/$$program ; \
--
2.6.1