From a55c70c74f75d7b745d3560c862dac69b45ec367 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Fri, 21 Dec 2007 13:05:33 +0000 Subject: [PATCH] fill in some more gaps in the user database support Organization: Straylight/Edgeware From: Richard Kettlewell --- clients/disorder.c | 20 ++++++++++++++++++-- doc/disorder.1.in | 14 +++++++++++++- lib/client.c | 5 +++-- lib/client.h | 3 ++- scripts/completion.bash | 2 +- 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/clients/disorder.c b/clients/disorder.c index 215ec0c..1491b2e 100644 --- a/clients/disorder.c +++ b/clients/disorder.c @@ -427,13 +427,25 @@ static void cf_adduser(disorder_client *c, exit(EXIT_FAILURE); } +static void cf_deluser(disorder_client *c, + char **argv) { + if(disorder_deluser(c, argv[0])) + exit(EXIT_FAILURE); +} + static void cf_edituser(disorder_client *c, char **argv) { if(disorder_edituser(c, argv[0], argv[1], argv[2])) exit(EXIT_FAILURE); } -/* TODO: userinfo */ +static void cf_userinfo(disorder_client *c, char **argv) { + char *s; + + if(disorder_userinfo(c, argv[0], argv[1], &s)) + exit(EXIT_FAILURE); + xprintf("%s\n", nullcheck(utf82mb(s))); +} static const struct command { const char *name; @@ -450,13 +462,15 @@ static const struct command { "Authorize USER to connect to the server" }, { "become", 1, 1, cf_become, 0, "USER", "Become user USER" }, + { "deluser", 1, 1, cf_deluser, 0, "USER", + "Delete a user" }, { "dirs", 1, 2, cf_dirs, isarg_regexp, "DIR [~REGEXP]", "List directories in DIR" }, { "disable", 0, 0, cf_disable, 0, "", "Disable play" }, { "disable-random", 0, 0, cf_random_disable, 0, "", "Disable random play" }, - { "edituser", 3, 3, cf_edituser, 0, "USER KEY VALUE", + { "edituser", 3, 3, cf_edituser, 0, "USER PROPERTY VALUE", "Set a property of a user" }, { "enable", 0, 0, cf_enable, 0, "", "Enable play" }, @@ -531,6 +545,8 @@ static const struct command { "Unset a preference" }, { "unset-global", 1, 1, cf_unset_global, 0, "NAME", "Unset a global preference" }, + { "userinfo", 2, 2, cf_userinfo, 0, "USER PROPERTY", + "Get a property of as user" }, { "users", 0, 0, cf_users, 0, "", "List all users" }, { "version", 0, 0, cf_version, 0, "", diff --git a/doc/disorder.1.in b/doc/disorder.1.in index 89863de..8e8c010 100644 --- a/doc/disorder.1.in +++ b/doc/disorder.1.in @@ -1,5 +1,5 @@ .\" -.\" Copyright (C) 2004, 2005, 2006 Richard Kettlewell +.\" Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell .\" .\" This program is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by @@ -54,6 +54,12 @@ Display version number. List all known commands. .SH COMMANDS .TP +.B adduser \fIUSER PASSWORD\fR +Create a new user with default rights. +.TP +.B deluser \fIUSER\fR +Delete a user. +.TP .B dirs \fIDIRECTORY\fR [\fB~\fIREGEXP\fR] List all the directories in \fIDIRECTORY\fR. .IP @@ -63,6 +69,9 @@ directories with a basename matching the regexp will be returned. .B disable Disables playing after the current track finishes. .TP +.B edituser \fIUSER PROPERTY VALUE +Set some property of a user. +.TP .B enable (Re-)enable playing. .TP @@ -183,6 +192,9 @@ Unset the preference \fIKEY\fR for \fITRACK\fR. .B unset-global \fIKEY\fR Unset the global preference \fIKEY\fR. .TP +.B users +List known users. +.TP .B version Report the daemon's version number. .PP diff --git a/lib/client.c b/lib/client.c index 4fd2f48..e4792db 100644 --- a/lib/client.c +++ b/lib/client.c @@ -665,8 +665,9 @@ int disorder_deluser(disorder_client *c, const char *user) { return disorder_simple(c, 0, "deluser", user, (char *)0); } -int disorder_userinfo(disorder_client *c, const char *user, const char *key) { - return disorder_simple(c, 0, "userinfo", user, key, (char *)0); +int disorder_userinfo(disorder_client *c, const char *user, const char *key, + char **valuep) { + return disorder_simple(c, valuep, "userinfo", user, key, (char *)0); } int disorder_edituser(disorder_client *c, const char *user, diff --git a/lib/client.h b/lib/client.h index c81129d..f336de6 100644 --- a/lib/client.h +++ b/lib/client.h @@ -191,7 +191,8 @@ int disorder_rtp_address(disorder_client *c, char **addressp, char **portp); int disorder_adduser(disorder_client *c, const char *user, const char *password); int disorder_deluser(disorder_client *c, const char *user); -int disorder_userinfo(disorder_client *c, const char *user, const char *key); +int disorder_userinfo(disorder_client *c, const char *user, const char *key, + char **valuep); int disorder_edituser(disorder_client *c, const char *user, const char *key, const char *value); int disorder_users(disorder_client *c, diff --git a/scripts/completion.bash b/scripts/completion.bash index f9b823a..41da55a 100644 --- a/scripts/completion.bash +++ b/scripts/completion.bash @@ -31,7 +31,7 @@ complete -o default \ random-enable recent reconfigure remove rescan scratch search set set-volume shutdown stats unset version resolve part pause resume scratch-id get-global set-global unset-global - tags new rtp-address adduser users edituser + tags new rtp-address adduser users edituser deluser -h --help -H --help-commands --version -V --config -c --length --debug -d" \ disorder -- [mdw]