diff options
author | Andreas Brodmann <andreas.brodmann@gmail.com> | 2008-01-14 15:16:51 +0000 |
---|---|---|
committer | Andreas Brodmann <andreas.brodmann@gmail.com> | 2008-01-14 15:16:51 +0000 |
commit | d3f6fac84e5ed293b121ce0d92f07eb438cf6c96 (patch) | |
tree | eabf5f56ff5ec31380a21ec78f035b964f64d087 /squid-model.lua | |
parent | 7c8b2854e579402d546b41457828bf7622868d5a (diff) | |
download | acf-squid-d3f6fac84e5ed293b121ce0d92f07eb438cf6c96.tar.bz2 acf-squid-d3f6fac84e5ed293b121ce0d92f07eb438cf6c96.tar.xz |
1) you can now change to auth methods
2) tags insertion into config file solved with default config
3) modifications on views to look better with css
git-svn-id: svn://svn.alpinelinux.org/acf/squid/trunk@563 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'squid-model.lua')
-rw-r--r-- | squid-model.lua | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/squid-model.lua b/squid-model.lua index 7e7fed7..0a080a2 100644 --- a/squid-model.lua +++ b/squid-model.lua @@ -5,6 +5,7 @@ module (..., package.seeall) require "format" squidconf = "/etc/squid/squid.conf" +squidtempl = "/etc/squid/squid.conf.template" --- the tokenizer functions - must be dislocated into a library later tokenizer = {} @@ -768,3 +769,94 @@ update_basic_config = function( config ) return error end +upd_authmethod = function( method ) + + local tmpfilename = os.tmpname() + local tmpfile = io.open( tmpfilename, "w+" ) + local cfgfile = io.open( squidconf, "r" ) + local error = "" + local line = "" + local done = false + + config_preblock_copy( cfgfile, tmpfile, "### ACF-SQUID-TAG-0004" ) + + while not done do + line = cfgfile:read( "*l" ) + if string.sub( line, 1, 7 ) == "### ACF" then + done = true + tmpfile:write( line .. "\n" ) + else + if string.sub( line, 1, 17 ) == "auth_param digest" then + if string.find( method, "D" ) ~= nil then + tmpfile:write( line .. "\n" ) + else + tmpfile:write( "#" .. line .. "\n" ) + end + elseif string.sub( line, 1, 18 ) == "#auth_param digest" then + if string.find( method, "D" ) ~= nil then + tmpfile:write( string.sub( line, 2 ) .. "\n" ) + else + tmpfile:write( line .. "\n" ) + end + elseif string.sub( line, 1, 15 ) == "auth_param ntlm" then + if string.find( method, "N" ) ~= nil then + tmpfile:write( line .. "\n" ) + else + tmpfile:write( "#" .. line .. "\n" ) + end + elseif string.sub( line, 1, 16 ) == "#auth_param ntlm" then + if string.find( method, "N" ) ~= nil then + tmpfile:write( string.sub( line, 2 ) .. "\n" ) + else + tmpfile:write( line .. "\n" ) + end + else + tmpfile:write( line .. "\n" ) + end + end + end + + config_postblock_copy( cfgfile, tmpfile ) + + tmpfile:close() + cfgfile:close() + os.rename( tmpfilename, squidconf ) + + return error +end + +dependancy_ok = function() + + local retval = false + local cfgfile = io.open( squidconf ) + local line = "" + + if cfgfile ~= nil then + line = cfgfile:read( "*l" ) + if string.sub( line, 1, 19 ) == "### ACF-SQUID-MAGIC" then + retval = true + end + end + + return retval +end + +create_cfg_from_template = function() + + local from = io.open( squidtempl ) + local to = io.open( squidconf, "wb+" ) + local line = "" + + while line ~= nil do + line = from:read( "*l" ) + if line ~= nil then + to:write( line .. "\n" ) + end + end + + from:close() + to:close() + + return +end + |