From: Sebastian Harl Date: Fri, 12 Dec 2014 07:55:39 +0000 (+0100) Subject: Merged branch 'master' of git://git.tokkee.org/sysdb. X-Git-Tag: sysdb-0.7.0~112 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=13fe0f9ec3d161fab7a015054649910541d75f5e;p=sysdb.git Merged branch 'master' of git://git.tokkee.org/sysdb. --- 13fe0f9ec3d161fab7a015054649910541d75f5e diff --cc src/tools/sysdb/input.h index 0ba5c0a,b8501f4..ba2b32d --- a/src/tools/sysdb/input.h +++ b/src/tools/sysdb/input.h @@@ -33,6 -33,7 +33,7 @@@ typedef struct { sdb_client_t *client; - const char *user; ++ char *user; sdb_strbuf_t *input; size_t tokenizer_pos; diff --cc src/tools/sysdb/main.c index b3a73c6,6e10e8d..357ef34 --- a/src/tools/sysdb/main.c +++ b/src/tools/sysdb/main.c @@@ -264,23 -288,20 +263,23 @@@ main(int argc, char **argv if (! host) host = DEFAULT_SOCKET; - if (! user) - user = sdb_get_current_user(); - if (! input.user) { - input.user = get_current_user(); - if (! input.user) - exit(1); - } ++ if (! input.user) ++ input.user = sdb_get_current_user(); + else - user = strdup(user); - if (! user) ++ input.user = strdup(input.user); ++ if (! input.user) + exit(1); input.client = sdb_client_create(host); if (! input.client) { sdb_log(SDB_LOG_ERR, "Failed to create client object"); - free(user); ++ free(input.user); exit(1); } - if (sdb_client_connect(input.client, user)) { + if (sdb_client_connect(input.client, input.user)) { sdb_log(SDB_LOG_ERR, "Failed to connect to SysDBd"); sdb_client_destroy(input.client); - free(user); ++ free(input.user); exit(1); } @@@ -288,7 -309,6 +287,7 @@@ int status = execute_commands(input.client, commands); sdb_llist_destroy(commands); sdb_client_destroy(input.client); - free(user); ++ free(input.user); if ((status != SDB_CONNECTION_OK) && (status != SDB_CONNECTION_DATA)) exit(1); exit(0); @@@ -312,7 -332,6 +311,7 @@@ hist_file, sdb_strerror(errno, errbuf, sizeof(errbuf))); } } - free(user); ++ free(input.user); input.input = sdb_strbuf_create(2048); sdb_input_init(&input); diff --cc t/integration/query.sh index 5536c70,f8287b4..eb4ccd8 --- a/t/integration/query.sh +++ b/t/integration/query.sh @@@ -48,13 -48,8 +48,13 @@@ run_sysdbd -D -C "$SYSDBD_CONF wait_for_sysdbd sleep 3 +# Invalid user. +output="$( run_sysdb_nouser -H "$SOCKET_FILE" \ + -U $SYSDB_USER-invalid -c 'LIST hosts' 2>&1 )" && exit 1 +echo "$output" | grep -F 'Access denied' + # On parse errors, expect a non-zero exit code. - output="$( run_sysdb -H "$SOCKET_FILE" -c INVALID )" && exit 1 + output="$( run_sysdb -H "$SOCKET_FILE" -c INVALID 2>&1 )" && exit 1 echo "$output" | grep "Failed to parse query 'INVALID'" echo "$output" | grep "parse error: syntax error"