1 Add support for logging daemon messages to an SQL database.
3 After applying this patch, run these commands for a successful build:
7 ./configure --with-ODBC
13 This patch adds the following options:
16 If set to True, rsync will attempt to connect to
17 the specified datasource and write to the named tables.
21 Specifies the name of the ODBC data source to use.
24 The username to use when connecting to the database.
27 The password to use when connecting to the database.
30 The name of the transfer table to log to. This table contains individual
31 filenames, file sizes, bytes transferred, checksum bytes transferred,
32 operation (send or receive), and a timestamp.
35 The name of the session table to log to. This table contains the username,
36 module name, module path, ip address, process ID, and a timestamp.
40 The name of the exit table to log to. This table contains the total bytes
41 read, total bytes written, total size of all files, error code, line the
42 error occured at, file the error occured at and the text of the error.
43 (most of which will be blank if the program exited normally).
46 Different databases use different methods to get a unique identifier.
47 Some databases support sequence objects, and use various forms of the
48 nextval command to retrieve a unique identifier from it. Other databases
49 support an autonumber field, and support different methds of retrieving
50 the ID used in the last insert. Valid values for this option are:
53 uses the syntax of nextval for PostgreSQL databases
56 uses the syntax of nextval for Oracle databases
59 uses the syntax of nextval for DB2 databases
62 uses the last_insert_id() command for the MySQL databases
65 uses the @@IDENTITY command for Sybase databases
68 Define your own method to get a unique identifier. See the
69 "custom unique id select", and the "get custom id before select"
73 If your database supports sequences, list the name of the sequence to use
74 for the session unique identifier.
76 "custom unique id select"
77 Only used if you specify the custom method in "unique id method". This is
78 a SQL statement to be executed to get a unique ID. This SQL statement must
79 return one column with the unique ID to use for the session ID. Should be
80 used in concert with the "get custom id before select" parameter.
82 "get custom id before insert"
83 This parameter is ignored unless the "unique id method" is set to custom.
84 If set to true, the "custom unique id select" statement will be executed
85 BEFORE the session row is inserted into the database. (as is done when a
86 sequence is used for unique IDs). If False the statement will be executed
87 after the session row is inserted (as is done when the session ID is
88 automatically generates unique IDs). Defaults to True.
90 --- orig/Makefile.in 2005-07-07 23:11:07
91 +++ Makefile.in 2005-05-23 23:31:30
92 @@ -31,7 +31,7 @@ LIBOBJ=lib/wildmatch.o lib/compat.o lib/
93 ZLIBOBJ=zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o \
94 zlib/trees.o zlib/zutil.o zlib/adler32.o zlib/compress.o zlib/crc32.o
95 OBJS1=rsync.o generator.o receiver.o cleanup.o sender.o exclude.o util.o \
96 - main.o checksum.o match.o syscall.o log.o backup.o
97 + main.o checksum.o match.o syscall.o log.o backup.o @EXTRA_OBJECT@
98 OBJS2=options.o flist.o io.o compat.o hlink.o token.o uidlist.o socket.o \
99 fileio.o batch.o clientname.o
100 OBJS3=progress.o pipe.o
101 --- orig/cleanup.c 2005-03-05 18:58:38
102 +++ cleanup.c 2005-05-23 23:28:28
103 @@ -39,6 +39,10 @@ void close_all(void)
111 max_fd = sysconf(_SC_OPEN_MAX) - 1;
112 for (fd = max_fd; fd >= 0; fd--) {
113 if ((ret = do_fstat(fd, &st)) == 0) {
114 @@ -144,8 +148,12 @@ void _exit_cleanup(int code, const char
120 log_exit(code, file, line);
122 + db_log_exit(code,file,line);
127 rprintf(FINFO,"_exit_cleanup(code=%d, file=%s, line=%d): about to call exit(%d)\n",
128 --- orig/clientserver.c 2005-09-15 18:09:14
129 +++ clientserver.c 2005-05-23 23:29:31
130 @@ -349,6 +349,9 @@ static int rsync_module(int f_in, int f_
131 XFLG_ANCHORED2ABS | XFLG_OLD_PREFIXES);
139 s = lp_prexfer_exec(i);
140 @@ -535,6 +538,9 @@ static int rsync_module(int f_in, int f_
141 rprintf(FLOG, "rsync %s %s from %s@%s (%s)\n",
142 am_sender ? "on" : "to",
143 request, auth_user, host, addr);
148 rprintf(FLOG, "rsync %s %s from %s (%s)\n",
149 am_sender ? "on" : "to",
150 --- orig/configure.in 2005-07-29 02:47:19
151 +++ configure.in 2005-05-23 23:32:21
152 @@ -92,6 +92,8 @@ AC_ARG_WITH(rsync-path,
153 [ --with-rsync-path=PATH set default --rsync-path to PATH (default: rsync)],
154 [ RSYNC_PATH="$with_rsync_path" ],
155 [ RSYNC_PATH="rsync" ])
157 + [ --with-ODBC compile in support for ODBC database logging])
159 AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [location of rsync on remote machine])
161 @@ -547,6 +549,14 @@ then
162 AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
165 +if test x"$with_ODBC" = x"yes"
167 + AC_CHECK_HEADERS(sql.h sqlext.h sqltypes.h)
168 + AC_CHECK_LIB(odbc,SQLExecDirect)
169 + EXTRA_OBJECT="$EXTRA_OBJECT dblog.o"
170 + AC_SUBST(EXTRA_OBJECT)
173 AC_MSG_CHECKING([whether to use included libpopt])
174 if test x"$with_included_popt" = x"yes"
176 --- orig/dblog-tables-mysql.sql 2005-05-23 23:28:40
177 +++ dblog-tables-mysql.sql 2005-05-23 23:28:40
179 +drop table transfer;
183 +CREATE TABLE session (
184 + id int auto_increment NOT NULL,
185 + date timestamp NOT NULL,
186 + ip_address varchar(15) NOT NULL,
187 + username varchar(20) NOT NULL,
188 + module_name varchar(20) NOT NULL,
189 + module_path varchar(255) NOT NULL,
190 + process_id int NOT NULL,
194 +CREATE TABLE transfer (
195 + id int auto_increment NOT NULL,
196 + session_id int NOT NULL,
197 + date timestamp NOT NULL,
198 + file_name varchar(255) NOT NULL,
199 + file_size bigint NOT NULL,
200 + bytes_transferred bigint NOT NULL,
201 + checksum_bytes_transferred bigint NOT NULL,
202 + operation varchar(20),
204 + foreign key (session_id) references session (id)
208 + id int auto_increment NOT NULL,
209 + session_id int NOT NULL,
210 + date timestamp NOT NULL,
211 + total_bytes_written bigint NOT NULL,
212 + total_bytes_read bigint NOT NULL,
213 + total_size bigint NOT NULL,
214 + error_text varchar(128) NOT NULL,
215 + error_code int NOT NULL,
216 + error_file varchar(64) NOT NULL,
217 + error_line int NOT NULL,
218 + process_id int NOT NULL,
220 + foreign key (session_id) references session (id)
222 --- orig/dblog-tables-postgresql.sql 2005-05-23 23:28:48
223 +++ dblog-tables-postgresql.sql 2005-05-23 23:28:48
225 +drop table transfer;
228 +drop sequence session_id_seq;
229 +create sequence session_id_seq;
231 +CREATE TABLE "session" (
233 + "date" timestamp NOT NULL default now(),
234 + "ip_address" varchar(15) NOT NULL,
235 + "username" varchar(20) NOT NULL,
236 + "module_name" varchar(20) NOT NULL,
237 + "module_path" varchar(255) NOT NULL,
238 + "process_id" int NOT NULL,
242 +CREATE TABLE "transfer" (
243 + "id" serial NOT NULL,
244 + "session_id" int NOT NULL,
245 + "date" timestamp NOT NULL default now(),
246 + "file_name" varchar(512) NOT NULL,
247 + "file_size" bigint NOT NULL,
248 + "bytes_transferred" bigint NOT NULL,
249 + "checksum_bytes_transferred" bigint NOT NULL,
250 + "operation" varchar(20),
252 + foreign key (session_id) references session (id)
255 +CREATE TABLE "exit" (
256 + "id" serial NOT NULL,
257 + "session_id" int NOT NULL,
258 + "date" timestamp NOT NULL default now(),
259 + "total_bytes_written" bigint NOT NULL,
260 + "total_bytes_read" bigint NOT NULL,
261 + "total_size" bigint NOT NULL,
262 + "error_text" varchar(128) NOT NULL,
263 + "error_code" int NOT NULL,
264 + "error_file" varchar(64) NOT NULL,
265 + "error_line" int NOT NULL,
266 + "process_id" int NOT NULL,
268 + foreign key (session_id) references session (id)
270 --- orig/dblog.c 2005-05-24 07:12:54
271 +++ dblog.c 2005-05-24 07:12:54
274 + * ODBC Database logging functions
276 + * Written by Steve Sether, April 2004
277 + * steve@vellmont.com
285 +#ifdef HAVE_ODBC_SQL_H
286 +#include <odbc/sql.h>
290 +#ifdef HAVE_SQLEXT_H
293 +#ifdef HAVE_ODBC_SQLEXT_H
294 +#include <odbc/sqlext.h>
298 +#ifdef HAVE_SQLTYPES_H
299 +#include <sqltypes.h>
301 +#ifdef HAVE_ODBC_SQLTYPES_H
302 +#include <odbc/sqltypes.h>
306 +SQLHENV db_environ_handle; /* Handle ODBC environment */
307 +long result; /* result of functions */
308 +SQLHDBC db_handle= NULL; /* database connection handle */
309 +SQLHSTMT sql_statement_handle; /* SQL statement handle */
310 +extern int am_sender;
311 +extern char *auth_user;
312 +extern int module_id;
314 +char sql_status[10]; /* Status SQL */
315 +SQLINTEGER V_OD_err, V_OD_rowanz, V_OD_id;
316 +SQLSMALLINT V_OD_mlen, V_OD_colanz;
317 +char V_OD_msg[200], V_OD_buffer[200];
318 +SQLINTEGER session_id;
321 +/* This function simply removes invalid characters from the SQL statement
322 + * to prevent SQL injection attacks. */
323 +char *sanitizeSql(const char *input)
328 + if (strlen(input) > ((~(unsigned int)0)>>1)-3)
330 + if (!(out = ptr = new_array(char, strlen(input) * 2 + 1)))
333 + for (c = input; *c; c++) {
364 +void db_log_open(void)
366 + if (lp_database_logging(module_id)) {
367 + if (db_handle == NULL) {
368 + /* get ODBC environment handle */
369 + result = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&db_environ_handle);
370 + if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO) {
371 + rprintf(FERROR, "Error: couldn't get database environment handle\n");
375 + /* Setting database enviroment */
376 + result = SQLSetEnvAttr(db_environ_handle, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
377 + if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO) {
378 + rprintf(FERROR, "Error: couldn't set database environment.\n");
379 + SQLFreeHandle(SQL_HANDLE_ENV, db_environ_handle);
380 + db_environ_handle = NULL;
384 + /* Get a database handle */
385 + result = SQLAllocHandle(SQL_HANDLE_DBC, db_environ_handle, &db_handle);
386 + if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO) {
387 + rprintf(FERROR, "Error: couldn't allocate database handle\n");
388 + SQLFreeHandle(SQL_HANDLE_ENV, db_environ_handle);
389 + db_environ_handle = NULL;
393 + /* Set connection attributes */
394 + SQLSetConnectAttr(db_handle, SQL_LOGIN_TIMEOUT, (SQLPOINTER *)5, 0);
396 + /* Connect to the database. */
397 + result = SQLConnect(db_handle, (SQLCHAR*) lp_database_datasource(module_id), SQL_NTS,
398 + (SQLCHAR*) lp_database_username(module_id), SQL_NTS,
399 + (SQLCHAR*) lp_database_password(module_id), SQL_NTS);
401 + if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO) {
402 + SQLGetDiagRec(SQL_HANDLE_DBC, db_handle,1,
403 + sql_status, &V_OD_err,V_OD_msg,100,&V_OD_mlen);
404 + rprintf(FERROR,"Error Connecting to Database %s\n",V_OD_msg);
405 + SQLFreeHandle(SQL_HANDLE_DBC,db_handle);
407 + SQLFreeHandle(SQL_HANDLE_ENV, db_environ_handle);
408 + db_environ_handle = NULL;
411 + rprintf(FLOG,"Connected to database!\n");
413 + /* get SQL statement handle */
414 + result = SQLAllocHandle(SQL_HANDLE_STMT, db_handle, &sql_statement_handle);
415 + if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO) {
416 + SQLGetDiagRec(SQL_HANDLE_DBC, db_handle,1, sql_status,&V_OD_err,V_OD_msg,100,&V_OD_mlen);
417 + rprintf(FERROR,"Error in allocating SQL statement handle %s\n",V_OD_msg);
418 + SQLDisconnect(db_handle);
419 + SQLFreeHandle(SQL_HANDLE_DBC,db_handle);
421 + SQLFreeHandle(SQL_HANDLE_ENV, db_environ_handle);
422 + db_environ_handle = NULL;
426 + rprintf(FERROR,"Already connected to database\n");
433 + if (lp_database_logging(module_id)) {
434 + if (sql_statement_handle != NULL) {
435 + /* free the statement handle first */
436 + SQLFreeHandle(SQL_HANDLE_STMT,sql_statement_handle);
437 + sql_statement_handle = NULL;
439 + rprintf(FERROR,"No sql statement handle to close\n");
441 + if (db_handle != NULL) {
442 + /* disconnect, and free the database handle. */
443 + SQLDisconnect(db_handle);
444 + SQLFreeHandle(SQL_HANDLE_DBC,db_handle);
447 + rprintf(FERROR,"Database already closed");
449 + if (db_environ_handle != NULL) {
450 + /* free the environment handle */
451 + SQLFreeHandle(SQL_HANDLE_ENV, db_environ_handle);
452 + db_environ_handle = NULL;
454 + rprintf(FERROR,"No environment handle to close");
459 +static long get_unique_session_id()
462 + char strSqlStatement[1024];
464 + if (db_handle != NULL) {
465 + /* choose the appropriate select statement based upon which DBMS we're using.
466 + * different datbases use different methods to get a unique ID. Some use a counter
467 + * object (sequence), others use an auto increment datatype and have a method
468 + * to get the last ID inserted using this connection. */
469 + if (strcmp(lp_unique_id_method(module_id),"nextval-postgresql") == 0) {
470 + snprintf(strSqlStatement,sizeof(strSqlStatement),"SELECT NEXTVAL('%s');",lp_sequence_name(module_id));
471 + } else if (strcmp(lp_unique_id_method(module_id),"nextval-oracle") == 0) {
472 + snprintf(strSqlStatement,sizeof(strSqlStatement),"SELECT %s.NEXTVAL FROM dual;",lp_sequence_name(module_id));
473 + } else if (strcmp(lp_unique_id_method(module_id),"nextval-db2") == 0) {
474 + snprintf(strSqlStatement,sizeof(strSqlStatement),"VALUES NEXTVAL FOR %s;",lp_sequence_name(module_id));
475 + } else if (strcmp(lp_unique_id_method(module_id),"last_insert_id") == 0) { /* MySql */
476 + snprintf(strSqlStatement,sizeof(strSqlStatement),"SELECT LAST_INSERT_ID()");
477 + } else if (strcmp(lp_unique_id_method(module_id),"@@IDENTITY") == 0) { /* Sybase */
478 + snprintf(strSqlStatement,sizeof(strSqlStatement),"SELECT @@IDENTITY");
479 + } else if (strcmp(lp_unique_id_method(module_id),"custom") == 0){ /* Users custom statement */
480 + snprintf(strSqlStatement,sizeof(strSqlStatement),lp_custom_unique_id_select(module_id));
483 + /* bind the 1st column to unique */
484 + SQLBindCol(sql_statement_handle,1,SQL_C_LONG,&unique,150,&V_OD_err);
485 + /* execute the SQL statement */
486 + result = SQLExecDirect(sql_statement_handle,strSqlStatement,SQL_NTS);
487 + if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO) {
488 + SQLGetDiagRec(SQL_HANDLE_DBC, db_handle,1, sql_status,&V_OD_err,V_OD_msg,100,&V_OD_mlen);
489 + rprintf(FERROR,"Error at get_sequence: Error in Select! %s %s\n",strSqlStatement,V_OD_msg);
491 + result = SQLFetch(sql_statement_handle);
492 + if (result != SQL_NO_DATA && unique != 0) {
493 + rprintf(FINFO,"Got unique sequence! %ld\n",unique);
495 + rprintf(FERROR,"Error at get_sequence: Didn't get unique session ID\n");
497 + /* Close the cursor so the statement can be re-used */
498 + result = SQLFreeStmt(sql_statement_handle,SQL_CLOSE);
499 + if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO) {
500 + SQLGetDiagRec(SQL_HANDLE_DBC, db_handle,1, sql_status,&V_OD_err,V_OD_msg,100,&V_OD_mlen);
501 + rprintf(FERROR,"Error at get_sequence: Error in closing SQL statement handle %s\n",V_OD_msg);
507 + rprintf(FERROR,"Error at get_sequence: Not connected to database\n");
512 +void db_log_session()
514 + char strSqlStatement[1024];
515 + int gotSessionID = 0;
516 + if (lp_database_logging(module_id)) {
517 + /* if we're using a sequence via the nextval command to get a unique ID, we need to get it before
518 + * we do the insert. We also get the unique ID now if custom, and get_custom_id_before_insert is set. */
519 + if (strcmp(lp_unique_id_method(module_id),"nextval-postgresql") == 0
520 + || strcmp(lp_unique_id_method(module_id),"nextval-oracle") == 0
521 + || strcmp(lp_unique_id_method(module_id),"nextval-db2") == 0
522 + || (strcmp(lp_unique_id_method(module_id),"custom") == 0
523 + && lp_get_custom_id_before_insert(module_id))) {
524 + session_id = get_unique_session_id();
526 + snprintf(strSqlStatement,sizeof(strSqlStatement),"INSERT INTO %s (id, date, ip_address, username, module_name, module_path, process_id) VALUES ('%ld', '%s', '%s', '%s','%s','%s','%d');",lp_session_table_name(module_id),session_id,timestring(time(NULL)),client_addr(0),auth_user,lp_name(module_id),lp_path(module_id),getpid());
528 + /* Otherwise the ID gets created automatically, and we get the ID it used after the insert. */
529 + snprintf(strSqlStatement,sizeof(strSqlStatement),"INSERT INTO %s (date, ip_address, username, module_name, module_path, process_id) VALUES ('%s', '%s', '%s', '%s','%s','%d');",lp_session_table_name(module_id),timestring(time(NULL)),client_addr(0),auth_user,lp_name(module_id),lp_path(module_id),getpid());
532 + /* Insert the new session into the database */
533 + result = SQLExecDirect(sql_statement_handle,strSqlStatement,SQL_NTS);
534 + if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO) {
535 + SQLGetDiagRec(SQL_HANDLE_DBC, db_handle,1, sql_status,&V_OD_err,V_OD_msg,100,&V_OD_mlen);
536 + rprintf(FERROR,"Error at db_log_session: Error in Insert %s %s\n",strSqlStatement,V_OD_msg);
539 + /* close the cursor so the statement handle can be re-used. */
540 + result = SQLFreeStmt(sql_statement_handle,SQL_CLOSE);
541 + if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO) {
542 + SQLGetDiagRec(SQL_HANDLE_DBC, db_handle,1, sql_status,&V_OD_err,V_OD_msg,100,&V_OD_mlen);
543 + rprintf(FERROR,"Error in resetting SQL statement handle %s\n",V_OD_msg);
545 + /* get the session ID for databases that give the unique ID after an insert */
546 + if (gotSessionID == 0) {
547 + session_id = get_unique_session_id();
551 + rprintf(FERROR,"Error at db_log_session: Not connected to database!\n");
555 +void db_log_transfer(struct file_struct *file,struct stats *initial_stats,char *operation)
557 + extern struct stats stats;
558 + char strSqlStatement[2048];
559 + char strFileName[MAXPATHLEN];
560 + char *strFileNamePtr;
561 + char strFileSize[255];
562 + int64 intBytesTransferred;
563 + int64 intCheckSumBytes;
565 + if (lp_database_logging(module_id)) {
566 + if (db_handle != NULL) {
567 + strFileNamePtr = safe_fname(f_name(file));
568 + if (am_sender && file->dir.root) {
569 + pathjoin(strFileName, sizeof strFileName,
570 + file->dir.root, strFileNamePtr);
571 + strFileNamePtr = strFileName;
573 + clean_fname(strFileNamePtr, 0);
574 + if (*strFileNamePtr == '/')
577 + snprintf(strFileSize,sizeof(strFileSize),"%.0f", (double)file->length);
579 + intBytesTransferred = stats.total_written - initial_stats->total_written;
581 + intBytesTransferred = stats.total_read - initial_stats->total_read;
585 + intCheckSumBytes = stats.total_written - initial_stats->total_written;
587 + intCheckSumBytes = stats.total_read - initial_stats->total_read;
590 + snprintf(strSqlStatement,sizeof(strSqlStatement),"INSERT INTO %s (session_id,date, file_name, file_size, bytes_transferred, checksum_bytes_transferred, operation) VALUES ('%ld','%s','%s','%s','%Ld','%Ld','%s');",lp_transfer_table_name(module_id),session_id,timestring(time(NULL)),sanitizeSql(strFileNamePtr),strFileSize,intBytesTransferred,intCheckSumBytes,operation);
591 + result = SQLExecDirect(sql_statement_handle,strSqlStatement,SQL_NTS);
592 + if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO) {
593 + SQLGetDiagRec(SQL_HANDLE_DBC, db_handle,1, sql_status,&V_OD_err,V_OD_msg,100,&V_OD_mlen);
594 + rprintf(FERROR,"Error at db_log_transfer: Error in Insert %s %s\n",strSqlStatement,V_OD_msg);
595 + if (result == SQL_INVALID_HANDLE)
596 + rprintf(FERROR,"INVALID HANDLE\n");
599 + rprintf(FERROR,"Error at db_log_transfer: Not connected to database!\n");
605 +void db_log_exit(int code, const char *file, int line)
607 + char strSqlStatement[2048];
608 + const char *error_text;
609 + extern struct stats stats;
610 + if (db_handle != NULL) {
611 + if (lp_database_logging(module_id)) {
613 + error_text = rerr_name(code);
615 + error_text = "unexplained error";
620 + snprintf(strSqlStatement,sizeof(strSqlStatement),"INSERT INTO %s (session_id, date, total_bytes_written,total_bytes_read,total_size,error_text,error_code,error_file,error_line,process_id) VALUES ('%ld','%s','%Ld','%Ld','%Ld','%s','%d','%s','%d','%d');",lp_exit_table_name(module_id),session_id,timestring(time(NULL)),stats.total_written,stats.total_read,stats.total_size,error_text,code,file,line,getpid());
622 + result = SQLExecDirect(sql_statement_handle,strSqlStatement,SQL_NTS);
624 + if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO) {
625 + SQLGetDiagRec(SQL_HANDLE_DBC, db_handle,1, sql_status,&V_OD_err,V_OD_msg,100,&V_OD_mlen);
626 + rprintf(FERROR,"Error at db_log_exit: Error in Insert %s %s\n",strSqlStatement,V_OD_msg);
630 + rprintf(FERROR,"Error at db_log_exit: Not connected to database!\n");
633 --- orig/loadparm.c 2005-09-19 17:21:10
634 +++ loadparm.c 2005-09-19 17:22:53
635 @@ -120,9 +120,14 @@ typedef struct
639 + char *custom_unique_id_select;
640 + char *database_datasource;
641 + char *database_password;
642 + char *database_username;
646 + char *exit_table_name;
650 @@ -137,13 +142,19 @@ typedef struct
652 char *refuse_options;
654 + char *sequence_name;
655 + char *session_table_name;
657 + char *transfer_table_name;
659 + char *unique_id_method;
665 + BOOL database_logging;
666 + BOOL get_custom_id_before_insert;
668 BOOL ignore_nonreadable;
670 @@ -163,9 +174,14 @@ static service sDefault =
672 /* auth_users; */ NULL,
674 + /* custom_unique_id_select; */ NULL,
675 + /* database_datasource; */ NULL,
676 + /* database_password; */ NULL,
677 + /* database_username; */ NULL,
678 /* dont_compress; */ "*.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz",
680 /* exclude_from; */ NULL,
681 + /* exit_table_name; */ NULL,
683 /* gid; */ NOBODY_GROUP,
684 /* hosts_allow; */ NULL,
685 @@ -180,13 +196,19 @@ static service sDefault =
686 /* prexfer_exec; */ NULL,
687 /* refuse_options; */ NULL,
688 /* secrets_file; */ NULL,
689 + /* sequence_name; */ NULL,
690 + /* session_table_name; */ NULL,
691 /* temp_dir; */ NULL,
692 + /* transfer_table_name; */ NULL,
693 /* uid; */ NOBODY_USER,
694 + /* unique_id_method; */ NULL,
696 /* max_connections; */ 0,
697 /* max_verbosity; */ 1,
700 + /* database_logging; */ False,
701 + /* get_custom_id_before_insert; */ True,
702 /* ignore_errors; */ False,
703 /* ignore_nonreadable; */ False,
705 @@ -287,10 +309,17 @@ static struct parm_struct parm_table[] =
707 {"auth users", P_STRING, P_LOCAL, &sDefault.auth_users, NULL,0},
708 {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL,0},
709 + {"custom unique id select",P_STRING,P_LOCAL,&sDefault.custom_unique_id_select,NULL,0},
710 + {"database datasource",P_STRING,P_LOCAL, &sDefault.database_datasource,NULL,0},
711 + {"database logging", P_BOOL, P_LOCAL, &sDefault.database_logging, NULL,0},
712 + {"database password", P_STRING, P_LOCAL, &sDefault.database_password, NULL,0},
713 + {"database username", P_STRING, P_LOCAL, &sDefault.database_username, NULL,0},
714 {"dont compress", P_STRING, P_LOCAL, &sDefault.dont_compress, NULL,0},
715 {"exclude from", P_STRING, P_LOCAL, &sDefault.exclude_from, NULL,0},
716 {"exclude", P_STRING, P_LOCAL, &sDefault.exclude, NULL,0},
717 + {"exit table name", P_STRING, P_LOCAL, &sDefault.exit_table_name, NULL,0},
718 {"filter", P_STRING, P_LOCAL, &sDefault.filter, NULL,0},
719 + {"get custom id before insert",P_BOOL,P_LOCAL,&sDefault.get_custom_id_before_insert,NULL,0},
720 {"gid", P_STRING, P_LOCAL, &sDefault.gid, NULL,0},
721 {"hosts allow", P_STRING, P_LOCAL, &sDefault.hosts_allow, NULL,0},
722 {"hosts deny", P_STRING, P_LOCAL, &sDefault.hosts_deny, NULL,0},
723 @@ -305,6 +334,10 @@ static struct parm_struct parm_table[] =
724 {"max verbosity", P_INTEGER,P_LOCAL, &sDefault.max_verbosity, NULL,0},
725 {"name", P_STRING, P_LOCAL, &sDefault.name, NULL,0},
726 {"path", P_PATH, P_LOCAL, &sDefault.path, NULL,0},
727 + {"sequence name", P_STRING, P_LOCAL, &sDefault.sequence_name, NULL,0},
728 + {"session table name",P_STRING, P_LOCAL, &sDefault.session_table_name,NULL,0},
729 + {"transfer table name",P_STRING,P_LOCAL, &sDefault.transfer_table_name,NULL,0},
730 + {"unique id method", P_STRING, P_LOCAL, &sDefault.unique_id_method, NULL,0},
732 {"post-xfer exec", P_STRING, P_LOCAL, &sDefault.postxfer_exec, NULL,0},
733 {"pre-xfer exec", P_STRING, P_LOCAL, &sDefault.prexfer_exec, NULL,0},
734 @@ -377,9 +410,14 @@ FN_GLOBAL_INTEGER(lp_syslog_facility, &G
736 FN_LOCAL_STRING(lp_auth_users, auth_users)
737 FN_LOCAL_STRING(lp_comment, comment)
738 +FN_LOCAL_STRING(lp_custom_unique_id_select,custom_unique_id_select)
739 +FN_LOCAL_STRING(lp_database_datasource, database_datasource)
740 +FN_LOCAL_STRING(lp_database_password, database_password)
741 +FN_LOCAL_STRING(lp_database_username, database_username)
742 FN_LOCAL_STRING(lp_dont_compress, dont_compress)
743 FN_LOCAL_STRING(lp_exclude, exclude)
744 FN_LOCAL_STRING(lp_exclude_from, exclude_from)
745 +FN_LOCAL_STRING(lp_exit_table_name, exit_table_name)
746 FN_LOCAL_STRING(lp_filter, filter)
747 FN_LOCAL_STRING(lp_gid, gid)
748 FN_LOCAL_STRING(lp_hosts_allow, hosts_allow)
749 @@ -394,13 +432,19 @@ FN_LOCAL_STRING(lp_postxfer_exec, postxf
750 FN_LOCAL_STRING(lp_prexfer_exec, prexfer_exec)
751 FN_LOCAL_STRING(lp_refuse_options, refuse_options)
752 FN_LOCAL_STRING(lp_secrets_file, secrets_file)
753 +FN_LOCAL_STRING(lp_sequence_name,sequence_name)
754 +FN_LOCAL_STRING(lp_session_table_name,session_table_name)
755 FN_LOCAL_STRING(lp_temp_dir, temp_dir)
756 +FN_LOCAL_STRING(lp_transfer_table_name, transfer_table_name)
757 FN_LOCAL_STRING(lp_uid, uid)
758 +FN_LOCAL_STRING(lp_unique_id_method,unique_id_method)
760 FN_LOCAL_INTEGER(lp_max_connections, max_connections)
761 FN_LOCAL_INTEGER(lp_max_verbosity, max_verbosity)
762 FN_LOCAL_INTEGER(lp_timeout, timeout)
764 +FN_LOCAL_BOOL(lp_database_logging, database_logging)
765 +FN_LOCAL_BOOL(lp_get_custom_id_before_insert,get_custom_id_before_insert)
766 FN_LOCAL_BOOL(lp_ignore_errors, ignore_errors)
767 FN_LOCAL_BOOL(lp_ignore_nonreadable, ignore_nonreadable)
768 FN_LOCAL_BOOL(lp_list, list)
769 --- orig/log.c 2005-06-10 21:33:28
770 +++ log.c 2005-05-23 23:29:54
771 @@ -84,7 +84,7 @@ struct {
773 * Map from rsync error code to name, or return NULL.
775 -static char const *rerr_name(int code)
776 +char const *rerr_name(int code)
779 for (i = 0; rerr_names[i].name; i++) {
780 --- orig/main.c 2005-09-16 16:38:53
781 +++ main.c 2005-05-23 23:30:01
782 @@ -139,6 +139,9 @@ static void handle_stats(int f)
785 log_exit(0, __FILE__, __LINE__);
787 + db_log_exit(0,__FILE__,__LINE__);
789 if (f == -1 || !am_sender)
792 --- orig/receiver.c 2005-09-16 05:41:02
793 +++ receiver.c 2005-05-23 23:30:07
794 @@ -674,6 +674,9 @@ int recv_files(int f_in, struct file_lis
796 if (!log_before_transfer)
797 log_item(file, &initial_stats, iflags, NULL);
799 + db_log_transfer(file, &initial_stats, "receive");
804 --- orig/sender.c 2005-07-28 01:46:25
805 +++ sender.c 2005-05-23 23:30:15
806 @@ -356,6 +356,9 @@ void send_files(struct file_list *flist,
808 if (!log_before_transfer)
809 log_item(file, &initial_stats, iflags, NULL);
811 + db_log_transfer(file, &initial_stats,"send");
815 j = unmap_file(mbuf);