Einar Bordewich spoke forth with the blessed manuscript:
> ----- Original Message -----
> From: "Bill Shupp" <[EMAIL PROTECTED]>
>
> <snip>
> > I think Gabriel's changes are a good start, and eventually Einar's way
> > should probably be implemented. However, this to me is mostly a cosmetic
> > issue, as I don't think there are any significant performance
> disadvantages.
>
> I agree that this is mostly a cosmetic issue. But, it's according to the
> thoughts about virtualdomains and qmail. My colleague Reier Pytte (not on
> this list) made a patch for vaddaliasdomain on how to handle alias
> virtualdomains correct. This was done last minutes on friday afternoon.
> Deletion of domain/aliasdomain is not finnished yet, but it's work in
> progress. If domain is deleted and it has aliasdomains, all of these will be
> removed (just entries in rcpthosts/morercpthosts and virtualdomains). If
> aliasdomain is deleted, only the aliasdomain is removed ;-)
I did basically the same thing, but did cut and pasting of code
rather than copy and pasting. :)
Patch attached.
--
-- Casey Zacek
Senior Staff Engineer
NeoSpire, Inc.
diff -ur old/vpopmail-4.10.35/vaddaliasdomain.c new/vpopmail-4.10.35/vaddaliasdomain.c
--- old/vpopmail-4.10.35/vaddaliasdomain.c Tue Jun 26 05:11:23 2001
+++ new/vpopmail-4.10.35/vaddaliasdomain.c Fri Aug 31 09:08:13 2001
@@ -63,18 +63,8 @@
usage();
vexit(0);
}
- strncpy(TmpBuf3, Dir, MAX_BUFF);
-
- tmpstr = strstr(Dir, "/domains");
- *tmpstr = 0;
-
- snprintf(TmpBuf1, MAX_BUFF, "%s/domains/%s", Dir, Domain_new);
- snprintf(TmpBuf2, MAX_BUFF, "%s/domains/%s", Dir, Domain_old);
- if ( symlink(TmpBuf2, TmpBuf1) != 0 ) {
- fprintf(stderr, "Could not make link\n");
- perror("making link");
- }
- add_domain_assign( Domain_new, TmpBuf3, uid, gid );
+ add_domain_rcpthosts( Domain_new );
+ add_domain_virtualdomains( Domain_new, Domain_old );
signal_process("qmail-send", SIGHUP);
return(vexit(0));
diff -ur old/vpopmail-4.10.35/vpopmail.c new/vpopmail-4.10.35/vpopmail.c
--- old/vpopmail-4.10.35/vpopmail.c Thu Aug 23 11:05:54 2001
+++ new/vpopmail-4.10.35/vpopmail.c Sat Sep 1 18:37:15 2001
@@ -531,6 +531,52 @@
return(0);
}
+/*
+ * Add a domain to rcpthosts (or morercpthosts)
+ */
+void add_domain_rcpthosts( char *domain )
+{
+ static char tmpstr[MAX_BUFF];
+
+ /* If we have more than 50 domains in rcpthosts
+ * make a morercpthosts and compile it
+ */
+ if ( count_rcpthosts() >= 50 ) {
+ snprintf(tmpstr, MAX_BUFF, "%s/control/morercpthosts", QMAILDIR);
+ update_file(tmpstr, domain);
+ snprintf(tmpstr, MAX_BUFF, "%s/control/morercpthosts", QMAILDIR);
+ chmod(tmpstr, VPOPMAIL_QMAIL_MODE );
+ if ( OptimizeAddDomain == 0 ) {
+ compile_morercpthosts();
+ }
+
+ /* or just add to rcpthosts */
+ } else {
+ snprintf(tmpstr, MAX_BUFF, "%s/control/rcpthosts", QMAILDIR);
+ update_file(tmpstr, domain);
+ snprintf(tmpstr, MAX_BUFF, "%s/control/rcpthosts", QMAILDIR);
+ chmod(tmpstr, VPOPMAIL_QMAIL_MODE );
+ }
+}
+
+/*
+ * Add a domain to the virtualdomains control file, remove dupes, set mode
+ * FIXME: won't remove a bob.com:bob.com "duplicate" if being replaced with
+ * bob.com:reallybob.com. Also, vice-versa.. need to remove all
+ * bob.com:* lines.
+ */
+void add_domain_virtualdomains( char *domain, char *real_domain )
+{
+ static char tmpstr1[MAX_BUFF];
+ static char tmpstr2[MAX_BUFF];
+
+ /* Add to virtualdomains file and remove duplicates and set mode */
+ snprintf(tmpstr1, MAX_BUFF, "%s/control/virtualdomains", QMAILDIR );
+ snprintf(tmpstr2, MAX_BUFF, "%s:%s", domain, real_domain );
+ update_file(tmpstr1, tmpstr2);
+ chmod(tmpstr1, VPOPMAIL_QMAIL_MODE );
+}
+
/*
* Add a domain to all the control files
* And signal qmail
@@ -544,7 +590,6 @@
struct stat mystat;
static char tmpstr1[MAX_BUFF];
static char tmpstr2[MAX_BUFF];
- static char tmpstr3[MAX_BUFF];
snprintf(tmpstr1, MAX_BUFF, "%s/users/assign", QMAILDIR);
@@ -559,11 +604,11 @@
fclose(fs1);
}
- snprintf(tmpstr3, MAX_BUFF, "+%s-:%s:%lu:%lu:%s:-::",
+ snprintf(tmpstr2, MAX_BUFF, "+%s-:%s:%lu:%lu:%s:-::",
domain, domain, (long unsigned)uid, (long unsigned)gid, dir);
/* update the file and add the above line and remove duplicates */
- update_file(tmpstr1, tmpstr3);
+ update_file(tmpstr1, tmpstr2);
/* set the mode in case we are running with a strange mask */
chmod(tmpstr1, VPOPMAIL_QMAIL_MODE );
@@ -573,31 +618,8 @@
update_newu();
}
- /* If we have more than 50 domains in rcpthosts
- * make a morercpthosts and compile it
- */
- if ( count_rcpthosts() >= 50 ) {
- snprintf(tmpstr1, MAX_BUFF, "%s/control/morercpthosts", QMAILDIR);
- update_file(tmpstr1, domain);
- snprintf(tmpstr1, MAX_BUFF, "%s/control/morercpthosts", QMAILDIR);
- chmod(tmpstr1, VPOPMAIL_QMAIL_MODE );
- if ( OptimizeAddDomain == 0 ) {
- compile_morercpthosts();
- }
-
- /* or just add to rcpthosts */
- } else {
- snprintf(tmpstr1, MAX_BUFF, "%s/control/rcpthosts", QMAILDIR);
- update_file(tmpstr1, domain);
- snprintf(tmpstr1, MAX_BUFF, "%s/control/rcpthosts", QMAILDIR);
- chmod(tmpstr1, VPOPMAIL_QMAIL_MODE );
- }
-
- /* Add to virtualdomains file and remove duplicates and set mode */
- snprintf(tmpstr1, MAX_BUFF, "%s/control/virtualdomains", QMAILDIR );
- snprintf(tmpstr2, MAX_BUFF, "%s:%s", domain, domain );
- update_file(tmpstr1, tmpstr2);
- chmod(tmpstr1, VPOPMAIL_QMAIL_MODE );
+ add_domain_rcpthosts( domain );
+ add_domain_virtualdomains( domain, domain );
/* make sure it's not in locals and set mode */
snprintf(tmpstr1, MAX_BUFF, "%s/control/locals", QMAILDIR);
diff -ur old/vpopmail-4.10.35/vpopmail.h new/vpopmail-4.10.35/vpopmail.h
--- old/vpopmail-4.10.35/vpopmail.h Thu Aug 23 11:06:40 2001
+++ new/vpopmail-4.10.35/vpopmail.h Fri Aug 31 09:09:28 2001
@@ -95,6 +95,8 @@
int mkpasswd3( char *, char *, int);
char *vgetpasswd( char *);
int vdelfiles( char *);
+void add_domain_rcpthosts(char *domain);
+void add_domain_virtualdomains(char *domain, char *real_domain);
int add_domain_assign( char *domain, char *dir, uid_t uid, gid_t gid);
int del_control( char *);
int del_domain_assign( char *domain, char *dir, uid_t uid, gid_t gid);