Adapt to CVS version as of 2006-09-23.
[privoxy.git] / debian / patches / 26_edit_only_writable.dpatch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 26_edit_only_writable.dpatch by Roland Rosenfeld <roland@debian.org>
3 ##
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: Hide the edit button on http://p.p/show-status if action file can 
6 ## DP: not be written by the privoxy user.
7
8 @DPATCH@
9 diff -urNad privoxy~/cgisimple.c privoxy/cgisimple.c
10 --- privoxy~/cgisimple.c
11 +++ privoxy/cgisimple.c
12 @@ -244,6 +244,10 @@
13  #include <string.h>
14  #include <assert.h>
15  
16 +#if !defined(_WIN32) && !defined(__OS2__)
17 +#include <unistd.h>
18 +#endif
19 +
20  #ifdef _WIN32
21  #define snprintf _snprintf
22  #endif /* def _WIN32 */
23 @@ -1030,8 +1034,14 @@
24  #ifdef FEATURE_CGI_EDIT_ACTIONS
25           if (NULL == strstr(csp->actions_list[i]->filename, "standard.action") && NULL != csp->config->actions_file_short[i])
26           {
27 +#if !defined(_WIN32) && !defined(__OS2__)
28 +            if (access(csp->config->actions_file[i], W_OK) == 0) {
29 +#endif
30              snprintf(buf, 100, "&nbsp;&nbsp;<a href=\"/edit-actions-list?f=%s\">Edit</a>", csp->config->actions_file_short[i]);
31              if (!err) err = string_append(&s, buf);
32 +#if !defined(_WIN32) && !defined(__OS2__)
33 +            }
34 +#endif
35           }
36  #endif
37