Here ya go :-)
Aaron
On Sat, 8 Feb 2003, Roel Rozendaal - IC&S wrote:
> As long as it works safely i certainly don't mind including those
> calls. A patch would be very nice :-)
>
> regards roel
>
> Aaron Stone heeft op zaterdag, 8 feb 2003 om 06:06 (Europe/Amsterdam)
> het volgende geschreven:
>
> > Roel,
> >
> > Would you consider also including my changes to auth_connect() so that
> > it
> > can be safely called alongside every db_connect() call without wasting
> > a
> > database connection? If you specifically want it as a patch I can...
> >
> > Aaron
> >
> >
> > On Fri, 7 Feb 2003, Roel Rozendaal - IC&S wrote:
> >
> >> Hi all,
> >>
> >> could some of you verify the autoconf now in CVS? If it works
> >> correctly
> >> we'll submit dbmail-1.1 :-)
> >>
> >> Ulrich: i've applied your patches (4 feb 2003) for freebsd compiling -
> >> could you check wheter current cvs works immediately?
> >>
> >> regards roel
> >>
> >> Met vriendelijke groet,
> >>
> >>
> >> Roel Rozendaal
> >>
> >>
> >> _________________________
> >> R.A. Rozendaal
> >> ICT Manager
> >> IC&S
> >> T: +31 30 2322878
> >> F: +31 30 2322305
> >> www.ic-s.nl
> >>
> >> _______________________________________________
> >> Dbmail mailing list
> >> [email protected]
> >> https://mailman.fastxs.nl/mailman/listinfo/dbmail
> >>
> >
> > _______________________________________________
> > Dbmail mailing list
> > [email protected]
> > https://mailman.fastxs.nl/mailman/listinfo/dbmail
> >
> Met vriendelijke groet,
>
>
> Roel Rozendaal
>
>
> _________________________
> R.A. Rozendaal
> ICT Manager
> IC&S
> T: +31 30 2322878
> F: +31 30 2322305
> www.ic-s.nl
>
> _______________________________________________
> Dbmail mailing list
> [email protected]
> https://mailman.fastxs.nl/mailman/listinfo/dbmail
>
diff -cr dbmail/injector.c dbmail-auth/injector.c
*** dbmail/injector.c 2002-06-14 06:19:39.000000000 -0700
--- dbmail-auth/injector.c 2003-02-09 12:01:45.000000000 -0800
***************
*** 78,87 ****
return 0;
}
! /* open dbase connections */
! if (db_connect() != 0 || auth_connect() != 0)
{
! trace(TRACE_FATAL,"main(): could not connect to dbases");
return -1;
}
--- 78,94 ----
return 0;
}
! /* open database connection */
! if (db_connect() != 0)
{
! printf("Error opening database connection\n");
! return -1;
! }
!
! /* open authentication connection */
! if (auth_connect() != 0)
! {
! printf("Error opening authentication connection\n");
return -1;
}
diff -cr dbmail/main.c dbmail-auth/main.c
*** dbmail/main.c 2002-12-28 08:57:04.000000000 -0800
--- dbmail-auth/main.c 2003-02-09 12:04:25.000000000 -0800
***************
*** 66,74 ****
SetTraceLevel(&smtpItems);
GetDBParams(_db_host, _db_db, _db_user, _db_pass, &sysItems);
! if (db_connect() < 0)
trace(TRACE_FATAL,"main(): database connection failed");
list_init(&users);
list_init(&mimelist);
--- 66,77 ----
SetTraceLevel(&smtpItems);
GetDBParams(_db_host, _db_db, _db_user, _db_pass, &sysItems);
! if (db_connect() != 0)
trace(TRACE_FATAL,"main(): database connection failed");
+ if (auth_connect() != 0)
+ trace(TRACE_FATAL,"main(): authentication connection failed");
+
list_init(&users);
list_init(&mimelist);
diff -cr dbmail/maintenance.c dbmail-auth/maintenance.c
*** dbmail/maintenance.c 2002-12-28 11:07:14.000000000 -0800
--- dbmail-auth/maintenance.c 2003-02-09 12:05:08.000000000 -0800
***************
*** 141,149 ****
return 0;
}
! printf ("Opening connection to the database... ");
! if (db_connect()==-1)
{
printf ("Failed. An error occured. Please check log.\n");
return -1;
--- 141,155 ----
return 0;
}
! printf ("Opening connection to database... ");
! if (db_connect() != 0)
! {
! printf ("Failed. An error occured. Please check log.\n");
! return -1;
! }
! printf ("Opening connection to authentication... ");
! if (auth_connect() != 0)
{
printf ("Failed. An error occured. Please check log.\n");
return -1;
diff -cr dbmail/mini-injector.c dbmail-auth/mini-injector.c
*** dbmail/mini-injector.c 2002-05-22 08:53:01.000000000 -0700
--- dbmail-auth/mini-injector.c 2003-02-09 12:06:38.000000000 -0800
***************
*** 41,50 ****
openlog(PNAME, LOG_PID, LOG_MAIL); /* open connection to syslog */
configure_debug(TRACE_ERROR, 1, 0); /* do not spill time on reading
settings */
! /* open dbase connections */
if (db_connect() != 0)
{
! trace(TRACE_FATAL,"main(): could not connect to dbase");
return -1;
}
--- 41,57 ----
openlog(PNAME, LOG_PID, LOG_MAIL); /* open connection to syslog */
configure_debug(TRACE_ERROR, 1, 0); /* do not spill time on reading
settings */
! /* open database connections */
if (db_connect() != 0)
{
! trace(TRACE_FATAL,"main(): could not connect to database");
! return -1;
! }
!
! /* open authentication connections */
! if (auth_connect() != 0)
! {
! trace(TRACE_FATAL,"main(): could not connect to authentication");
return -1;
}
diff -cr dbmail/mysql/dbauthmysql.c dbmail-auth/mysql/dbauthmysql.c
*** dbmail/mysql/dbauthmysql.c 2003-02-07 20:58:15.000000000 -0800
--- dbmail-auth/mysql/dbauthmysql.c 2003-02-09 11:53:44.000000000 -0800
***************
*** 52,57 ****
--- 52,58 ----
*/
int auth_connect()
{
+ #ifndef DBMAIL_USE_SAME_CONNECTION
mysql_init(&__auth_conn);
if (mysql_real_connect (&__auth_conn, _auth_host, _auth_user, _auth_pass,
_auth_db, 0, NULL, 0) == NULL)
{
***************
*** 59,72 ****
mysql_error(&__auth_conn));
return -1;
}
!
return 0;
}
int auth_disconnect()
{
mysql_close(&__auth_conn);
return 0;
}
--- 60,75 ----
mysql_error(&__auth_conn));
return -1;
}
! #endif
return 0;
}
int auth_disconnect()
{
+ #ifndef DBMAIL_USE_SAME_CONNECTION
mysql_close(&__auth_conn);
+ #endif
return 0;
}
diff -cr dbmail/pgsql/dbauthpgsql.c dbmail-auth/pgsql/dbauthpgsql.c
*** dbmail/pgsql/dbauthpgsql.c 2003-02-07 20:58:15.000000000 -0800
--- dbmail-auth/pgsql/dbauthpgsql.c 2003-02-09 11:54:35.000000000 -0800
***************
*** 51,56 ****
--- 51,57 ----
*/
int auth_connect ()
{
+ #ifndef DBMAIL_USE_SAME_CONNECTION
char connectionstring[255];
/* connecting */
***************
*** 64,70 ****
trace(TRACE_ERROR,"auth_connect(): PQconnectdb failed:
%s",PQerrorMessage(__auth_conn));
return -1;
}
!
/* database connection OK */
return 0;
}
--- 65,71 ----
trace(TRACE_ERROR,"auth_connect(): PQconnectdb failed:
%s",PQerrorMessage(__auth_conn));
return -1;
}
! #endif
/* database connection OK */
return 0;
}
***************
*** 72,78 ****
--- 73,81 ----
int auth_disconnect()
{
+ #ifndef DBMAIL_USE_SAME_CONNECTION
PQfinish(__auth_conn);
+ #endif
return 0;
}
diff -cr dbmail/raw-convert.c dbmail-auth/raw-convert.c
*** dbmail/raw-convert.c 2002-05-30 11:43:26.000000000 -0700
--- dbmail-auth/raw-convert.c 2003-02-09 12:07:16.000000000 -0800
***************
*** 148,157 ****
printf("Inserting into dbase...");
fflush(stdout);
! /* open dbase connections */
if (db_connect() != 0)
{
! printf("Error opening dbase connections\n");
return -1;
}
--- 148,164 ----
printf("Inserting into dbase...");
fflush(stdout);
! /* open database connections */
if (db_connect() != 0)
{
! printf("Error opening database connection\n");
! return -1;
! }
!
! /* open authentication connections */
! if (auth_connect() != 0)
! {
! printf("Error opening authentication connection\n");
return -1;
}
diff -cr dbmail/serverchild.c dbmail-auth/serverchild.c
*** dbmail/serverchild.c 2002-12-13 03:05:15.000000000 -0800
--- dbmail-auth/serverchild.c 2003-02-09 12:07:34.000000000 -0800
***************
*** 234,245 ****
return -1;
}
! if ( db_connect() != 0)
{
trace(TRACE_ERROR, "PerformChildTask(): could not connect to database");
return -1;
}
connected = 1;
for (i=0; i<info->maxConnect && !ChildStopRequested; i++)
--- 234,251 ----
return -1;
}
! if (db_connect() != 0)
{
trace(TRACE_ERROR, "PerformChildTask(): could not connect to database");
return -1;
}
+ if (auth_connect() != 0)
+ {
+ trace(TRACE_ERROR, "PerformChildTask(): could not connect to
authentication");
+ return -1;
+ }
+
connected = 1;
for (i=0; i<info->maxConnect && !ChildStopRequested; i++)
diff -cr dbmail/settings.c dbmail-auth/settings.c
*** dbmail/settings.c 2002-12-03 07:05:56.000000000 -0800
--- dbmail-auth/settings.c 2003-02-09 12:08:04.000000000 -0800
***************
*** 30,41 ****
fname = argv[1];
}
! if (db_connect()==-1)
{
printf ("Could not connect to database.\n");
return -1;
}
printf("reading configuration for %s...\n", fname);
configfile = fopen(fname,"r"); /* open the configuration file */
if (configfile == NULL) /* error test */
--- 30,47 ----
fname = argv[1];
}
! if (db_connect() != 0)
{
printf ("Could not connect to database.\n");
return -1;
}
+ if (auth_connect() != 0)
+ {
+ printf ("Could not connect to authentication.\n");
+ return -1;
+ }
+
printf("reading configuration for %s...\n", fname);
configfile = fopen(fname,"r"); /* open the configuration file */
if (configfile == NULL) /* error test */
diff -cr dbmail/smtp-convert.c dbmail-auth/smtp-convert.c
*** dbmail/smtp-convert.c 2002-12-03 07:18:47.000000000 -0800
--- dbmail-auth/smtp-convert.c 2003-02-09 11:59:18.000000000 -0800
***************
*** 46,58 ****
openlog(PNAME, LOG_PID, LOG_MAIL); /* open connection to syslog */
configure_debug(TRACE_ERROR, 1, 0);
! /* open dbase connections */
! if (db_connect() != 0 || auth_connect() != 0)
{
! printf("Error opening dbase connections\n");
return -1;
}
time (&start); /* mark the starting time */
result = traverse (argv[1]);
--- 46,64 ----
openlog(PNAME, LOG_PID, LOG_MAIL); /* open connection to syslog */
configure_debug(TRACE_ERROR, 1, 0);
! /* open database connection */
! if (db_connect() != 0)
{
! printf("Error opening database connection\n");
return -1;
}
+ /* open authentication connection */
+ if (auth_connect() != 0)
+ {
+ printf("Error opening authentication connection\n");
+ return -1;
+ }
time (&start); /* mark the starting time */
result = traverse (argv[1]);
diff -cr dbmail/user.c dbmail-auth/user.c
*** dbmail/user.c 2003-02-07 20:58:15.000000000 -0800
--- dbmail-auth/user.c 2003-02-09 12:01:05.000000000 -0800
***************
*** 100,113 ****
return -1;
}
! /* quiet_printf ("Opening connection to the user database... ");
! if (auth_connect()==-1)
{
! quiet_printf ("Failed. Could not connect to user database (check
log)\n");
! db_disconnect();
return -1;
}
- */
quiet_printf ("Ok. Connected\n");
configure_debug(TRACE_ERROR, 1, 0);
--- 100,120 ----
return -1;
}
! /* open database connection */
! quiet_printf ("Opening connection to database... ");
! if (db_connect() != 0)
{
! quiet_printf ("Failed. Could not connect to database (check log)\n");
! return -1;
! }
!
! /* open authentication connection */
! quiet_printf ("Opening connection to authentication... ");
! if (auth_connect() != 0)
! {
! quiet_printf ("Failed. Could not connect to authentication (check
log)\n");
return -1;
}
quiet_printf ("Ok. Connected\n");
configure_debug(TRACE_ERROR, 1, 0);
diff -cr dbmail/vut2dbmail.c dbmail-auth/vut2dbmail.c
*** dbmail/vut2dbmail.c 2002-05-09 05:15:48.000000000 -0700
--- dbmail-auth/vut2dbmail.c 2003-02-09 12:02:50.000000000 -0800
***************
*** 23,37 ****
int i,result;
char *left, *right, *tmp;
! if (db_connect() == -1)
{
! fprintf(stderr, "Could not connect to dbase server\n");
return 1;
}
! if (auth_connect() == -1)
{
! fprintf(stderr, "Could not connect to authentication server\n");
db_disconnect();
return 1;
}
--- 23,37 ----
int i,result;
char *left, *right, *tmp;
! if (db_connect() != 0)
{
! fprintf(stderr, "Could not connect to database\n");
return 1;
}
! if (auth_connect() != 0)
{
! fprintf(stderr, "Could not connect to authentication\n");
db_disconnect();
return 1;
}