Login
Check-in [d3662155ca]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Minor internal cleanups. libfossil sync can now log in to a fossil(1) instance running [fossil:/timeline?b=xfer-login-card | the xfer-login-card branch].
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d3662155ca7eafe53eea999db8a0702ea6e466f883ebc193f8eb01d390d6e111
User & Date: stephan 2025-07-22 17:51:39.950
Context
2025-07-22
19:49
Add some random bytes in a comment to the bottom of each sync request payload, as fossil does, so that the login card nonces are more random. check-in: 157648a7f2 user: stephan tags: trunk
17:51
Minor internal cleanups. libfossil sync can now log in to a fossil(1) instance running [fossil:/timeline?b=xfer-login-card | the xfer-login-card branch]. check-in: d3662155ca user: stephan tags: trunk
17:42
Fix an SHA1 init bug which caused fsl_sha1_shared_secret2() to give wrong results. This was the cause of the broken libf-to-fossil login, but this code is ancient (but also unused because sync was missing), so it did not occurr to me to look _there_ for the bug. check-in: 6e02acacfc user: stephan tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to f-apps/f-test-sync.c.
109
110
111
112
113
114
115












116
117
118
119
120
121
122

123

124
125
126
127
128
129
130
                           fsl_buffer const * b, .../*TBD*/){
  int rc = 0;
  (void)xf;
  MARKER(("NYI. Doing nothing for %" FSL_SIZE_T_PFMT
          " bytes of config section %s\n", b->used, zName));
  return rc;
}













static int fsl__rcv_pragma(fsl__xfer * const xf){
  int rc = 0;
  //unsigned char const * const * aTok = xf->line.aToken;
  assert( xf->line.nToken > 1 );
  if( 5==xf->line.nToken &&
      0==fsl_strcmp((char const *)xf->line.aToken[1], "server-version") ){

    xf->remote.version = atoi((char const *)xf->line.aToken[2]);

    if( xf->remote.version != 22701 ){
      rc = fsl_sc_error(xf->ch, FSL_RC_RANGE,
                        "libfossil currently requires remote fossil v22701");
    }
    goto end;
  }
  MARKER(("NYI. Doing nothing for %s\n", fsl_buffer_cstr(&xf->line.bRaw)));







>
>
>
>
>
>
>
>
>
>
>
>






|
>

>







109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
                           fsl_buffer const * b, .../*TBD*/){
  int rc = 0;
  (void)xf;
  MARKER(("NYI. Doing nothing for %" FSL_SIZE_T_PFMT
          " bytes of config section %s\n", b->used, zName));
  return rc;
}

static inline char const * fsl__xfer_tok_at(fsl__xfer const * const xf,
                                            int tokNdx){
  return (tokNdx>=0 && tokNdx<xf->line.nToken)
    ? (char const *)xf->line.aToken[tokNdx] : NULL;
}

static inline bool fsl__xfer_tok_match(fsl__xfer const * const xf,
                                       int tokNdx,
                                       char const * zStr){
  return 0==fsl_strcmp(fsl__xfer_tok_at(xf, tokNdx), zStr);
}

static int fsl__rcv_pragma(fsl__xfer * const xf){
  int rc = 0;
  //unsigned char const * const * aTok = xf->line.aToken;
  assert( xf->line.nToken > 1 );
  if( 5==xf->line.nToken &&
      (fsl__xfer_tok_match(xf, 1, "server-version")
       || fsl__xfer_tok_match(xf, 1, "client-version"))){
    xf->remote.version = atoi((char const *)xf->line.aToken[2]);
    MARKER(("\nremote: %s", fsl_buffer_cstr(&xf->line.bRaw)));
    if( xf->remote.version != 22701 ){
      rc = fsl_sc_error(xf->ch, FSL_RC_RANGE,
                        "libfossil currently requires remote fossil v22701");
    }
    goto end;
  }
  MARKER(("NYI. Doing nothing for %s\n", fsl_buffer_cstr(&xf->line.bRaw)));
Changes to src/sha1.c.
1
2
3
4
5
6
7
8
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 
/* vim: set ts=2 et sw=2 tw=80: */
#include "libfossil.h"
#include <assert.h>
#include <string.h> /* strlen() */
#include <stddef.h> /* NULL on linux */

#include <sys/types.h>
|







1
2
3
4
5
6
7
8
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
#include "libfossil.h"
#include <assert.h>
#include <string.h> /* strlen() */
#include <stddef.h> /* NULL on linux */

#include <sys/types.h>
Changes to src/sync.c.
458
459
460
461
462
463
464

465



466
467
468
469
470
471
472
    char const * const zPCKey =
      1 ? "project-code" : "parent-project-code"
      /* TODO: a way to tell it to use the parent-project-code (or some
         other project code, for that matter). */;
    char * zProjCode = fsl_config_get_text(xf->ch->f, FSL_CONFDB_REPO,
                                           zPCKey, NULL);
#endif

    char * zSSS = fsl_sha1_shared_secret2(xf->ch->f, xf->user.name, zPw, NULL);



#if 0
    if( !zProjCode ){
      if( 0==(rc = fsl_cx_err_get(xf->ch->f, 0, 0)) ){
        rc = fsl_sc_errorf(xf->ch, FSL_RC_ERROR, "Cannot determine %q", zPCKey);
      }
      goto end;
    }else







>
|
>
>
>







458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
    char const * const zPCKey =
      1 ? "project-code" : "parent-project-code"
      /* TODO: a way to tell it to use the parent-project-code (or some
         other project code, for that matter). */;
    char * zProjCode = fsl_config_get_text(xf->ch->f, FSL_CONFDB_REPO,
                                           zPCKey, NULL);
#endif
    char * zSSS = 1
      ? fsl_sha1_shared_secret2(xf->ch->f, xf->user.name, zPw, 0)
      : 0;
    /*MARKER(("\n[%s/%s/%s]=>\n%s\n",
      zProjCode, xf->user.name, zPw, zSSS));*/
#if 0
    if( !zProjCode ){
      if( 0==(rc = fsl_cx_err_get(xf->ch->f, 0, 0)) ){
        rc = fsl_sc_errorf(xf->ch, FSL_RC_ERROR, "Cannot determine %q", zPCKey);
      }
      goto end;
    }else