summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/libnet/py_net.c60
-rw-r--r--source4/scripting/python/samba/netcmd/export.py2
-rw-r--r--source4/utils/net/config.mk1
-rw-r--r--source4/utils/net/net_time.c78
4 files changed, 50 insertions, 91 deletions
diff --git a/source4/libnet/py_net.c b/source4/libnet/py_net.c
index 569f3955bb..d6bd134fe5 100644
--- a/source4/libnet/py_net.c
+++ b/source4/libnet/py_net.c
@@ -106,26 +106,20 @@ static PyObject *py_net_set_password(py_net_Object *self, PyObject *args, PyObje
static const char py_net_set_password_doc[] = "set_password(account_name, domain_name, newpassword) -> True\n\n" \
"Set password for a user. You must supply credential with enough rights to do this.\n\n" \
"Sample usage is:\n" \
-"creds = samba.credentials.Credentials()\n" \
-"creds.set_username('admin_user')\n" \
-"creds.set_domain('domain_name')\n" \
-"creds.set_password('pass')\n\n" \
"net.set_password(account_name=<account_name>,\n" \
-" domain_name=creds.get_domain(),\n" \
-" newpassword=new_pass,\n" \
-" credentials=creds)\n";
+" domain_name=domain_name,\n" \
+" newpassword=new_pass)\n";
static PyObject *py_net_export_keytab(py_net_Object *self, PyObject *args, PyObject *kwargs)
{
struct libnet_export_keytab r;
TALLOC_CTX *mem_ctx;
- const char *kwnames[] = { "keytab", "creds", NULL };
- PyObject *py_creds;
+ const char *kwnames[] = { "keytab", NULL };
NTSTATUS status;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO:export_keytab", discard_const_p(char *, kwnames),
- &r.in.keytab_name, &py_creds)) {
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:export_keytab", discard_const_p(char *, kwnames),
+ &r.in.keytab_name)) {
return NULL;
}
@@ -146,10 +140,54 @@ static PyObject *py_net_export_keytab(py_net_Object *self, PyObject *args, PyObj
static const char py_net_export_keytab_doc[] = "export_keytab(keytab, name)\n\n"
"Export the DC keytab to a keytab file.";
+static PyObject *py_net_time(py_net_Object *self, PyObject *args, PyObject *kwargs)
+{
+ const char *kwnames[] = { "server_name", NULL };
+ union libnet_RemoteTOD r;
+ NTSTATUS status;
+ TALLOC_CTX *mem_ctx;
+ char timestr[64];
+ PyObject *ret;
+ struct tm *tm;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s",
+ discard_const_p(char *, kwnames), &r.generic.in.server_name))
+ return NULL;
+
+ r.generic.level = LIBNET_REMOTE_TOD_GENERIC;
+
+ mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ status = libnet_RemoteTOD(self->libnet_ctx, mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ PyErr_SetString(PyExc_RuntimeError, r.generic.out.error_string);
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+
+ ZERO_STRUCT(timestr);
+ tm = localtime(&r.generic.out.time);
+ strftime(timestr, sizeof(timestr)-1, "%c %Z",tm);
+
+ ret = PyString_FromString(timestr);
+
+ talloc_free(mem_ctx);
+
+ return ret;
+}
+
+static const char py_net_time_doc[] = "time(server_name) -> timestr\n"
+"Retrieve the remote time on a server";
+
static PyMethodDef net_obj_methods[] = {
{"join", (PyCFunction)py_net_join, METH_VARARGS|METH_KEYWORDS, py_net_join_doc},
{"set_password", (PyCFunction)py_net_set_password, METH_VARARGS|METH_KEYWORDS, py_net_set_password_doc},
{"export_keytab", (PyCFunction)py_net_export_keytab, METH_VARARGS|METH_KEYWORDS, py_net_export_keytab_doc},
+ {"time", (PyCFunction)py_net_time, METH_VARARGS|METH_KEYWORDS, py_net_time_doc},
{ NULL }
};
diff --git a/source4/scripting/python/samba/netcmd/export.py b/source4/scripting/python/samba/netcmd/export.py
index 90b83689dd..9f1ff3d133 100644
--- a/source4/scripting/python/samba/netcmd/export.py
+++ b/source4/scripting/python/samba/netcmd/export.py
@@ -46,7 +46,7 @@ class cmd_export_keytab(Command):
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp)
net = Net(creds, lp)
- net.export_keytab(keytab=keytab, creds=creds)
+ net.export_keytab(keytab=keytab)
class cmd_export(SuperCommand):
diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk
index 5b1e696882..496d339bf8 100644
--- a/source4/utils/net/config.mk
+++ b/source4/utils/net/config.mk
@@ -41,7 +41,6 @@ net_OBJ_FILES = $(addprefix $(utilssrcdir)/net/, \
net.o \
net_machinepw.o \
net_password.o \
- net_time.o \
net_join.o \
net_vampire.o \
net_user.o)
diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c
deleted file mode 100644
index 92e6e77481..0000000000
--- a/source4/utils/net/net_time.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- Samba Unix/Linux SMB client library
- Distributed SMB/CIFS Server Management Utility
-
- Copyright (C) 2004 Stefan Metzmacher (metze@samba.org)
-
- 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
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-#include "libnet/libnet.h"
-#include "utils/net/net.h"
-#include "system/time.h"
-#include "lib/events/events.h"
-
-/*
- * Code for getting the remote time
- */
-
-int net_time(struct net_context *ctx, int argc, const char **argv)
-{
- NTSTATUS status;
- struct libnet_context *libnetctx;
- union libnet_RemoteTOD r;
- const char *server_name;
- struct tm *tm;
- char timestr[64];
-
- if (argc > 0 && argv[0]) {
- server_name = argv[0];
- } else {
- return net_time_usage(ctx, argc, argv);
- }
-
- libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
- if (!libnetctx) {
- return -1;
- }
- libnetctx->cred = ctx->credentials;
-
- /* prepare to get the time */
- r.generic.level = LIBNET_REMOTE_TOD_GENERIC;
- r.generic.in.server_name = server_name;
-
- /* get the time */
- status = libnet_RemoteTOD(libnetctx, ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0,("net_time: %s\n",r.generic.out.error_string));
- return -1;
- }
-
- ZERO_STRUCT(timestr);
- tm = localtime(&r.generic.out.time);
- strftime(timestr, sizeof(timestr)-1, "%c %Z",tm);
-
- printf("%s\n",timestr);
-
- talloc_free(libnetctx);
-
- return 0;
-}
-
-int net_time_usage(struct net_context *ctx, int argc, const char **argv)
-{
- d_printf("net time <server> [options]\n");
- return 0;
-}