imported openchange_user_cleanup script from old version

This is for ldb backends
user_cleanup_script updated for mysql backends
openchange_user_cleanup: pretty format and --ignore=sogo|openchange|imap option
openchange_user_cleanup: typo in help
openchange_user_cleanup: change regexp format to get connection strings
openchange_user_cleanup: ignore default to empty list
openchange_user_cleanup: enable autocommit
openchange_user_cleanup: drop sogo table instead of truncate data
Merge pull request #127 from openchange/jgarcia/user-cleanup-script

user cleanup script
Use new 4.0 old repo to retrace old crashes
Fix #CR-633 in oxcfxics on folder change

Set retval while getting specific props from a openchange db table row.

The problem comes from the `retvals[i]` is overwritten in L1789 so we
have to store the retval in the local variable likewise other switch
functions does.
Merge pull request #132 from sixstone-qq/ejhernandez/fix-crash-folder-change-oc-db-folder

Fix #CR-633 in oxcfxics on folder change
Remove prototypes already defined by flex.

This prevents conflicting prototype errors for yyget_leng with some versions of flex.
CR-131 and CR-50: Fix sync FAI messages when Only Specified Properties is set at RopSyncConfigure

This avoids leading to crash on getting FAI properties in sync operations
when OnlySpecificProperties and FAI synchronisation flags are set.

This also implements IgnoreSpecifiedOnFAI flag according
to the [MS-OXCFXICS] page 131 specification:

   If the OnlySpecifiedProperties flag is set and the IgnoreSpecifiedOnFAI flag is not set, the
   server writes only the specified properties and subobjects for all messages to the FastTransfer
   stream.
   If the OnlySpecifiedProperties flag is set and the IgnoreSpecifiedOnFAI flag is also set, the
   server MUST write only the specified properties and subobjects for all non-FAI messages to the
   FastTransfer stream. For FAI messages, the server MUST write all properties and subobjects to the
   FastTransfer stream.
Add a mapitest to crash on ModifyRecipients

When the number of additional properties in a recipient row is lower
than the number of additional properties set by ModifyRecipientsROP.

Adapt IMessage.c to set the proper prop_count in recipient row
by counting the added properties instead of blindly set the ModifyRecipientsROP
property count.
Fix CR-657: RecipientRow prop number is lower than ModifyRecipientsROP prop count

Instead of crashing when trying to get properties which are not
set, we set the data to NULL and at mapistore level the property count
is equal for all recipient rows.
Fix memory leak mysql result not freed

Trace:

==4142== 7,100,544 (73,920 direct, 7,026,624 indirect) bytes in 440 blocks are definitely lost in loss record 12,026 of 12,026
==4142==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4142==    by 0x27F2E5B3: my_malloc (in /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18.0.0)
==4142==    by 0x27F11964: mysql_store_result (in /usr/lib/x86_64-linux-gnu/libmysqlclient.so.18.0.0)
==4142==    by 0x295CF221: select_without_fetch (in /usr/lib/x86_64-linux-gnu/libmapistore.so.2.2)
==4142==    by 0x295CD987: mysql_record_get_uri (in /usr/lib/x86_64-linux-gnu/libmapistore.so.2.2)
==4142==    by 0x3512DBB4: _i_MAPIStoreMapping__urlFromID_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend)
==4142==    by 0x3513908D: _i_MAPIStoreContext__getRootFolder_withFID_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend)
==4142==    by 0x2AA1B534: sogo_context_get_root_folder (in /usr/lib/x86_64-linux-gnu/mapistore_backends/libMAPIStoreSOGo.so.1.0.0)
==4142==    by 0x295C41E4: mapistore_backend_create_context (in /usr/lib/x86_64-linux-gnu/libmapistore.so.2.2)
==4142==    by 0x295BBE39: mapistore_add_context (in /usr/lib/x86_64-linux-gnu/libmapistore.so.2.2)
==4142==    by 0x2905922F: emsmdbp_object_open_folder (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==4142==    by 0x2907295A: oxcfxics_push_folderChange (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==4142==    by 0x29072C25: oxcfxics_prepare_synccontext_with_folderChange (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==4142==    by 0x290737D5: oxcfxics_fill_synccontext_fasttransfer_response (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==4142==    by 0x29073BF5: EcDoRpc_RopFastTransferSourceGetBuffer (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==4142==    by 0x29053EC8: EcDoRpc_process_transaction (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==4142==    by 0x290563C7: dcesrv_EcDoRpcExt2 (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==4142==    by 0x2905689A: dcesrv_exchange_emsmdb_dispatch (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==4142==    by 0x278C9E23: mapiproxy_server_dispatch (in /usr/lib/x86_64-linux-gnu/libmapiproxy.so.2.2)
==4142==    by 0x268D7213: mapiproxy_op_dispatch (in /usr/lib/x86_64-linux-gnu/samba/dcerpc_server/dcesrv_mapiproxy.so)
==4142==    by 0x16267BAF: dcesrv_process_ncacn_packet (in /usr/lib/x86_64-linux-gnu/libdcerpc-server.so.0.0.1)
==4142==    by 0x16268980: dcesrv_read_fragment_done (in /usr/lib/x86_64-linux-gnu/libdcerpc-server.so.0.0.1)
==4142==    by 0x809ECB6: dcerpc_read_ncacn_packet_done (in /usr/lib/x86_64-linux-gnu/libdcerpc-binding.so.0.0.1)
==4142==    by 0xB5137C8: tstream_readv_pdu_readv_done (in /usr/lib/x86_64-linux-gnu/samba/libsamba-sockets.so.0)
==4142==    by 0xB5126A5: tstream_readv_done (in /usr/lib/x86_64-linux-gnu/samba/libsamba-sockets.so.0)
==4142==    by 0x8B04E13: tevent_common_loop_immediate (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.19)
==4142==    by 0x8B09436: epoll_event_loop_once (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.19)
==4142==    by 0x8B07B26: std_event_loop_once (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.19)
==4142==    by 0x8B045EC: _tevent_loop_once (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.19)
==4142==    by 0x8B0478A: tevent_common_loop_wait (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.19)
==4142==    by 0x8B07AC6: std_event_loop_wait (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.19)
==4142==    by 0x11DF4685: standard_new_task (in /usr/lib/x86_64-linux-gnu/samba/process_model/standard.so)
==4142==    by 0x5D10EF9: task_server_startup (in /usr/lib/x86_64-linux-gnu/samba/libservice.so.0)
==4142==    by 0x5D0FBA2: server_service_startup (in /usr/lib/x86_64-linux-gnu/samba/libservice.so.0)
==4142==    by 0x111A54: binary_smbd_main.constprop.1 (in /usr/sbin/samba)
==4142==    by 0x8D2FEC4: (below main) (libc-start.c:287)
Fix memory leak in mapistore_backend_get_path

Trace:

==26758== 23,518 bytes in 175 blocks are definitely lost in loss record 9,688 of 9,930
==26758==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26758==    by 0x86EDE3D: talloc_strndup (talloc.c:613)
==26758==    by 0x34D2BB9E: _i_NSString_MAPIStoreDataTypes_asUnicodeInMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend)
==26758==    by 0x34CF1F12: _i_MAPIStoreContext__getPath_ofFMID_inMemCtx_ (in /usr/lib/GNUstep/SOGo/SOGoBackend.MAPIStore/SOGoBackend)
==26758==    by 0x2A5D4325: sogo_context_get_path (in /usr/lib/x86_64-linux-gnu/mapistore_backends/libMAPIStoreSOGo.so.1.0.0)
==26758==    by 0x2917D582: mapistore_backend_get_path (in /usr/lib/x86_64-linux-gnu/libmapistore.so.2.2)
==26758==    by 0x2917FECE: mapistore_indexing_record_add_fmid (in /usr/lib/x86_64-linux-gnu/libmapistore.so.2.2)
==26758==    by 0x29180297: mapistore_indexing_record_add_fid (in /usr/lib/x86_64-linux-gnu/libmapistore.so.2.2)
==26758==    by 0x28C12281: emsmdbp_object_open_folder (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==26758==    by 0x28C2B95A: oxcfxics_push_folderChange (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==26758==    by 0x28C2BC25: oxcfxics_prepare_synccontext_with_folderChange (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==26758==    by 0x28C2C7D5: oxcfxics_fill_synccontext_fasttransfer_response (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==26758==    by 0x28C2CBF5: EcDoRpc_RopFastTransferSourceGetBuffer (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==26758==    by 0x28C0CEC8: EcDoRpc_process_transaction (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==26758==    by 0x28C0F3C7: dcesrv_EcDoRpcExt2 (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==26758==    by 0x28C0F89A: dcesrv_exchange_emsmdb_dispatch (in /usr/lib/x86_64-linux-gnu/openchange/dcerpc_mapiproxy_server/exchange_emsmdb.so)
==26758==    by 0x26BF8E23: mapiproxy_server_dispatch (in /usr/lib/x86_64-linux-gnu/libmapiproxy.so.2.2)
==26758==    by 0x268D7213: mapiproxy_op_dispatch (in /usr/lib/x86_64-linux-gnu/samba/dcerpc_server/dcesrv_mapiproxy.so)
==26758==    by 0x16267BAF: dcesrv_process_ncacn_packet (in /usr/lib/x86_64-linux-gnu/libdcerpc-server.so.0.0.1)
==26758==    by 0x16268980: dcesrv_read_fragment_done (in /usr/lib/x86_64-linux-gnu/libdcerpc-server.so.0.0.1)
==26758==    by 0x809ECB6: dcerpc_read_ncacn_packet_done (in /usr/lib/x86_64-linux-gnu/libdcerpc-binding.so.0.0.1)
==26758==    by 0xB5137C8: tstream_readv_pdu_readv_done (in /usr/lib/x86_64-linux-gnu/samba/libsamba-sockets.so.0)
==26758==    by 0xB5126A5: tstream_readv_done (in /usr/lib/x86_64-linux-gnu/samba/libsamba-sockets.so.0)
==26758==    by 0x8B04E13: tevent_common_loop_immediate (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.19)
==26758==    by 0x8B09436: epoll_event_loop_once (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.19)
==26758==    by 0x8B07B26: std_event_loop_once (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.19)
==26758==    by 0x8B045EC: _tevent_loop_once (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.19)
==26758==    by 0x8B0478A: tevent_common_loop_wait (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.19)
==26758==    by 0x8B07AC6: std_event_loop_wait (in /usr/lib/x86_64-linux-gnu/libtevent.so.0.9.19)
==26758==    by 0x11DF4685: standard_new_task (in /usr/lib/x86_64-linux-gnu/samba/process_model/standard.so)
==26758==    by 0x5D10EF9: task_server_startup (in /usr/lib/x86_64-linux-gnu/samba/libservice.so.0)
==26758==    by 0x5D0FBA2: server_service_startup (in /usr/lib/x86_64-linux-gnu/samba/libservice.so.0)
==26758==    by 0x111A54: binary_smbd_main.constprop.1 (in /usr/sbin/samba)
==26758==    by 0x8D2FEC4: (below main) (libc-start.c:287)
Ensure mysql result pointer is valid only when returning MYSQL_SUCCESS
s/openchange.ldb/OpenChange database/, since this condition can also
occur with the MySQL backend.