Browse Source

Add share number to share's path

When auto-assigning a share number to a share, update the path
component to add the share number at the end.
develop
Damien Goutte-Gattat 5 years ago
parent
commit
1b727cac2e
  1. 7
      src/secret.c

7
src/secret.c

@ -364,6 +364,7 @@ gfsec_secret_add_share(gfsec_secret_t *secret, gfsec_share_t *share)
if ( share->number == GFSEC_SHARE_NUMBER_AUTOASSIGN ) {
unsigned nr, u;
char *tmp;
do {
nr = (random() & 0xFF00) >> 8;
@ -376,6 +377,12 @@ gfsec_secret_add_share(gfsec_secret_t *secret, gfsec_share_t *share)
} while ( nr == 0 );
share->number = nr;
if ( asprintf(&tmp, "%s.%03d", share->path, nr) == -1 )
return GFSEC_ERR_SYSTEM_ERROR;
free(share->path);
share->path = tmp;
}
secret->shares[secret->n_shares++] = share;

Loading…
Cancel
Save