#! /bin/sh /usr/share/dpatch/dpatch-run ## 26_edit_only_writable.dpatch by Fabian Keil ## ## 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 @@ -248,6 +248,10 @@ #include #include +#ifdef HAVE_ACCESS +#include +#endif /* def HAVE_ACCESS */ + #ifdef _WIN32 #define snprintf _snprintf #endif /* def _WIN32 */ @@ -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]) { - snprintf(buf, 100, "  Edit", 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, "  Edit", + csp->config->actions_file_short[i]); + if (!err) err = string_append(&s, buf); +#ifdef HAVE_ACCESS + } + else + { + if (!err) err = string_append(&s, "  File is write protected."); + } +#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 =================================================================