[SCM] Samba Shared Repository - branch v3-3-test updated -
release-3-2-0pre2-4293-gc69741c
Günther Deschner
gd at samba.org
Thu Oct 23 12:06:38 GMT 2008
The branch, v3-3-test has been updated
via c69741cf19828ffcb051727029022a319437ee39 (commit)
via bf5934ebc7c2207f4813a3019ca109ca3b7c84c0 (commit)
via a156ab0597f539aea36cafa3429c7646c9eb5d7f (commit)
via b6e11d038a7620b6dfcae157a5cc353f193b6fa6 (commit)
from 579732653fc2354575303dbde392eb9c4eb4d62c (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test
- Log -----------------------------------------------------------------
commit c69741cf19828ffcb051727029022a319437ee39
Author: Jeremy Allison <jra at samba.org>
Date: Mon Oct 20 16:34:56 2008 -0700
Fix warnings. Jeremy.
commit bf5934ebc7c2207f4813a3019ca109ca3b7c84c0
Author: Günther Deschner <gd at samba.org>
Date: Fri Sep 12 17:24:37 2008 +0200
netapi: add NetFile testsuite.
Guenther
commit a156ab0597f539aea36cafa3429c7646c9eb5d7f
Author: Günther Deschner <gd at samba.org>
Date: Mon Sep 22 19:31:44 2008 +0200
netapi: fix case statement in example NetUserSetModals code.
Guenther
commit b6e11d038a7620b6dfcae157a5cc353f193b6fa6
Author: Günther Deschner <gd at samba.org>
Date: Tue Sep 16 17:53:06 2008 +0200
netapi: start supporting NetUserSetInfo level 3.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source/lib/netapi/examples/user/user_modalsset.c | 1 +
source/lib/netapi/tests/Makefile.in | 2 +-
source/lib/netapi/tests/common.h | 2 +
source/lib/netapi/tests/netapitest.c | 5 +
.../{examples/file/file_enum.c => tests/netfile.c} | 137 ++++++++++----------
source/lib/netapi/tests/netgroup.c | 10 +-
source/lib/netapi/tests/netlocalgroup.c | 6 +-
source/lib/netapi/tests/netshare.c | 8 +-
source/lib/netapi/tests/netuser.c | 20 ++--
source/lib/netapi/user.c | 53 +++++++-
10 files changed, 145 insertions(+), 99 deletions(-)
copy source/lib/netapi/{examples/file/file_enum.c => tests/netfile.c} (56%)
Changeset truncated at 500 lines:
diff --git a/source/lib/netapi/examples/user/user_modalsset.c b/source/lib/netapi/examples/user/user_modalsset.c
index 57e1ef7..c6958a9 100644
--- a/source/lib/netapi/examples/user/user_modalsset.c
+++ b/source/lib/netapi/examples/user/user_modalsset.c
@@ -95,6 +95,7 @@ int main(int argc, const char **argv)
case 1:
case 2:
case 3:
+ break;
case 1001:
u1001.usrmod1001_min_passwd_len = 0;
buffer = (uint8_t *)&u1001;
diff --git a/source/lib/netapi/tests/Makefile.in b/source/lib/netapi/tests/Makefile.in
index d3f0663..339e367 100644
--- a/source/lib/netapi/tests/Makefile.in
+++ b/source/lib/netapi/tests/Makefile.in
@@ -44,7 +44,7 @@ bin/.dummy:
CMDLINE_OBJ = common.o
NETAPIBUFFER_OBJ = netapibuffer.o
-NETAPITEST_OBJ = netapitest.o netlocalgroup.o netuser.o netgroup.o netdisplay.o netshare.o $(CMDLINE_OBJ)
+NETAPITEST_OBJ = netapitest.o netlocalgroup.o netuser.o netgroup.o netdisplay.o netshare.o netfile.o $(CMDLINE_OBJ)
bin/netapitest at EXEEXT@: $(BINARY_PREREQS) $(NETAPITEST_OBJ)
@echo Linking $@
diff --git a/source/lib/netapi/tests/common.h b/source/lib/netapi/tests/common.h
index 5a32032..9320840 100644
--- a/source/lib/netapi/tests/common.h
+++ b/source/lib/netapi/tests/common.h
@@ -41,6 +41,8 @@ NET_API_STATUS netapitest_display(struct libnetapi_ctx *ctx,
const char *hostname);
NET_API_STATUS netapitest_share(struct libnetapi_ctx *ctx,
const char *hostname);
+NET_API_STATUS netapitest_file(struct libnetapi_ctx *ctx,
+ const char *hostname);
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
diff --git a/source/lib/netapi/tests/netapitest.c b/source/lib/netapi/tests/netapitest.c
index 8714402..4a38f72 100644
--- a/source/lib/netapi/tests/netapitest.c
+++ b/source/lib/netapi/tests/netapitest.c
@@ -84,6 +84,11 @@ int main(int argc, const char **argv)
goto out;
}
+ status = netapitest_file(ctx, hostname);
+ if (status) {
+ goto out;
+ }
+
out:
if (status != 0) {
printf("testsuite failed with: %s\n",
diff --git a/source/lib/netapi/examples/file/file_enum.c b/source/lib/netapi/tests/netfile.c
similarity index 56%
copy from source/lib/netapi/examples/file/file_enum.c
copy to source/lib/netapi/tests/netfile.c
index 5fbb285..bee3c2e 100644
--- a/source/lib/netapi/examples/file/file_enum.c
+++ b/source/lib/netapi/tests/netfile.c
@@ -1,6 +1,6 @@
/*
* Unix SMB/CIFS implementation.
- * NetFileEnum query
+ * NetFile testsuite
* Copyright (C) Guenther Deschner 2008
*
* This program is free software; you can redistribute it and/or modify
@@ -27,72 +27,25 @@
#include "common.h"
-int main(int argc, const char **argv)
+static NET_API_STATUS test_netfileenum(const char *hostname,
+ uint32_t level)
{
NET_API_STATUS status;
- struct libnetapi_ctx *ctx = NULL;
- const char *hostname = NULL;
- const char *basepath = NULL;
- const char *username = NULL;
- uint32_t level = 3;
- uint8_t *buffer = NULL;
uint32_t entries_read = 0;
uint32_t total_entries = 0;
uint32_t resume_handle = 0;
+ uint8_t *buffer = NULL;
int i;
struct FILE_INFO_2 *i2 = NULL;
struct FILE_INFO_3 *i3 = NULL;
- poptContext pc;
- int opt;
-
- struct poptOption long_options[] = {
- POPT_AUTOHELP
- POPT_COMMON_LIBNETAPI_EXAMPLES
- POPT_TABLEEND
- };
-
- status = libnetapi_init(&ctx);
- if (status != 0) {
- return status;
- }
-
- pc = poptGetContext("file_enum", argc, argv, long_options, 0);
-
- poptSetOtherOptionHelp(pc, "hostname basepath username level");
- while((opt = poptGetNextOpt(pc)) != -1) {
- }
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- hostname = poptGetArg(pc);
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- basepath = poptGetArg(pc);
-
- if (!poptPeekArg(pc)) {
- poptPrintHelp(pc, stderr, 0);
- goto out;
- }
- username = poptGetArg(pc);
-
- if (poptPeekArg(pc)) {
- level = atoi(poptGetArg(pc));
- }
-
- /* NetFileEnum */
+ printf("testing NetFileEnum level %d\n", level);
do {
-
status = NetFileEnum(hostname,
- basepath,
- username,
+ NULL,
+ NULL,
level,
&buffer,
(uint32_t)-1,
@@ -100,7 +53,6 @@ int main(int argc, const char **argv)
&total_entries,
&resume_handle);
if (status == 0 || status == ERROR_MORE_DATA) {
- printf("total entries: %d\n", total_entries);
switch (level) {
case 2:
i2 = (struct FILE_INFO_2 *)buffer;
@@ -109,38 +61,85 @@ int main(int argc, const char **argv)
i3 = (struct FILE_INFO_3 *)buffer;
break;
default:
- break;
+ return -1;
}
+
for (i=0; i<entries_read; i++) {
+
+ switch (level) {
+ case 2:
+ case 3:
+ break;
+ default:
+ break;
+ }
+
switch (level) {
case 2:
- printf("file_id: %d\n", i2->fi2_id);
i2++;
break;
case 3:
- printf("file_id: %d\n", i3->fi3_id);
- printf("permissions: %d\n", i3->fi3_permissions);
- printf("num_locks: %d\n", i3->fi3_num_locks);
- printf("pathname: %s\n", i3->fi3_pathname);
- printf("username: %s\n", i3->fi3_username);
i3++;
break;
- default:
- break;
}
}
NetApiBufferFree(buffer);
}
} while (status == ERROR_MORE_DATA);
+ if (status) {
+ return status;
+ }
+
+ return 0;
+}
+
+NET_API_STATUS netapitest_file(struct libnetapi_ctx *ctx,
+ const char *hostname)
+{
+ NET_API_STATUS status = 0;
+ uint32_t enum_levels[] = { 2, 3 };
+ int i;
+
+ printf("NetFile tests\n");
+
+ /* test enum */
+
+ for (i=0; i<ARRAY_SIZE(enum_levels); i++) {
+
+ status = test_netfileenum(hostname, enum_levels[i]);
+ if (status) {
+ NETAPI_STATUS(ctx, status, "NetFileEnum");
+ goto out;
+ }
+ }
+
+ /* basic queries */
+#if 0
+ {
+ uint32_t levels[] = { 2, 3 };
+ for (i=0; i<ARRAY_SIZE(levels); i++) {
+ uint8_t *buffer = NULL;
+
+ printf("testing NetFileGetInfo level %d\n", levels[i]);
+
+ status = NetFileGetInfo(hostname, fid, levels[i], &buffer);
+ if (status && status != 124) {
+ NETAPI_STATUS(ctx, status, "NetFileGetInfo");
+ goto out;
+ }
+ }
+ }
+#endif
+
+ status = 0;
+
+ printf("NetFile tests succeeded\n");
+ out:
if (status != 0) {
- printf("NetFileEnum failed with: %s\n",
+ printf("NetFile testsuite failed with: %s\n",
libnetapi_get_error_string(ctx, status));
- goto out;
}
- out:
- libnetapi_free(ctx);
- poptFreeContext(pc);
return status;
}
diff --git a/source/lib/netapi/tests/netgroup.c b/source/lib/netapi/tests/netgroup.c
index a89a772..51a21b3 100644
--- a/source/lib/netapi/tests/netgroup.c
+++ b/source/lib/netapi/tests/netgroup.c
@@ -36,14 +36,14 @@ static NET_API_STATUS test_netgroupenum(const char *hostname,
uint32_t total_entries = 0;
uint32_t resume_handle = 0;
int found_group = 0;
- const char *current_name;
+ const char *current_name = NULL;
uint8_t *buffer = NULL;
int i;
- struct GROUP_INFO_0 *info0;
- struct GROUP_INFO_1 *info1;
- struct GROUP_INFO_2 *info2;
- struct GROUP_INFO_3 *info3;
+ struct GROUP_INFO_0 *info0 = NULL;
+ struct GROUP_INFO_1 *info1 = NULL;
+ struct GROUP_INFO_2 *info2 = NULL;
+ struct GROUP_INFO_3 *info3 = NULL;
printf("testing NetGroupEnum level %d\n", level);
diff --git a/source/lib/netapi/tests/netlocalgroup.c b/source/lib/netapi/tests/netlocalgroup.c
index 0d82059..76c59c8 100644
--- a/source/lib/netapi/tests/netlocalgroup.c
+++ b/source/lib/netapi/tests/netlocalgroup.c
@@ -36,12 +36,12 @@ static NET_API_STATUS test_netlocalgroupenum(const char *hostname,
uint32_t total_entries = 0;
uint32_t resume_handle = 0;
int found_group = 0;
- const char *current_name;
+ const char *current_name = NULL;
uint8_t *buffer = NULL;
int i;
- struct LOCALGROUP_INFO_0 *info0;
- struct LOCALGROUP_INFO_1 *info1;
+ struct LOCALGROUP_INFO_0 *info0 = NULL;
+ struct LOCALGROUP_INFO_1 *info1 = NULL;
printf("testing NetLocalGroupEnum level %d\n", level);
diff --git a/source/lib/netapi/tests/netshare.c b/source/lib/netapi/tests/netshare.c
index 9446c30..84af9e0 100644
--- a/source/lib/netapi/tests/netshare.c
+++ b/source/lib/netapi/tests/netshare.c
@@ -36,13 +36,13 @@ static NET_API_STATUS test_netshareenum(const char *hostname,
uint32_t total_entries = 0;
uint32_t resume_handle = 0;
int found_share = 0;
- const char *current_name;
+ const char *current_name = NULL;
uint8_t *buffer = NULL;
int i;
- struct SHARE_INFO_0 *i0;
- struct SHARE_INFO_1 *i1;
- struct SHARE_INFO_2 *i2;
+ struct SHARE_INFO_0 *i0 = NULL;
+ struct SHARE_INFO_1 *i1 = NULL;
+ struct SHARE_INFO_2 *i2 = NULL;
printf("testing NetShareEnum level %d\n", level);
diff --git a/source/lib/netapi/tests/netuser.c b/source/lib/netapi/tests/netuser.c
index f1622e4..7bbc5ca 100644
--- a/source/lib/netapi/tests/netuser.c
+++ b/source/lib/netapi/tests/netuser.c
@@ -35,20 +35,20 @@ static NET_API_STATUS test_netuserenum(const char *hostname,
uint32_t entries_read = 0;
uint32_t total_entries = 0;
uint32_t resume_handle = 0;
- const char *current_name;
+ const char *current_name = NULL;
int found_user = 0;
uint8_t *buffer = NULL;
int i;
- struct USER_INFO_0 *info0;
- struct USER_INFO_1 *info1;
- struct USER_INFO_2 *info2;
- struct USER_INFO_3 *info3;
- struct USER_INFO_4 *info4;
- struct USER_INFO_10 *info10;
- struct USER_INFO_11 *info11;
- struct USER_INFO_20 *info20;
- struct USER_INFO_23 *info23;
+ struct USER_INFO_0 *info0 = NULL;
+ struct USER_INFO_1 *info1 = NULL;
+ struct USER_INFO_2 *info2 = NULL;
+ struct USER_INFO_3 *info3 = NULL;
+ struct USER_INFO_4 *info4 = NULL;
+ struct USER_INFO_10 *info10 = NULL;
+ struct USER_INFO_11 *info11 = NULL;
+ struct USER_INFO_20 *info20 = NULL;
+ struct USER_INFO_23 *info23 = NULL;
printf("testing NetUserEnum level %d\n", level);
diff --git a/source/lib/netapi/user.c b/source/lib/netapi/user.c
index 7edf1ce..2abc25d 100644
--- a/source/lib/netapi/user.c
+++ b/source/lib/netapi/user.c
@@ -108,18 +108,18 @@ static void convert_USER_INFO_X_to_samr_user_info21(struct USER_INFO_X *infoX,
infoX->usriX_workstations,
infoX->usriX_usr_comment,
&zero_parameters,
- 0,
+ infoX->usriX_user_id,
infoX->usriX_primary_group_id,
infoX->usriX_flags,
fields_present,
zero_logon_hours,
- 0,
- 0,
+ infoX->usriX_bad_pw_count,
+ infoX->usriX_num_logons,
infoX->usriX_country_code,
+ infoX->usriX_code_page,
0,
0,
- 0,
- 0);
+ infoX->usriX_password_expired);
}
/****************************************************************
@@ -132,6 +132,7 @@ static NTSTATUS construct_USER_INFO_X(uint32_t level,
struct USER_INFO_0 *u0 = NULL;
struct USER_INFO_1 *u1 = NULL;
struct USER_INFO_2 *u2 = NULL;
+ struct USER_INFO_3 *u3 = NULL;
struct USER_INFO_1003 *u1003 = NULL;
struct USER_INFO_1006 *u1006 = NULL;
struct USER_INFO_1007 *u1007 = NULL;
@@ -193,6 +194,37 @@ static NTSTATUS construct_USER_INFO_X(uint32_t level,
uX->usriX_country_code = u2->usri2_country_code;
uX->usriX_code_page = u2->usri2_code_page;
break;
+ case 3:
+ u3 = (struct USER_INFO_3 *)buffer;
+ uX->usriX_name = u3->usri3_name;
+ uX->usriX_password_age = u3->usri3_password_age;
+ uX->usriX_priv = u3->usri3_priv;
+ uX->usriX_home_dir = u3->usri3_home_dir;
+ uX->usriX_comment = u3->usri3_comment;
+ uX->usriX_flags = u3->usri3_flags;
+ uX->usriX_script_path = u3->usri3_script_path;
+ uX->usriX_auth_flags = u3->usri3_auth_flags;
+ uX->usriX_full_name = u3->usri3_full_name;
+ uX->usriX_usr_comment = u3->usri3_usr_comment;
+ uX->usriX_parms = u3->usri3_parms;
+ uX->usriX_workstations = u3->usri3_workstations;
+ uX->usriX_last_logon = u3->usri3_last_logon;
+ uX->usriX_last_logoff = u3->usri3_last_logoff;
+ uX->usriX_acct_expires = u3->usri3_acct_expires;
+ uX->usriX_max_storage = u3->usri3_max_storage;
+ uX->usriX_units_per_week= u3->usri3_units_per_week;
+ uX->usriX_logon_hours = u3->usri3_logon_hours;
+ uX->usriX_bad_pw_count = u3->usri3_bad_pw_count;
+ uX->usriX_num_logons = u3->usri3_num_logons;
+ uX->usriX_logon_server = u3->usri3_logon_server;
+ uX->usriX_country_code = u3->usri3_country_code;
+ uX->usriX_code_page = u3->usri3_code_page;
+ uX->usriX_user_id = u3->usri3_user_id;
+ uX->usriX_primary_group_id = u3->usri3_primary_group_id;
+ uX->usriX_profile = u3->usri3_profile;
+ uX->usriX_home_dir_drive = u3->usri3_home_dir_drive;
+ uX->usriX_password_expired = u3->usri3_password_expired;
+ break;
case 1003:
u1003 = (struct USER_INFO_1003 *)buffer;
uX->usriX_password = u1003->usri1003_password;
@@ -237,7 +269,6 @@ static NTSTATUS construct_USER_INFO_X(uint32_t level,
u1053 = (struct USER_INFO_1053 *)buffer;
uX->usriX_home_dir_drive = u1053->usri1053_home_dir_drive;
break;
- case 3:
case 4:
default:
return NT_STATUS_INVALID_INFO_CLASS;
@@ -1753,9 +1784,17 @@ WERROR NetUserSetInfo_r(struct libnetapi_ctx *ctx,
user_mask = SAMR_USER_ACCESS_SET_ATTRIBUTES |
SAMR_USER_ACCESS_GET_GROUPS;
break;
+ case 3:
+ user_mask = STD_RIGHT_READ_CONTROL_ACCESS |
+ STD_RIGHT_WRITE_DAC_ACCESS |
+ SAMR_USER_ACCESS_GET_GROUPS |
+ SAMR_USER_ACCESS_SET_PASSWORD |
+ SAMR_USER_ACCESS_SET_ATTRIBUTES |
+ SAMR_USER_ACCESS_GET_ATTRIBUTES |
+ SAMR_USER_ACCESS_SET_LOC_COM;
+ break;
case 1:
case 2:
- case 3:
case 4:
case 21:
case 22:
--
Samba Shared Repository
More information about the samba-cvs
mailing list