diff --git a/indimail-x/.gitignore b/indimail-x/.gitignore index 53f73efd0..8a5500fa6 100644 --- a/indimail-x/.gitignore +++ b/indimail-x/.gitignore @@ -155,6 +155,7 @@ vhostid vipmap vlimit vmoddomain +vmoddomain.1 vmoduser vmoduser.1 vmoveuserdir diff --git a/indimail-x/Makefile.am b/indimail-x/Makefile.am index bc6504d4e..84b93aaab 100644 --- a/indimail-x/Makefile.am +++ b/indimail-x/Makefile.am @@ -83,7 +83,7 @@ include_HEADERS = addaliasdomain.h add_control.h add_domain_assign.h addressToke pipe_exec.h post_handle.h print_control.h ProcessInFifo.h proxylogin.h \ purge_files.h pwcomp.h PwdInLookup.h qmail_remote.h recalc_quota.h \ RelayInLookup.h relay_select.h RemoteBulkMail.h remove_line.h remove_quotes.h \ - renameuser.h runcmmd.h SendWelcomeMail.h \ + renameuser.h runcmmd.h SendWelcomeMail.h print_limits.h \ set_mysql_options.h setuserquota.h skip_relay.h \ skip_system_files.h sockwrite.h smtp_port.h spam.h sql_active.h sql_adddomain.h \ sql_adduser.h sql_delaliasdomain.h sql_deldomain.h sql_deluser.h sql_getall.h \ @@ -111,7 +111,7 @@ COMMONSOURCES = addaliasdomain.c add_atrn_map.c add_control.c add_domain_assign. CreateDomainDirs.c create_table.c dbinfoAdd.c dbinfoDel.c dbinfoSelect.c \ dbinfoUpdate.c dbload.c dec_dir_control.c del_atrn_map.c del_control.c \ del_domain_assign.c deldomain.c del_ip_map.c del_user_assign.c compat.c \ - deluser.c delusercntrl.c fappend.c \ + deluser.c delusercntrl.c fappend.c print_limits.c \ FifoCreate.c filewrt.c findhost.c findmdahost.c fstabChangeCounters.c \ getactualpath.c get_assign.c getDbLock.c \ get_indimailuidgid.c get_local_hostid.c get_local_ip.c get_localtime.c \ @@ -640,6 +640,8 @@ vadduser.1: vadduser.9 $(editman) vadduser.9 > $@ vdeluser.1: vdeluser.9 $(editman) vdeluser.9 > $@ +vmoddomain.1: vmoddomain.9 + $(editman) vmoddomain.9 > $@ vrenamedomain.1: vrenamedomain.9 $(editman) vrenamedomain.9 > $@ vrenameuser.1: vrenameuser.9 diff --git a/indimail-x/ProcessInFifo.c b/indimail-x/ProcessInFifo.c index 4eb2fb2c3..fcd6b1fa4 100644 --- a/indimail-x/ProcessInFifo.c +++ b/indimail-x/ProcessInFifo.c @@ -1,65 +1,5 @@ /* - * $Log: ProcessInFifo.c,v $ - * Revision 1.20 2024-05-27 22:52:54+05:30 Cprogrammer - * initialize struct vlimits - * - * Revision 1.19 2024-05-17 16:25:48+05:30 mbhangui - * fix discarded-qualifier compiler warnings - * - * Revision 1.18 2023-06-08 17:48:50+05:30 Cprogrammer - * renamed fifo directory from FIFODIR to INFIFODIR. - * - * Revision 1.17 2023-04-09 11:57:57+05:30 Cprogrammer - * skip logging of binary search walk on SIGUSR1 (log only when debug is set) - * - * Revision 1.16 2023-04-08 23:46:28+05:30 Cprogrammer - * modified for qmailmrtg inlookup stats - * - * Revision 1.15 2023-03-20 10:16:03+05:30 Cprogrammer - * standardize getln handling - * - * Revision 1.14 2022-08-04 14:41:01+05:30 Cprogrammer - * fetch scram password - * - * Revision 1.13 2022-07-04 22:23:56+05:30 Cprogrammer - * fixed typo - * - * Revision 1.12 2021-07-28 12:19:56+05:30 Cprogrammer - * shortened display in logs on signal - * - * Revision 1.11 2021-07-27 18:10:43+05:30 Cprogrammer - * use getEnvConfigStr to set default domain - * - * Revision 1.10 2021-06-09 17:04:06+05:30 Cprogrammer - * BUG: Fixed read failing on fifo because of O_NDELAY flag - * - * Revision 1.9 2021-02-07 19:54:52+05:30 Cprogrammer - * respond to TCP/IP request when run under tcpserver - * - * Revision 1.8 2020-10-11 23:13:41+05:30 Cprogrammer - * replace deprecated sys_siglist with strsignal - * - * Revision 1.7 2020-10-01 18:27:59+05:30 Cprogrammer - * Darwin Port - * - * Revision 1.6 2020-09-17 14:48:15+05:30 Cprogrammer - * FreeBSD fix for missing tdestroy - * - * Revision 1.5 2020-04-01 18:57:29+05:30 Cprogrammer - * moved authentication functions to libqmail - * - * Revision 1.4 2019-05-28 17:41:50+05:30 Cprogrammer - * added load_mysql.h for mysql interceptor function prototypes - * - * Revision 1.3 2019-05-02 14:37:54+05:30 Cprogrammer - * added argument to specify a 'where clause' - * - * Revision 1.2 2019-04-22 23:18:33+05:30 Cprogrammer - * replaced exit with _exit - * - * Revision 1.1 2019-04-20 08:27:23+05:30 Cprogrammer - * Initial revision - * + * $Id: ProcessInFifo.c,v 1.21 2024-05-28 19:45:25+05:30 Cprogrammer Exp mbhangui $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -135,9 +75,10 @@ #include "get_assign.h" #include "dbload.h" #include "FifoCreate.h" +#include "inquery.h" #ifndef lint -static char sccsid[] = "$Id: ProcessInFifo.c,v 1.20 2024-05-27 22:52:54+05:30 Cprogrammer Exp mbhangui $"; +static char sccsid[] = "$Id: ProcessInFifo.c,v 1.21 2024-05-28 19:45:25+05:30 Cprogrammer Exp mbhangui $"; #endif int user_query_count, relay_query_count, pwd_query_count, alias_query_count; @@ -207,7 +148,7 @@ getFifo_name() if (!stralloc_copys(&inFifo, infifo) || !stralloc_0(&inFifo)) die_nomem(); } else { - getEnvConfigStr(&infifo_dir, "INFIFODIR", "/tmp/indimail/inlookup"); + getEnvConfigStr(&infifo_dir, "INFIFODIR", INFIFODIR); if (*infifo_dir == '/') { if (indimailuid == -1 || indimailgid == -1) get_indimailuidgid(&indimailuid, &indimailgid); @@ -1461,7 +1402,18 @@ ProcessInFifo(int instNum) break; #ifdef ENABLE_DOMAIN_LIMITS case LIMIT_QUERY: - if ((status = VlimitInLookup(email, &limits)) == -1) + i = str_rchr(email, '@'); + if (!email[i]) { + status = vget_limits(email, &limits); + if (!status) + status = 1; + else + if (status > 0) + status = 0; + } else + status = VlimitInLookup(email, &limits); + + if (status == -1) bytes = -1; else if (status) /*- user not found */ @@ -1521,3 +1473,70 @@ ProcessInFifo(int instNum) signal(SIGPIPE, pstat); return (1); } +/* + * $Log: ProcessInFifo.c,v $ + * Revision 1.21 2024-05-28 19:45:25+05:30 Cprogrammer + * Use INFIFODIR #define from inquery.h for infifo + * use vget_limits when argument is domain instead of email + * + * Revision 1.20 2024-05-27 22:52:54+05:30 Cprogrammer + * initialize struct vlimits + * + * Revision 1.19 2024-05-17 16:25:48+05:30 mbhangui + * fix discarded-qualifier compiler warnings + * + * Revision 1.18 2023-06-08 17:48:50+05:30 Cprogrammer + * renamed fifo directory from FIFODIR to INFIFODIR. + * + * Revision 1.17 2023-04-09 11:57:57+05:30 Cprogrammer + * skip logging of binary search walk on SIGUSR1 (log only when debug is set) + * + * Revision 1.16 2023-04-08 23:46:28+05:30 Cprogrammer + * modified for qmailmrtg inlookup stats + * + * Revision 1.15 2023-03-20 10:16:03+05:30 Cprogrammer + * standardize getln handling + * + * Revision 1.14 2022-08-04 14:41:01+05:30 Cprogrammer + * fetch scram password + * + * Revision 1.13 2022-07-04 22:23:56+05:30 Cprogrammer + * fixed typo + * + * Revision 1.12 2021-07-28 12:19:56+05:30 Cprogrammer + * shortened display in logs on signal + * + * Revision 1.11 2021-07-27 18:10:43+05:30 Cprogrammer + * use getEnvConfigStr to set default domain + * + * Revision 1.10 2021-06-09 17:04:06+05:30 Cprogrammer + * BUG: Fixed read failing on fifo because of O_NDELAY flag + * + * Revision 1.9 2021-02-07 19:54:52+05:30 Cprogrammer + * respond to TCP/IP request when run under tcpserver + * + * Revision 1.8 2020-10-11 23:13:41+05:30 Cprogrammer + * replace deprecated sys_siglist with strsignal + * + * Revision 1.7 2020-10-01 18:27:59+05:30 Cprogrammer + * Darwin Port + * + * Revision 1.6 2020-09-17 14:48:15+05:30 Cprogrammer + * FreeBSD fix for missing tdestroy + * + * Revision 1.5 2020-04-01 18:57:29+05:30 Cprogrammer + * moved authentication functions to libqmail + * + * Revision 1.4 2019-05-28 17:41:50+05:30 Cprogrammer + * added load_mysql.h for mysql interceptor function prototypes + * + * Revision 1.3 2019-05-02 14:37:54+05:30 Cprogrammer + * added argument to specify a 'where clause' + * + * Revision 1.2 2019-04-22 23:18:33+05:30 Cprogrammer + * replaced exit with _exit + * + * Revision 1.1 2019-04-20 08:27:23+05:30 Cprogrammer + * Initial revision + * + */ diff --git a/indimail-x/VlimitInLookup.c b/indimail-x/VlimitInLookup.c index f8c7de41c..78a1c53ba 100644 --- a/indimail-x/VlimitInLookup.c +++ b/indimail-x/VlimitInLookup.c @@ -1,5 +1,8 @@ /* * $Log: VlimitInLookup.c,v $ + * Revision 1.4 2024-05-28 19:34:57+05:30 Cprogrammer + * return domain level record of user level record not found + * * Revision 1.3 2024-05-27 22:53:54+05:30 Cprogrammer * initialize struct vlimits * @@ -15,7 +18,7 @@ #endif #ifndef lint -static char sccsid[] = "$Id: VlimitInLookup.c,v 1.3 2024-05-27 22:53:54+05:30 Cprogrammer Exp mbhangui $"; +static char sccsid[] = "$Id: VlimitInLookup.c,v 1.4 2024-05-28 19:34:57+05:30 Cprogrammer Exp mbhangui $"; #endif #ifdef ENABLE_DOMAIN_LIMITS @@ -36,14 +39,14 @@ static char sccsid[] = "$Id: VlimitInLookup.c,v 1.3 2024-05-27 22:53:54+05:3 #include "variables.h" #include "vlimits.h" +static struct vlimits limits = { 0 }; + int VlimitInLookup(const char *email, struct vlimits *lim) { static stralloc user = {0}, domain = {0}; const char *real_domain; -#ifdef ENABLE_DOMAIN_LIMITS - struct vlimits limits = { 0 }; -#endif + int r; #ifdef CLUSTERED_SITE if (sqlOpen_user(email, 1)) @@ -52,18 +55,24 @@ VlimitInLookup(const char *email, struct vlimits *lim) #endif { if(userNotFound) - return(1); + return 1; else - return(-1); + return -1; } - parse_email(email, &user, &domain); - if (!(real_domain = get_real_domain(domain.s))) - real_domain = domain.s; - if (vget_limits(real_domain, &limits)) { - strerr_warn3("VlimitInLookup: ", real_domain, ": failed to get domain limits", 0); - return (-1); + if ((r = vget_limits(email, &limits)) == -1) { + strerr_warn3("VlimitInLookup: ", email, ": failed to get domain limits", 0); + return -1; + } else + if (!r) { + parse_email(email, &user, &domain); + if (!(real_domain = get_real_domain(domain.s))) + real_domain = domain.s; + if (vget_limits(real_domain, &limits) == -1) { + strerr_warn3("VlimitInLookup: ", real_domain, ": failed to get domain limits", 0); + return -1; + } } *lim = limits; - return (0); + return 0; } #endif diff --git a/indimail-x/authindi.c b/indimail-x/authindi.c index 25d75ce9e..e0f4d043f 100644 --- a/indimail-x/authindi.c +++ b/indimail-x/authindi.c @@ -1,5 +1,5 @@ /* - * $Id: authindi.c,v 1.20 2024-05-27 22:50:29+05:30 Cprogrammer Exp mbhangui $ + * $Id: authindi.c,v 1.21 2024-05-28 19:13:20+05:30 Cprogrammer Exp mbhangui $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -57,7 +57,7 @@ #define WARN "authindi: warn: " #ifndef lint -static char sccsid[] = "$Id: authindi.c,v 1.20 2024-05-27 22:50:29+05:30 Cprogrammer Exp mbhangui $"; +static char sccsid[] = "$Id: authindi.c,v 1.21 2024-05-28 19:13:20+05:30 Cprogrammer Exp mbhangui $"; #endif static stralloc tmpbuf = {0}; @@ -653,7 +653,7 @@ main(int argc, char **argv) struct vlimits *lmt; #ifdef QUERY_CACHE if (!env_get("QUERY_CACHE")) { - if (vget_limits(real_domain, &limits)) { + if (vget_limits(real_domain, &limits) == -1) { strerr_warn3(FATAL, "unable to get domain limits for for ", real_domain, 0); failure1(argv, auth_method, service, imapargs, pop3args, authstr, 0); } @@ -661,7 +661,7 @@ main(int argc, char **argv) } else lmt = inquery(LIMIT_QUERY, login, 0); #else - if (vget_limits(real_domain, &limits)) { + if (vget_limits(real_domain, &limits) == -1) { strerr_warn3(FATAL, "unable to get domain limits for for ", real_domain, 0); failure1(argv, auth_method, service, imapargs, pop3args, authstr, 0); } @@ -684,6 +684,9 @@ main(int argc, char **argv) /* * $Log: authindi.c,v $ + * Revision 1.21 2024-05-28 19:13:20+05:30 Cprogrammer + * handle -1 return code for vget_limits() + * * Revision 1.20 2024-05-27 22:50:29+05:30 Cprogrammer * initialize struct vlimits * diff --git a/indimail-x/authpgsql.c b/indimail-x/authpgsql.c index 0bbdc10df..f5282f968 100644 --- a/indimail-x/authpgsql.c +++ b/indimail-x/authpgsql.c @@ -1,5 +1,8 @@ /* * $Log: authpgsql.c,v $ + * Revision 1.12 2024-05-28 19:14:12+05:30 Cprogrammer + * handle -1 return code for vget_limits() + * * Revision 1.11 2024-05-27 22:51:10+05:30 Cprogrammer * initialize struct vlimits * @@ -76,7 +79,7 @@ #include "runcmmd.h" #ifndef lint -static char sccsid[] = "$Id: authpgsql.c,v 1.11 2024-05-27 22:51:10+05:30 Cprogrammer Exp mbhangui $"; +static char sccsid[] = "$Id: authpgsql.c,v 1.12 2024-05-28 19:14:12+05:30 Cprogrammer Exp mbhangui $"; #endif #ifdef HAVE_PGSQL @@ -177,10 +180,10 @@ pg_getpw(char *user, char *domain) pwent.pw_shell = IShell.s; #ifdef ENABLE_DOMAIN_LIMITS if (env_get("DOMAIN_LIMITS") && !(pwent.pw_gid & V_OVERRIDE)) { - if (!vget_limits(domain, &limits)) - pwent.pw_gid |= vlimits_get_flag_mask(&limits); - else + if (vget_limits(domain, &limits) == -1) return ((struct passwd *) 0); + else + pwent.pw_gid |= vlimits_get_flag_mask(&limits); } #endif return (&pwent); @@ -335,7 +338,7 @@ main(int argc, char **argv) struct vlimits *lmt; #ifdef QUERY_CACHE if (!env_get("QUERY_CACHE")) { - if (vget_limits(domain.s, &limits)) { + if (vget_limits(domain.s, &limits) == -1) { strerr_warn2("authpgsql: unable to get domain limits for for ", domain.s, 0); subprintfe(subfdout, "authpgsql", "454-unable to get domain limits for %s (#4.3.0)\r\n", domain.s); flush("authpgsql"); @@ -345,7 +348,7 @@ main(int argc, char **argv) } else lmt = inquery(LIMIT_QUERY, login, 0); #else - if (vget_limits(domain.s, &limits)) { + if (vget_limits(domain.s, &limits) == -1) { strerr_warn2("authpgsql: unable to get domain limits for for ", domain.s, 0); subprintfe(subfdout, "authpgsql", "454-unable to get domain limits for %s (#4.3.0)\r\n", domain.s); flush("authpgsql"); diff --git a/indimail-x/doc/ChangeLog b/indimail-x/doc/ChangeLog index 9b74c2d21..00864a436 100644 --- a/indimail-x/doc/ChangeLog +++ b/indimail-x/doc/ChangeLog @@ -30,6 +30,21 @@ Release @version@-@release@ Start 02/05/2024 End XX/XX/XXXX 19. vlimit.c: fixed data types 20. inquerytest: change data type to long 21. vadduser.c: fix .domain_limits path +22. vmoddomain.c: added -H method to configure hash method for domain +23. authindi.c, authpgsql.c, iauth.c, vchkpass.c, sql_getpw.c, vadduser.c, + vmoduser.c: handle -1 return code for vget_limits() +24. indimail.h: re-arranged gid bit field masks +25. added print_limits() common function for inquerytest.c, vlimit.c +26. inquery.c, tcplookup.c, ProcessInFifo: Use INFIFODIR #define from inquery.h for infifo +27. inquery.h: define INFIFODIR for infifo +28. limits.c: fetch entry for domain when entry not found for user +29. vadduser.c, vmoduser.c, vsetuserquota.c: removed check for perms_defaultquota +30. vlimit.c: use print_limits() from print_limits.c to print domain limits + information +31. vlimit.c: handle both domain and user level records +32. VlimitInLookup.c: return domain level record of user level record not found +33. vlimits.h: added limit_type member to vlimits sructure +34. ProcessInFifo.c: use vget_limits when argument is domain instead of email * Mon Jan 01 2024 09:24:41 +0000 Manvendra Bhangui 3.4.6-1.1%{?dist} Release 3.4.6-1.1 Start 09/09/2023 End 01/01/2024 diff --git a/indimail-x/iauth.c b/indimail-x/iauth.c index afe2e4f75..88de5234c 100644 --- a/indimail-x/iauth.c +++ b/indimail-x/iauth.c @@ -1,5 +1,5 @@ /* - * $Id: iauth.c,v 1.11 2024-05-27 22:51:20+05:30 Cprogrammer Exp mbhangui $ + * $Id: iauth.c,v 1.12 2024-05-28 19:14:50+05:30 Cprogrammer Exp mbhangui $ * * authenticate.c - Generic PAM Authentication module for pam_multi * Copyright (C) <2008-2023> Manvendra Bhangui @@ -81,7 +81,7 @@ #include "common.h" #ifndef lint -static char sccsid[] = "$Id: iauth.c,v 1.11 2024-05-27 22:51:20+05:30 Cprogrammer Exp mbhangui $"; +static char sccsid[] = "$Id: iauth.c,v 1.12 2024-05-28 19:14:50+05:30 Cprogrammer Exp mbhangui $"; #endif static int defaultTask(char *, char *, struct passwd *, char *, int); @@ -246,7 +246,7 @@ i_acctmgmt(char *email, char *service, int *size, int *nitems, int debug) struct vlimits *lmt; #ifdef QUERY_CACHE if (!env_get("QUERY_CACHE")) { - if (vget_limits(real_domain, &limits)) { + if (vget_limits(real_domain, &limits) == -1) { strerr_warn2("iauth.so: i_acctmgmt: unable to get domain limits for for ", real_domain, 0); out("iauth.so", "454-unable to get domain limits for "); out("iauth.so", real_domain); @@ -258,7 +258,7 @@ i_acctmgmt(char *email, char *service, int *size, int *nitems, int debug) } else lmt = inquery(LIMIT_QUERY, email, 0); #else - if (vget_limits(real_domain, &limits)) { + if (vget_limits(real_domain, &limits) == -1) { strerr_warn2("iauth.so: i_acctmgmt: unable to get domain limits for for ", real_domain, 0); return ((char *) 0); } @@ -470,6 +470,9 @@ defaultTask(char *email, char *TheDomain, struct passwd *pw, char *service, int /* * $Log: iauth.c,v $ + * Revision 1.12 2024-05-28 19:14:50+05:30 Cprogrammer + * handle -1 return code for vget_limits() + * * Revision 1.11 2024-05-27 22:51:20+05:30 Cprogrammer * initialize struct vlimits * diff --git a/indimail-x/indimail.h b/indimail-x/indimail.h index 1d7ade158..385e47f14 100644 --- a/indimail-x/indimail.h +++ b/indimail-x/indimail.h @@ -1,5 +1,8 @@ /* * $Log: indimail.h,v $ + * Revision 1.12 2024-05-28 19:15:18+05:30 Cprogrammer + * changed value of V_OVERRIDE + * * Revision 1.11 2023-07-30 19:45:09+05:30 Cprogrammer * updated ip address field lengths * @@ -38,7 +41,7 @@ #define INDIMAILH_H #ifndef lint -static char sccsidh[] = "$Id: indimail.h,v 1.11 2023-07-30 19:45:09+05:30 Cprogrammer Exp mbhangui $"; +static char sccsidh[] = "$Id: indimail.h,v 1.12 2024-05-28 19:15:18+05:30 Cprogrammer Exp mbhangui $"; #endif #ifdef HAVE_CONFIG_H @@ -503,12 +506,12 @@ primary key(id)" #define NO_RELAY 0x20 #define NO_DIALUP 0x40 #define QA_ADMIN 0x80 -#define V_OVERRIDE 0x100 -#define NO_SMTP 0x200 -#define V_USER0 0x400 -#define V_USER1 0x800 -#define V_USER2 0x1000 -#define V_USER3 0x2000 +#define NO_SMTP 0x100 +#define V_USER0 0x200 +#define V_USER1 0x400 +#define V_USER2 0x800 +#define V_USER3 0x1000 +#define V_OVERRIDE 0x2000 /*- not subject to vlimits */ /* modes for indimail dirs, files and qmail files */ #define OVERQUOTA_MAILSIZE 1000 diff --git a/indimail-x/indimail.spec.in b/indimail-x/indimail.spec.in index 21a1dbff9..0f5d5191a 100644 --- a/indimail-x/indimail.spec.in +++ b/indimail-x/indimail.spec.in @@ -1,6 +1,6 @@ # # -# $Id: indimail.spec.in,v 1.146 2024-05-23 17:39:15+05:30 Cprogrammer Exp mbhangui $ +# $Id: indimail.spec.in,v 1.147 2024-05-28 19:16:01+05:30 Cprogrammer Exp mbhangui $ %undefine _missing_build_ids_terminate_build %global _unpackaged_files_terminate_build 1 @@ -762,6 +762,7 @@ done %attr(644,root,root) %{_prefix}/include/indimail/pipe_exec.h %attr(644,root,root) %{_prefix}/include/indimail/post_handle.h %attr(644,root,root) %{_prefix}/include/indimail/print_control.h +%attr(644,root,root) %{_prefix}/include/indimail/print_limits.h %attr(644,root,root) %{_prefix}/include/indimail/ProcessInFifo.h %attr(644,root,root) %{_prefix}/include/indimail/proxylogin.h %attr(644,root,root) %{_prefix}/include/indimail/purge_files.h diff --git a/indimail-x/inquery.c b/indimail-x/inquery.c index 2de13d691..a6033aeaf 100644 --- a/indimail-x/inquery.c +++ b/indimail-x/inquery.c @@ -1,41 +1,5 @@ /* - * $Log: inquery.c,v $ - * Revision 1.12 2024-05-10 11:43:51+05:30 mbhangui - * fix discarded-qualifier compiler warnings - * - * Revision 1.11 2023-06-08 17:46:57+05:30 Cprogrammer - * renamed fifo directory from FIFODIR to INFIFODIR - * - * Revision 1.10 2023-04-23 19:19:32+05:30 Cprogrammer - * write error messages for all errors - * - * Revision 1.9 2023-02-14 01:10:39+05:30 Cprogrammer - * use FIFOTMPDIR instead of TMPDIR for inquery fifo - * - * Revision 1.8 2022-08-04 14:39:07+05:30 Cprogrammer - * refactored code - * - * Revision 1.7 2022-07-31 10:06:35+05:30 Cprogrammer - * use TMPDIR for /tmp - * - * Revision 1.6 2021-09-12 11:52:36+05:30 Cprogrammer - * removed redundant multiple initialization of InFifo.len - * - * Revision 1.5 2021-02-07 19:55:54+05:30 Cprogrammer - * make request over TCP/IP (tcpclient) using fd 6 and 7. - * - * Revision 1.4 2020-10-18 07:49:06+05:30 Cprogrammer - * use alloc() instead of alloc_re() - * - * Revision 1.3 2020-04-01 18:55:52+05:30 Cprogrammer - * moved authentication functions to libqmail - * - * Revision 1.2 2019-04-22 23:12:30+05:30 Cprogrammer - * replaced realloc() with alloc() - * - * Revision 1.1 2019-04-17 19:00:32+05:30 Cprogrammer - * Initial revision - * + * $Id: inquery.c,v 1.13 2024-05-28 19:23:45+05:30 Cprogrammer Exp mbhangui $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -68,9 +32,10 @@ #include "common.h" #include "variables.h" #include "strToPw.h" +#include "inquery.h" #ifndef lint -static char sccsid[] = "$Id: inquery.c,v 1.12 2024-05-10 11:43:51+05:30 mbhangui Exp mbhangui $"; +static char sccsid[] = "$Id: inquery.c,v 1.13 2024-05-28 19:23:45+05:30 Cprogrammer Exp mbhangui $"; #endif #define FATAL "inquery: fatal: " @@ -208,7 +173,7 @@ inquery(char query_type, const char *email, const char *ip) return ((void *) 0); } } else { - getEnvConfigStr(&infifo_dir, "INFIFODIR", "/tmp/indimail/inlookup"); + getEnvConfigStr(&infifo_dir, "INFIFODIR", INFIFODIR); if (*infifo_dir == '/') { if (!stralloc_copys(&InFifo, infifo_dir) || !stralloc_catb(&InFifo, "/", 1) || @@ -474,3 +439,45 @@ inquery(char query_type, const char *email, const char *ip) } return ((void *) 0); } +/* + * $Log: inquery.c,v $ + * Revision 1.13 2024-05-28 19:23:45+05:30 Cprogrammer + * Use INFIFODIR #define from inquery.h for infifo + * + * Revision 1.12 2024-05-10 11:43:51+05:30 mbhangui + * fix discarded-qualifier compiler warnings + * + * Revision 1.11 2023-06-08 17:46:57+05:30 Cprogrammer + * renamed fifo directory from FIFODIR to INFIFODIR + * + * Revision 1.10 2023-04-23 19:19:32+05:30 Cprogrammer + * write error messages for all errors + * + * Revision 1.9 2023-02-14 01:10:39+05:30 Cprogrammer + * use FIFOTMPDIR instead of TMPDIR for inquery fifo + * + * Revision 1.8 2022-08-04 14:39:07+05:30 Cprogrammer + * refactored code + * + * Revision 1.7 2022-07-31 10:06:35+05:30 Cprogrammer + * use TMPDIR for /tmp + * + * Revision 1.6 2021-09-12 11:52:36+05:30 Cprogrammer + * removed redundant multiple initialization of InFifo.len + * + * Revision 1.5 2021-02-07 19:55:54+05:30 Cprogrammer + * make request over TCP/IP (tcpclient) using fd 6 and 7. + * + * Revision 1.4 2020-10-18 07:49:06+05:30 Cprogrammer + * use alloc() instead of alloc_re() + * + * Revision 1.3 2020-04-01 18:55:52+05:30 Cprogrammer + * moved authentication functions to libqmail + * + * Revision 1.2 2019-04-22 23:12:30+05:30 Cprogrammer + * replaced realloc() with alloc() + * + * Revision 1.1 2019-04-17 19:00:32+05:30 Cprogrammer + * Initial revision + * + */ diff --git a/indimail-x/inquery.h b/indimail-x/inquery.h index 219807c2d..5b549ddc7 100644 --- a/indimail-x/inquery.h +++ b/indimail-x/inquery.h @@ -1,5 +1,8 @@ /* * $Log: inquery.h,v $ + * Revision 1.3 2024-05-28 19:24:35+05:30 Cprogrammer + * define INFIFODIR for infifo + * * Revision 1.2 2024-05-10 11:43:51+05:30 mbhangui * fix discarded-qualifier compiler warnings * @@ -10,6 +13,8 @@ #ifndef INQUERY_H #define INQUERY_H +#define INFIFODIR "/run/indimail/inlookup" + void *inquery(char, const char *, const char *); #endif diff --git a/indimail-x/inquerytest.c b/indimail-x/inquerytest.c index 759570250..e5edc3867 100644 --- a/indimail-x/inquerytest.c +++ b/indimail-x/inquerytest.c @@ -1,38 +1,5 @@ /* - * $Log: inquerytest.c,v $ - * Revision 1.11 2024-05-27 22:51:37+05:30 Cprogrammer - * change data type to long - * - * Revision 1.10 2023-06-08 17:48:31+05:30 Cprogrammer - * renamed fifo directory from FIFODIR to INFIFODIR - * - * Revision 1.9 2023-01-22 10:40:03+05:30 Cprogrammer - * replaced qprintf with subprintf - * - * Revision 1.8 2021-09-12 11:53:22+05:30 Cprogrammer - * removed unused variable controldir - * - * Revision 1.7 2021-09-01 18:29:48+05:30 Cprogrammer - * mark functions not returning as __attribute__ ((noreturn)) - * - * Revision 1.6 2021-06-09 18:59:10+05:30 Cprogrammer - * test fifo for read to ensure inlookup process has opened fifo in write mode - * - * Revision 1.5 2021-06-09 17:03:49+05:30 Cprogrammer - * BUG: Fixed SIGSEGV - * - * Revision 1.4 2021-02-07 20:30:25+05:30 Cprogrammer - * minor code optimization - * - * Revision 1.3 2020-04-01 18:55:55+05:30 Cprogrammer - * moved authentication functions to libqmail - * - * Revision 1.2 2019-06-07 16:05:57+05:30 Cprogrammer - * use sgetopt library for getopt() - * - * Revision 1.1 2019-04-18 08:19:53+05:30 Cprogrammer - * Initial revision - * + * $id: $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -77,9 +44,10 @@ #include "FifoCreate.h" #include "ProcessInFifo.h" #include "vlimits.h" +#include "print_limits.h" #ifndef lint -static char sccsid[] = "$Id: inquerytest.c,v 1.11 2024-05-27 22:51:37+05:30 Cprogrammer Exp mbhangui $"; +static char sccsid[] = "$Id: inquerytest.c,v 1.12 2024-05-28 19:25:06+05:30 Cprogrammer Exp mbhangui $"; #endif #define FATAL "inquerytest: fatal: " @@ -106,72 +74,6 @@ die_nomem() _exit(111); } -void -print_limits(struct vlimits *limits) -{ - subprintfe(subfdout, "inquerytest", "Domain Expiry Date : %s", - limits->domain_expiry == -1 ? "Never Expires\n" : ctime(&limits->domain_expiry)); - subprintfe(subfdout, "inquerytest", "Password Expiry Date : %s\n", - limits->passwd_expiry == -1 ? "Never Expires\n" : ctime(&limits->passwd_expiry)); - subprintfe(subfdout, "inquerytest", "Max Domain Quota : %13lu\n", limits->diskquota); - subprintfe(subfdout, "inquerytest", "Max Domain Messages : %13lu\n", limits->maxmsgcount); - subprintfe(subfdout, "inquerytest", "Default User Quota : %13ld\n", limits->defaultquota); - subprintfe(subfdout, "inquerytest", "Default User Messages: %13lu\n", limits->defaultmaxmsgcount); - subprintfe(subfdout, "inquerytest", "Max Pop Accounts : %13ld\n", limits->maxpopaccounts); - subprintfe(subfdout, "inquerytest", "Max Aliases : %13ld\n", limits->maxaliases); - subprintfe(subfdout, "inquerytest", "Max Forwards : %13ld\n", limits->maxforwards); - subprintfe(subfdout, "inquerytest", "Max Autoresponders : %13ld\n", limits->maxautoresponders); - subprintfe(subfdout, "inquerytest", "Max Mailinglists : %13ld\n", limits->maxmailinglists); - out("inquerytest", "\n"); - subprintfe(subfdout, "inquerytest", "GID Flags:\n"); - subprintfe(subfdout, "inquerytest", " %s\n", limits->disable_imap ? "NO_IMAP" : "IMAP"); - subprintfe(subfdout, "inquerytest", " %s\n", limits->disable_smtp ? "NO_SMTP" : "SMTP"); - subprintfe(subfdout, "inquerytest", " %s\n", limits->disable_pop ? "NO_POP" : "POP3"); - subprintfe(subfdout, "inquerytest", " %s\n", limits->disable_webmail ? "NO_WEBMAIL" : "WEBMAIL"); - subprintfe(subfdout, "inquerytest", " %s\n", limits->disable_passwordchanging ? "NO_PASSWD_CHNG" : "PASSWD CHNG"); - subprintfe(subfdout, "inquerytest", " %s\n", limits->disable_relay ? "NO_RELAY" : "RELAY"); - subprintfe(subfdout, "inquerytest", " %s\n", limits->disable_dialup ? "NO_DIALUP" : "DIALUP"); - out("inquerytest", "\n"); - subprintfe(subfdout, "inquerytest", "Flags for non postmaster accounts:\n"); - subprintfe(subfdout, "inquerytest", " pop account : %12s %12s %12s\n", - limits->perm_account & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits->perm_account & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits->perm_account & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "inquerytest", " alias : %12s %12s %12s\n", - limits->perm_alias & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits->perm_alias & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits->perm_alias & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "inquerytest", " forward : %12s %12s %12s\n", - limits->perm_forward & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits->perm_forward & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits->perm_forward & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "inquerytest", " autoresponder : %12s %12s %12s\n", - limits->perm_autoresponder & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits->perm_autoresponder & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits->perm_autoresponder & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "inquerytest", " mailinglist : %12s %12s %12s\n", - limits->perm_maillist & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits->perm_maillist & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits->perm_maillist & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "inquerytest", " mailinglist users : %12s %12s %12s\n", - limits->perm_maillist_users & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits->perm_maillist_users & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits->perm_maillist_users & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "inquerytest", " mailinglist moderators: %12s %12s %12s\n", - limits->perm_maillist_moderators & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits->perm_maillist_moderators & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits->perm_maillist_moderators & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "inquerytest", " domain quota : %12s %12s %12s\n", - limits->perm_quota & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits->perm_quota & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits->perm_quota & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "inquerytest", " default quota : %12s %12s\n", - limits->perm_defaultquota & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits->perm_defaultquota & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY"); - flush("inquerytest"); - return; -} - #ifdef HAVE_QMAIL no_return #endif @@ -252,7 +154,7 @@ main(int argc, char **argv) die_nomem(); InFifo.len--; } else { - getEnvConfigStr(&infifo_dir, "INFIFODIR", "/tmp/indimail/inlookup"); + getEnvConfigStr(&infifo_dir, "INFIFODIR", INFIFODIR); if (*infifo_dir == '/') { if (indimailuid == -1 || indimailgid == -1) get_indimailuidgid(&indimailuid, &indimailgid); @@ -307,7 +209,7 @@ main(int argc, char **argv) die_nomem(); InFifo.len--; } else { - getEnvConfigStr(&infifo_dir, "INFIFODIR", "/tmp/indimail/inlookup"); + getEnvConfigStr(&infifo_dir, "INFIFODIR", INFIFODIR); if (*infifo_dir == '/') { if (!stralloc_copys(&InFifo, infifo_dir) || !stralloc_append(&InFifo, "/") || @@ -441,3 +343,43 @@ main(int argc, char **argv) wait(&status); return (0); } + +/* + * $Log: inquerytest.c,v $ + * Revision 1.12 2024-05-28 19:25:06+05:30 Cprogrammer + * use print_limit function from print_limit.c + * + * Revision 1.11 2024-05-27 22:51:37+05:30 Cprogrammer + * change data type to long + * + * Revision 1.10 2023-06-08 17:48:31+05:30 Cprogrammer + * renamed fifo directory from FIFODIR to INFIFODIR + * + * Revision 1.9 2023-01-22 10:40:03+05:30 Cprogrammer + * replaced qprintf with subprintf + * + * Revision 1.8 2021-09-12 11:53:22+05:30 Cprogrammer + * removed unused variable controldir + * + * Revision 1.7 2021-09-01 18:29:48+05:30 Cprogrammer + * mark functions not returning as __attribute__ ((noreturn)) + * + * Revision 1.6 2021-06-09 18:59:10+05:30 Cprogrammer + * test fifo for read to ensure inlookup process has opened fifo in write mode + * + * Revision 1.5 2021-06-09 17:03:49+05:30 Cprogrammer + * BUG: Fixed SIGSEGV + * + * Revision 1.4 2021-02-07 20:30:25+05:30 Cprogrammer + * minor code optimization + * + * Revision 1.3 2020-04-01 18:55:55+05:30 Cprogrammer + * moved authentication functions to libqmail + * + * Revision 1.2 2019-06-07 16:05:57+05:30 Cprogrammer + * use sgetopt library for getopt() + * + * Revision 1.1 2019-04-18 08:19:53+05:30 Cprogrammer + * Initial revision + * + */ diff --git a/indimail-x/limits.c b/indimail-x/limits.c index a2c073eba..e38a4c99a 100644 --- a/indimail-x/limits.c +++ b/indimail-x/limits.c @@ -1,5 +1,8 @@ /* * $Log: limits.c,v $ + * Revision 1.8 2024-05-28 19:27:57+05:30 Cprogrammer + * fetch entry for domain when entry not found for user + * * Revision 1.7 2024-05-28 00:20:32+05:30 Cprogrammer * fixed data types to fix stack smashing * @@ -28,7 +31,7 @@ #endif #ifndef lint -static char sccsid[] = "$Id: limits.c,v 1.7 2024-05-28 00:20:32+05:30 Cprogrammer Exp mbhangui $"; +static char sccsid[] = "$Id: limits.c,v 1.8 2024-05-28 19:27:57+05:30 Cprogrammer Exp mbhangui $"; #endif #ifdef ENABLE_DOMAIN_LIMITS @@ -53,6 +56,7 @@ static char sccsid[] = "$Id: limits.c,v 1.7 2024-05-28 00:20:32+05:30 Cprogr #include #include #include +#include #endif #include "indimail.h" #include "create_table.h" @@ -74,8 +78,7 @@ die_nomem(char *str) int vget_limits(const char *domain, struct vlimits *limits) { - int err; - int perm; + int err, perm, num_rows; MYSQL_ROW row; MYSQL_RES *res; @@ -106,7 +109,7 @@ vget_limits(const char *domain, struct vlimits *limits) strerr_warn2("vget_limits: mysql_store_results: ", (char *) in_mysql_error(&mysql[1]), 0); return (-1); } - if (!in_mysql_num_rows(res)) { + if (!(num_rows = in_mysql_num_rows(res))) { in_mysql_free_result(res); return (0); } @@ -179,7 +182,12 @@ vget_limits(const char *domain, struct vlimits *limits) scan_short(row[24], &(limits->perm_defaultquota)); } in_mysql_free_result(res); - return (0); + err = str_rchr(domain, '@'); + if (domain[err] && domain[err + 1]) + limits->limit_type = 2; + else + limits->limit_type = 1; + return (num_rows); } int diff --git a/indimail-x/print_limits.c b/indimail-x/print_limits.c new file mode 100644 index 000000000..25e0ec664 --- /dev/null +++ b/indimail-x/print_limits.c @@ -0,0 +1,117 @@ +/* + * $Id: $ + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifndef lint +static char rcsid[] = "$Id: $"; +#endif + +#ifdef HAVE_QMAIL +#include +#include +#endif +#include +#include "common.h" +#include "print_limits.h" + +void +print_limits(struct vlimits *lmt) +{ + if (lmt->limit_type == 1) { + subprintfe(subfdout, "vlimits", "Domain Expiry Date : %s", + lmt->domain_expiry == -1 ? "Never Expires\n" : ctime(&lmt->domain_expiry)); + subprintfe(subfdout, "vlimits", "Password Expiry Date : %s", + lmt->passwd_expiry == -1 ? "Never Expires\n" : ctime(&lmt->passwd_expiry)); + if (!lmt->diskquota) + subprintfe(subfdout, "vlimits", "Max Domain Quota : unlimited\n"); + else + subprintfe(subfdout, "vlimits", "Max Domain Quota : %13lu\n", lmt->diskquota); + if (!lmt->maxmsgcount) + subprintfe(subfdout, "vlimits", "Max Domain Messages : unlimited\n"); + else + subprintfe(subfdout, "vlimits", "Max Domain Messages : %13lu\n", lmt->maxmsgcount); + if (!lmt->defaultquota) + subprintfe(subfdout, "vlimits", "Default User Quota : unlimited\n"); + else + subprintfe(subfdout, "vlimits", "Default User Quota : %13lu\n", lmt->defaultquota); + if (!lmt->defaultmaxmsgcount) + subprintfe(subfdout, "vlimits", "Default User Messages: unlimited\n"); + else + subprintfe(subfdout, "vlimits", "Default User Messages: %13lu\n", lmt->defaultmaxmsgcount); + if (lmt->maxpopaccounts == -1) + subprintfe(subfdout, "vlimits", "Max Pop Accounts : unlimited\n"); + else + subprintfe(subfdout, "vlimits", "Max Pop Accounts : %13ld\n", lmt->maxpopaccounts); + if (lmt->maxaliases == -1) + subprintfe(subfdout, "vlimits", "Max Aliases : unlimited\n"); + else + subprintfe(subfdout, "vlimits", "Max Aliases : %13ld\n", lmt->maxaliases); + if (lmt->maxforwards == -1) + subprintfe(subfdout, "vlimits", "Max Forwards : unlimited\n"); + else + subprintfe(subfdout, "vlimits", "Max Forwards : %13ld\n", lmt->maxforwards); + if (lmt->maxautoresponders == -1) + subprintfe(subfdout, "vlimits", "Max Autoresponders : unlimited\n"); + else + subprintfe(subfdout, "vlimits", "Max Autoresponders : %13ld\n", lmt->maxautoresponders); + if (lmt->maxmailinglists == -1) + subprintfe(subfdout, "vlimits", "Max Mailinglists : unlimited\n"); + else + subprintfe(subfdout, "vlimits", "Max Mailinglists : %13ld\n", lmt->maxmailinglists); + out("vlimits", "\n"); + subprintfe(subfdout, "vlimits", "GID Flags:\n"); + subprintfe(subfdout, "vlimits", " %s\n", lmt->disable_dialup ? "NO_DIALUP" : "DIALUP"); + subprintfe(subfdout, "vlimits", " %s\n", lmt->disable_passwordchanging ? "NO_PASSWD_CHNG" : "PASSWD CHNG"); + subprintfe(subfdout, "vlimits", " %s\n", lmt->disable_smtp ? "NO_SMTP" : "SMTP"); + subprintfe(subfdout, "vlimits", " %s\n", lmt->disable_imap ? "NO_IMAP" : "IMAP"); + subprintfe(subfdout, "vlimits", " %s\n", lmt->disable_pop ? "NO_POP" : "POP3"); + subprintfe(subfdout, "vlimits", " %s\n", lmt->disable_webmail ? "NO_WEBMAIL" : "WEBMAIL"); + subprintfe(subfdout, "vlimits", " %s\n", lmt->disable_relay ? "NO_RELAY" : "RELAY"); + } else { + subprintfe(subfdout, "vlimits", "Flags for non postmaster accounts:\n"); + subprintfe(subfdout, "vlimits", " pop account : %12s %12s %12s\n", + lmt->perm_account & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", + lmt->perm_account & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", + lmt->perm_account & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); + subprintfe(subfdout, "vlimits", " alias : %12s %12s %12s\n", + lmt->perm_alias & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", + lmt->perm_alias & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", + lmt->perm_alias & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); + subprintfe(subfdout, "vlimits", " forward : %12s %12s %12s\n", + lmt->perm_forward & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", + lmt->perm_forward & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", + lmt->perm_forward & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); + subprintfe(subfdout, "vlimits", " autoresponder : %12s %12s %12s\n", + lmt->perm_autoresponder & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", + lmt->perm_autoresponder & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", + lmt->perm_autoresponder & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); + subprintfe(subfdout, "vlimits", " mailinglist : %12s %12s %12s\n", + lmt->perm_maillist & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", + lmt->perm_maillist & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", + lmt->perm_maillist & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); + subprintfe(subfdout, "vlimits", " mailinglist users : %12s %12s %12s\n", + lmt->perm_maillist_users & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", + lmt->perm_maillist_users & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", + lmt->perm_maillist_users & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); + subprintfe(subfdout, "vlimits", " mailinglist moderators: %12s %12s %12s\n", + lmt->perm_maillist_moderators & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", + lmt->perm_maillist_moderators & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", + lmt->perm_maillist_moderators & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); + subprintfe(subfdout, "vlimits", " domain quota : %12s %12s %12s\n", + lmt->perm_quota & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", + lmt->perm_quota & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", + lmt->perm_quota & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); + subprintfe(subfdout, "vlimits", " default quota : %12s %12s\n", + lmt->perm_defaultquota & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", + lmt->perm_defaultquota & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY"); + } + flush("vlimits"); + return; +} + +/* + * $Log: $ + */ diff --git a/indimail-x/print_limits.h b/indimail-x/print_limits.h new file mode 100644 index 000000000..f754c724a --- /dev/null +++ b/indimail-x/print_limits.h @@ -0,0 +1,7 @@ +#ifndef _PRINT_LIMITS_H +#define _PRINT_LIMITS_H +#include + +void print_limits(struct vlimits *); + +#endif diff --git a/indimail-x/sql_getpw.c b/indimail-x/sql_getpw.c index 0425f1348..90f475b4f 100644 --- a/indimail-x/sql_getpw.c +++ b/indimail-x/sql_getpw.c @@ -1,5 +1,5 @@ /* - * $Id: sql_getpw.c,v 1.6 2024-05-27 22:53:02+05:30 Cprogrammer Exp mbhangui $ + * $Id: sql_getpw.c,v 1.7 2024-05-28 19:29:33+05:30 Cprogrammer Exp mbhangui $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -27,7 +27,7 @@ #include "strToPw.h" #ifndef lint -static char sccsid[] = "$Id: sql_getpw.c,v 1.6 2024-05-27 22:53:02+05:30 Cprogrammer Exp mbhangui $"; +static char sccsid[] = "$Id: sql_getpw.c,v 1.7 2024-05-28 19:29:33+05:30 Cprogrammer Exp mbhangui $"; #endif #ifdef QUERY_CACHE @@ -199,10 +199,10 @@ sql_getpw(const char *user, const char *domain) pwent.pw_shell = IShell.s; #ifdef ENABLE_DOMAIN_LIMITS if (env_get("DOMAIN_LIMITS") && !(pwent.pw_gid & V_OVERRIDE)) { - if (!vget_limits(_domain.s, &limits)) - pwent.pw_gid |= vlimits_get_flag_mask(&limits); - else + if (vget_limits(_domain.s, &limits) == -1) return ((struct passwd *) 0); + else + pwent.pw_gid |= vlimits_get_flag_mask(&limits); } #endif return (&pwent); @@ -222,6 +222,9 @@ sql_getpw_cache(char cache_switch) /* * $Log: sql_getpw.c,v $ + * Revision 1.7 2024-05-28 19:29:33+05:30 Cprogrammer + * handle -1 return code for vget_limits() + * * Revision 1.6 2024-05-27 22:53:02+05:30 Cprogrammer * initialize struct vlimits * diff --git a/indimail-x/tcplookup.c b/indimail-x/tcplookup.c index ba81a6612..5544f67c6 100644 --- a/indimail-x/tcplookup.c +++ b/indimail-x/tcplookup.c @@ -1,5 +1,8 @@ /* * $Log: tcplookup.c,v $ + * Revision 1.7 2024-05-28 19:30:02+05:30 Cprogrammer + * Use INFIFODIR #define from inquery.h for infifo + * * Revision 1.6 2023-06-08 17:49:14+05:30 Cprogrammer * renamed fifo directory from FIFODIR to INFIFODIR * @@ -56,9 +59,10 @@ #include "FifoCreate.h" #include "common.h" #include "variables.h" +#include "inquery.h" #ifndef lint -static char sccsid[] = "$Id: tcplookup.c,v 1.6 2023-06-08 17:49:14+05:30 Cprogrammer Exp mbhangui $"; +static char sccsid[] = "$Id: tcplookup.c,v 1.7 2024-05-28 19:30:02+05:30 Cprogrammer Exp mbhangui $"; #endif char strnum[FMT_ULONG]; @@ -179,7 +183,7 @@ prepare_wfifo(int *wfd, int *fifo_len, int *pipe_size, int bytes) if (!stralloc_copys(&InFifo, infifo) || !stralloc_0(&InFifo)) die_nomem(); } else { - getEnvConfigStr(&infifo_dir, "INFIFODIR", "/tmp/indimail/inlookup"); + getEnvConfigStr(&infifo_dir, "INFIFODIR", INFIFODIR); if (*infifo_dir == '/') { if (!stralloc_copys(&InFifo, infifo_dir) || !stralloc_catb(&InFifo, "/", 1) || diff --git a/indimail-x/vadduser.c b/indimail-x/vadduser.c index 97d2628ed..f5afaf67e 100644 --- a/indimail-x/vadduser.c +++ b/indimail-x/vadduser.c @@ -1,5 +1,5 @@ /* - * $Id: vadduser.c,v 1.16 2024-05-27 22:53:14+05:30 Cprogrammer Exp mbhangui $ + * $Id: vadduser.c,v 1.17 2024-05-28 19:30:32+05:30 Cprogrammer Exp mbhangui $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -64,7 +64,7 @@ #include "common.h" #ifndef lint -static char rcsid[] = "$Id: vadduser.c,v 1.16 2024-05-27 22:53:14+05:30 Cprogrammer Exp mbhangui $"; +static char rcsid[] = "$Id: vadduser.c,v 1.17 2024-05-28 19:30:32+05:30 Cprogrammer Exp mbhangui $"; #endif #define FATAL "vadduser: fatal: " @@ -183,14 +183,10 @@ main(int argc, char **argv) !stralloc_0(&tmpbuf)) die_nomem(); domain_limits = !access(tmpbuf.s, F_OK); - if (domain_limits && vget_limits(real_domain, &limits)) { + if (domain_limits && vget_limits(real_domain, &limits) == -1) { strerr_warn2("vadduser: Unable to get domain limits for ", real_domain, 0); return (1); } - if (Quota.len && (limits.perm_defaultquota & VLIMIT_DISABLE_CREATE)) { - strerr_warn2("vadduser: -q option not allowed for ", real_domain, 0); - return (1); - } #endif /*- if the comment field is blank use the user name */ if (Gecos.len == 0) { @@ -588,6 +584,10 @@ get_options(int argc, char **argv, char **base_path, int *users_per_level, /* * $Log: vadduser.c,v $ + * Revision 1.17 2024-05-28 19:30:32+05:30 Cprogrammer + * removed check for perms_defaultquota + * handle -1 return code for vget_limits() + * * Revision 1.16 2024-05-27 22:53:14+05:30 Cprogrammer * initialize struct vlimits * fix .domain_limits path diff --git a/indimail-x/vchkpass.c b/indimail-x/vchkpass.c index 9e1ba760a..74d6822b0 100644 --- a/indimail-x/vchkpass.c +++ b/indimail-x/vchkpass.c @@ -1,5 +1,5 @@ /* - * $Id: vchkpass.c,v 1.21 2024-05-27 22:53:42+05:30 Cprogrammer Exp mbhangui $ + * $Id: vchkpass.c,v 1.22 2024-05-28 19:31:53+05:30 Cprogrammer Exp mbhangui $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -44,7 +44,7 @@ #include "runcmmd.h" #ifndef lint -static char sccsid[] = "$Id: vchkpass.c,v 1.21 2024-05-27 22:53:42+05:30 Cprogrammer Exp mbhangui $"; +static char sccsid[] = "$Id: vchkpass.c,v 1.22 2024-05-28 19:31:53+05:30 Cprogrammer Exp mbhangui $"; #endif #ifdef AUTH_SIZE @@ -361,7 +361,7 @@ main(int argc, char **argv) struct vlimits *lmt; #ifdef QUERY_CACHE if (!env_get("QUERY_CACHE")) { - if (vget_limits(domain.s, &limits)) { + if (vget_limits(domain.s, &limits) == -1) { strerr_warn2("vchkpass: unable to get domain limits for for ", domain.s, 0); subprintfe(subfdout, "vchkpass", "454-unable to get domain limits for %s (#4.3.0)\r\n", domain.s); flush("vchkpass"); @@ -371,7 +371,7 @@ main(int argc, char **argv) } else lmt = inquery(LIMIT_QUERY, login, 0); #else - if (vget_limits(domain.s, &limits)) { + if (vget_limits(domain.s, &limits) == -1) { strerr_warn2("vchkpass: unable to get domain limits for for ", domain.s, 0); subprintfe(subfdout, "vchkpass", "454-unable to get domain limits for %s (#4.3.0)\r\n", domain.s); flush("vchkpass"); @@ -428,6 +428,9 @@ main(int argc, char **argv) /* * $Log: vchkpass.c,v $ + * Revision 1.22 2024-05-28 19:31:53+05:30 Cprogrammer + * handle -1 return code for vget_limits() + * * Revision 1.21 2024-05-27 22:53:42+05:30 Cprogrammer * initialize struct vlimits * diff --git a/indimail-x/vlimit.1 b/indimail-x/vlimit.1 index 6804a578d..f9bb1d36d 100644 --- a/indimail-x/vlimit.1 +++ b/indimail-x/vlimit.1 @@ -4,11 +4,10 @@ vlimit \- Set / Modify Domain wide Limits .SH SYNOPSYS -.B vlimit -[ -.I options -] -.I domain +\fBvlimit\fR [ \fIoptions\fR ] \fIdomain\fR + + +\fBvlimit\fR [ \fIoptions\fR ] \fIuser@domain\fR .SH OPTIONS .PP diff --git a/indimail-x/vlimit.c b/indimail-x/vlimit.c index 80884ac65..4319c4ffd 100644 --- a/indimail-x/vlimit.c +++ b/indimail-x/vlimit.c @@ -1,12 +1,12 @@ /* - * $Id: vlimit.c,v 1.8 2024-05-28 00:21:32+05:30 Cprogrammer Exp mbhangui $ + * $Id: vlimit.c,v 1.9 2024-05-28 19:34:10+05:30 Cprogrammer Exp mbhangui $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #ifndef lint -static char sccsid[] = "$Id: vlimit.c,v 1.8 2024-05-28 00:21:32+05:30 Cprogrammer Exp mbhangui $"; +static char sccsid[] = "$Id: vlimit.c,v 1.9 2024-05-28 19:34:10+05:30 Cprogrammer Exp mbhangui $"; #endif #ifdef ENABLE_DOMAIN_LIMITS @@ -43,6 +43,7 @@ static char sccsid[] = "$Id: vlimit.c,v 1.8 2024-05-28 00:21:32+05:30 Cprogr #include "common.h" #include "parse_quota.h" #include "check_group.h" +#include "print_limits.h" #define FATAL "vlimits: fatal: " #define WARN "vlimits: warning: " @@ -94,7 +95,7 @@ static char *usage = static int toggle; int -get_options(int argc, char **argv, char **Domain, char **DomainQuota, char **DefaultUserQuota, +get_options(int argc, char **argv, char **User, char **DomainQuota, char **DefaultUserQuota, char **DomainMaxMsgCount, char **DefaultUserMaxMsgCount, char **MaxPopAccounts, char **MaxAliases, char **MaxForwards, char **MaxAutoresponders, char **MaxMailinglists, char **GidFlagString, char **PermAccountFlagString, char **PermAliasFlagString, @@ -112,7 +113,7 @@ get_options(int argc, char **argv, char **Domain, char **DomainQuota, char **Def char flag[4]; struct tm tm = {0}; - *Domain = *DomainQuota = *DefaultUserQuota = *DomainMaxMsgCount = + *User = *DomainQuota = *DefaultUserQuota = *DomainMaxMsgCount = *DefaultUserMaxMsgCount = *MaxPopAccounts = *MaxAliases = *MaxForwards = *MaxAutoresponders = *MaxMailinglists = *GidFlagString = 0; @@ -141,7 +142,6 @@ get_options(int argc, char **argv, char **Domain, char **DomainQuota, char **Def *ShowLimits = 1; break; case 'e': /*- domain expiry */ - *ShowLimits = 0; flag[0] = 1; if (str_diffn(optarg, "-1", 3)) { if (str_len(optarg) != 14 || !strptime(optarg, "%d%m%Y%H%M%S", &tm)) { @@ -158,14 +158,12 @@ get_options(int argc, char **argv, char **Domain, char **DomainQuota, char **Def *domain_expiry = -1; /* Disable check on expiry date*/ break; case 'n': /*- domain expiry */ - *ShowLimits = 0; flag[1] = 1; scan_long(optarg, domain_expiry); *domain_expiry *= 86400; *domain_expiry += time(0); break; case 't': /*- password expiry */ - *ShowLimits = 0; flag[2] = 1; if (str_diffn(optarg, "-1", 3)) { if (str_len(optarg) != 14 || !strptime(optarg, "%d%m%Y%H%M%S", &tm)) { @@ -182,54 +180,42 @@ get_options(int argc, char **argv, char **Domain, char **DomainQuota, char **Def *passwd_expiry = -1; /* Disable check on expiry date*/ break; case 'N': /*- password expiry */ - *ShowLimits = 0; flag[3] = 1; scan_long(optarg, passwd_expiry); *passwd_expiry *= 86400; *passwd_expiry += time(0); break; case 'D': - *ShowLimits = 0; *DeleteLimits = 1; break; case 'Q': - *ShowLimits = 0; *DomainQuota = optarg; break; case 'q': - *ShowLimits = 0; *DefaultUserQuota = optarg; break; case 'M': - *ShowLimits = 0; *DomainMaxMsgCount = optarg; break; case 'm': - *ShowLimits = 0; *DefaultUserMaxMsgCount = optarg; break; case 'P': - *ShowLimits = 0; *MaxPopAccounts = optarg; break; case 'A': - *ShowLimits = 0; *MaxAliases = optarg; break; case 'F': - *ShowLimits = 0; *MaxForwards = optarg; break; case 'R': - *ShowLimits = 0; *MaxAutoresponders = optarg; break; case 'L': - *ShowLimits = 0; *MaxMailinglists = optarg; break; case 'g': - *ShowLimits = 0; *GidFlagString = optarg; *GidFlag = 1; break; @@ -237,56 +223,45 @@ get_options(int argc, char **argv, char **Domain, char **DomainQuota, char **Def toggle = 1; break; case 'p': - *ShowLimits = 0; *PermAccountFlagString = optarg; *PermAccountFlag = 1; break; case 'a': - *ShowLimits = 0; *PermAliasFlagString = optarg; *PermAliasFlag = 1; break; case 'f': - *ShowLimits = 0; *PermForwardFlagString = optarg; *PermForwardFlag = 1; break; case 'r': - *ShowLimits = 0; *PermAutoresponderFlagString = optarg; *PermAutoresponderFlag = 1; break; case 'l': - *ShowLimits = 0; *PermMaillistFlagString = optarg; *PermMaillistFlag = 1; break; case 'u': - *ShowLimits = 0; *PermMaillistUsersFlagString = optarg; *PermMaillistUsersFlag = 1; break; case 'o': - *ShowLimits = 0; *PermMaillistModeratorsFlagString = optarg; *PermMaillistModeratorsFlag = 1; break; case 'x': - *ShowLimits = 0; *PermQuotaFlagString = optarg; *PermQuotaFlag = 1; break; case 'z': - *ShowLimits = 0; *PermDefaultQuotaFlagString = optarg; *PermDefaultQuotaFlag = 1; break; case 'h': - *ShowLimits = 0; strerr_warn2(WARN, usage, 0); return (1); default: - *ShowLimits = 0; break; } } @@ -301,8 +276,8 @@ get_options(int argc, char **argv, char **Domain, char **DomainQuota, char **Def return(1); } if (optind < argc) - *Domain = argv[optind++]; - if (!*Domain) { + *User = argv[optind++]; + if (!*User) { strerr_warn2(WARN, usage, 0); return (1); } @@ -313,26 +288,26 @@ int main(int argc, char *argv[]) { struct vlimits limits = { 0 }; - char *Domain, *DomainQuota, *DefaultUserQuota, *DomainMaxMsgCount, + char *domain, *DomainQuota, *DefaultUserQuota, *DomainMaxMsgCount, *DefaultUserMaxMsgCount, *MaxPopAccounts, *MaxAliases, *MaxForwards, *MaxAutoresponders, *MaxMailinglists, *GidFlagString, *PermAccountFlagString, *PermAliasFlagString, *PermForwardFlagString, *PermAutoresponderFlagString, *PermMaillistFlagString, *PermMaillistUsersFlagString, *PermMaillistModeratorsFlagString, *PermQuotaFlagString, - *PermDefaultQuotaFlagString; + *PermDefaultQuotaFlagString, *User; char strnum1[FMT_ULONG], strnum2[FMT_ULONG]; int QuotaFlag, GidFlag, PermAccountFlag, PermAliasFlag, PermForwardFlag, PermAutoresponderFlag, PermMaillistFlag, PermMaillistUsersFlag, PermMaillistModeratorsFlag, PermQuotaFlag, PermDefaultQuotaFlag, ShowLimits, - DeleteLimits, i; + DeleteLimits, i, limit_type; uid_t Uid, myuid; gid_t Gid, mygid; long domain_expiry = 0, passwd_expiry = 0; - if (get_options(argc, argv, &Domain, &DomainQuota, &DefaultUserQuota, &DomainMaxMsgCount, + if (get_options(argc, argv, &User, &DomainQuota, &DefaultUserQuota, &DomainMaxMsgCount, &DefaultUserMaxMsgCount, &MaxPopAccounts, &MaxAliases, &MaxForwards, &MaxAutoresponders, &MaxMailinglists, &GidFlagString, &PermAccountFlagString, &PermAliasFlagString, &PermForwardFlagString, &PermAutoresponderFlagString, @@ -345,136 +320,132 @@ main(int argc, char *argv[]) return (1); myuid = getuid(); mygid = getgid(); - if (!get_assign(Domain, 0, &Uid, &Gid)) { - strerr_warn2(Domain, ": No such domain", 0); - return (1); + i = str_rchr(User, '@'); + if (User[i]) { + if (!User[i + 1]) + strerr_die2x(100, WARN, "domain cannot be NULL"); + domain = User + i + 1; + limit_type = 2; + } else { + domain = User; + limit_type = 1; } + if (!get_assign(domain, 0, &Uid, &Gid)) + strerr_die3x(100, WARN, domain, ": No such domain"); if (!Uid) - strerr_die4x(100, FATAL, "domain ", Domain, " with uid 0"); + strerr_die4x(100, FATAL, "domain ", domain, " with uid 0"); if (myuid != Uid && mygid != Gid && myuid != 0 && check_group(Gid, FATAL) != 1) { strnum1[fmt_ulong(strnum1, Uid)] = 0; strnum2[fmt_ulong(strnum2, Gid)] = 0; - strerr_warn6(WARN, "you must be root or domain user (uid=", strnum1, "/gid=", strnum2, ") to run this program", 0); - return(1); - } - if (vget_limits(Domain, &limits)) { - strerr_warn2(FATAL, "Failed to get limits: ", 0); - return (-1); + strerr_die6x(100, WARN, "you must be root or domain user (uid=", strnum1, "/gid=", strnum2, ") to run this program"); } + if ((i = vget_limits(User, &limits)) == -1) + strerr_die2x(111, FATAL, "Failed to get limits: "); if (DeleteLimits) { - if (vdel_limits(Domain) == 0) { + if (vdel_limits(User) == 0) { out("vlimits", "Limits deleted\n"); flush("vlimits"); return (0); - } else { - strerr_warn2(FATAL, "failed to delete limits", 0); - return (-1); - } - } - if (domain_expiry) - limits.domain_expiry = domain_expiry; - if (passwd_expiry) - limits.passwd_expiry = passwd_expiry; - if (MaxPopAccounts) - scan_long(MaxPopAccounts, &limits.maxpopaccounts); - if (MaxAliases) - scan_long(MaxAliases, &limits.maxaliases); - if (MaxForwards) - scan_long(MaxForwards, &limits.maxforwards); - if (MaxAutoresponders) - scan_long(MaxAutoresponders, &limits.maxautoresponders); - if (MaxMailinglists) - scan_long(MaxMailinglists, &limits.maxmailinglists); - /*- quota & message count limits */ - if (DomainQuota && (limits.diskquota = parse_quota(DomainQuota, 0)) == -1) { - strerr_warn2(FATAL, "diskquota: ", &strerr_sys); - return (-1); - } - if (DomainMaxMsgCount && - (limits.maxmsgcount = strtoll(DomainMaxMsgCount, 0, 0)) == -1) - { - strerr_warn2(FATAL, "maxmsgcount: ", &strerr_sys); - return (-1); + } else + strerr_die2x(111, FATAL, "failed to delete limits"); + } else + if (ShowLimits) { + print_limits(&limits); + return 0; } + if (limit_type == 1) { + if (domain_expiry) + limits.domain_expiry = domain_expiry; + if (passwd_expiry) + limits.passwd_expiry = passwd_expiry; + if (MaxPopAccounts) + scan_long(MaxPopAccounts, &limits.maxpopaccounts); + if (MaxAliases) + scan_long(MaxAliases, &limits.maxaliases); + if (MaxForwards) + scan_long(MaxForwards, &limits.maxforwards); + if (MaxAutoresponders) + scan_long(MaxAutoresponders, &limits.maxautoresponders); + if (MaxMailinglists) + scan_long(MaxMailinglists, &limits.maxmailinglists); + /*- quota & message count limits */ + if (DomainQuota && (limits.diskquota = parse_quota(DomainQuota, 0)) == -1) + strerr_die2sys(111, WARN, "diskquota: "); + if (DomainMaxMsgCount && + (limits.maxmsgcount = strtoll(DomainMaxMsgCount, 0, 0)) == -1) + strerr_die2sys(111, WARN, "maxmsgcount: "); #if defined(LLONG_MIN) && defined(LLONG_MAX) - if (limits.maxmsgcount == LLONG_MIN || limits.maxmsgcount == LLONG_MAX) + if (limits.maxmsgcount == LLONG_MIN || limits.maxmsgcount == LLONG_MAX) #else - if (errno == ERANGE) + if (errno == ERANGE) #endif - { - strerr_warn2(FATAL, "maxmsgcount: ", &strerr_sys); - return (-1); - } + strerr_die2sys(100, FATAL, "maxmsgcount: "); - if (DefaultUserQuota) { - if (!str_diffn(DefaultUserQuota, "NOQUOTA", 8)) - limits.defaultquota = -1; - else - if ((limits.defaultquota = parse_quota(DefaultUserQuota, 0)) == -1) { - strerr_warn2(FATAL, "defaultquota: ", &strerr_sys); - return (-1); + if (DefaultUserQuota) { + if (!str_diffn(DefaultUserQuota, "NOQUOTA", 8)) + limits.defaultquota = -1; + else + if ((limits.defaultquota = parse_quota(DefaultUserQuota, 0)) == -1) + strerr_die2sys(111, WARN, "defaultquota: "); } - } - if (DefaultUserMaxMsgCount && - (limits.defaultmaxmsgcount = strtoll(DefaultUserMaxMsgCount, 0, 0)) == -1) - { - strerr_warn2(FATAL, "defaultmaxmsgcount: ", &strerr_sys); - return (-1); - } + if (DefaultUserMaxMsgCount && + (limits.defaultmaxmsgcount = strtoll(DefaultUserMaxMsgCount, 0, 0)) == -1) + strerr_die2sys(100, FATAL, "defaultmaxmsgcount: "); #if defined(LLONG_MIN) && defined(LLONG_MAX) - if (limits.defaultmaxmsgcount == LLONG_MIN || limits.defaultmaxmsgcount == LLONG_MAX) + if (limits.defaultmaxmsgcount == LLONG_MIN || limits.defaultmaxmsgcount == LLONG_MAX) #else - if (errno == ERANGE) + if (errno == ERANGE) #endif - { - strerr_warn2(FATAL, "defaultmaxmsgcount: ", &strerr_sys); - return (-1); - } - if (GidFlag == 1) { - GidFlag = 0; - limits.disable_dialup = 0; - limits.disable_passwordchanging = 0; - limits.disable_pop = 0; - limits.disable_smtp = 0; - limits.disable_webmail = 0; - limits.disable_imap = 0; - limits.disable_relay = 0; - for (i = 0; i < str_len(GidFlagString); i++) { - switch (GidFlagString[i]) - { - case 'u': - limits.disable_dialup = toggle ? 0 : 1; - break; - case 'd': - limits.disable_passwordchanging = toggle ? 0 : 1; - break; - case 'p': - limits.disable_pop = toggle ? 0 : 1; - break; - case 's': - limits.disable_smtp = toggle ? 0 : 1; - break; - case 'w': - limits.disable_webmail = toggle ? 0 : 1; - break; - case 'i': - limits.disable_imap = toggle ? 0 : 1; - break; - case 'r': - limits.disable_relay = toggle ? 0 : 1; - break; - case 'x': - limits.disable_dialup = 0; - limits.disable_passwordchanging = 0; - limits.disable_pop = 0; - limits.disable_smtp = 0; - limits.disable_webmail = 0; - limits.disable_imap = 0; - limits.disable_relay = 0; - break; + strerr_die2sys(100, FATAL, "defaultmaxmsgcount: "); + if (GidFlag == 1) { + GidFlag = 0; + limits.disable_dialup = 0; + limits.disable_passwordchanging = 0; + limits.disable_pop = 0; + limits.disable_smtp = 0; + limits.disable_webmail = 0; + limits.disable_imap = 0; + limits.disable_relay = 0; + for (i = 0; i < str_len(GidFlagString); i++) { + switch (GidFlagString[i]) + { + case 'u': + limits.disable_dialup = toggle ? 0 : 1; + break; + case 'd': + limits.disable_passwordchanging = toggle ? 0 : 1; + break; + case 'p': + limits.disable_pop = toggle ? 0 : 1; + break; + case 's': + limits.disable_smtp = toggle ? 0 : 1; + break; + case 'w': + limits.disable_webmail = toggle ? 0 : 1; + break; + case 'i': + limits.disable_imap = toggle ? 0 : 1; + break; + case 'r': + limits.disable_relay = toggle ? 0 : 1; + break; + case 'x': + limits.disable_dialup = 0; + limits.disable_passwordchanging = 0; + limits.disable_pop = 0; + limits.disable_smtp = 0; + limits.disable_webmail = 0; + limits.disable_imap = 0; + limits.disable_relay = 0; + break; + } } } - } + if (vset_limits(User, &limits) != 0) + strerr_die2x(1, FATAL, "vset_limits: Failed to set limits"); + return 0; + } /* if (limit_type == 1) */ if (PermAccountFlag == 1) { limits.perm_account = 0; for (i = 0; i < str_len(PermAccountFlagString); i++) { @@ -652,76 +623,8 @@ main(int argc, char *argv[]) } } } - if (!ShowLimits && vset_limits(Domain, &limits) != 0) { - strerr_warn1("vset_limits: Failed to set limits", 0); - return (-1); - } - if (ShowLimits) { - subprintfe(subfdout, "vlimits", "Domain Expiry Date : %s", - limits.domain_expiry == -1 ? "Never Expires\n" : ctime(&limits.domain_expiry)); - subprintfe(subfdout, "vlimits", "Password Expiry Date : %s", - limits.passwd_expiry == -1 ? "Never Expires\n" : ctime(&limits.passwd_expiry)); - subprintfe(subfdout, "vlimits", "Max Domain Quota : %13lu\n", (unsigned long) limits.diskquota); - subprintfe(subfdout, "vlimits", "Max Domain Messages : %13lu\n", (unsigned long) limits.maxmsgcount); - if (limits.defaultquota == -1) - subprintfe(subfdout, "vlimits", "Default User Quota : unlimited\n"); - else - subprintfe(subfdout, "vlimits", "Default User Quota : %13lu\n", (unsigned long) limits.defaultquota); - subprintfe(subfdout, "vlimits", "Default User Messages: %13lu\n", (unsigned long) limits.defaultmaxmsgcount); - subprintfe(subfdout, "vlimits", "Max Pop Accounts : %13ld\n", limits.maxpopaccounts); - subprintfe(subfdout, "vlimits", "Max Aliases : %13ld\n", limits.maxaliases); - subprintfe(subfdout, "vlimits", "Max Forwards : %13ld\n", limits.maxforwards); - subprintfe(subfdout, "vlimits", "Max Autoresponders : %13ld\n", limits.maxautoresponders); - subprintfe(subfdout, "vlimits", "Max Mailinglists : %13ld\n", limits.maxmailinglists); - out("vlimits", "\n"); - subprintfe(subfdout, "vlimits", "GID Flags:\n"); - subprintfe(subfdout, "vlimits", " %s\n", limits.disable_dialup ? "NO_DIALUP" : "DIALUP"); - subprintfe(subfdout, "vlimits", " %s\n", limits.disable_passwordchanging ? "NO_PASSWD_CHNG" : "PASSWD CHNG"); - subprintfe(subfdout, "vlimits", " %s\n", limits.disable_smtp ? "NO_SMTP" : "SMTP"); - subprintfe(subfdout, "vlimits", " %s\n", limits.disable_imap ? "NO_IMAP" : "IMAP"); - subprintfe(subfdout, "vlimits", " %s\n", limits.disable_pop ? "NO_POP" : "POP3"); - subprintfe(subfdout, "vlimits", " %s\n", limits.disable_webmail ? "NO_WEBMAIL" : "WEBMAIL"); - subprintfe(subfdout, "vlimits", " %s\n", limits.disable_relay ? "NO_RELAY" : "RELAY"); - out("vlimits", "\n"); - subprintfe(subfdout, "vlimits", "Flags for non postmaster accounts:\n"); - subprintfe(subfdout, "vlimits", " pop account : %12s %12s %12s\n", - limits.perm_account & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits.perm_account & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits.perm_account & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "vlimits", " alias : %12s %12s %12s\n", - limits.perm_alias & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits.perm_alias & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits.perm_alias & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "vlimits", " forward : %12s %12s %12s\n", - limits.perm_forward & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits.perm_forward & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits.perm_forward & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "vlimits", " autoresponder : %12s %12s %12s\n", - limits.perm_autoresponder & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits.perm_autoresponder & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits.perm_autoresponder & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "vlimits", " mailinglist : %12s %12s %12s\n", - limits.perm_maillist & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits.perm_maillist & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits.perm_maillist & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "vlimits", " mailinglist users : %12s %12s %12s\n", - limits.perm_maillist_users & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits.perm_maillist_users & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits.perm_maillist_users & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "vlimits", " mailinglist moderators: %12s %12s %12s\n", - limits.perm_maillist_moderators & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits.perm_maillist_moderators & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits.perm_maillist_moderators & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "vlimits", " domain quota : %12s %12s %12s\n", - limits.perm_quota & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits.perm_quota & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY", - limits.perm_quota & VLIMIT_DISABLE_DELETE ? "DENY_DELETE" : "ALLOW_DELETE"); - subprintfe(subfdout, "vlimits", " default quota : %12s %12s\n", - limits.perm_defaultquota & VLIMIT_DISABLE_CREATE ? "DENY_CREATE" : "ALLOW_CREATE", - limits.perm_defaultquota & VLIMIT_DISABLE_MODIFY ? "DENY_MODIFY" : "ALLOW_MODIFY"); - flush("vlimits"); - return (0); - } + if (vset_limits(User, &limits) != 0) + strerr_die2x(1, FATAL, "vset_limits: Failed to set limits"); return (0); } #else @@ -735,6 +638,10 @@ main() #endif /* * $Log: vlimit.c,v $ + * Revision 1.9 2024-05-28 19:34:10+05:30 Cprogrammer + * handle both domain and user level records + * use print_limits() from print_limits.c to print domain limits information + * * Revision 1.8 2024-05-28 00:21:32+05:30 Cprogrammer * fixed data types * added -T option to toggle gid flags diff --git a/indimail-x/vlimits.h b/indimail-x/vlimits.h index 804699869..fa64debb4 100644 --- a/indimail-x/vlimits.h +++ b/indimail-x/vlimits.h @@ -1,5 +1,8 @@ /* * $Log: vlimits.h,v $ + * Revision 1.5 2024-05-28 19:35:50+05:30 Cprogrammer + * added limit_type member to vlimits sructure + * * Revision 1.4 2024-05-27 08:05:16+05:30 Cprogrammer * changed data type of variables to long * @@ -42,7 +45,7 @@ struct vlimits { /* quota & message count limits */ umdir_t diskquota; /*- domain quota */ umdir_t maxmsgcount; /*- domain quota total message count */ - mdir_t defaultquota; /*- user quota total message size */ + umdir_t defaultquota; /*- user quota total message size */ umdir_t defaultmaxmsgcount; /* -user quota total message count */ /* the following are 0 (false) or 1 (true) */ @@ -64,6 +67,7 @@ struct vlimits { short perm_maillist_moderators; short perm_quota; short perm_defaultquota; + short limit_type; }; int vget_limits(const char *, struct vlimits *); diff --git a/indimail-x/vmoddomain.1 b/indimail-x/vmoddomain.9 similarity index 79% rename from indimail-x/vmoddomain.1 rename to indimail-x/vmoddomain.9 index 4290ea5ed..fd4e88791 100644 --- a/indimail-x/vmoddomain.1 +++ b/indimail-x/vmoddomain.9 @@ -5,17 +5,14 @@ vmoddomain - Modify delivery instruction for a virtual domain or set domain limits .SH SYNOPSYS -.B vmoddomain -[ -.I options -] -.I virtual_domain +\fBvmoddomain [ \fIoptions\fR ] \fIvirtual_domain\fR .SH DESCRIPTION .PP \fBvmoddomain\fR modifies delivery instructions for a virtual domain by modifying \fB.qmail-default\fR. \fBvmoddomain\fR can also be used to set -domain limits when using the -\fBl\fR option. +domain limits when using the -\fBl\fR option or hash method using -\fBH\fR +option. .SH OPTIONS .PP @@ -23,12 +20,15 @@ domain limits when using the -\fBl\fR option. .TP \fB\-v\fR verbose -.TP + +.TP 3 \fB\-l\fR \fI0\fR | \fI1\fR Set domain limit. 0 to turn off, 1 to turn on. + .TP \fB\-f\fR \fI0\fR | \fI1\fR Sets the domain with VFILTER capability. 0 to turn off, 1 to turn on. + .TP \fB\-h\fR \fIhandler\fR Sets the handler for delivery instruction for non-existing local users. The @@ -54,11 +54,17 @@ which has the user. .RE .EX -Example Usage + Example Usage -vmoddomain -f 1 bounce-no-mailbox example.com + vmoddomain -f 1 bounce-no-mailbox example.com .EE +.TP +\fB\-H\fR \fIhash_method\fR +You can set domain specific hash method to override hash method configured +in \fI@controldir@/hash_method\fR. It has to be one of DES, MD5, SHA-256, +SHA-512 or YESCRYPT at the moment + .SH RETURN VALUE 0 if all steps were successful, non-zero otherwise. If any of the steps fail, a diagnostic message is printed. diff --git a/indimail-x/vmoddomain.c b/indimail-x/vmoddomain.c index bff6962af..eeeb1a1a7 100644 --- a/indimail-x/vmoddomain.c +++ b/indimail-x/vmoddomain.c @@ -1,5 +1,8 @@ /* * $Log: vmoddomain.c,v $ + * Revision 1.6 2024-05-28 17:09:05+05:30 Cprogrammer + * added -H option to configure hash method for a domain + * * Revision 1.5 2024-05-17 16:24:31+05:30 mbhangui * fix discarded-qualifier compiler warnings * @@ -43,6 +46,7 @@ #include #include #include +#include #endif #include "get_indimailuidgid.h" #include "get_assign.h" @@ -54,7 +58,7 @@ #include "variables.h" #ifndef lint -static char sccsid[] = "$Id: vmoddomain.c,v 1.5 2024-05-17 16:24:31+05:30 mbhangui Exp mbhangui $"; +static char sccsid[] = "$Id: vmoddomain.c,v 1.6 2024-05-28 17:09:05+05:30 Cprogrammer Exp mbhangui $"; #endif #define WARN "vmoddomain: warning: " @@ -64,27 +68,31 @@ static stralloc tmpbuf = {0}; int set_handler(char *, char *, uid_t, gid_t, int); int set_domain_limits(char *, uid_t, gid_t, int); +int set_hash_method(char *, uid_t, gid_t, int); static void -usage() +usage(void) { errout("vmoddomain", "usage: vmoddomain [options] domain\n" - "options: -V (print version number)\n" - " -v (verbose)\n" - " -l 0|1 Enable Domain Limits\n" - " -f 0|1 Enable VFILTER capability\n" - " -h handler (can be one of the following\n" - " " + "options: -V (print version number)\n" + " -v (verbose)\n" + " -l 0|1 Enable Domain Limits\n" + " -H 0|1|2|3|4|5 Enable Hash Method (DES, MD5, SHA-256,\n" + " SHA-512, YESCRYPT)\n" + " -f 0|1 Enable VFILTER capability\n" + " -h handler (can be one of the following\n" + " " DELETE_ALL "\n" - " " + " " BOUNCE_ALL "\n" - " Maildir - Maildir Path\n" - " email - Email Addres\n" - " IP Address - SMTPROUTE/QMTPROUTE spec)\n" - "you need to specify handler and vfilter option or domain limits\n"); + " Maildir - Maildir Path\n" + " email - Email Addres\n" + " IP Address - SMTPROUTE/QMTPROUTE spec)\n" + "you need to specify handler and vfilter option, domain limits\n" + "or hash method\n"); errflush("vmoddomain"); return; } @@ -97,15 +105,16 @@ die_nomem() static int get_options(int argc, char **argv, int *use_vfilter, int *domain_limits, - char **handler, char **domain) + int *hash_method, char **handler, char **domain) { int c; char *ptr; *use_vfilter = -1; *domain_limits = -1; + *hash_method = -1; *handler = *domain = 0; - while ((c = getopt(argc, argv, "avf:h:l:")) != opteof) { + while ((c = getopt(argc, argv, "avf:h:H:l:")) != opteof) { switch (c) { case 'v': @@ -120,13 +129,32 @@ get_options(int argc, char **argv, int *use_vfilter, int *domain_limits, case 'h': *handler = optarg; break; + case 'H': + if (!str_diffn(optarg, "DES", 4) || !str_diffn(optarg, "0", 2)) + *hash_method = DES_HASH; + else + if (!str_diffn(optarg, "MD5", 4) || !str_diffn(optarg, "1", 2)) + *hash_method = MD5_HASH; + else + if (!str_diffn(optarg, "SHA-256", 7) || !str_diffn(optarg, "2", 2)) + *hash_method = SHA256_HASH; + else + if (!str_diffn(optarg, "SHA-256", 7) || !str_diffn(optarg, "3", 2)) + *hash_method = SHA512_HASH; + else + if (!str_diffn(optarg, "YESCRYPT", 7) || !str_diffn(optarg, "4", 2)) + *hash_method = YESCRYPT_HASH; + else + usage(); + break; default: usage(); return (1); } } if ((*use_vfilter != -1 && !*handler) || (*handler && *use_vfilter == -1) || - (!*handler && *domain_limits == -1 && *use_vfilter == -1)) { + (!*handler && *domain_limits == -1 && *use_vfilter == -1 && *hash_method == -1) || + (*hash_method < DES_HASH || *hash_method > YESCRYPT_HASH)) { usage(); return (1); } else @@ -149,11 +177,11 @@ main(int argc, char **argv) char *domain = 0, *handler = 0; static stralloc TheDir = {0}; - int use_vfilter, domain_limits; + int use_vfilter, domain_limits, hash_method; uid_t uid, myuid; gid_t gid, mygid; - if (get_options(argc, argv, &use_vfilter, &domain_limits, &handler, &domain)) + if (get_options(argc, argv, &use_vfilter, &domain_limits, &hash_method, &handler, &domain)) return (1); if (!get_assign(domain, &TheDir, &uid, &gid)) { strerr_warn2(domain, ": domain does not exist", 0); @@ -175,7 +203,9 @@ main(int argc, char **argv) if (handler && set_handler(TheDir.s, handler, uid, gid, use_vfilter)) return (1); if ((domain_limits == 0 || domain_limits == 1) && - set_domain_limits(TheDir.s, uid, gid, domain_limits)) + set_domain_limits(TheDir.s, uid, gid, domain_limits)) + return (1); + if (hash_method != -1 && set_hash_method(TheDir.s, uid, gid, hash_method)) return (1); return (0); } @@ -335,3 +365,88 @@ set_domain_limits(char *dir, uid_t uid, gid_t gid, int domain_limits) close(fd); return (0); } + +int +set_hash_method(char *dir, uid_t uid, gid_t gid, int hash_method) +{ + int fd, len = 8; + char dbuf[FMT_ULONG + FMT_ULONG + 21], outbuf[512]; + char *s, *h = "YESCRYPT"; + struct substdio ssout; +#ifdef FILE_LOCKING + int lockfd; +#endif + + if (!stralloc_copys(&tmpbuf, dir) || + !stralloc_catb(&tmpbuf, "/hash_method", 12) || + !stralloc_0(&tmpbuf)) + die_nomem(); +#ifdef FILE_LOCKING + if ((lockfd = getDbLock(tmpbuf.s, 1)) == -1) + strerr_die4sys(111, FATAL, "get_write_lock: ", tmpbuf.s, ": "); +#endif + if ((fd = open(tmpbuf.s, O_CREAT|O_TRUNC|O_WRONLY, 0400)) == -1) { + strerr_warn4(FATAL, "open: ", tmpbuf.s, ": ", &strerr_sys); +#ifdef FILE_LOCKING + delDbLock(lockfd, tmpbuf.s, 1); +#endif + return (1); + } + if (fchown(fd, uid, gid)) { + s = dbuf; + s += fmt_strn(s, ": (uid = ", 9); + s += fmt_uint(s, uid); + s += fmt_strn(s, ", gid = ", 8); + s += fmt_uint(s, gid); + s += fmt_strn(s, "): ", 3); + *s++ = 0; + strerr_warn4(FATAL, "chown: ", tmpbuf.s, dbuf, &strerr_sys); + close(fd); + unlink(tmpbuf.s); + return (1); + } + substdio_fdbuf(&ssout, write, fd, outbuf, sizeof(outbuf)); + switch (hash_method) + { + case DES_HASH: + h = "DES"; + len = 3; + break; + case MD5_HASH: + h = "MD5"; + len = 3; + break; + case SHA256_HASH: + h = "SHA-256"; + len = 7; + break; + case SHA512_HASH: + h = "SHA-512"; + len = 7; + break; + case YESCRYPT_HASH: + h = "YESCRYPT"; + len = 8; + break; + default: + h = "YESCRYPT"; + len = 8; + break; + } + if (substdio_put(&ssout, h, len) || + substdio_put(&ssout, "\n", 1) || + substdio_flush(&ssout)) { + strerr_warn4(FATAL, "write error: ", tmpbuf.s, ": ", &strerr_sys); + close(fd); + unlink(tmpbuf.s); +#ifdef FILE_LOCKING + delDbLock(lockfd, tmpbuf.s, 1); +#endif + return (1); + } + close(fd); +#ifdef FILE_LOCKING + delDbLock(lockfd, tmpbuf.s, 1); +#endif + return (0); +} diff --git a/indimail-x/vmoduser.9 b/indimail-x/vmoduser.9 index 2649c3505..eb6cf806a 100644 --- a/indimail-x/vmoduser.9 +++ b/indimail-x/vmoduser.9 @@ -231,10 +231,12 @@ BOUNCE_MAIL 0x10 NO_RELAY 0x20 NO_DIALUP 0x40 QA_ADMIN 0x80 -V_USER0 0x100 -V_USER1 0x200 -V_USER2 0x400 -V_USER3 0x800 +V_OVERRIDE 0x100 +NO_SMTP 0x200 +V_USER0 0x400 +V_USER1 0x800 +V_USER2 0x1000 +V_USER3 0x2000 .fi .SH RETURN VALUES diff --git a/indimail-x/vmoduser.c b/indimail-x/vmoduser.c index 6a6a0f4af..c646fc9f0 100644 --- a/indimail-x/vmoduser.c +++ b/indimail-x/vmoduser.c @@ -1,5 +1,5 @@ /* - * $Id: vmoduser.c,v 1.23 2024-05-27 22:53:57+05:30 Cprogrammer Exp mbhangui $ + * $Id: vmoduser.c,v 1.24 2024-05-28 19:37:25+05:30 Cprogrammer Exp mbhangui $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -60,7 +60,7 @@ #include "get_hashmethod.h" #ifndef lint -static char sccsid[] = "$Id: vmoduser.c,v 1.23 2024-05-27 22:53:57+05:30 Cprogrammer Exp mbhangui $"; +static char sccsid[] = "$Id: vmoduser.c,v 1.24 2024-05-28 19:37:25+05:30 Cprogrammer Exp mbhangui $"; #endif #define FATAL "vmoduser: fatal: " @@ -438,10 +438,8 @@ main(int argc, char **argv) strerr_die5x(1, WARN, "no such user ", User.s, "@", real_domain); #ifdef ENABLE_DOMAIN_LIMITS if (!(pw->pw_gid & V_OVERRIDE) && domain_limits) { - if (vget_limits(real_domain, &limits)) + if (vget_limits(real_domain, &limits) == -1) strerr_die3x(1, WARN, "Unable to get domain limits for ", real_domain); - if (QuotaFlag && (limits.perm_defaultquota & VLIMIT_DISABLE_MODIFY)) - strerr_die3x(1, WARN, "quota modification not allowed for ", Email.s); } #endif if (clear_text) { @@ -665,6 +663,10 @@ main(int argc, char **argv) /* * $Log: vmoduser.c,v $ + * Revision 1.24 2024-05-28 19:37:25+05:30 Cprogrammer + * removed check for perms_defaultquota + * handle -1 return code for vget_limits() + * * Revision 1.23 2024-05-27 22:53:57+05:30 Cprogrammer * initialize struct vlimits * diff --git a/indimail-x/vsetuserquota.c b/indimail-x/vsetuserquota.c index f40de1d23..b26223fd3 100644 --- a/indimail-x/vsetuserquota.c +++ b/indimail-x/vsetuserquota.c @@ -1,5 +1,9 @@ /* * $Log: vsetuserquota.c,v $ + * Revision 1.7 2024-05-28 19:37:57+05:30 Cprogrammer + * handle -1 return code for vget_limits() + * removed check for perms_defaultquota + * * Revision 1.6 2024-05-27 22:54:09+05:30 Cprogrammer * initialize struct vlimits * @@ -55,7 +59,7 @@ #include "setuserquota.h" #ifndef lint -static char sccsid[] = "$Id: vsetuserquota.c,v 1.6 2024-05-27 22:54:09+05:30 Cprogrammer Exp mbhangui $"; +static char sccsid[] = "$Id: vsetuserquota.c,v 1.7 2024-05-28 19:37:57+05:30 Cprogrammer Exp mbhangui $"; #endif #define FATAL "vsetuserquota: fatal: " @@ -171,16 +175,11 @@ main(int argc, char **argv) } #ifdef ENABLE_DOMAIN_LIMITS if (!(pw->pw_gid & V_OVERRIDE) && domain_limits) { - if (vget_limits(real_domain, &limits)) { + if (vget_limits(real_domain, &limits) == -1) { strerr_warn2("Unable to get domain limits for ", real_domain, 0); iclose(); return (1); } - if (limits.perm_defaultquota & VLIMIT_DISABLE_MODIFY) { - strerr_warn2("quota modification not allowed for ", email, 0); - iclose(); - return (1); - } } #endif i = setuserquota(User.s, real_domain, quota);