From 671eacc5e6173e01ef058d9609231ab9ec0e0847 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 20 Jan 2007 16:29:38 +0000 Subject: [PATCH] Suppress edit buttons for action files if Privoxy has no write access. Suggested by Roland in PR 1564026. --- cgisimple.c | 26 +++++++++++++++++++++++--- configure.in | 11 ++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/cgisimple.c b/cgisimple.c index 545bedc0..b82dbde6 100644 --- a/cgisimple.c +++ b/cgisimple.c @@ -1,4 +1,4 @@ -const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.47 2007/01/12 15:07:10 fabiankeil Exp $"; +const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.48 2007/01/20 15:31:31 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgisimple.c,v $ @@ -36,6 +36,10 @@ const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.47 2007/01/12 15:07:10 fabian * * Revisions : * $Log: cgisimple.c,v $ + * Revision 1.48 2007/01/20 15:31:31 fabiankeil + * Display warning if show-url-info CGI page + * is used while Privoxy is toggled off. + * * Revision 1.47 2007/01/12 15:07:10 fabiankeil * Use zalloc in cgi_send_user_manual. * @@ -281,6 +285,10 @@ const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.47 2007/01/12 15:07:10 fabian #include #include +#ifdef HAVE_ACCESS +#include +#endif /* def HAVE_ACCESS */ + #ifdef _WIN32 #define snprintf _snprintf #endif /* def _WIN32 */ @@ -1078,8 +1086,20 @@ jb_err cgi_show_status(struct client_state *csp, #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, "  No write access."); + } +#endif /* def HAVE_ACCESS */ } #endif diff --git a/configure.in b/configure.in index 0f9f97e0..2669e8e2 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. dnl -dnl $Id: configure.in,v 1.101 2007/01/12 15:20:17 fabiankeil Exp $ +dnl $Id: configure.in,v 1.102 2007/01/18 14:55:45 fabiankeil Exp $ dnl dnl Written by and Copyright (C) 2001 - 2004 the SourceForge dnl Privoxy team. http://www.privoxy.org/ @@ -28,6 +28,11 @@ dnl or write to the Free Software Foundation, Inc., 59 dnl Temple Place - Suite 330, Boston, MA 02111-1307, USA. dnl dnl $Log: configure.in,v $ +dnl Revision 1.102 2007/01/18 14:55:45 fabiankeil +dnl Check for tzset() and putenv() to make sure the +dnl replacement timegm() isn't included on systems +dnl where it fails to compile. +dnl dnl Revision 1.101 2007/01/12 15:20:17 fabiankeil dnl Temporarily ignore external libpcrs to prevent dnl problems that are fixed in Privoxy's own version. @@ -481,7 +486,7 @@ dnl ================================================================= dnl AutoConf Initialization dnl ================================================================= -AC_REVISION($Revision: 1.101 $) +AC_REVISION($Revision: 1.102 $) AC_INIT(jcc.c) if test ! -f config.h.in; then @@ -1148,7 +1153,7 @@ AC_FUNC_SETPGRP 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 putenv random regcomp select setlocale socket strchr strdup strerror strftime strptime strstr strtoul timegm tzset]) +AC_CHECK_FUNCS([access atexit getcwd gethostbyaddr gethostbyaddr_r gethostbyname gethostbyname_r inet_ntoa localtime_r memchr memmove memset putenv random regcomp select setlocale socket strchr strdup strerror strftime strptime strstr strtoul timegm tzset]) dnl ================================================================= -- 2.39.2