[xiph-commits] r13568 - in experimental/moritz/iceadmin: . include
lib
moritz at svn.xiph.org
moritz at svn.xiph.org
Sat Aug 18 08:02:41 PDT 2007
Author: moritz
Date: 2007-08-18 08:02:41 -0700 (Sat, 18 Aug 2007)
New Revision: 13568
Removed:
experimental/moritz/iceadmin/lib/b64_ntop.txt
experimental/moritz/iceadmin/lib/strnstr.txt
Modified:
experimental/moritz/iceadmin/COPYING
experimental/moritz/iceadmin/configure.in
experimental/moritz/iceadmin/include/iceadmin.h
experimental/moritz/iceadmin/lib/Makefile.am
experimental/moritz/iceadmin/lib/iceadmin_internal.c
experimental/moritz/iceadmin/lib/iceadmin_internal.h
experimental/moritz/iceadmin/lib/libiceadmin.c
Log:
More ...
Modified: experimental/moritz/iceadmin/COPYING
===================================================================
--- experimental/moritz/iceadmin/COPYING 2007-08-18 12:18:18 UTC (rev 13567)
+++ experimental/moritz/iceadmin/COPYING 2007-08-18 15:02:41 UTC (rev 13568)
@@ -1,3 +1,89 @@
IceAdmin is Copyright (C) 2007 Moritz Grimm <mdgrimm at gmx.net>
IceAdmin does not exist, yet.
+
+
+
+Parts of IceAdmin are based on 3rd party code, with their own respective
+licenses:
+
+
+lib/iceadmin_internal.c:_iceadmin_strnstr(), based on strnstr() from
+$FreeBSD: src/lib/libc/string/strnstr.c,v 1.4 2007/01/09 00:28:12 imp Exp $:
+/*-
+ * Copyright (c) 2001 Mike Barcroft <mike at FreeBSD.org>
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+lib/iceadmin_internal.c:_iceadmin_base64_encode(), based on b64_ntop() from
+$OpenBSD: src/lib/libc/net/base64.c,v 1.5 2006/10/21 09:55:03 otto Exp $:
+/*
+ * Copyright (c) 1996 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/*
+ * Portions Copyright (c) 1995 by International Business Machines, Inc.
+ *
+ * International Business Machines, Inc. (hereinafter called IBM) grants
+ * permission under its copyrights to use, copy, modify, and distribute this
+ * Software with or without fee, provided that the above copyright notice and
+ * all paragraphs of this notice appear in all copies, and that the name of IBM
+ * not be used in connection with the marketing of any product incorporating
+ * the Software or modifications thereof, without specific, written prior
+ * permission.
+ *
+ * To the extent it has a right to do so, IBM grants an immunity from suit
+ * under its patents, if any, for the use, sale or manufacture of products to
+ * the extent that such products are used for performing Domain Name System
+ * dynamic updates in TCP/IP networks by means of the Software. No immunity is
+ * granted for any product per se or for any other function of any product.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
+ * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
+ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+*/
Modified: experimental/moritz/iceadmin/configure.in
===================================================================
--- experimental/moritz/iceadmin/configure.in 2007-08-18 12:18:18 UTC (rev 13567)
+++ experimental/moritz/iceadmin/configure.in 2007-08-18 15:02:41 UTC (rev 13568)
@@ -68,12 +68,6 @@
AC_C_CONST
AC_TYPE_SIZE_T
-AC_CHECK_MEMBER(struct sockaddr.sa_len,
- AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1,
- [Define whether we have struct sockaddr.sa_len]), ,
- [ #include <sys/types.h>
- #include <sys/socket.h> ]
-)
dnl USEFUL HEADERS
Modified: experimental/moritz/iceadmin/include/iceadmin.h
===================================================================
--- experimental/moritz/iceadmin/include/iceadmin.h 2007-08-18 12:18:18 UTC (rev 13567)
+++ experimental/moritz/iceadmin/include/iceadmin.h 2007-08-18 15:02:41 UTC (rev 13568)
@@ -51,7 +51,7 @@
/*
* Commands that work without a mountpoint.
* A buffer is allocated and its size stored. The buffer needs to be freed by
- * the caller.
+ * the caller with iceadmin_free().
*/
int iceadmin_cmd_get_stats(iceadmin_t /* handle */,
char ** /* buffer */,
@@ -69,7 +69,7 @@
/*
* Commands that require a mountpoint.
* A buffer is allocated and its size stored. The buffer needs to be freed by
- * the caller.
+ * the caller with iceadmin_free().
*/
int iceadmin_cmd_list_clients(iceadmin_t /* handle */,
char ** /* buffer */,
@@ -77,6 +77,12 @@
int iceadmin_cmd_list_xmlclients(iceadmin_t /* handle */,
char ** /* buffer */,
size_t * /* buffer size */);
+int iceadmin_cmd_auth_list_users(iceadmin_t /* handle */,
+ char ** /* buffer */,
+ size_t * /* buffer size */);
+int iceadmin_cmd_auth_list_xmlusers(iceadmin_t /* handle */,
+ char ** /* buffer */,
+ size_t * /* buffer size */);
/*
* Miscellaneous commands that work on a mountpoint.
@@ -93,6 +99,11 @@
int iceadmin_cmd_update_artist_title(iceadmin_t /* handle */,
const char * /* artist */,
const char * /* title */);
+int iceadmin_cmd_auth_adduser(iceadmin_t /* handle */,
+ const char * /* username */,
+ const char * /* password */);
+int iceadmin_cmd_auth_deluser(iceadmin_t /* handle */,
+ const char * /* username */);
__END_DECLS
#endif /* __ICEADMIN_H__ */
Modified: experimental/moritz/iceadmin/lib/Makefile.am
===================================================================
--- experimental/moritz/iceadmin/lib/Makefile.am 2007-08-18 12:18:18 UTC (rev 13567)
+++ experimental/moritz/iceadmin/lib/Makefile.am 2007-08-18 15:02:41 UTC (rev 13568)
@@ -10,7 +10,6 @@
AM_CFLAGS = @XML2_CFLAGS@
AM_CPPFLAGS = @XIPH_CPPFLAGS@ @XALLOC_CPPFLAGS@
-EXTRA_DIST = error.h iceadmin_internal.h xalloc.h \
- b64_ntop.txt strnstr.txt
+EXTRA_DIST = error.h iceadmin_internal.h xalloc.h
CLEANFILES = core *.core *~ .*~
Deleted: experimental/moritz/iceadmin/lib/b64_ntop.txt
===================================================================
--- experimental/moritz/iceadmin/lib/b64_ntop.txt 2007-08-18 12:18:18 UTC (rev 13567)
+++ experimental/moritz/iceadmin/lib/b64_ntop.txt 2007-08-18 15:02:41 UTC (rev 13568)
@@ -1,43 +0,0 @@
-License of the code used in _iceadmin_base64_encode()
-
-/*
- * Copyright (c) 1996 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-/*
- * Portions Copyright (c) 1995 by International Business Machines, Inc.
- *
- * International Business Machines, Inc. (hereinafter called IBM) grants
- * permission under its copyrights to use, copy, modify, and distribute this
- * Software with or without fee, provided that the above copyright notice and
- * all paragraphs of this notice appear in all copies, and that the name of IBM
- * not be used in connection with the marketing of any product incorporating
- * the Software or modifications thereof, without specific, written prior
- * permission.
- *
- * To the extent it has a right to do so, IBM grants an immunity from suit
- * under its patents, if any, for the use, sale or manufacture of products to
- * the extent that such products are used for performing Domain Name System
- * dynamic updates in TCP/IP networks by means of the Software. No immunity is
- * granted for any product per se or for any other function of any product.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
- * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
- * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
-*/
Modified: experimental/moritz/iceadmin/lib/iceadmin_internal.c
===================================================================
--- experimental/moritz/iceadmin/lib/iceadmin_internal.c 2007-08-18 12:18:18 UTC (rev 13567)
+++ experimental/moritz/iceadmin/lib/iceadmin_internal.c 2007-08-18 15:02:41 UTC (rev 13568)
@@ -160,11 +160,6 @@
return (buf1);
}
-/*
- * Based on b64_ntop() by IBM and ISC, from
- * $OpenBSD: src/lib/libc/net/base64.c,v 1.5 2006/10/21 09:55:03 otto Exp $
- * License is in b64_ntop.txt
- */
int
_iceadmin_base64_encode(const char *in, size_t inputlen, char **out_p, size_t *outputlen)
{
@@ -311,11 +306,6 @@
return (ICEADMIN_SUCCESS);
}
-/*
- * Based on FreeBSD's strnstr():
- * $FreeBSD: src/lib/libc/string/strnstr.c,v 1.4 2007/01/09 00:28:12 imp Exp $
- * License is in strnstr.txt
- */
char *
_iceadmin_strnstr(const char *s, const char *find, size_t slen, size_t *pos_p)
{
Modified: experimental/moritz/iceadmin/lib/iceadmin_internal.h
===================================================================
--- experimental/moritz/iceadmin/lib/iceadmin_internal.h 2007-08-18 12:18:18 UTC (rev 13567)
+++ experimental/moritz/iceadmin/lib/iceadmin_internal.h 2007-08-18 15:02:41 UTC (rev 13568)
@@ -19,6 +19,12 @@
#define PFX_KILL_CLIENT "/admin/killclient?"
/* Args: mount= */
#define PFX_KILL_SOURCE "/admin/killsource?"
+/* Args: mount= */
+#define PFX_AUTH_LISTUSERS "/admin/manageauth?"
+/* Args: mount=, username=, password= */
+#define PFX_AUTH_ADDUSER "/admin/manageauth?action=add&"
+/* Args: mount=, username= */
+#define PFX_AUTH_DELUSER "/admin/manageauth?action=delete&"
#ifndef BUFSIZ
# define BUFSIZ 1024
Modified: experimental/moritz/iceadmin/lib/libiceadmin.c
===================================================================
--- experimental/moritz/iceadmin/lib/libiceadmin.c 2007-08-18 12:18:18 UTC (rev 13567)
+++ experimental/moritz/iceadmin/lib/libiceadmin.c 2007-08-18 15:02:41 UTC (rev 13568)
@@ -26,17 +26,7 @@
#include "error.h"
#include "xalloc.h"
-#ifndef SA_LEN
-# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
-# define SA_LEN(x) ((x)->sa_len)
-# else
-# define SA_LEN(x) ((x)->sa_family == AF_INET6 ? \
- sizeof(struct sockaddr_in6) : \
- sizeof(struct sockaddr_in))
-# endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */
-#endif /* !SA_LEN */
-
char *_iceadmin_useragent = NULL;
void
@@ -230,7 +220,8 @@
if (iceadmin->initialized != 1)
return (ICEADMIN_BADHANDLE);
- if (iceadmin_cmd_get_xmlstats(iceadmin, &buf, &bufsize) != ICEADMIN_SUCCESS)
+ if (iceadmin_cmd_get_xmlstats(iceadmin, &buf, &bufsize)
+ != ICEADMIN_SUCCESS)
return (ICEADMIN_ERROR);
if ((doc = xmlParseMemory(buf, bufsize)) == NULL) {
@@ -241,7 +232,8 @@
}
xfree(buf);
- if (_iceadmin_format_xmltree(iceadmin, &buf, &bufsize, doc) != ICEADMIN_SUCCESS) {
+ if (_iceadmin_format_xmltree(iceadmin, &buf, &bufsize, doc)
+ != ICEADMIN_SUCCESS) {
xmlFreeDoc(doc);
return (ICEADMIN_ERROR);
}
@@ -324,7 +316,8 @@
if (iceadmin->initialized != 1)
return (ICEADMIN_BADHANDLE);
- if (iceadmin_cmd_list_xmlmounts(iceadmin, &buf, &bufsize) != ICEADMIN_SUCCESS)
+ if (iceadmin_cmd_list_xmlmounts(iceadmin, &buf, &bufsize)
+ != ICEADMIN_SUCCESS)
return (ICEADMIN_ERROR);
if ((doc = xmlParseMemory(buf, bufsize)) == NULL) {
@@ -335,7 +328,8 @@
}
xfree(buf);
- if (_iceadmin_format_xmltree(iceadmin, &buf, &bufsize, doc) != ICEADMIN_SUCCESS) {
+ if (_iceadmin_format_xmltree(iceadmin, &buf, &bufsize, doc)
+ != ICEADMIN_SUCCESS) {
xmlFreeDoc(doc);
return (ICEADMIN_ERROR);
}
@@ -420,7 +414,8 @@
if (iceadmin->mountpoint[0] == '\0')
return (ICEADMIN_ERROR);
- if (iceadmin_cmd_list_xmlclients(iceadmin, &buf, &bufsize) != ICEADMIN_SUCCESS)
+ if (iceadmin_cmd_list_xmlclients(iceadmin, &buf, &bufsize)
+ != ICEADMIN_SUCCESS)
return (ICEADMIN_ERROR);
if ((doc = xmlParseMemory(buf, bufsize)) == NULL) {
@@ -431,7 +426,8 @@
}
xfree(buf);
- if (_iceadmin_format_xmltree(iceadmin, &buf, &bufsize, doc) != ICEADMIN_SUCCESS) {
+ if (_iceadmin_format_xmltree(iceadmin, &buf, &bufsize, doc)
+ != ICEADMIN_SUCCESS) {
xmlFreeDoc(doc);
return (ICEADMIN_ERROR);
}
@@ -513,6 +509,116 @@
}
int
+iceadmin_cmd_auth_list_users(struct iceadmin *iceadmin,
+ char **buf_p, size_t *bufsize_p)
+{
+ char *buf;
+ size_t bufsize;
+ xmlDocPtr doc;
+
+ if (iceadmin == NULL || buf_p == NULL)
+ return (ICEADMIN_ABUSE);
+ if (iceadmin->initialized != 1)
+ return (ICEADMIN_BADHANDLE);
+ if (iceadmin->mountpoint[0] == '\0')
+ return (ICEADMIN_ERROR);
+
+ if (iceadmin_cmd_auth_list_xmlusers(iceadmin, &buf, &bufsize)
+ != ICEADMIN_SUCCESS)
+ return (ICEADMIN_ERROR);
+
+ if ((doc = xmlParseMemory(buf, bufsize)) == NULL) {
+ _set_error(iceadmin, 0, 0, "[%s]:%s: XML parse error (not well-formed)",
+ iceadmin->hostname, iceadmin->service);
+ xfree(buf);
+ return (ICEADMIN_ERROR);
+ }
+ xfree(buf);
+
+ if (_iceadmin_format_xmltree(iceadmin, &buf, &bufsize, doc)
+ != ICEADMIN_SUCCESS) {
+ xmlFreeDoc(doc);
+ return (ICEADMIN_ERROR);
+ }
+ xmlFreeDoc(doc);
+
+ *buf_p = buf;
+ if (bufsize_p != NULL)
+ *bufsize_p = bufsize;
+
+ return (ICEADMIN_SUCCESS);
+}
+
+int
+iceadmin_cmd_auth_list_xmlusers(struct iceadmin *iceadmin,
+ char **buf_p, size_t *bufsize_p)
+{
+ char *buf, *auth;
+ size_t bufsize;
+ int sock;
+ char static_buf[BUFSIZ];
+ unsigned int httpret;
+ int ret;
+ char *enc_mount;
+
+ if (iceadmin == NULL || buf_p == NULL)
+ return (ICEADMIN_ABUSE);
+ if (iceadmin->initialized != 1)
+ return (ICEADMIN_BADHANDLE);
+ if (iceadmin->mountpoint[0] == '\0')
+ return (ICEADMIN_ERROR);
+
+ if (_iceadmin_connect(iceadmin, &sock) != ICEADMIN_SUCCESS)
+ return (ICEADMIN_ERROR);
+
+ enc_mount = _iceadmin_url_encode(iceadmin->mountpoint);
+ auth = _iceadmin_auth_basic_string(iceadmin->username,
+ iceadmin->password);
+ ret = snprintf(static_buf, sizeof(static_buf), "GET %smount=%s HTTP/1.0\r\nUser-Agent: %s\r\n%s\r\n",
+ PFX_AUTH_LISTUSERS, enc_mount,
+ _iceadmin_useragent, auth);
+ if (ret < 0 || ret >= (int)sizeof(static_buf)) {
+ _set_error(iceadmin, 0, 0, "Bad request -- too long");
+ xfree(auth);
+ xfree(enc_mount);
+ return (ICEADMIN_ERROR);
+ }
+ xfree(auth);
+ xfree(enc_mount);
+
+ if (write(sock, static_buf, strlen(static_buf)) == -1) {
+ _set_error(iceadmin, 0, errno, "write: [%s]:%s",
+ iceadmin->hostname, iceadmin->service);
+ close(sock);
+ return (ICEADMIN_ERROR);
+ }
+
+ httpret = 0;
+ if (_iceadmin_read_http_reply(iceadmin, sock, &httpret)
+ != ICEADMIN_SUCCESS) {
+ close(sock);
+ if (httpret == 400)
+ _set_error(iceadmin, 0, 0, "[%s]:%s: Mountpoint '%s' not found",
+ iceadmin->hostname, iceadmin->service,
+ iceadmin->mountpoint);
+ return (ICEADMIN_ERROR);
+ }
+
+ if (_iceadmin_read_xml_data(iceadmin, sock, &buf, &bufsize)
+ != ICEADMIN_SUCCESS) {
+ close(sock);
+ return (ICEADMIN_ERROR);
+ }
+ close(sock);
+
+ *buf_p = buf;
+ if (bufsize_p != NULL)
+ *bufsize_p = bufsize;
+
+ return (ICEADMIN_SUCCESS);
+}
+
+int
iceadmin_cmd_kill_source(struct iceadmin *iceadmin)
{
char *auth;
@@ -629,7 +735,8 @@
}
close(sock);
- ret = _iceadmin_get_xml_reply(buf, bufsize, static_buf, sizeof(static_buf));
+ ret = _iceadmin_get_xml_reply(buf, bufsize, static_buf,
+ sizeof(static_buf));
xfree(buf);
switch (ret) {
@@ -841,7 +948,8 @@
}
close(sock);
- ret = _iceadmin_get_xml_reply(buf, bufsize, static_buf, sizeof(static_buf));
+ ret = _iceadmin_get_xml_reply(buf, bufsize, static_buf,
+ sizeof(static_buf));
xfree(buf);
switch (ret) {
@@ -930,6 +1038,106 @@
}
close(sock);
+ ret = _iceadmin_get_xml_reply(buf, bufsize, static_buf,
+ sizeof(static_buf));
+ xfree(buf);
+
+ switch (ret) {
+ case 1:
+ /* Okay */
+ break;
+ case 0:
+ _set_error(iceadmin, 0, 0, "[%s]:%s: %s",
+ iceadmin->hostname, iceadmin->service,
+ static_buf);
+ return (ICEADMIN_FAILURE);
+ default:
+ _set_error(iceadmin, 0, 0, "[%s]:%s: Bad XML reply",
+ iceadmin->hostname, iceadmin->service);
+ return (ICEADMIN_ERROR);
+ }
+
+ return (ICEADMIN_SUCCESS);
+}
+
+int
+iceadmin_cmd_auth_adduser(struct iceadmin *iceadmin, const char *username,
+ const char *password)
+{
+ char *buf, *auth;
+ size_t bufsize;
+ int sock;
+ char static_buf[BUFSIZ];
+ unsigned int httpret;
+ int ret;
+ char *enc_mount, *enc_user, *enc_pass;
+
+ if (iceadmin == NULL || username == NULL || password == NULL)
+ return (ICEADMIN_ABUSE);
+ if (iceadmin->initialized != 1)
+ return (ICEADMIN_BADHANDLE);
+ if (iceadmin->mountpoint[0] == '\0')
+ return (ICEADMIN_ERROR);
+
+ if (_iceadmin_connect(iceadmin, &sock) != ICEADMIN_SUCCESS)
+ return (ICEADMIN_ERROR);
+
+ enc_mount = _iceadmin_url_encode(iceadmin->mountpoint);
+ enc_user = _iceadmin_url_encode(username);
+ enc_pass = _iceadmin_url_encode(password);
+ auth = _iceadmin_auth_basic_string(iceadmin->username,
+ iceadmin->password);
+ ret = snprintf(static_buf, sizeof(static_buf), "GET %smount=%s&username=%s&password=%s HTTP/1.0\r\nUser-Agent: %s\r\n%s\r\n",
+ PFX_AUTH_ADDUSER, enc_mount, enc_user, enc_pass,
+ _iceadmin_useragent, auth);
+ if (ret < 0 || ret >= (int)sizeof(static_buf)) {
+ _set_error(iceadmin, 0, 0, "Bad request -- too long");
+ xfree(auth);
+ xfree(enc_pass);
+ xfree(enc_user);
+ xfree(enc_mount);
+ return (ICEADMIN_ERROR);
+ }
+ xfree(auth);
+ xfree(enc_pass);
+ xfree(enc_user);
+ xfree(enc_mount);
+
+ if (write(sock, static_buf, strlen(static_buf)) == -1) {
+ _set_error(iceadmin, 0, errno, "write: [%s]:%s",
+ iceadmin->hostname, iceadmin->service);
+ close(sock);
+ return (ICEADMIN_ERROR);
+ }
+
+ httpret = 0;
+ if (_iceadmin_read_http_reply(iceadmin, sock, &httpret)
+ != ICEADMIN_SUCCESS) {
+ close(sock);
+ switch (httpret) {
+ case 400:
+ _set_error(iceadmin, 0, 0, "[%s]:%s: Mountpoint '%s' not found",
+ iceadmin->hostname, iceadmin->service,
+ iceadmin->mountpoint);
+ break;
+ case 404:
+ _set_error(iceadmin, 0, 0, "[%s]:%s: No auth facility configured for mountpoint '%s'",
+ iceadmin->hostname, iceadmin->service,
+ iceadmin->mountpoint);
+ break;
+ default:
+ break;
+ }
+ return (ICEADMIN_ERROR);
+ }
+
+ if (_iceadmin_read_xml_data(iceadmin, sock, &buf, &bufsize)
+ != ICEADMIN_SUCCESS) {
+ close(sock);
+ return (ICEADMIN_ERROR);
+ }
+ close(sock);
+
ret = _iceadmin_get_xml_reply(buf, bufsize, static_buf, sizeof(static_buf));
xfree(buf);
@@ -950,3 +1158,99 @@
return (ICEADMIN_SUCCESS);
}
+
+int
+iceadmin_cmd_auth_deluser(struct iceadmin *iceadmin, const char *username)
+{
+ char *buf, *auth;
+ size_t bufsize;
+ int sock;
+ char static_buf[BUFSIZ];
+ unsigned int httpret;
+ int ret;
+ char *enc_mount, *enc_user;
+
+ if (iceadmin == NULL || username == NULL)
+ return (ICEADMIN_ABUSE);
+ if (iceadmin->initialized != 1)
+ return (ICEADMIN_BADHANDLE);
+ if (iceadmin->mountpoint[0] == '\0')
+ return (ICEADMIN_ERROR);
+
+ if (_iceadmin_connect(iceadmin, &sock) != ICEADMIN_SUCCESS)
+ return (ICEADMIN_ERROR);
+
+ enc_mount = _iceadmin_url_encode(iceadmin->mountpoint);
+ enc_user = _iceadmin_url_encode(username);
+ auth = _iceadmin_auth_basic_string(iceadmin->username,
+ iceadmin->password);
+ ret = snprintf(static_buf, sizeof(static_buf), "GET %smount=%s&username=%s HTTP/1.0\r\nUser-Agent: %s\r\n%s\r\n",
+ PFX_AUTH_DELUSER, enc_mount, enc_user,
+ _iceadmin_useragent, auth);
+ if (ret < 0 || ret >= (int)sizeof(static_buf)) {
+ _set_error(iceadmin, 0, 0, "Bad request -- too long");
+ xfree(auth);
+ xfree(enc_user);
+ xfree(enc_mount);
+ return (ICEADMIN_ERROR);
+ }
+ xfree(auth);
+ xfree(enc_user);
+ xfree(enc_mount);
+
+ if (write(sock, static_buf, strlen(static_buf)) == -1) {
+ _set_error(iceadmin, 0, errno, "write: [%s]:%s",
+ iceadmin->hostname, iceadmin->service);
+ close(sock);
+ return (ICEADMIN_ERROR);
+ }
+
+ httpret = 0;
+ if (_iceadmin_read_http_reply(iceadmin, sock, &httpret)
+ != ICEADMIN_SUCCESS) {
+ close(sock);
+ switch (httpret) {
+ case 400:
+ _set_error(iceadmin, 0, 0, "[%s]:%s: Mountpoint '%s' not found",
+ iceadmin->hostname, iceadmin->service,
+ iceadmin->mountpoint);
+ break;
+ case 404:
+ _set_error(iceadmin, 0, 0, "[%s]:%s: No auth facility configured for mountpoint '%s'",
+ iceadmin->hostname, iceadmin->service,
+ iceadmin->mountpoint);
+ break;
+ default:
+ break;
+ }
+ return (ICEADMIN_ERROR);
+ }
+
+ if (_iceadmin_read_xml_data(iceadmin, sock, &buf, &bufsize)
+ != ICEADMIN_SUCCESS) {
+ close(sock);
+ return (ICEADMIN_ERROR);
+ }
+ close(sock);
+
+ ret = _iceadmin_get_xml_reply(buf, bufsize, static_buf,
+ sizeof(static_buf));
+ xfree(buf);
+
+ switch (ret) {
+ case 1:
+ /* Okay */
+ break;
+ case 0:
+ _set_error(iceadmin, 0, 0, "[%s]:%s: %s",
+ iceadmin->hostname, iceadmin->service,
+ static_buf);
+ return (ICEADMIN_FAILURE);
+ default:
+ _set_error(iceadmin, 0, 0, "[%s]:%s: Bad XML reply",
+ iceadmin->hostname, iceadmin->service);
+ return (ICEADMIN_ERROR);
+ }
+
+ return (ICEADMIN_SUCCESS);
+}
Deleted: experimental/moritz/iceadmin/lib/strnstr.txt
===================================================================
--- experimental/moritz/iceadmin/lib/strnstr.txt 2007-08-18 12:18:18 UTC (rev 13567)
+++ experimental/moritz/iceadmin/lib/strnstr.txt 2007-08-18 15:02:41 UTC (rev 13568)
@@ -1,34 +0,0 @@
-License of the code used in _iceadmin_strnstr()
-
-/*-
- * Copyright (c) 2001 Mike Barcroft <mike at FreeBSD.org>
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
More information about the commits
mailing list