1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 26_edit_only_writable.dpatch by Fabian Keil <fabiankeil@users.sf.net>
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 ## DP: Extended version action.patch by Fabian Keil which shows a
8 ## DP: message, that the file is write protected.
9 ## DP: http://sf.net/tracker/?func=detail&atid=311118&aid=1564026&group_id=11118
12 diff -urNad privoxy~/cgisimple.c privoxy/cgisimple.c
13 --- privoxy~/cgisimple.c
14 +++ privoxy/cgisimple.c
21 +#endif /* def HAVE_ACCESS */
24 #define snprintf _snprintf
25 #endif /* def _WIN32 */
26 @@ -1040,8 +1044,20 @@
27 #ifdef FEATURE_CGI_EDIT_ACTIONS
28 if (NULL == strstr(csp->actions_list[i]->filename, "standard.action") && NULL != csp->config->actions_file_short[i])
30 - snprintf(buf, 100, " <a href=\"/edit-actions-list?f=%s\">Edit</a>", csp->config->actions_file_short[i]);
31 - if (!err) err = string_append(&s, buf);
33 + if (access(csp->config->actions_file[i], W_OK) == 0)
35 +#endif /* def HAVE_ACCESS */
36 + snprintf(buf, 100, " <a href=\"/edit-actions-list?f=%s\">Edit</a>",
37 + csp->config->actions_file_short[i]);
38 + if (!err) err = string_append(&s, buf);
43 + if (!err) err = string_append(&s, " <strong>File is write protected.</strong>");
45 +#endif /* def HAVE_ACCESS */
49 diff -urNad privoxy~/configure.in privoxy/configure.in
50 --- privoxy~/configure.in
51 +++ privoxy/configure.in
54 dnl uncommenting does not work for swa. suse linux
56 -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])
57 +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])
60 dnl =================================================================