Temporary workaround for BR#1730105.
[privoxy.git] / debian / patches / 26_edit_only_writable.dpatch
index 64d9246..de75113 100755 (executable)
@@ -1,37 +1,60 @@
 #! /bin/sh /usr/share/dpatch/dpatch-run
-## 26_edit_only_writable.dpatch by Roland Rosenfeld <roland@debian.org>
+## 26_edit_only_writable.dpatch by Fabian Keil <fabiankeil@users.sf.net>
 ##
 ## All lines beginning with `## DP:' are a description of the patch.
 ## DP: Hide the edit button on http://p.p/show-status if action file can 
 ## DP: not be written by the privoxy user.
+## DP: Extended version action.patch by Fabian Keil which shows a
+## DP: message, that the file is write protected.
+## DP: http://sf.net/tracker/?func=detail&atid=311118&aid=1564026&group_id=11118
 
 @DPATCH@
 diff -urNad privoxy~/cgisimple.c privoxy/cgisimple.c
 --- privoxy~/cgisimple.c
 +++ privoxy/cgisimple.c
-@@ -244,6 +244,10 @@
+@@ -248,6 +248,10 @@
  #include <string.h>
  #include <assert.h>
  
-+#if !defined(_WIN32) && !defined(__OS2__)
++#ifdef HAVE_ACCESS
 +#include <unistd.h>
-+#endif
++#endif /* def HAVE_ACCESS */
 +
  #ifdef _WIN32
  #define snprintf _snprintf
  #endif /* def _WIN32 */
-@@ -1030,8 +1034,14 @@
+@@ -1040,8 +1044,20 @@
  #ifdef FEATURE_CGI_EDIT_ACTIONS
           if (NULL == strstr(csp->actions_list[i]->filename, "standard.action") && NULL != csp->config->actions_file_short[i])
           {
-+#if !defined(_WIN32) && !defined(__OS2__)
-+            if (access(csp->config->actions_file[i], W_OK) == 0) {
-+#endif
-             snprintf(buf, 100, "&nbsp;&nbsp;<a href=\"/edit-actions-list?f=%s\">Edit</a>", csp->config->actions_file_short[i]);
-             if (!err) err = string_append(&s, buf);
-+#if !defined(_WIN32) && !defined(__OS2__)
+-            snprintf(buf, 100, "&nbsp;&nbsp;<a href=\"/edit-actions-list?f=%s\">Edit</a>", csp->config->actions_file_short[i]);
+-            if (!err) err = string_append(&s, buf);
++#ifdef HAVE_ACCESS
++            if (access(csp->config->actions_file[i], W_OK) == 0)
++            {
++#endif /* def HAVE_ACCESS */
++               snprintf(buf, 100, "&nbsp;&nbsp;<a href=\"/edit-actions-list?f=%s\">Edit</a>",
++                  csp->config->actions_file_short[i]);
++               if (!err) err = string_append(&s, buf);
++#ifdef HAVE_ACCESS
 +            }
-+#endif
++            else
++            {
++               if (!err) err = string_append(&s, "&nbsp;&nbsp;<strong>File is write protected.</strong>");
++            }
++#endif /* def HAVE_ACCESS */
           }
  #endif
  
+diff -urNad privoxy~/configure.in privoxy/configure.in
+--- privoxy~/configure.in
++++ privoxy/configure.in
+@@ -1129,7 +1129,7 @@
+ AC_TYPE_SIGNAL
+ dnl uncommenting does not work for swa. suse linux
+ dnl AC_FUNC_STAT
+-AC_CHECK_FUNCS([atexit getcwd gethostbyaddr gethostbyaddr_r gethostbyname gethostbyname_r inet_ntoa localtime_r memchr memmove memset random regcomp select setlocale socket strchr strdup strerror strftime strptime strstr strtoul timegm])
++AC_CHECK_FUNCS([access atexit getcwd gethostbyaddr gethostbyaddr_r gethostbyname gethostbyname_r inet_ntoa localtime_r memchr memmove memset random regcomp select setlocale socket strchr strdup strerror strftime strptime strstr strtoul timegm])
+ dnl =================================================================