# HG changeset patch # User Tomas Zeman # Date 1445605539 -7200 # Node ID 9c1ee7dfe89e105348466ef871da0eb26de1af3b # Parent c3f2c8485f709ea38685fa8e89042ed4df114f2d anyvar.patch diff -r c3f2c8485f70 -r 9c1ee7dfe89e anyvar.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/anyvar.patch Fri Oct 23 15:05:39 2015 +0200 @@ -0,0 +1,384 @@ +# HG changeset patch +# Parent 9e657f6cad9e122bf465a264f31e26a57fd27c60 +Anyvar module + +diff --git a/Makefile b/Makefile +--- a/Makefile ++++ b/Makefile +@@ -153,7 +153,7 @@ + # (which will cause the Makefiles to be regenerated when you run `make'); + # (2) otherwise, pass the desired values on the `make' command line. + +-MAKE=make ++ + + all-recursive install-data-recursive install-exec-recursive \ + installdirs-recursive install-recursive uninstall-recursive \ +diff --git a/config.status b/config.status +--- a/config.status ++++ b/config.status +@@ -512,7 +512,7 @@ + s,@AUTOMAKE@,/home/tzeman/dev/vmailmgr-0.97/missing automake-1.4,;t t + s,@AUTOHEADER@,/home/tzeman/dev/vmailmgr-0.97/missing autoheader,;t t + s,@MAKEINFO@,makeinfo,;t t +-s,@SET_MAKE@,MAKE=make,;t t ++s,@SET_MAKE@,,;t t + s,@KRB5_TRUE@,#,;t t + s,@KRB5_FALSE@,,;t t + s,@VPWTABLE_CDB_TRUE@,,;t t +diff --git a/daemon/Makefile b/daemon/Makefile +--- a/daemon/Makefile ++++ b/daemon/Makefile +@@ -95,7 +95,7 @@ + + INCLUDES = -I../lib + +-vmailmgrd_SOURCES = daemon.h adduser.cc autoresponse.cc chattr.cc check.cc command.h command.cc deluser.cc dispatch.cc listdomain.cc log.h log.cc lookup.cc main.cc stat.cc state.h state.cc ++vmailmgrd_SOURCES = daemon.h adduser.cc anyvar.cc autoresponse.cc chattr.cc check.cc command.h command.cc deluser.cc dispatch.cc listdomain.cc log.h log.cc lookup.cc main.cc stat.cc state.h state.cc + + vmailmgrd_LDADD = ../lib/libvmailmgr.a ../lib/cli++/libcli++.a + mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +@@ -108,7 +108,7 @@ + CPPFLAGS = + LDFLAGS = + LIBS = -lcrypt +-vmailmgrd_OBJECTS = adduser.o autoresponse.o chattr.o check.o command.o \ ++vmailmgrd_OBJECTS = adduser.o anyvar.o autoresponse.o chattr.o check.o command.o \ + deluser.o dispatch.o listdomain.o log.o lookup.o main.o stat.o state.o + vmailmgrd_DEPENDENCIES = ../lib/libvmailmgr.a ../lib/cli++/libcli++.a + vmailmgrd_LDFLAGS = +@@ -288,6 +288,17 @@ + ../lib/vpwtable/vpwtable.h ../lib/misc/response.h command.h \ + log.h ../lib/fdbuf/fdbuf.h ../lib/fdbuf/fdibuf.h \ + ../lib/fdbuf/fdobuf.h ++anyvar.o: anyvar.cc ../config.h daemon.h \ ++ ../lib/mystring/mystring.h ../lib/mystring/rep.h \ ++ ../lib/mystring/iter.h ../lib/mystring/join.h \ ++ ../lib/misc/pwentry.h ../lib/config/configrc.h \ ++ ../lib/misc/strlist.h ../lib/vpwentry/vpwentry.h \ ++ ../lib/misc/pwcrypt.h ../lib/misc/itoa.h state.h \ ++ ../lib/vdomain/vdomain.h ../lib/vpwtable/vpwtable.h \ ++ ../lib/misc/response.h command.h log.h ../lib/fdbuf/fdbuf.h \ ++ ../lib/fdbuf/fdibuf.h ../lib/fdbuf/fdobuf.h \ ++ ../lib/misc/lookup.h ../lib/misc/maildir.h \ ++ ../lib/misc/pwentry_table.h ../lib/misc/stat_fns.h + autoresponse.o: autoresponse.cc ../config.h daemon.h \ + ../lib/mystring/mystring.h ../lib/mystring/rep.h \ + ../lib/mystring/iter.h ../lib/mystring/join.h \ +diff --git a/daemon/Makefile.am b/daemon/Makefile.am +--- a/daemon/Makefile.am ++++ b/daemon/Makefile.am +@@ -24,6 +24,7 @@ + + vmailmgrd_SOURCES = daemon.h \ + adduser.cc \ ++ anyvar.cc \ + autoresponse.cc \ + chattr.cc \ + check.cc \ +diff --git a/daemon/Makefile.in b/daemon/Makefile.in +--- a/daemon/Makefile.in ++++ b/daemon/Makefile.in +@@ -95,7 +95,7 @@ + + INCLUDES = -I../lib + +-vmailmgrd_SOURCES = daemon.h adduser.cc autoresponse.cc chattr.cc check.cc command.h command.cc deluser.cc dispatch.cc listdomain.cc log.h log.cc lookup.cc main.cc stat.cc state.h state.cc ++vmailmgrd_SOURCES = daemon.h adduser.cc anyvar.cc autoresponse.cc chattr.cc check.cc command.h command.cc deluser.cc dispatch.cc listdomain.cc log.h log.cc lookup.cc main.cc stat.cc state.h state.cc + + vmailmgrd_LDADD = ../lib/libvmailmgr.a ../lib/cli++/libcli++.a + mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +@@ -108,7 +108,7 @@ + CPPFLAGS = @CPPFLAGS@ + LDFLAGS = @LDFLAGS@ + LIBS = @LIBS@ +-vmailmgrd_OBJECTS = adduser.o autoresponse.o chattr.o check.o command.o \ ++vmailmgrd_OBJECTS = adduser.o anyvar.o autoresponse.o chattr.o check.o command.o \ + deluser.o dispatch.o listdomain.o log.o lookup.o main.o stat.o state.o + vmailmgrd_DEPENDENCIES = ../lib/libvmailmgr.a ../lib/cli++/libcli++.a + vmailmgrd_LDFLAGS = +@@ -288,6 +288,17 @@ + ../lib/vpwtable/vpwtable.h ../lib/misc/response.h command.h \ + log.h ../lib/fdbuf/fdbuf.h ../lib/fdbuf/fdibuf.h \ + ../lib/fdbuf/fdobuf.h ++anyvar.o: anyvar.cc ../config.h daemon.h \ ++ ../lib/mystring/mystring.h ../lib/mystring/rep.h \ ++ ../lib/mystring/iter.h ../lib/mystring/join.h \ ++ ../lib/misc/pwentry.h ../lib/config/configrc.h \ ++ ../lib/misc/strlist.h ../lib/vpwentry/vpwentry.h \ ++ ../lib/misc/pwcrypt.h ../lib/misc/itoa.h state.h \ ++ ../lib/vdomain/vdomain.h ../lib/vpwtable/vpwtable.h \ ++ ../lib/misc/response.h command.h log.h ../lib/fdbuf/fdbuf.h \ ++ ../lib/fdbuf/fdibuf.h ../lib/fdbuf/fdobuf.h \ ++ ../lib/misc/lookup.h ../lib/misc/maildir.h \ ++ ../lib/misc/pwentry_table.h ../lib/misc/stat_fns.h + autoresponse.o: autoresponse.cc ../config.h daemon.h \ + ../lib/mystring/mystring.h ../lib/mystring/rep.h \ + ../lib/mystring/iter.h ../lib/mystring/join.h \ +diff --git a/daemon/autoresponse.cc b/daemon/anyvar.cc +copy from daemon/autoresponse.cc +copy to daemon/anyvar.cc +--- a/daemon/autoresponse.cc ++++ b/daemon/anyvar.cc +@@ -27,7 +27,7 @@ + #include "misc/pwentry_table.h" + #include "misc/stat_fns.h" + +-response autoresponse_write(const mystring& directory, ++response anyvar_write(const mystring& directory, + const mystring& location, + const mystring& disabled, + const mystring& msg) +@@ -36,18 +36,18 @@ + + if(!is_dir(directory.c_str())) { + if(mkdir(directory.c_str(), 0755)) +- RETURN(err, "Could not create autoresponse directory"); ++ RETURN(err, "Could not create anyvar directory"); + } + + if(is_exist(tmpfile.c_str())) +- RETURN(err, "Temporary autoresponse file already exists"); ++ RETURN(err, "Temporary anyvar file already exists"); + + if(is_exist(disabled.c_str())) + RETURN(err, "Autoresponse is disabled, reenable it before writing a new message"); + + fdobuf out(tmpfile.c_str(), fdobuf::create | fdobuf::excl, 0644); + if(!out) +- RETURN(err, "Unable to open temporary autoresponse file for writing"); ++ RETURN(err, "Unable to open temporary anyvar file for writing"); + + out << msg; + if(!out.flush() || !out.close()) { +@@ -56,34 +56,34 @@ + } + if(rename(tmpfile.c_str(), location.c_str())) { + unlink(tmpfile.c_str()); +- RETURN(err, "Unable to rename temporary autoresponse file"); ++ RETURN(err, "Unable to rename temporary anyvar file"); + } + +- RETURN(ok, "Message successfully written to autoresponse file"); ++ RETURN(ok, "Message successfully written to anyvar file"); + } + +-response autoresponse_disable(const mystring& location, ++response anyvar_disable(const mystring& location, + const mystring& disabled) + { + if(!is_exist(location.c_str())) +- RETURN(ok, "Autoresponse file did not exist"); ++ RETURN(ok, "Anyvar file did not exist"); + if(is_exist(disabled.c_str())) +- RETURN(err, "Disabled autoresponse file already exists"); ++ RETURN(err, "Disabled anyvar file already exists"); + if(rename(location.c_str(), disabled.c_str())) +- RETURN(err, "Unable to rename autoresponse file"); +- RETURN(ok, "Autoresponse file sucessfully disabled"); ++ RETURN(err, "Unable to rename anyvar file"); ++ RETURN(ok, "Anyvar file sucessfully disabled"); + } + +-response autoresponse_enable(const mystring& location, ++response anyvar_enable(const mystring& location, + const mystring& disabled) + { + if(is_exist(location.c_str())) +- RETURN(ok, "Autoresponse is already enabled"); ++ RETURN(ok, "Anyvar is already enabled"); + if(!is_exist(disabled.c_str())) +- RETURN(err, "Disabled autoresponse file did not exist"); ++ RETURN(err, "Disabled anyvar file did not exist"); + if(rename(disabled.c_str(), location.c_str())) +- RETURN(err, "Unable to rename previously disabled autoresponse file"); +- RETURN(ok, "Autoresponse file sucessfully restored"); ++ RETURN(err, "Unable to rename previously disabled anyvar file"); ++ RETURN(ok, "Anyvar file sucessfully restored"); + } + + static bool read_file(const mystring& filename, mystring& out) +@@ -99,33 +99,39 @@ + return true; + } + +-response autoresponse_read(const mystring& location, ++response anyvar_read(const mystring& location, + const mystring& disabled, int fd) + { + mystring line; + if(!is_exist(location.c_str()) && + !is_exist(disabled.c_str())) +- RETURN(err, "Autoresponder file does not exist"); ++ RETURN(err, "Anyvar file does not exist"); + + mystring contents; + if(!read_file(location, contents) && + !read_file(disabled, contents)) +- RETURN(err, "Unable to read data from autoresponse file"); ++ RETURN(err, "Unable to read data from anyvar file"); + response resp(response::ok, contents); + resp.write(fd); +- RETURN(ok, "Retrieved autoresponse file"); ++ RETURN(ok, "Retrieved anyvar file"); + } + +-response autoresponse_delete(const mystring& directory) ++response anyvar_delete(const mystring& directory, ++ const mystring& location, ++ const mystring& disabled) + { + if(!is_dir(directory.c_str())) +- RETURN(err, "Autoresponse directory does not exist."); +- if(!delete_directory(directory)) +- RETURN(err, "Could not delete autoresponse directory."); +- RETURN(ok, "Autoresponse directory deleted."); ++ RETURN(err, "Anyvar directory does not exist."); ++ const char* fn = is_file(location.c_str()) ? location.c_str() : ++ is_file(disabled.c_str()) ? disabled.c_str() : NULL; ++ if(fn == NULL) ++ RETURN(err, "Anyvar file does not exist."); ++ if(unlink(fn)) ++ RETURN(err, "Failed to remove anyvar file."); ++ RETURN(ok, "Anyvar file deleted."); + } + +-response autoresponse_status(const mystring& directory, ++response anyvar_status(const mystring& directory, + const mystring& location, + const mystring& disabled) + { +@@ -141,18 +147,19 @@ + RETURN(ok, msg); + } + +-CMD_FD(autoresponse) +- // Usage: autoresponse baseuser-virtuser pass action [autorespmessage] ++CMD_FD(anyvar) ++ // Usage: anyvar baseuser-virtuser pass action varname [value] + { + + mystring user = args[0]; + mystring pass = args[1]; + args[1] = LOG_PASSWORD; + mystring action = args[2]; +- mystring message; +- if(args.count() == 4) { +- message = args[3]; +- args[3] = LOG_MESSAGE; ++ mystring varname = args[3]; ++ mystring value; ++ if(args.count() == 5) { ++ value = args[4]; ++ args[4] = LOG_MESSAGE; + } + logcommand(args); + +@@ -160,25 +167,25 @@ + vpwentry* vpw; + OK_RESPONSE(lookup_and_validate(user, pw, vpw, pass, true, true)); + +- const mystring directory = vpw->directory + "/" + config->autoresponse_dir(); +- const mystring filename = directory + "/" + config->autoresponse_file(); ++ const mystring directory = vpw->directory + "/anyvar"; // XXX: + config->anyvar_dir(); ++ const mystring filename = directory + "/" + varname; + const mystring disabled = filename + ".disabled"; + + if(action == "disable") +- return autoresponse_disable(filename, disabled); ++ return anyvar_disable(filename, disabled); + else if(action == "enable") +- return autoresponse_enable(filename, disabled); ++ return anyvar_enable(filename, disabled); + else if(action == "read") +- return autoresponse_read(filename, disabled, fd); ++ return anyvar_read(filename, disabled, fd); + else if(action == "write") +- if(!message) +- RETURN(bad, "Missing autoresponse message argument"); ++ if(!value) ++ RETURN(bad, "Missing anyvar value argument"); + else +- return autoresponse_write(directory, filename, disabled, message); ++ return anyvar_write(directory, filename, disabled, value); + else if(action == "delete") +- return autoresponse_delete(directory); ++ return anyvar_delete(directory, filename, disabled); + else if(action == "status") +- return autoresponse_status(directory, filename, disabled); ++ return anyvar_status(directory, filename, disabled); + + RETURN(err, "Unrecognized command"); + } +diff --git a/daemon/dispatch.cc b/daemon/dispatch.cc +--- a/daemon/dispatch.cc ++++ b/daemon/dispatch.cc +@@ -21,6 +21,7 @@ + // declare the commands + extern CMD(adduser2); + extern CMD(adduser3); ++extern CMD(anyvar); + extern CMD(autoresponse); + extern CMD(chattr); + extern CMD(check); +@@ -72,6 +73,7 @@ + ENTRY(chattr, 5, -1, true), + ENTRY(adduser2, 4, -1, true), + ENTRY(adduser3, 5, -1, true), ++ ENTRY(anyvar, 5, 6, true), + ENTRY(autoresponse, 4, 5, true), + ENTRY(deluser, 3, 3, true), + ENTRY(stat, 3, 3, true), +diff --git a/lib/Makefile b/lib/Makefile +--- a/lib/Makefile ++++ b/lib/Makefile +@@ -166,7 +166,7 @@ + # (which will cause the Makefiles to be regenerated when you run `make'); + # (2) otherwise, pass the desired values on the `make' command line. + +-MAKE=make ++ + + all-recursive install-data-recursive install-exec-recursive \ + installdirs-recursive install-recursive uninstall-recursive \ +diff --git a/python/commands.py b/python/commands.py +--- a/python/commands.py ++++ b/python/commands.py +@@ -45,6 +45,12 @@ + def lookup(domain, username, password): + return types.VUser(execute('lookup', domain, username, password)) + ++def anyvar(domain, user, password, action, varname, value=None): ++ cmd = [ domain, user, password, action, varname ] ++ if value: ++ cmd.append(value) ++ return daemon.execute('anyvar', cmd) ++ + def autoresponse(domain, user, password, action, message=None): + cmd = [ domain, user, password, action ] + if message: +diff --git a/python/config.py b/python/config.py +--- a/python/config.py ++++ b/python/config.py +@@ -16,7 +16,7 @@ + + import os + import string +-import local ++#import local + + def read(name, default): + try: +diff --git a/python/types.py b/python/types.py +--- a/python/types.py ++++ b/python/types.py +@@ -94,7 +94,8 @@ + if flag == ATTR_MAILBOX_ENABLED: + self.mailbox_enabled = Flag(val) + else: +- raise ValueError, "Invalid flag number %d in vuser data" % flag ++ #raise ValueError, "Invalid flag number %d in vuser data" % flag ++ print "Invalid flag number %d in vuser data" % flag + bin = string.split(bin[i+1:], '\0') + self.password = bin[0] + self.mailbox = bin[1] diff -r c3f2c8485f70 -r 9c1ee7dfe89e series --- a/series Sun Jan 20 01:58:36 2008 +0100 +++ b/series Fri Oct 23 15:05:39 2015 +0200 @@ -1,1 +1,2 @@ compile-0.96.9.patch +anyvar.patch