diff --git a/src/tools/sysdb/main.c b/src/tools/sysdb/main.c
index e5f20ea4bbfbaf8c151ec11aa6d20f218c1daf35..b22e11f0f89da462596783a000ffdcb2d70835fa 100644 (file)
--- a/src/tools/sysdb/main.c
+++ b/src/tools/sysdb/main.c
# endif
#endif /* READLINEs */
+#include <openssl/ssl.h>
+#include <openssl/err.h>
+
#ifndef DEFAULT_SOCKET
# define DEFAULT_SOCKET "unix:"LOCALSTATEDIR"/run/sysdbd.sock"
#endif
-static const char *
-get_homedir(void)
-{
- char *username = sdb_get_current_user();
-
- struct passwd pw_entry;
- struct passwd *result = NULL;
-
- /* needs to be static because we return a pointer into this buffer
- * to the caller */
- static char buf[1024];
-
- int status;
-
- if (username) {
- memset(&pw_entry, 0, sizeof(pw_entry));
- status = getpwnam_r(username, &pw_entry, buf, sizeof(buf), &result);
- }
- else
- status = -1;
-
- if (status || (! result)) {
- char errbuf[1024];
- sdb_log(SDB_LOG_WARNING, "Failed to determine home directory "
- "for user %s: %s", username,
- sdb_strerror(errno, errbuf, sizeof(errbuf)));
- free(username);
- return NULL;
- }
- free(username);
- return result->pw_dir;
-} /* get_homedir */
static void
exit_usage(char *name, int status)
{
const char *host = NULL;
- const char *homedir;
+ char *homedir;
char hist_file[1024] = "";
sdb_input_t input = SDB_INPUT_INIT;
if (! input.user)
exit(1);
+ SSL_load_error_strings();
+ OpenSSL_add_ssl_algorithms();
+
input.client = sdb_client_create(host);
if (! input.client) {
sdb_log(SDB_LOG_ERR, "Failed to create client object");
using_history();
- if ((homedir = get_homedir())) {
+ if ((homedir = sdb_get_homedir())) {
snprintf(hist_file, sizeof(hist_file) - 1,
"%s/.sysdb_history", homedir);
hist_file[sizeof(hist_file) - 1] = '\0';
+ free(homedir);
+ homedir = NULL;
errno = 0;
if (read_history(hist_file) && (errno != ENOENT)) {
sdb_client_destroy(input.client);
sdb_strbuf_destroy(input.input);
+
+ ERR_free_strings();
return 0;
} /* main */