- if(get_config_string
- (lookup_config(c->config_tree, "PublicKeyFile"), &fname)) {
- if(is_safe_path(fname)) {
- fp = fopen(fname, "r");
-
- if(!fp) {
- syslog(LOG_ERR, _("Error reading RSA public key file `%s': %s"),
- fname, strerror(errno));
- free(fname);
- return -1;
- }
-
- free(fname);
- c->rsa_key = PEM_read_RSAPublicKey(fp, &c->rsa_key, NULL, NULL);
- fclose(fp);
-
- if(c->rsa_key)
- return 0; /* Woohoo. */
-
- /* If it fails, try PEM_read_RSA_PUBKEY. */
- fp = fopen(fname, "r");
-
- if(!fp) {
- syslog(LOG_ERR, _("Error reading RSA public key file `%s': %s"),
- fname, strerror(errno));
- free(fname);
- return -1;
- }
-
- free(fname);
- c->rsa_key = PEM_read_RSA_PUBKEY(fp, &c->rsa_key, NULL, NULL);
- fclose(fp);
-
- if(c->rsa_key)
- return 0;
-
- syslog(LOG_ERR, _("Reading RSA public key file `%s' failed: %s"),
- fname, strerror(errno));
- return -1;
- } else {
- free(fname);
- return -1;
- }
- }
-
- /* Else, check if a harnessed public key is in the config file */
+ if(!get_config_string(lookup_config(c->config_tree, "PublicKeyFile"), &fname))
+ xasprintf(&fname, "%s/hosts/%s", confbase, c->name);