summaryrefslogtreecommitdiffstats
path: root/source/utils
diff options
context:
space:
mode:
Diffstat (limited to 'source/utils')
-rw-r--r--source/utils/net.c4
-rw-r--r--source/utils/net.h13
-rw-r--r--source/utils/net_help.c3
-rw-r--r--source/utils/net_rpc.c149
-rw-r--r--source/utils/net_rpc_join.c4
-rw-r--r--source/utils/net_rpc_rights.c413
-rw-r--r--source/utils/net_rpc_samsync.c8
-rw-r--r--source/utils/pdbedit.c6
-rw-r--r--source/utils/smbfilter.c4
-rw-r--r--source/utils/testprns.c18
10 files changed, 592 insertions, 30 deletions
diff --git a/source/utils/net.c b/source/utils/net.c
index 251e94db906..cfbc8aca512 100644
--- a/source/utils/net.c
+++ b/source/utils/net.c
@@ -602,8 +602,8 @@ static uint32 get_maxrid(void)
int num_entries = 0;
int i;
- if (!pdb_setsampwent(False)) {
- DEBUG(0, ("load_sampwd_entries: Unable to open passdb.\n"));
+ if (!pdb_setsampwent(False, 0)) {
+ DEBUG(0, ("get_maxrid: Unable to open passdb.\n"));
return 0;
}
diff --git a/source/utils/net.h b/source/utils/net.h
index 5e65ca0d4cd..2d9fbd16448 100644
--- a/source/utils/net.h
+++ b/source/utils/net.h
@@ -17,8 +17,21 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+/*
+ * A function of this type is passed to the '
+ * run_rpc_command' wrapper. Must go before the net_proto.h
+ * include
+ */
+
+typedef NTSTATUS (*rpc_command_fn)(const DOM_SID *, const char *,
+ struct cli_state *, TALLOC_CTX *, int, const char **);
+
+/* INCLUDE FILES */
+
#include "utils/net_proto.h"
+/* MACROS & DEFINES */
+
#define NET_FLAGS_MASTER 1
#define NET_FLAGS_DMB 2
diff --git a/source/utils/net_help.c b/source/utils/net_help.c
index 8286e853216..328e1344591 100644
--- a/source/utils/net_help.c
+++ b/source/utils/net_help.c
@@ -76,6 +76,9 @@ int net_help_user(int argc, const char **argv)
d_printf("\nnet [<method>] user ADD <name> [password] [-c container] "\
"[-F user flags] [misc. options]"\
" [targets]\n\tAdd specified user\n");
+ d_printf("\nnet [<method>] user RENAME <oldusername> <newusername>"\
+ " [targets]\n\tRename specified user\n\n");
+
net_common_methods_usage(argc, argv);
net_common_flags_usage(argc, argv);
diff --git a/source/utils/net_rpc.c b/source/utils/net_rpc.c
index 4c5544aa973..430649d81bb 100644
--- a/source/utils/net_rpc.c
+++ b/source/utils/net_rpc.c
@@ -37,10 +37,6 @@
**/
-/* A function of this type is passed to the 'run_rpc_command' wrapper */
-typedef NTSTATUS (*rpc_command_fn)(const DOM_SID *, const char *,
- struct cli_state *, TALLOC_CTX *, int, const char **);
-
/**
* Many of the RPC functions need the domain sid. This function gets
* it at the start of every run
@@ -100,7 +96,7 @@ static DOM_SID *net_get_remote_domain_sid(struct cli_state *cli, TALLOC_CTX *mem
* @return A shell status integer (0 for success)
*/
-static int run_rpc_command(struct cli_state *cli_arg, const int pipe_idx, int conn_flags,
+int run_rpc_command(struct cli_state *cli_arg, const int pipe_idx, int conn_flags,
rpc_command_fn fn,
int argc, const char **argv)
{
@@ -145,7 +141,7 @@ static int run_rpc_command(struct cli_state *cli_arg, const int pipe_idx, int co
}
if (!(conn_flags & NET_FLAGS_NO_PIPE)) {
- if (cli->nt_pipe_fnum)
+ if (cli->nt_pipe_fnum[cli->pipe_idx])
cli_nt_session_close(cli);
}
@@ -674,6 +670,133 @@ static NTSTATUS rpc_user_del_internals(const DOM_SID *domain_sid,
}
/**
+ * Rename a user on a remote RPC server
+ *
+ * All parameters are provided by the run_rpc_command function, except for
+ * argc, argv which are passes through.
+ *
+ * @param domain_sid The domain sid acquired from the remote server
+ * @param cli A cli_state connected to the server.
+ * @param mem_ctx Talloc context, destoyed on completion of the function.
+ * @param argc Standard main() style argc
+ * @param argv Standard main() style argv. Initial components are already
+ * stripped
+ *
+ * @return Normal NTSTATUS return.
+ **/
+
+static NTSTATUS rpc_user_rename_internals(const DOM_SID *domain_sid, const char *domain_name,
+ struct cli_state *cli, TALLOC_CTX *mem_ctx,
+ int argc, const char **argv) {
+
+ POLICY_HND connect_pol, domain_pol, user_pol;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ uint32 info_level = 7;
+ const char *old_name, *new_name;
+ uint32 *user_rid;
+ uint32 flags = 0x000003e8; /* Unknown */
+ uint32 num_rids, *name_types;
+ uint32 num_names = 1;
+ const char **names;
+ SAM_USERINFO_CTR *user_ctr;
+ SAM_USERINFO_CTR ctr;
+ SAM_USER_INFO_7 info7;
+
+ if (argc != 2) {
+ d_printf("New and old username must be specified\n");
+ rpc_user_usage(argc, argv);
+ return NT_STATUS_OK;
+ }
+
+ old_name = argv[0];
+ new_name = argv[1];
+
+ ZERO_STRUCT(ctr);
+ ZERO_STRUCT(user_ctr);
+
+ /* Get sam policy handle */
+
+ result = cli_samr_connect(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ /* Get domain policy handle */
+
+ result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ domain_sid, &domain_pol);
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ names = TALLOC_ARRAY(mem_ctx, const char *, num_names);
+ names[0] = old_name;
+ result = cli_samr_lookup_names(cli, mem_ctx, &domain_pol,
+ flags, num_names, names,
+ &num_rids, &user_rid, &name_types);
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ /* Open domain user */
+ result = cli_samr_open_user(cli, mem_ctx, &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS, user_rid[0], &user_pol);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ /* Query user info */
+ result = cli_samr_query_userinfo(cli, mem_ctx, &user_pol,
+ info_level, &user_ctr);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ ctr.switch_value = info_level;
+ ctr.info.id7 = &info7;
+
+ init_sam_user_info7(&info7, new_name);
+
+ /* Set new name */
+ result = cli_samr_set_userinfo(cli, mem_ctx, &user_pol,
+ info_level, &cli->user_session_key, &ctr);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ goto done;
+ }
+
+ done:
+ if (!NT_STATUS_IS_OK(result)) {
+ d_printf("Failed to rename user from %s to %s - %s\n", old_name, new_name,
+ nt_errstr(result));
+ } else {
+ d_printf("Renamed user from %s to %s\n", old_name, new_name);
+ }
+ return result;
+}
+
+
+/**
+ * Rename a user on a remote RPC server
+ *
+ * @param argc Standard main() style argc
+ * @param argv Standard main() style argv. Initial components are already
+ * stripped
+ *
+ * @return A shell status integer (0 for success)
+ **/
+
+static int rpc_user_rename(int argc, const char **argv)
+{
+ return run_rpc_command(NULL, PI_SAMR, 0, rpc_user_rename_internals,
+ argc, argv);
+}
+
+/**
* Delete a user from a remote RPC server
*
* @param argc Standard main() style argc
@@ -1015,6 +1138,7 @@ int net_rpc_user(int argc, const char **argv)
{"info", rpc_user_info},
{"delete", rpc_user_delete},
{"password", rpc_user_password},
+ {"rename", rpc_user_rename},
{NULL, NULL}
};
@@ -4008,7 +4132,7 @@ static NTSTATUS rpc_reg_shutdown_abort_internals(const DOM_SID *domain_sid,
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- result = cli_reg_abort_shutdown(cli, mem_ctx);
+ result = werror_to_ntstatus(cli_reg_abort_shutdown(cli, mem_ctx));
if (NT_STATUS_IS_OK(result)) {
d_printf("\nShutdown successfully aborted\n");
@@ -4149,7 +4273,7 @@ static NTSTATUS rpc_reg_shutdown_internals(const DOM_SID *domain_sid,
}
/* create an entry */
- result = cli_reg_shutdown(cli, mem_ctx, msg, timeout, opt_reboot, opt_force);
+ result = werror_to_ntstatus(cli_reg_shutdown(cli, mem_ctx, msg, timeout, opt_reboot, opt_force));
if (NT_STATUS_IS_OK(result)) {
d_printf("\nShutdown of remote machine succeeded\n");
@@ -4437,7 +4561,7 @@ static int rpc_trustdom_establish(int argc, const char **argv)
return -1;
}
- if (cli->nt_pipe_fnum)
+ if (cli->nt_pipe_fnum[cli->pipe_idx])
cli_nt_session_close(cli);
@@ -4504,7 +4628,7 @@ static int rpc_trustdom_establish(int argc, const char **argv)
return -1;
}
- if (cli->nt_pipe_fnum)
+ if (cli->nt_pipe_fnum[cli->pipe_idx])
cli_nt_session_close(cli);
talloc_destroy(mem_ctx);
@@ -5260,10 +5384,10 @@ int net_rpc_usage(int argc, const char **argv)
d_printf(" net rpc getsid \t\tfetch the domain sid into the local secrets.tdb\n");
d_printf(" net rpc vampire \t\tsyncronise an NT PDC's users and groups into the local passdb\n");
d_printf(" net rpc samdump \t\tdiplay an NT PDC's users, groups and other data\n");
- d_printf(" net rpc trustdom \t\tto create trusting domain's account\n"
- "\t\t\t\t\tor establish trust\n");
+ d_printf(" net rpc trustdom \t\tto create trusting domain's account or establish trust\n");
d_printf(" net rpc abortshutdown \tto abort the shutdown of a remote server\n");
d_printf(" net rpc shutdown \t\tto shutdown a remote server\n");
+ d_printf(" net rpc rights\t\tto manage privileges assigned to SIDs\n");
d_printf("\n");
d_printf("'net rpc shutdown' also accepts the following miscellaneous options:\n"); /* misc options */
d_printf("\t-r or --reboot\trequest remote server reboot on shutdown\n");
@@ -5332,6 +5456,7 @@ int net_rpc(int argc, const char **argv)
{"samdump", rpc_samdump},
{"vampire", rpc_vampire},
{"getsid", net_rpc_getsid},
+ {"rights", net_rpc_rights},
{"help", net_rpc_help},
{NULL, NULL}
};
diff --git a/source/utils/net_rpc_join.c b/source/utils/net_rpc_join.c
index 79c632f8314..f1a41c7c99c 100644
--- a/source/utils/net_rpc_join.c
+++ b/source/utils/net_rpc_join.c
@@ -78,7 +78,7 @@ static int net_rpc_join_ok(const char *domain)
done:
/* Close down pipe - this will clean up open policy handles */
- if (cli->nt_pipe_fnum)
+ if (cli->nt_pipe_fnum[cli->pipe_idx])
cli_nt_session_close(cli);
cli_shutdown(cli);
@@ -347,7 +347,7 @@ int net_rpc_join_newstyle(int argc, const char **argv)
done:
/* Close down pipe - this will clean up open policy handles */
- if (cli->nt_pipe_fnum)
+ if (cli->nt_pipe_fnum[cli->pipe_idx])
cli_nt_session_close(cli);
/* Display success or failure */
diff --git a/source/utils/net_rpc_rights.c b/source/utils/net_rpc_rights.c
new file mode 100644
index 00000000000..feb50b457a8
--- /dev/null
+++ b/source/utils/net_rpc_rights.c
@@ -0,0 +1,413 @@
+/*
+ Samba Unix/Linux SMB client library
+ Distributed SMB/CIFS Server Management Utility
+ Copyright (C) Gerald (Jerry) Carter 2004
+
+ 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
+ (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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include "includes.h"
+#include "utils/net.h"
+
+/********************************************************************
+********************************************************************/
+
+static NTSTATUS sid_to_name(struct cli_state *cli,
+ TALLOC_CTX *mem_ctx,
+ DOM_SID *sid, fstring name)
+{
+ POLICY_HND pol;
+ uint32 *sid_types;
+ NTSTATUS result;
+ char **domains, **names;
+
+ result = cli_lsa_open_policy(cli, mem_ctx, True,
+ SEC_RIGHTS_MAXIMUM_ALLOWED, &pol);
+
+ if ( !NT_STATUS_IS_OK(result) )
+ return result;
+
+ result = cli_lsa_lookup_sids(cli, mem_ctx, &pol, 1, sid, &domains, &names, &sid_types);
+
+ if ( NT_STATUS_IS_OK(result) ) {
+ if ( *domains[0] )
+ fstr_sprintf( name, "%s\\%s", domains[0], names[0] );
+ else
+ fstrcpy( name, names[0] );
+ }
+
+ cli_lsa_close(cli, mem_ctx, &pol);
+ return result;
+}
+
+/********************************************************************
+********************************************************************/
+
+static NTSTATUS name_to_sid(struct cli_state *cli,
+ TALLOC_CTX *mem_ctx,
+ DOM_SID *sid, const char *name)
+{
+ POLICY_HND pol;
+ uint32 *sid_types;
+ NTSTATUS result;
+ DOM_SID *sids;
+
+ /* maybe its a raw SID */
+ if ( strncmp(name, "S-", 2) == 0 && string_to_sid(sid, name) )
+ {
+ return NT_STATUS_OK;
+ }
+
+ result = cli_lsa_open_policy(cli, mem_ctx, True,
+ SEC_RIGHTS_MAXIMUM_ALLOWED, &pol);
+
+ if ( !NT_STATUS_IS_OK(result) )
+ return result;
+
+ result = cli_lsa_lookup_names(cli, mem_ctx, &pol, 1, &name, &sids, &sid_types);
+
+ if ( NT_STATUS_IS_OK(result) )
+ sid_copy( sid, &sids[0] );
+
+ cli_lsa_close(cli, mem_ctx, &pol);
+ return result;
+}
+
+/********************************************************************
+********************************************************************/
+
+static NTSTATUS enum_privileges( TALLOC_CTX *ctx, struct cli_state *cli,
+ POLICY_HND *pol )
+{
+ NTSTATUS result;
+ uint32 enum_context = 0;
+ uint32 pref_max_length=0x1000;
+ uint32 count=0;
+ char **privs_name;
+ uint32 *privs_high;
+ uint32 *privs_low;
+ int i;
+ uint16 lang_id=0;
+ uint16 lang_id_sys=0;
+ uint16 lang_id_desc;
+ fstring description;
+
+ result = cli_lsa_enum_privilege(cli, ctx, pol, &enum_context,
+ pref_max_length, &count, &privs_name, &privs_high, &privs_low);
+
+ if ( !NT_STATUS_IS_OK(result) )
+ return result;
+
+ /* Print results */
+
+ for (i = 0; i < count; i++) {
+ d_printf("%30s ", privs_name[i] ? privs_name[i] : "*unknown*" );
+
+ /* try to get the description */
+
+ if ( !NT_STATUS_IS_OK(cli_lsa_get_dispname(cli, ctx, pol,
+ privs_name[i], lang_id, lang_id_sys, description, &lang_id_desc)) )
+ {
+ d_printf("??????\n");
+ continue;
+ }
+
+ d_printf("%s\n", description );
+ }
+
+ return NT_STATUS_OK;
+
+}
+
+/********************************************************************
+********************************************************************/
+
+static NTSTATUS enum_privileges_for_user( TALLOC_CTX *ctx, struct cli_state *cli,
+ POLICY_HND *pol, DOM_SID *sid )
+{
+ NTSTATUS result;
+ uint32 count;
+ char **rights;
+ int i;
+
+ result = cli_lsa_enum_account_rights(cli, ctx, pol, sid, &count, &rights);
+
+ if (!NT_STATUS_IS_OK(result))
+ return result;
+
+ if ( count == 0 )
+ d_printf("No privileges assigned\n");
+
+ for (i = 0; i < count; i++) {
+ printf("%s\n", rights[i]);
+ }
+
+ return NT_STATUS_OK;
+}
+
+/********************************************************************
+********************************************************************/
+
+static NTSTATUS enum_privileges_for_accounts( TALLOC_CTX *ctx, struct cli_state *cli,
+ POLICY_HND *pol )
+{
+ NTSTATUS result;
+ uint32 enum_context=0;
+ uint32 pref_max_length=0x1000;
+ DOM_SID *sids;
+ uint32 count=0;
+ int i;
+ fstring name;
+
+ result = cli_lsa_enum_sids(cli, ctx, pol, &enum_context,
+ pref_max_length, &count, &sids);
+
+ if (!NT_STATUS_IS_OK(result))
+ return result;
+
+ for ( i=0; i<count; i++ ) {
+
+ /* try to convert the SID to a name. Fall back to
+ printing the raw SID if necessary */
+
+ result = sid_to_name( cli, ctx, &sids[i], name );
+ if ( !NT_STATUS_IS_OK (result) )
+ fstrcpy( name, sid_string_static(&sids[i]) );
+
+ d_printf("%s\n", name);
+
+ result = enum_privileges_for_user( ctx, cli, pol, &sids[i] );
+
+ if ( !NT_STATUS_IS_OK(result) )
+ return result;
+
+ d_printf("\n");
+ }
+
+ return NT_STATUS_OK;
+}
+
+/********************************************************************
+********************************************************************/
+
+static NTSTATUS rpc_rights_list_internal( const DOM_SID *domain_sid, const char *domain_name,
+ struct cli_state *cli, TALLOC_CTX *mem_ctx,
+ int argc, const char **argv )
+{
+ POLICY_HND pol;
+ NTSTATUS result;
+ DOM_SID sid;
+
+ result = cli_lsa_open_policy(cli, mem_ctx, True,
+ SEC_RIGHTS_MAXIMUM_ALLOWED, &pol);
+
+ if ( !NT_STATUS_IS_OK(result) )
+ return result;
+
+ switch (argc) {
+ case 0:
+ result = enum_privileges( mem_ctx, cli, &pol );
+ break;
+
+ case 1:
+ /* special case to enuemrate all privileged SIDs
+ with associated rights */
+
+ if ( strequal( argv[0], "accounts" ) ) {
+ result = enum_privileges_for_accounts( mem_ctx, cli, &pol );
+ }
+ else {
+
+ result = name_to_sid(cli, mem_ctx, &sid, argv[0]);
+ if (!NT_STATUS_IS_OK(result))
+ goto done;
+ result = enum_privileges_for_user( mem_ctx, cli, &pol, &sid );
+ }
+ break;
+
+ default:
+ if ( argc > 1 ) {
+ d_printf("Usage: net rpc rights list [name|SID]\n");
+ result = NT_STATUS_OK;
+ }
+ }
+
+
+
+
+done:
+ cli_lsa_close(cli, mem_ctx, &pol);
+
+ return result;
+}
+
+/********************************************************************
+********************************************************************/
+
+static NTSTATUS rpc_rights_grant_internal( const DOM_SID *domain_sid, const char *domain_name,
+ struct cli_state *cli, TALLOC_CTX *mem_ctx,
+ int argc, const char **argv )
+{
+ POLICY_HND dom_pol;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+
+ DOM_SID sid;
+
+ if (argc < 2 ) {
+ d_printf("Usage: net rpc rights grant <name|SID> <rights...>\n");
+ return NT_STATUS_OK;
+ }
+
+ result = name_to_sid(cli, mem_ctx, &sid, argv[0]);
+ if (!NT_STATUS_IS_OK(result))
+ return result;
+
+ result = cli_lsa_open_policy2(cli, mem_ctx, True,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &dom_pol);
+
+ if (!NT_STATUS_IS_OK(result))
+ return result;
+
+ result = cli_lsa_add_account_rights(cli, mem_ctx, &dom_pol, sid,
+ argc-1, argv+1);
+
+ if (!NT_STATUS_IS_OK(result))
+ goto done;
+
+ d_printf("Successfully granted rights.\n");
+
+ done:
+ if ( !NT_STATUS_IS_OK(result) ) {
+ d_printf("Failed to grant privileges for %s (%s)\n",
+ argv[0], nt_errstr(result));
+ }
+
+ cli_lsa_close(cli, mem_ctx, &dom_pol);
+
+ return result;
+}
+
+/********************************************************************
+********************************************************************/
+
+static NTSTATUS rpc_rights_revoke_internal( const DOM_SID *domain_sid, const char *domain_name,
+ struct cli_state *cli, TALLOC_CTX *mem_ctx,
+ int argc, const char **argv )
+{
+ POLICY_HND dom_pol;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+
+ DOM_SID sid;
+
+ if (argc < 2 ) {
+ d_printf("Usage: net rpc rights revoke <name|SID> <rights...>\n");
+ return NT_STATUS_OK;
+ }
+
+ result = name_to_sid(cli, mem_ctx, &sid, argv[0]);
+ if (!NT_STATUS_IS_OK(result))
+ return result;
+
+ result = cli_lsa_open_policy2(cli, mem_ctx, True,
+ SEC_RIGHTS_MAXIMUM_ALLOWED,
+ &dom_pol);
+
+ if (!NT_STATUS_IS_OK(result))
+ return result;
+
+ result = cli_lsa_remove_account_rights(cli, mem_ctx, &dom_pol, sid,
+ False, argc-1, argv+1);
+
+ if (!NT_STATUS_IS_OK(result))
+ goto done;
+
+ d_printf("Successfully revoked rights.\n");
+
+done:
+ if ( !NT_STATUS_IS_OK(result) ) {
+ d_printf("Failed to revoke privileges for %s (%s)",
+ argv[0], nt_errstr(result));
+ }
+
+ cli_lsa_close(cli, mem_ctx, &dom_pol);
+
+ return result;
+}
+
+
+/********************************************************************
+********************************************************************/
+
+static int rpc_rights_list( int argc, const char **argv )
+{
+ return run_rpc_command( NULL, PI_LSARPC, 0,
+ rpc_rights_list_internal, argc, argv );
+}
+
+/********************************************************************
+********************************************************************/
+
+static int rpc_rights_grant( int argc, const char **argv )
+{
+ return run_rpc_command( NULL, PI_LSARPC, 0,
+ rpc_rights_grant_internal, argc, argv );
+}
+
+/********************************************************************
+********************************************************************/
+
+static int rpc_rights_revoke( int argc, const char **argv )
+{
+ return run_rpc_command( NULL, PI_LSARPC, 0,
+ rpc_rights_revoke_internal, argc, argv );
+}
+
+/********************************************************************
+********************************************************************/
+
+static int net_help_rights( int argc, const char **argv )
+{
+ d_printf("net rpc rights list [accounts|username] View available or assigned privileges\n");
+ d_printf("net rpc rights grant <name|SID> <right> Assign privilege[s]\n");
+ d_printf("net rpc rights revoke <name|SID> <right> Revoke privilege[s]\n");
+
+ d_printf("\nBoth 'grant' and 'revoke' require a SID and a list of privilege names.\n");
+ d_printf("For example\n");
+ d_printf("\n net rpc grant 'VALE\\biddle' SePrintOperatorPrivilege SeDiskOperatorPrivlege\n");
+ d_printf("\nwould grant the printer admin and disk manager rights to the user 'VALE\\biddle'\n\n");
+
+
+ return -1;
+}
+
+/********************************************************************
+********************************************************************/
+
+int net_rpc_rights(int argc, const char **argv)
+{
+ struct functable func[] = {
+ {"list", rpc_rights_list},
+ {"grant", rpc_rights_grant},
+ {"revoke", rpc_rights_revoke},
+ {NULL, NULL}
+ };
+
+ if ( argc )
+ return net_run_function( argc, argv, func, net_help_rights );
+
+ return net_help_rights( argc, argv );
+}
+
+
diff --git a/source/utils/net_rpc_samsync.c b/source/utils/net_rpc_samsync.c
index fccdc5f5ba5..320341ec050 100644
--- a/source/utils/net_rpc_samsync.c
+++ b/source/utils/net_rpc_samsync.c
@@ -445,6 +445,9 @@ sam_account_from_delta(SAM_ACCOUNT *account, SAM_ACCOUNT_INFO *delta)
stored_time = pdb_get_pass_last_set_time(account);
if (stored_time != unix_time)
pdb_set_pass_last_set_time(account, unix_time, PDB_CHANGED);
+ } else {
+ /* no last set time, make it now */
+ pdb_set_pass_last_set_time(account, time(NULL), PDB_CHANGED);
}
#if 0
@@ -1018,7 +1021,10 @@ static NTSTATUS fetch_domain_info(uint32 rid, SAM_DOMAIN_INFO *delta)
if (!account_policy_set(AP_RESET_COUNT_TIME, (uint32)u_lockoutreset/60))
return nt_status;
- if (!account_policy_set(AP_LOCK_ACCOUNT_DURATION, (uint32)u_lockouttime/60))
+ if (u_lockouttime != -1)
+ u_lockouttime /= 60;
+
+ if (!account_policy_set(AP_LOCK_ACCOUNT_DURATION, (uint32)u_lockouttime))
return nt_status;
if (!account_policy_set(AP_USER_MUST_LOGON_TO_CHG_PASS, delta->logon_chgpass))
diff --git a/source/utils/pdbedit.c b/source/utils/pdbedit.c
index ff08642f407..ea2faebdff4 100644
--- a/source/utils/pdbedit.c
+++ b/source/utils/pdbedit.c
@@ -64,7 +64,7 @@ static int export_database (struct pdb_context *in, struct pdb_context
DEBUG(3, ("called with username=\"%s\"\n", username));
- if (NT_STATUS_IS_ERR(in->pdb_setsampwent(in, 0))) {
+ if (NT_STATUS_IS_ERR(in->pdb_setsampwent(in, 0, 0))) {
fprintf(stderr, "Can't sampwent!\n");
return 1;
}
@@ -237,7 +237,7 @@ static int print_users_list (struct pdb_context *in, BOOL verbosity, BOOL smbpwd
SAM_ACCOUNT *sam_pwent=NULL;
BOOL check, ret;
- check = NT_STATUS_IS_OK(in->pdb_setsampwent(in, False));
+ check = NT_STATUS_IS_OK(in->pdb_setsampwent(in, False, 0));
if (!check) {
return 1;
}
@@ -266,7 +266,7 @@ static int fix_users_list (struct pdb_context *in)
SAM_ACCOUNT *sam_pwent=NULL;
BOOL check, ret;
- check = NT_STATUS_IS_OK(in->pdb_setsampwent(in, False));
+ check = NT_STATUS_IS_OK(in->pdb_setsampwent(in, False, 0));
if (!check) {
return 1;
}
diff --git a/source/utils/smbfilter.c b/source/utils/smbfilter.c
index 5d67c8fc7cf..3665647905d 100644
--- a/source/utils/smbfilter.c
+++ b/source/utils/smbfilter.c
@@ -34,7 +34,7 @@
static char *netbiosname;
static char packet[BUFFER_SIZE];
-static void save_file(const char *fname, void *packet, size_t length)
+static void save_file(const char *fname, void *ppacket, size_t length)
{
int fd;
fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0644);
@@ -42,7 +42,7 @@ static void save_file(const char *fname, void *packet, size_t length)
perror(fname);
return;
}
- if (write(fd, packet, length) != length) {
+ if (write(fd, ppacket, length) != length) {
fprintf(stderr,"Failed to write %s\n", fname);
return;
}
diff --git a/source/utils/testprns.c b/source/utils/testprns.c
index 7e52b86afb6..1525ab11d0f 100644
--- a/source/utils/testprns.c
+++ b/source/utils/testprns.c
@@ -32,14 +32,17 @@
#include "includes.h"
+/*
+ * NOTE: this code is likely to be removed, and no longer supports
+ * checking against non-configured printcap files. -Rob
+ */
+
int main(int argc, char *argv[])
{
- const char *pszTemp;
-
setup_logging(argv[0],True);
- if (argc < 2 || argc > 3)
- printf("Usage: testprns printername [printcapfile]\n");
+ if (argc != 2)
+ printf("Usage: testprns printername\n");
else
{
dbf = x_fopen("test.log", O_WRONLY|O_CREAT|O_TRUNC, 0644);
@@ -47,10 +50,9 @@ int main(int argc, char *argv[])
printf("Unable to open logfile.\n");
} else {
DEBUGLEVEL = 3;
- pszTemp = (argc < 3) ? PRINTCAP_NAME : argv[2];
- printf("Looking for printer %s in printcap file %s\n",
- argv[1], pszTemp);
- if (!pcap_printername_ok(argv[1], pszTemp))
+ printf("Looking for printer %s\n", argv[1]);
+ load_printers();
+ if (!pcap_printername_ok(argv[1]))
printf("Printer name %s is not valid.\n", argv[1]);
else
printf("Printer name %s is valid.\n", argv[1]);