Allow environment variables to be used for Name.
When the Name starts with a $, the rest will be interpreted as the name of an environment variable containing the real Name. When Name is $HOST, but this environment variable does not exist, gethostname() will be used to set the Name. In both cases, illegal characters will be converted to underscores.
This commit is contained in:
parent
89f4574e0b
commit
535a55100b
5 changed files with 60 additions and 17 deletions
12
src/tincd.c
12
src/tincd.c
|
|
@ -337,16 +337,9 @@ static void indicator(int a, int b, void *p) {
|
|||
static bool keygen(int bits) {
|
||||
RSA *rsa_key;
|
||||
FILE *f;
|
||||
char *name = NULL;
|
||||
char *name = get_name();
|
||||
char *filename;
|
||||
|
||||
get_config_string(lookup_config(config_tree, "Name"), &name);
|
||||
|
||||
if(name && !check_id(name)) {
|
||||
fprintf(stderr, "Invalid name for myself!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Generating %d bits keys:\n", bits);
|
||||
rsa_key = RSA_generate_key(bits, 0x10001, indicator, NULL);
|
||||
|
||||
|
|
@ -386,8 +379,7 @@ static bool keygen(int bits) {
|
|||
PEM_write_RSAPublicKey(f, rsa_key);
|
||||
fclose(f);
|
||||
free(filename);
|
||||
if(name)
|
||||
free(name);
|
||||
free(name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue