payproc.git
4 years agoMake socket name a configure option.
Werner Koch [Fri, 13 Jun 2014 06:45:41 +0000 (08:45 +0200)]
Make socket name a configure option.

* configure.ac (PAYPROCD_SOCKET_NAME): New var.
* src/payprocd.c (SOCKET_NAME): Replace by PAYPROCD_SOCKET_NAME.

4 years agoNew tool payproc-jrnl.
Werner Koch [Wed, 28 May 2014 06:44:36 +0000 (08:44 +0200)]
New tool payproc-jrnl.

* src/percent.c: New.  From GnuPG master.
* src/util.c (memstr): New.  From my addrutil.c.
(memistr, memicmp): New.  From GnuPG master.
* src/util.h (atoi_1, atoi_2, atoi_4): New.
(xtoi_1, xtoi_2, xtoi_4): New.
* src/payproc-jrnl.c: New.
--

The record selection code has been derived from code I wrote for
addrutil.c.

4 years agoFix brown paper bag allocation bug.
Werner Koch [Mon, 26 May 2014 08:23:49 +0000 (10:23 +0200)]
Fix brown paper bag allocation bug.

* src/util.c (keyvalue_create): Use key and not value for the
allocation.
--

Despite that I have used the pattern of variable length structs for
soooo many times, I got it wrong this time. :-(.  It might be useful
to have a dedicated malloc function+macro to help with that.  This
could actually do the calloc only for the static part of the struct
and copy the string into the dynamic part.

4 years agoPost release updates.
Werner Koch [Fri, 23 May 2014 19:00:49 +0000 (21:00 +0200)]
Post release updates.

--

4 years agoRelease 0.2.0. payproc-0.2.0
Werner Koch [Fri, 23 May 2014 18:58:07 +0000 (20:58 +0200)]
Release 0.2.0.

4 years agoUse -Wno-psabi with gcc.
Werner Koch [Fri, 23 May 2014 18:53:17 +0000 (20:53 +0200)]
Use -Wno-psabi with gcc.

* configure.ac: Rework GCC warning option detection.

4 years agoSESSION - Add command.
Werner Koch [Fri, 23 May 2014 18:45:00 +0000 (20:45 +0200)]
SESSION - Add command.

* configure.ac (NEED_LIBGCRYPT_VERSION): Require Libgcrypt.
* src/session.c, src/session.h: New.
* src/Makefile.am (payprocd_SOURCES): Add them.
(LDADD, AM_CFLAGS): Add Libgcrypt.
(t_connection_CFLAGS, t_connection_LDADD): Ditto.
(t_connection_SOURCES): Add session.c
* src/payprocd.c (TIMERTICK_INTERVAL, HOUSEKEEPING_INTERVAL): New.
(main): Init Libgcrypt.
(time_for_housekeeping_p): New.
(housekeeping_thread): New.
(handle_tick): New.
(server_loop): Call handle_tick.
* src/util.h (JNLIB_GCC_HAVE_PUSH_PRAGMA): New.
* src/connection.c (cmd_session): New.
(connection_handler): Add command SESSION.

4 years agoCHARGECARD - Return a timestamp.
Werner Koch [Fri, 23 May 2014 18:27:40 +0000 (20:27 +0200)]
CHARGECARD - Return a timestamp.

* src/connection.c (cmd_cardtoken): Print timestamp on success.
* src/journal.c (TIMESTAMP_SIZE): New.
(put_current_time): Remove.
(get_current_time): New.
(start_record): Add arg optoonal TIMESTAMP.
(jrnl_store_charge_record): Change arg to a pointer.  Put timestamp
into DICT.

4 years agoAdd zb32_index function.
Werner Koch [Fri, 23 May 2014 17:19:11 +0000 (19:19 +0200)]
Add zb32_index function.

* src/util.c (zb32_index): New.
(zb32_encode): Factor table out to
(zb32asc): .. static global.

4 years agoCheck that GNUTLS 3.0 has been installed.
Werner Koch [Thu, 22 May 2014 14:02:22 +0000 (16:02 +0200)]
Check that GNUTLS 3.0 has been installed.

* configure.ac (NEED_GNUTLS_VERSION): New.
(LIBGNUTLS): Fix gnutls version check.

4 years agoAdd zb32 encoder.
Werner Koch [Thu, 22 May 2014 14:00:16 +0000 (16:00 +0200)]
Add zb32 encoder.

* src/util.c (zb32_encode): New.
--

The code has been taken from current GnuPG master common/zb32.c.

4 years agoMake use of the samethread mode keyword.
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
Make use of the samethread mode keyword.

* src/connection.c (connection_handler): Open stream with samethread.
* src/payprocd.c (already_running_p): Ditto.
* src/journal.c (start_record): Open memstream with samethread.

4 years agoestream: Implement "samethread" mode keyword.
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
estream: Implement "samethread" mode keyword.

* src/estream.c (estream_internal): Add field SAMETHREAD.
(init_stream_lock, lock_stream, trylock_stream, unlock_stream): Use it.
(parse_mode): Add arg SAMETHREAD and parse that keyword.
(es_initialize): Rename to ...
(init_stream_obj): this.  Add arg SAMETHREAD.
(es_create): Add arg SAMETHREAD.  Call init_stream_lock after
init_stream_obj.
(doreadline): Call es_create with samethread flag.
(es_fopen, es_mopen, es_fopenmem, es_fopencookie, do_fdopen)
(do_fpopen, do_w32open): Implement "samethread" keyword.
(es_freopen): Take samthread flag from old stream.
(es_tmpfile): Call es)_create w/o samethread.
--

Note: Unfortunately es_tmpfile has no mode arg so that we can't use
samethread.

4 years agoestream: Fix deadlock in s_fileno.
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
estream: Fix deadlock in s_fileno.

* src/estream.c (es_fileno_unlocked): Call the unlocked functions.

4 years agoestream: Add debug code to the lock functions.
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
estream: Add debug code to the lock functions.

4 years agoestream: Replace locking macros by functions.
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
estream: Replace locking macros by functions.

--

The macros were too hard to read and actually blew up the source.

5 years agoMove the command reference to a separate file.
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
Move the command reference to a separate file.

--

5 years agoAdd command CHECKAMOUNT
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
Add command CHECKAMOUNT

* src/connection.c (cmd_checkamount): New.

5 years agoRelease 0.1.0 payproc-0.1.0
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
Release 0.1.0

5 years agoReturn error messages and write a journal.
Werner Koch [Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)]
Return error messages and write a journal.

5 years agoPost release updates
Werner Koch [Thu, 3 Apr 2014 11:43:24 +0000 (13:43 +0200)]
Post release updates

--

5 years agoRelease 0.0.0 payproc-0.0.0
Werner Koch [Thu, 3 Apr 2014 11:37:14 +0000 (13:37 +0200)]
Release 0.0.0

--

Do not use this release for real transactions.

5 years agoVerify the TLS connection's peer.
Werner Koch [Thu, 3 Apr 2014 11:33:28 +0000 (13:33 +0200)]
Verify the TLS connection's peer.

* src/http.c (http_session_s): Add fields verify and servername.
(tls_ca_certlist): New.
(http_register_tls_ca): New.
(http_session_new): Set the CA certs into the credentials.
(send_request): Store the servername.
(http_verify_server_credentials): New.
* src/t-http.c (main): Register CAs.
(verify_callback): Call the new verify function.
* src/tlssupport.c (verify_callback): Ditto.
* src/tls-ca.pem: New.
--

We should implement a better system than to read the CA certs from the
file every time.  Keeping default credentials object would thus be
useful.

tls-ca.pem has certificates for stripe.com.  They use different root
CA and even a 1014 bit one.  The whole PKIX is anyway broken, so who
cares.  I considered to check just the fingerprint of the actual
certificate but that won't allow for an easy certificate replacement

5 years agoAdd a lot of more stuff.
Werner Koch [Wed, 2 Apr 2014 19:50:27 +0000 (21:50 +0200)]
Add a lot of more stuff.

* src/cred.c, src/cred.h: New.  Based on code from libassuan.
* src/t-connection.c: New.
* src/util.c (trim_spaces): New.  From GnuPG.
(keyvalue_put, keyvalue_putf): Add sanity check.
* src/util.h (spacep, digitp, hexdigitp): New.
(ascii_isspace): New.
* src/stripe.c (stripe_create_card_token): Replace test key by option
(stripe_charge_card): New.
* src/payprocd.c: Add option parsing.  Beautify disagnositcs for new
connections.  Allow setting of a stripe key.
(already_running_p): Implement.
(create_socket): Move log file setting to ...
(launch_server): here.
* src/connection.c (set_error): New.
(struct conn_s): Add field IDNO.
(currency_table): New.
(new_connection_obj): Set IDNO
(fd_from_connection_obj): New.
(id_from_connection_obj): New.
(capitalize_name): Add special case for brackets.
(valid_currency_p): New.
(convert_amount): New.
(cmd_cardtoken): Add plausibility checks.
(cmd_chargecard): New.
(cmd_getinfo): New.
(cmd_ping): New.
(connection_handler): Add new commands.  Call es_fflush.

5 years agoAdd argparse.c from GnuPG.
Werner Koch [Wed, 2 Apr 2014 19:41:25 +0000 (21:41 +0200)]
Add argparse.c from GnuPG.

--

5 years agoSimplify cJSON and add new macros.
Werner Koch [Wed, 2 Apr 2014 07:01:42 +0000 (09:01 +0200)]
Simplify cJSON and add new macros.

* src/cJSON.h: Re-indented.
(cjson_t): New.
(cjson_is_): New macros.
* src/cJSON.c: Re-indented.  Include errno.h and our util.h.
(ep): Remove global var.
(cJSON_GetErrorPtr): Remove.
(cJSON_strcasecmp): Cast args for use with tolower.
(cJSON_malloc, cJSON_free): Remove.  Change callers to use xtrymalloc
and xfree.
(cJSON_InitHooks): Remove.
(cJSON_strdup): Remove.  Change callers to use xtrystrdup.
(cJSON_New_Item): Simplify.
(cJSON_ParseWithOpts, cJSON_Parse): Add arg R_ERROFF.
(parse_string, parse_value, parse_array, parse_object): Add arg EP.
--

cJSON has been taken from cjson-code-58.zip.  The README file has been
renamed to cJSON.readme and the files have been changed to GNU coding
standards.  Because that parser is small enough to be source copied it
does not make sense to treat it as a library and I changed the memory
allocation functions to the usual xmalloc ones. The only external
dependency now is out util.h which declares those functions.

The lowercase cjson_t better fits into our coding style as well as the
new macros.  Thanks to Dave Gamble for this nice parser.

5 years agoInitial checkin.
Werner Koch [Wed, 2 Apr 2014 06:46:36 +0000 (08:46 +0200)]
Initial checkin.