r25598: Add missing become_root/unbecome_root around calls of add_aliases.
[samba.git] / source / python / py_srvsvc.c
index 40827cc2ed31660c1edf0fee06d06f539849e1e9..94f4271674420665b658322add61ce4b97f7b01a 100644 (file)
@@ -5,7 +5,7 @@
    
    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 2 of the License, or
+   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,
@@ -14,8 +14,7 @@
    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, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "python/py_srvsvc.h"
@@ -28,6 +27,33 @@ static struct const_vals {
        char *name;
        uint32 value;
 } module_const_vals[] = {
+       { "SV_TYPE_WORKSTATION", SV_TYPE_WORKSTATION },
+       { "SV_TYPE_SERVER", SV_TYPE_SERVER },
+       { "SV_TYPE_SQLSERVER", SV_TYPE_SQLSERVER },
+       { "SV_TYPE_DOMAIN_CTRL", SV_TYPE_DOMAIN_CTRL },
+       { "SV_TYPE_DOMAIN_BAKCTRL", SV_TYPE_DOMAIN_BAKCTRL },
+       { "SV_TYPE_TIME_SOURCE", SV_TYPE_TIME_SOURCE },
+       { "SV_TYPE_AFP", SV_TYPE_AFP },
+       { "SV_TYPE_NOVELL", SV_TYPE_NOVELL },
+       { "SV_TYPE_DOMAIN_MEMBER", SV_TYPE_DOMAIN_MEMBER },
+       { "SV_TYPE_PRINTQ_SERVER", SV_TYPE_PRINTQ_SERVER },
+       { "SV_TYPE_DIALIN_SERVER", SV_TYPE_DIALIN_SERVER },
+       { "SV_TYPE_SERVER_UNIX", SV_TYPE_SERVER_UNIX },
+       { "SV_TYPE_NT", SV_TYPE_NT },
+       { "SV_TYPE_WFW", SV_TYPE_WFW },
+       { "SV_TYPE_SERVER_MFPN", SV_TYPE_SERVER_MFPN },
+       { "SV_TYPE_SERVER_NT", SV_TYPE_SERVER_NT },
+       { "SV_TYPE_POTENTIAL_BROWSER", SV_TYPE_POTENTIAL_BROWSER },
+       { "SV_TYPE_BACKUP_BROWSER", SV_TYPE_BACKUP_BROWSER },
+       { "SV_TYPE_MASTER_BROWSER", SV_TYPE_MASTER_BROWSER },
+       { "SV_TYPE_DOMAIN_MASTER", SV_TYPE_DOMAIN_MASTER },
+       { "SV_TYPE_SERVER_OSF", SV_TYPE_SERVER_OSF },
+       { "SV_TYPE_SERVER_VMS", SV_TYPE_SERVER_VMS },
+       { "SV_TYPE_WIN95_PLUS", SV_TYPE_WIN95_PLUS },
+       { "SV_TYPE_DFS_SERVER", SV_TYPE_DFS_SERVER },
+       { "SV_TYPE_ALTERNATE_XPORT", SV_TYPE_ALTERNATE_XPORT },
+       { "SV_TYPE_LOCAL_LIST_ONLY", SV_TYPE_LOCAL_LIST_ONLY },
+       { "SV_TYPE_DOMAIN_ENUM", SV_TYPE_DOMAIN_ENUM },
        { NULL },
 };
 
@@ -66,7 +92,7 @@ PyObject *srvsvc_netservergetinfo(PyObject *self, PyObject *args,
                return NULL;
        }
 
-       server = strdup(unc_name + 2);
+       server = SMB_STRDUP(unc_name + 2);
 
        if (strchr(server, '\\')) {
                char *c = strchr(server, '\\');
@@ -93,15 +119,25 @@ PyObject *srvsvc_netservergetinfo(PyObject *self, PyObject *args,
 
        ZERO_STRUCT(ctr);
 
-       status = cli_srvsvc_net_srv_get_info(cli, mem_ctx, level, &ctr);
+       status = rpccli_srvsvc_net_srv_get_info(cli->pipe_list, mem_ctx, level, &ctr);
 
        if (!NT_STATUS_IS_OK(status)) {
                PyErr_SetObject(srvsvc_error, py_werror_tuple(status));
                goto done;
        }
 
-       result = Py_None;
-       Py_INCREF(Py_None);
+       if (level != ctr.switch_value) {
+               PyErr_SetString(srvsvc_error, "container level value wrong");
+               goto done;
+       }
+
+       switch(level) {
+       case 101:
+               py_from_SRV_INFO_101(&result, &ctr.srv.sv101);
+               break;
+       }
+
+       Py_INCREF(result);
 
 done:
        if (mem_ctx)
@@ -121,32 +157,32 @@ static PyMethodDef srvsvc_methods[] = {
 
        { "setup_logging", (PyCFunction)py_setup_logging, 
          METH_VARARGS | METH_KEYWORDS, 
-         "Set up debug logging.
-
-Initialises Samba's debug logging system.  One argument is expected which
-is a boolean specifying whether debugging is interactive and sent to stdout
-or logged to a file.
-
-Example:
-
->>> srvsvc.setup_logging(interactive = 1)" },
+         "Set up debug logging.\n"
+"\n"
+"Initialises Samba's debug logging system.  One argument is expected which\n"
+"is a boolean specifying whether debugging is interactive and sent to stdout\n"
+"or logged to a file.\n"
+"\n"
+"Example:\n"
+"\n"
+">>> srvsvc.setup_logging(interactive = 1)" },
 
        { "get_debuglevel", (PyCFunction)get_debuglevel, 
          METH_VARARGS, 
-         "Set the current debug level.
-
-Example:
-
->>> srvsvc.get_debuglevel()
-0" },
+         "Set the current debug level.\n"
+"\n"
+"Example:\n"
+"\n"
+">>> srvsvc.get_debuglevel()\n"
+"0" },
 
        { "set_debuglevel", (PyCFunction)set_debuglevel, 
          METH_VARARGS, 
-         "Get the current debug level.
-
-Example:
-
->>> srvsvc.set_debuglevel(10)" },
+         "Get the current debug level.\n"
+"\n"
+"Example:\n"
+"\n"
+">>> srvsvc.set_debuglevel(10)" },
 
        { NULL }
 };