-/*
- Samba Unix/Linux SMB client library
- Distributed SMB/CIFS Server Management Utility
+/*
+ Samba Unix/Linux SMB client library
+ Distributed SMB/CIFS Server Management Utility
Copyright (C) Rafal Szczesniak 2002
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/>.
*/
if (timeout_tm.tm_year != now_tm->tm_year ||
timeout_tm.tm_mon != now_tm->tm_mon ||
timeout_tm.tm_mday != now_tm->tm_mday) {
-
+
timeout_str = asctime(&timeout_tm);
if (!timeout_str) {
return;
- }
+ }
timeout_str[strlen(timeout_str) - 1] = '\0'; /* remove tailing CR */
} else {
asprintf(&alloc_str, "%.2d:%.2d:%.2d", timeout_tm.tm_hour,
}
timeout_str = alloc_str;
}
-
+
d_printf("Key: %s\t Timeout: %s\t Value: %s %s\n", keystr,
timeout_str, datastr, timeout > now_t ? "": "(expired)");
} else {
number_begin = 0;
}
-
+
/* unit detection */
len = strlen(timeout_str);
switch (timeout_str[len - 1]) {
case 'd':
case 'w': unit = timeout_str[len - 1];
}
-
+
/* number detection */
len = (sign) ? strlen(&timeout_str[number_begin]) : len;
number_end = (unit) ? len - 1 : len;
number = SMB_STRNDUP(&timeout_str[number_begin], number_end);
-
+
/* calculate actual timeout value */
timeout = (time_t)atoi(number);
case 'd': timeout *= 60*60*24; break;
case 'w': timeout *= 60*60*24*7; break; /* that's fair enough, I think :) */
}
-
+
switch (sign) {
case '!': timeout = time(NULL) - timeout; break;
case '+':
default: timeout += time(NULL); break;
}
-
+
if (number) SAFE_FREE(number);
- return timeout;
+ return timeout;
}
/**
* Add an entry to the cache. If it does exist, then set it.
- *
+ *
* @param c A net_context structure
* @param argv key, value and timeout are passed in command line
* @return 0 on success, otherwise failure
{
const char *keystr, *datastr, *timeout_str;
time_t timeout;
-
+
if (argc < 3) {
d_printf("\nUsage: net cache add <key string> <data string> <timeout>\n");
return -1;
}
-
+
keystr = argv[0];
datastr = argv[1];
timeout_str = argv[2];
-
+
/* parse timeout given in command line */
timeout = parse_timeout(timeout_str);
if (!timeout) {
d_fprintf(stderr, "Invalid timeout argument.\n");
return -1;
}
-
+
if (gencache_set(keystr, datastr, timeout)) {
d_printf("New cache entry stored successfully.\n");
gencache_shutdown();
return 0;
}
-
+
d_fprintf(stderr, "Entry couldn't be added. Perhaps there's already such a key.\n");
gencache_shutdown();
return -1;
/**
* Delete an entry in the cache
- *
+ *
* @param c A net_context structure
* @param argv key to delete an entry of
* @return 0 on success, otherwise failure
static int net_cache_del(struct net_context *c, int argc, const char **argv)
{
const char *keystr = argv[0];
-
+
if (argc < 1) {
d_printf("\nUsage: net cache del <key string>\n");
return -1;
}
-
+
if(gencache_del(keystr)) {
d_printf("Entry deleted.\n");
return 0;
/**
* Get and display an entry from the cache
- *
+ *
* @param c A net_context structure
* @param argv key to search an entry of
* @return 0 on success, otherwise failure
d_printf("\nUsage: net cache get <key>\n");
return -1;
}
-
+
if (gencache_get(keystr, &valuestr, &timeout)) {
print_cache_entry(keystr, valuestr, timeout, NULL);
return 0;
/**
* Search an entry/entries in the cache
- *
+ *
* @param c A net_context structure
* @param argv key pattern to match the entries to
* @return 0 on success, otherwise failure
static int net_cache_search(struct net_context *c, int argc, const char **argv)
{
const char* pattern;
-
+
if (argc < 1) {
d_printf("Usage: net cache search <pattern>\n");
return -1;
}
-
+
pattern = argv[0];
gencache_iterate(print_cache_entry, NULL, pattern);
return 0;
/**
* List the contents of the cache
- *
+ *
* @param c A net_context structure
* @param argv ignored in this functionailty
* @return always returns 0
/**
* Flush the whole cache
- *
+ *
* @param c A net_context structure
* @param argv ignored in this functionality
* @return always returns 0
if (c->opt_verbose || c->opt_long_list_entries)
long_list = True;
-
+
/* get the options */
for ( i=0; i<argc; i++ ) {
if ( !StrCaseCmp(argv[i], "verbose")) {
if ( !ntgroup[0] ) {
d_fprintf(stderr, "must supply a name\n");
return -1;
- }
+ }
}
else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
fstrcpy( sid_string, get_string_param( argv[i] ) );
if ( !sid_string[0] ) {
d_fprintf(stderr, "must supply a SID\n");
return -1;
- }
+ }
}
else {
d_fprintf(stderr, "Bad option: %s\n", argv[i]);
if ( ntgroup[0] || sid_string[0] ) {
DOM_SID sid;
GROUP_MAP map;
-
+
if ( sid_string[0] )
fstrcpy( ntgroup, sid_string);
-
+
if (!get_sid_from_input(&sid, ntgroup)) {
return -1;
}
d_fprintf(stderr, "Failure to local group SID in the database\n");
return -1;
}
-
+
print_map_entry( map, long_list );
}
else {
/* enumerate all group mappings */
if (!pdb_enum_group_mapping(NULL, SID_NAME_UNKNOWN, &map, &entries, ENUM_ALL_MAPPED))
return -1;
-
+
for (i=0; i<entries; i++) {
print_map_entry( map[i], long_list );
}
fstring type = "";
fstring ntcomment = "";
enum lsa_SidType sid_type = SID_NAME_DOM_GRP;
- uint32 rid = 0;
+ uint32 rid = 0;
gid_t gid;
int i;
GROUP_MAP map;
-
+
const char *name_type;
ZERO_STRUCT(map);
if ( !unixgrp[0] ) {
d_fprintf(stderr, "must supply a name\n");
return -1;
- }
+ }
}
else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
fstrcpy( ntgroup, get_string_param( argv[i] ) );
if ( !ntgroup[0] ) {
d_fprintf(stderr, "must supply a name\n");
return -1;
- }
+ }
}
else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
fstrcpy( string_sid, get_string_param( argv[i] ) );
if ( !string_sid[0] ) {
d_fprintf(stderr, "must supply a SID\n");
return -1;
- }
+ }
}
else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
fstrcpy( ntcomment, get_string_param( argv[i] ) );
if ( !ntcomment[0] ) {
d_fprintf(stderr, "must supply a comment string\n");
return -1;
- }
+ }
}
else if ( !StrnCaseCmp(argv[i], "type", strlen("type")) ) {
fstrcpy( type, get_string_param( argv[i] ) );
d_printf("Usage: net groupmap add {rid=<int>|sid=<string>} unixgroup=<string> [type=<domain|local|builtin>] [ntgroup=<string>] [comment=<string>]\n");
return -1;
}
-
+
if ( (gid = nametogid(unixgrp)) == (gid_t)-1 ) {
d_fprintf(stderr, "Can't lookup UNIX group %s\n", unixgrp);
return -1;
return -1;
}
}
-
+
if ( (rid == 0) && (string_sid[0] == '\0') ) {
d_printf("No rid or sid specified, choosing a RID\n");
if (pdb_rid_algorithm()) {
break;
}
}
-
+
if (!ntgroup[0] )
fstrcpy( ntgroup, unixgrp );
-
+
if (!NT_STATUS_IS_OK(add_initial_entry(gid, string_sid, sid_type, ntgroup, ntcomment))) {
d_fprintf(stderr, "adding entry for group %s failed!\n", ntgroup);
return -1;
if ( !ntgroup[0] ) {
d_fprintf(stderr, "must supply a name\n");
return -1;
- }
+ }
}
else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
fstrcpy( sid_string, get_string_param( argv[i] ) );
if ( !sid_string[0] ) {
d_fprintf(stderr, "must supply a name\n");
return -1;
- }
+ }
}
else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
fstrcpy( ntcomment, get_string_param( argv[i] ) );
if ( !ntcomment[0] ) {
d_fprintf(stderr, "must supply a comment string\n");
return -1;
- }
+ }
}
else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) {
fstrcpy( unixgrp, get_string_param( argv[i] ) );
if ( !unixgrp[0] ) {
d_fprintf(stderr, "must supply a group name\n");
return -1;
- }
+ }
}
else if ( !StrnCaseCmp(argv[i], "type", strlen("type")) ) {
fstrcpy( type, get_string_param( argv[i] ) );
return -1;
}
}
-
+
if ( !ntgroup[0] && !sid_string[0] ) {
d_printf("Usage: net groupmap modify {ntgroup=<string>|sid=<SID>} [comment=<string>] [unixgroup=<string>] [type=<domain|local>]\n");
return -1;
}
/* give preference to the SID; if both the ntgroup name and SID
- are defined, use the SID and assume that the group name could be a
+ are defined, use the SID and assume that the group name could be a
new name */
-
- if ( sid_string[0] ) {
+
+ if ( sid_string[0] ) {
if (!get_sid_from_input(&sid, sid_string)) {
return -1;
}
if (!get_sid_from_input(&sid, ntgroup)) {
return -1;
}
- }
+ }
/* Get the current mapping from the database */
if(!pdb_getgrsid(&map, sid)) {
d_fprintf(stderr, "Failure to local group SID in the database\n");
return -1;
}
-
+
/*
* Allow changing of group type only between domain and local
* We disallow changing Builtin groups !!! (SID problem)
- */
+ */
if (sid_type == SID_NAME_UNKNOWN) {
d_fprintf(stderr, "Can't map to an unknown group type.\n");
return -1;
/* Change comment if new one */
if ( ntcomment[0] )
fstrcpy( map.comment, ntcomment );
-
+
if ( ntgroup[0] )
fstrcpy( map.nt_name, ntgroup );
-
+
if ( unixgrp[0] ) {
gid = nametogid( unixgrp );
if ( gid == -1 ) {
unixgrp);
return -1;
}
-
+
map.gid = gid;
}
d_fprintf(stderr, "Could not update group database\n");
return -1;
}
-
+
d_printf("Updated mapping entry for %s\n", map.nt_name);
return 0;
if ( !ntgroup[0] ) {
d_fprintf(stderr, "must supply a name\n");
return -1;
- }
+ }
}
else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
fstrcpy( sid_string, get_string_param( argv[i] ) );
if ( !sid_string[0] ) {
d_fprintf(stderr, "must supply a SID\n");
return -1;
- }
+ }
}
else {
d_fprintf(stderr, "Bad option: %s\n", argv[i]);
return -1;
}
}
-
+
if ( !ntgroup[0] && !sid_string[0]) {
d_printf("Usage: net groupmap delete {ntgroup=<string>|sid=<SID>}\n");
return -1;
}
-
+
/* give preference to the SID if we have that */
-
+
if ( sid_string[0] )
fstrcpy( ntgroup, sid_string );
-
+
if ( !get_sid_from_input(&sid, ntgroup) ) {
d_fprintf(stderr, "Unable to resolve group %s to a SID\n", ntgroup);
return -1;
{
DOM_SID alias, member;
- if ( (argc != 2) ||
+ if ( (argc != 2) ||
!string_to_sid(&alias, argv[0]) ||
!string_to_sid(&member, argv[1]) ) {
d_printf("Usage: net groupmap addmem alias-sid member-sid\n");
"\n Set group mapping\n");
d_printf("net groupmap cleanup"\
"\n Remove foreign group mapping entries\n");
-
+
return -1;
}
d_fprintf(stderr, "You must be root to edit group mappings.\n");
return -1;
}
-
+
if ( argc )
return net_run_function(c, argc, argv, func, net_help_groupmap);
"net [<method>] share MIGRATE SHARES <sharename> [misc. options] [targets]"
"\n\tMigrates shares from remote to local server\n\n"
"net [<method>] share MIGRATE SECURITY <sharename> [misc. options] [targets]"
- "\n\tMigrates share-ACLs from remote to local server\n\n"
+ "\n\tMigrates share-ACLs from remote to local server\n\n"
"net [<method>] share MIGRATE ALL <sharename> [misc. options] [targets]"
"\n\tMigrates shares (including directories, files) from remote\n"
"\tto local server\n\n"
int net_help(struct net_context *c, int argc, const char **argv)
{
struct functable func[] = {
- {"ADS", net_ads_help},
+ {"ADS", net_ads_help},
{"RAP", net_rap_help},
{"RPC", net_rpc_help},
-/*
- Samba Unix/Linux SMB client library
- Distributed SMB/CIFS Server Management Utility
+/*
+ Samba Unix/Linux SMB client library
+ Distributed SMB/CIFS Server Management Utility
Copyright (C) 2003 Andrew Bartlett (abartlet@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/>.
*/
initialize_krb5_error_table();
rc = krb5_init_context(&ctx);
if (rc) {
- DEBUG(1,("krb5_init_context failed (%s)\n",
+ DEBUG(1,("krb5_init_context failed (%s)\n",
error_message(rc)));
return -1;
}
return table[i].fn(c, argc-1, argv+1);
}
- /* Default to lookup a hostname so 'net lookup foo#1b' can be
+ /* Default to lookup a hostname so 'net lookup foo#1b' can be
used instead of 'net lookup host foo#1b'. The host syntax
- is a bit confusing as non #00 names can't really be
+ is a bit confusing as non #00 names can't really be
considered hosts as such. */
return net_lookup_host(c, argc, argv);
-/*
- Samba Unix/Linux SMB client library
- Distributed SMB/CIFS Server Management Utility
+/*
+ Samba Unix/Linux SMB client library
+ Distributed SMB/CIFS Server Management Utility
Copyright (C) 2001 Steve French (sfrench@us.ibm.com)
Copyright (C) 2001 Jim McDonough (jmcd@us.ibm.com)
Copyright (C) 2001 Andrew Tridgell (tridge@samba.org)
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 "utils/net.h"
-/* The following messages were for error checking that is not properly
+/* The following messages were for error checking that is not properly
reported at the moment. Which should be reinstated? */
#define ERRMSG_TARGET_WG_NOT_VALID "\nTarget workgroup option not valid "\
"except on net rap server command, ignored"
/***************************************************************************
list info on an open file
***************************************************************************/
-static void file_fn(const char * pPath, const char * pUser, uint16 perms,
+static void file_fn(const char * pPath, const char * pUser, uint16 perms,
uint16 locks, uint32 id)
{
d_printf("%-7.1d %-20.20s 0x%-4.2x %-6.1d %s\n",
id, pUser, perms, locks, pPath);
}
-static void one_file_fn(const char *pPath, const char *pUser, uint16 perms,
+static void one_file_fn(const char *pPath, const char *pUser, uint16 perms,
uint16 locks, uint32 id)
{
d_printf("File ID %d\n"\
int ret;
if (argc == 0)
return net_rap_file_usage(c, argc, argv);
-
+
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
{"INFO", rap_file_info},
{NULL, NULL}
};
-
+
if (argc == 0) {
struct cli_state *cli;
int ret;
-
+
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
cli_shutdown(cli);
return ret;
}
-
+
return net_run_function(c, argc, argv, func, net_rap_file_usage);
}
-
+
int net_rap_share_usage(struct net_context *c, int argc, const char **argv)
{
return net_help_share(c, argc, argv);
}
-static void long_share_fn(const char *share_name, uint32 type,
+static void long_share_fn(const char *share_name, uint32 type,
const char *comment, void *state)
{
d_printf("%-12s %-8.8s %-50s\n",
share_name, share_type[type], comment);
}
-static void share_fn(const char *share_name, uint32 type,
+static void share_fn(const char *share_name, uint32 type,
const char *comment, void *state)
{
d_printf("%s\n", share_name);
{
struct cli_state *cli;
int ret;
-
+
if (argc == 0) {
d_printf("\n\nShare name not specified\n");
return net_rap_share_usage(c, argc, argv);
{
struct cli_state *cli;
int ret;
-
+
RAP_SHARE_INFO_2 sinfo;
char *p;
char *sharename;
d_printf("\n\nShare name not specified\n");
return net_rap_share_usage(c, argc, argv);
}
-
+
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
sinfo.path = p+1;
memset(sinfo.password, '\0', sizeof(sinfo.password));
sinfo.reserved2 = '\0';
-
+
ret = cli_NetShareAdd(cli, &sinfo);
cli_shutdown(cli);
return ret;
if (argc == 0) {
struct cli_state *cli;
int ret;
-
+
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
-
+
if (c->opt_long_list_entries) {
d_printf(
"\nEnumerating shared resources (exports) on remote server:\n\n"\
return net_run_function(c, argc, argv, func, net_rap_share_usage);
}
-
+
int net_rap_session_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
net_common_flags_usage(c, argc, argv);
return -1;
}
-
+
static void list_sessions_func(char *wsname, char *username, uint16 conns,
uint16 opens, uint16 users, uint32 sess_time,
uint32 idle_time, uint32 user_flags, char *clitype)
int hrs = idle_time / 3600;
int min = (idle_time / 60) % 60;
int sec = idle_time % 60;
-
+
d_printf("\\\\%-18.18s %-20.20s %-18.18s %5d %2.2d:%2.2d:%2.2d\n",
wsname, username, clitype, opens, hrs, min, sec);
}
-static void display_session_func(const char *wsname, const char *username,
- uint16 conns, uint16 opens, uint16 users,
- uint32 sess_time, uint32 idle_time,
+static void display_session_func(const char *wsname, const char *username,
+ uint16 conns, uint16 opens, uint16 users,
+ uint32 sess_time, uint32 idle_time,
uint32 user_flags, const char *clitype)
{
int ihrs = idle_time / 3600;
"Guest logon %-20.20s\n"\
"Client Type %-40.40s\n"\
"Sess time %2.2d:%2.2d:%2.2d\n"\
- "Idle time %2.2d:%2.2d:%2.2d\n",
- username, wsname,
+ "Idle time %2.2d:%2.2d:%2.2d\n",
+ username, wsname,
(user_flags&0x0)?"yes":"no", clitype,
shrs, smin, ssec, ihrs, imin, isec);
}
const char *sessname;
struct cli_state *cli;
int ret;
-
+
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
- if (argc == 0)
+ if (argc == 0)
return net_rap_session_usage(c, argc, argv);
sessname = argv[0];
{
struct cli_state *cli;
int ret;
-
+
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
- if (argc == 0)
+ if (argc == 0)
return net_rap_session_usage(c, argc, argv);
ret = cli_NetSessionDel(cli, argv[0]);
if (argc == 0) {
struct cli_state *cli;
int ret;
-
+
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
return net_run_function(c, argc, argv, func, net_rap_session_usage);
}
-
+
/****************************************************************************
list a server name
****************************************************************************/
cli_shutdown(cli);
return 0;
}
-
+
int net_rap_server(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
"\tServer name Server description\n"\
"\t------------- ----------------------------\n");
- ret = cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL,
- display_server_func,NULL);
+ ret = cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL,
+ display_server_func,NULL);
cli_shutdown(cli);
- return ret;
+ return ret;
}
-
+
int net_rap_domain_usage(struct net_context *c, int argc, const char **argv)
{
d_printf("net rap domain [misc. options] [target]\n\tlists the"\
{
struct cli_state *cli;
int ret;
-
+
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
"\t------------- ----------------------------\n");
ret = cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_DOMAIN_ENUM,
- display_server_func,NULL);
+ display_server_func,NULL);
cli_shutdown(cli);
- return ret;
+ return ret;
}
-
+
int net_rap_printq_usage(struct net_context *c, int argc, const char **argv)
{
d_printf(
net_common_flags_usage(c, argc, argv);
return -1;
-}
+}
-static void enum_queue(const char *queuename, uint16 pri, uint16 start,
- uint16 until, const char *sep, const char *pproc,
- const char *dest, const char *qparms,
- const char *qcomment, uint16 status, uint16 jobcount)
+static void enum_queue(const char *queuename, uint16 pri, uint16 start,
+ uint16 until, const char *sep, const char *pproc,
+ const char *dest, const char *qparms,
+ const char *qcomment, uint16 status, uint16 jobcount)
{
d_printf("%-17.17s Queue %5d jobs ",
queuename, jobcount);
}
}
-static void enum_jobs(uint16 jobid, const char *ownername,
+static void enum_jobs(uint16 jobid, const char *ownername,
const char *notifyname, const char *datatype,
- const char *jparms, uint16 pos, uint16 status,
- const char *jstatus, unsigned int submitted, unsigned int jobsize,
+ const char *jparms, uint16 pos, uint16 status,
+ const char *jstatus, unsigned int submitted, unsigned int jobsize,
const char *comment)
{
d_printf(" %-23.23s %5d %9d ",
{
struct cli_state *cli;
int ret;
-
- if (argc == 0)
+
+ if (argc == 0)
return net_rap_printq_usage(c, argc, argv);
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
{
struct cli_state *cli;
int ret;
-
- if (argc == 0)
+
+ if (argc == 0)
return net_rap_printq_usage(c, argc, argv);
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
{
struct cli_state *cli;
int ret;
-
+
struct functable func[] = {
{"INFO", rap_printq_info},
{"DELETE", rap_printq_delete},
static int net_rap_user_usage(struct net_context *c, int argc, const char **argv)
{
return net_help_user(c, argc, argv);
-}
-
+}
+
static void user_fn(const char *user_name, void *state)
{
d_printf("%-21.21s\n", user_name);
}
static void long_user_fn(const char *user_name, const char *comment,
- const char * home_dir, const char * logon_script,
+ const char * home_dir, const char * logon_script,
void *state)
{
d_printf("%-21.21s %s\n",
{
struct cli_state *cli;
int ret;
-
+
if (argc == 0) {
d_printf("\n\nUser name not specified\n");
return net_rap_user_usage(c, argc, argv);
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
-
+
safe_strcpy(userinfo.user_name, argv[0], sizeof(userinfo.user_name)-1);
if (c->opt_flags == -1)
c->opt_flags = 0x21;
-
+
userinfo.userflags = c->opt_flags;
userinfo.reserved1 = '\0';
userinfo.comment = smb_xstrdup(c->opt_comment);
- userinfo.priv = 1;
+ userinfo.priv = 1;
userinfo.home_dir = NULL;
userinfo.logon_script = NULL;
cli_shutdown(cli);
goto done;
}
- ret = cli_RNetUserEnum0(cli, user_fn, NULL);
+ ret = cli_RNetUserEnum0(cli, user_fn, NULL);
cli_shutdown(cli);
goto done;
}
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
-
+
/* BB check for length 21 or smaller explicitly ? BB */
safe_strcpy(grinfo.group_name, argv[0], sizeof(grinfo.group_name)-1);
grinfo.reserved1 = '\0';
grinfo.comment = smb_xstrdup(c->opt_comment);
-
+
ret = cli_NetGroupAdd(cli, &grinfo);
cli_shutdown(cli);
return ret;
cli_shutdown(cli);
return ret;
}
- ret = cli_RNetGroupEnum0(cli, group_fn, NULL);
+ ret = cli_RNetGroupEnum0(cli, group_fn, NULL);
cli_shutdown(cli);
return ret;
}
d_printf("\n\nGroup or user name not specified\n");
return net_rap_groupmember_usage(c, argc, argv);
}
-
+
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
- ret = cli_NetGroupGetUsers(cli, argv[0], group_member_fn, NULL );
+ ret = cli_NetGroupGetUsers(cli, argv[0], group_member_fn, NULL );
cli_shutdown(cli);
return ret;
}
{"DELETE", rap_groupmember_delete},
{NULL, NULL}
};
-
+
return net_run_function(c, argc, argv, func, net_rap_groupmember_usage);
}
"\n\tStart named service on remote server\n");
d_printf("\nnet rap service STOP <name> [misc. options] [targets]\n"\
"\n\tStop named service on remote server\n");
-
+
net_common_flags_usage(c, argc, argv);
return -1;
}
d_printf("-----------------------------\n");
ret = cli_RNetServiceEnum(cli, long_group_fn, NULL);
}
- ret = cli_RNetServiceEnum(cli, service_fn, NULL);
+ ret = cli_RNetServiceEnum(cli, service_fn, NULL);
cli_shutdown(cli);
return ret;
}
{
d_printf(
"net rap password <user> <oldpwo> <newpw> [misc. options] [target]\n"\
- "\tchanges the password for the specified user at target\n");
-
+ "\tchanges the password for the specified user at target\n");
+
return -1;
}
{
struct cli_state *cli;
int ret;
-
- if (argc < 3)
+
+ if (argc < 3)
return net_rap_password_usage(c, argc, argv);
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
{
d_printf(
"net rap admin <remote command> [cmd args [env]] [misc. options] [targets]"\
- "\n\texecutes a remote command on an os/2 target server\n");
-
+ "\n\texecutes a remote command on an os/2 target server\n");
+
return -1;
}
{"VALIDATE", net_rap_validate},
{"GROUPMEMBER", net_rap_groupmember},
{"ADMIN", net_rap_admin},
- {"SERVICE", net_rap_service},
+ {"SERVICE", net_rap_service},
{"PASSWORD", net_rap_password},
{"HELP", net_rap_help},
{NULL, NULL}
};
-
+
return net_run_function(c, argc, argv, func, net_rap_usage);
}
-/*
- Samba Unix/Linux SMB client library
- Distributed SMB/CIFS Server Management Utility
+/*
+ Samba Unix/Linux SMB client library
+ Distributed SMB/CIFS Server Management Utility
Copyright (C) 2001 Andrew Bartlett (abartlet@samba.org)
Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com)
Copyright (C) 2004,2008 Guenther Deschner (gd@samba.org)
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 "utils/net.h"
* @brief RPC based subcommands for the 'net' utility.
*
* This file should contain much of the functionality that used to
- * be found in rpcclient, execpt that the commands should change
- * less often, and the fucntionality should be sane (the user is not
+ * be found in rpcclient, execpt that the commands should change
+ * less often, and the fucntionality should be sane (the user is not
* expected to know a rid/sid before they conduct an operation etc.)
*
* @todo Perhaps eventually these should be split out into a number
/**
* Many of the RPC functions need the domain sid. This function gets
- * it at the start of every run
+ * it at the start of every run
*
* @param cli A cli_state already connected to the remote machine
*
d_fprintf(stderr, "Could not initialise lsa pipe\n");
return result;
}
-
- result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, False,
+
+ result = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, False,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&pol);
if (!NT_STATUS_IS_OK(result)) {
* Run a single RPC command, from start to finish.
*
* @param pipe_name the pipe to connect to (usually a PIPE_ constant)
- * @param conn_flag a NET_FLAG_ combination. Passed to
+ * @param conn_flag a NET_FLAG_ combination. Passed to
* net_make_ipc_connection.
* @param argc Standard main() style argc
* @param argc Standard main() style argv. Initial components are already
int conn_flags,
rpc_command_fn fn,
int argc,
- const char **argv)
+ const char **argv)
{
struct cli_state *cli = NULL;
struct rpc_pipe_client *pipe_hnd = NULL;
}
/* Create mem_ctx */
-
+
if (!(mem_ctx = talloc_init("run_rpc_command"))) {
DEBUG(0, ("talloc_init() failed\n"));
cli_shutdown(cli);
return -1;
}
-
+
nt_status = net_get_remote_domain_sid(cli, mem_ctx, &domain_sid,
&domain_name);
if (!NT_STATUS_IS_OK(nt_status)) {
}
}
}
-
+
nt_status = fn(c, domain_sid, domain_name, cli, pipe_hnd, mem_ctx, argc, argv);
-
+
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(1, ("rpc command function failed! (%s)\n", nt_errstr(nt_status)));
} else {
DEBUG(5, ("rpc command function succedded\n"));
}
-
+
if (!(conn_flags & NET_FLAGS_NO_PIPE)) {
if (pipe_hnd) {
TALLOC_FREE(pipe_hnd);
if (!cli_arg) {
cli_shutdown(cli);
}
-
+
talloc_destroy(mem_ctx);
return (!NT_STATUS_IS_OK(nt_status));
}
-/**
+/**
* Force a change of the trust acccount password.
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * argc, argv which are passes through.
*
* @param domain_sid The domain sid aquired from the remote server
* @param cli A cli_state connected to the server.
static NTSTATUS rpc_changetrustpw_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
-
+
return trust_pw_find_change_and_store_it(pipe_hnd, mem_ctx, c->opt_target_workgroup);
}
-/**
+/**
* Force a change of the trust acccount password.
*
* @param argc Standard main() style argc
argc, argv);
}
-/**
+/**
* Join a domain, the old way.
*
- * This uses 'machinename' as the inital password, and changes it.
+ * This uses 'machinename' as the inital password, and changes it.
*
* The password should be created with 'server manager' or equiv first.
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * argc, argv which are passes through.
*
* @param domain_sid The domain sid aquired from the remote server
* @param cli A cli_state connected to the server.
static NTSTATUS rpc_oldjoin_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
- struct cli_state *cli,
+ const char *domain_name,
+ struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
-
+
fstring trust_passwd;
unsigned char orig_trust_passwd_hash[16];
NTSTATUS result;
return result;
}
- /*
+ /*
check what type of join - if the user want's to join as
a BDC, the server must agree that we are a BDC.
*/
} else {
sec_channel_type = get_sec_channel_type(NULL);
}
-
+
fstrcpy(trust_passwd, global_myname());
strlower_m(trust_passwd);
return result;
}
-/**
+/**
* Join a domain, the old way.
*
* @param argc Standard main() style argc
static int net_rpc_perform_oldjoin(struct net_context *c, int argc, const char **argv)
{
return run_rpc_command(c, NULL, PI_NETLOGON,
- NET_FLAGS_NO_PIPE | NET_FLAGS_ANONYMOUS | NET_FLAGS_PDC,
+ NET_FLAGS_NO_PIPE | NET_FLAGS_ANONYMOUS | NET_FLAGS_PDC,
rpc_oldjoin_internals,
argc, argv);
}
-/**
+/**
* Join a domain, the old way. This function exists to allow
- * the message to be displayed when oldjoin was explicitly
+ * the message to be displayed when oldjoin was explicitly
* requested, but not when it was implied by "net rpc join"
*
* @param argc Standard main() style argc
return rc;
}
-/**
+/**
* Basic usage function for 'net rpc join'
* @param argc Standard main() style argc
* @param argc Standard main() style argv. Initial components are already
**/
static int rpc_join_usage(struct net_context *c, int argc, const char **argv)
-{
+{
d_printf("net rpc join -U <username>[%%password] <type>[options]\n"\
"\t to join a domain with admin username & password\n"\
"\t\t password will be prompted if needed and none is specified\n"\
return -1;
}
-/**
+/**
* 'net rpc join' entrypoint.
* @param argc Standard main() style argc
* @param argc Standard main() style argv. Initial components are already
* stripped
*
- * Main 'net_rpc_join()' (where the admin username/password is used) is
+ * Main 'net_rpc_join()' (where the admin username/password is used) is
* in net_rpc_join.c
* Try to just change the password, but if that doesn't work, use/prompt
* for a username/password.
if ((net_rpc_perform_oldjoin(c, argc, argv) == 0))
return 0;
-
+
return net_rpc_join_newstyle(c, argc, argv);
}
-/**
+/**
* display info about a rpc domain
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passed through.
+ * argc, argv which are passed through.
*
* @param domain_sid The domain sid acquired from the remote server
* @param cli A cli_state connected to the server.
NTSTATUS rpc_info_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
return result;
}
-/**
+/**
* 'net rpc info' entrypoint.
* @param argc Standard main() style argc
* @param argc Standard main() style argv. Initial components are already
argc, argv);
}
-/**
+/**
* Fetch domain SID into the local secrets.tdb
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * 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.
static NTSTATUS rpc_getsid_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
-/**
+/**
* 'net rpc getsid' entrypoint.
* @param argc Standard main() style argc
* @param argc Standard main() style argv. Initial components are already
return net_help_user(c, argc, argv);
}
-/**
+/**
* Add a new user to a remote RPC server
*
* @param argc Standard main() style argc
return 0;
}
-/**
+/**
* 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.
+ * 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.
static NTSTATUS rpc_user_rename_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
-
+
/* Get domain policy handle */
result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
return result;
}
-/**
+/**
* Rename a user on a remote RPC server
*
* @param argc Standard main() style argc
argc, argv);
}
-/**
+/**
* Delete a user from a remote RPC server
*
* @param argc Standard main() style argc
return 0;
}
-/**
+/**
* Set a password for 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.
+ * 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.
static NTSTATUS rpc_user_password_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
- struct cli_state *cli,
+ const char *domain_name,
+ struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
rpc_user_usage(c, argc, argv);
return NT_STATUS_OK;
}
-
+
user = argv[0];
if (argv[1]) {
done:
return result;
-}
+}
-/**
+/**
* Set a user's password on a remote RPC server
*
* @param argc Standard main() style argc
argc, argv);
}
-/**
+/**
* List user's groups on a remote RPC server
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * 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.
static NTSTATUS rpc_user_info_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
-
+
/* Get domain policy handle */
result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
return result;
}
-/**
+/**
* List a user's groups from a remote RPC server
*
* @param argc Standard main() style argc
argc, argv);
}
-/**
+/**
* List users on a remote RPC server
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * 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.
static NTSTATUS rpc_user_list_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
-
+
/* Get domain policy handle */
result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
return result;
}
-/**
+/**
* 'net rpc user' entrypoint.
* @param argc Standard main() style argc
* @param argc Standard main() style argv. Initial components are already
{ "show", NULL, PI_SAMR, rpc_sh_user_show,
"Show info about a user" },
- { "edit", net_rpc_user_edit_cmds, 0, NULL,
+ { "edit", net_rpc_user_edit_cmds, 0, NULL,
"Show/Modify a user's fields" },
{ NULL, NULL, 0, NULL, NULL }
*
* @return Normal NTSTATUS return.
**/
-
+
static NTSTATUS rpc_group_delete_internals(struct net_context *c,
const DOM_SID *domain_sid,
const char *domain_name,
d_fprintf(stderr, "Unable to query group members of %s",argv[0]);
goto done;
}
-
+
if (c->opt_verbose) {
d_printf("Domain Group %s (rid: %d) has %d members\n",
argv[0],group_rid, rids->count);
MAXIMUM_ALLOWED_ACCESS,
rids->rids[i],
&user_pol);
-
+
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Unable to open group member %d\n",
rids->rids[i]);
rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol);
}
-
+
if (group_is_primary) {
d_fprintf(stderr, "Unable to delete group because some "
"of it's members have it as primary group\n");
result = NT_STATUS_MEMBERS_PRIMARY_GROUP;
goto done;
}
-
+
/* remove all group members */
for (i = 0; i < rids->count; i++)
{
if (c->opt_verbose)
d_printf("failed\n");
goto done;
- }
+ }
}
result = rpccli_samr_DeleteDomainGroup(pipe_hnd, mem_ctx,
result = NT_STATUS_UNSUCCESSFUL;
goto done;
}
-
+
if (NT_STATUS_IS_OK(result)) {
if (c->opt_verbose)
d_printf("Deleted %s '%s'\n",sid_type_lookup(name_types.ids[0]),argv[0]);
d_fprintf(stderr, "Deleting of %s failed: %s\n",argv[0],
get_friendly_nt_error_msg(result));
}
-
+
done:
- return result;
-
+ return result;
+
}
static int rpc_group_delete(struct net_context *c, int argc, const char **argv)
static NTSTATUS rpc_group_add_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
-
+
/* Get domain policy handle */
result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
4,
&group_info);
if (!NT_STATUS_IS_OK(result)) goto done;
-
+
done:
if (NT_STATUS_IS_OK(result))
DEBUG(5, ("add group succeeded\n"));
static NTSTATUS rpc_alias_add_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
MAXIMUM_ALLOWED_ACCESS,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) goto done;
-
+
/* Get domain policy handle */
result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
&alias_info);
if (!NT_STATUS_IS_OK(result)) goto done;
-
+
done:
if (NT_STATUS_IS_OK(result))
DEBUG(5, ("add alias succeeded\n"));
static NTSTATUS rpc_group_addmem_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
static NTSTATUS rpc_group_delmem_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
}
if (group_type == SID_NAME_ALIAS) {
- NTSTATUS result = rpc_del_aliasmem(pipe_hnd, mem_ctx,
+ NTSTATUS result = rpc_del_aliasmem(pipe_hnd, mem_ctx,
&group_sid, argv[1]);
if (!NT_STATUS_IS_OK(result)) {
argc, argv);
}
-/**
+/**
* List groups on a remote RPC server
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * 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.
static NTSTATUS rpc_group_list_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
-
+
/* Get domain policy handle */
result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
sid_to_fstring(sid_str, &alias_sids[i]);
if (c->opt_long_list_entries) {
- printf("%s %s\\%s %d\n", sid_str,
- domains[i] ? domains[i] : "*unknown*",
+ printf("%s %s\\%s %d\n", sid_str,
+ domains[i] ? domains[i] : "*unknown*",
names[i] ? names[i] : "*unknown*", types[i]);
} else {
if (domains[i])
TALLOC_FREE(lsa_pipe);
return NT_STATUS_OK;
}
-
+
static NTSTATUS rpc_group_members_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(result))
return result;
-
+
/* Get domain policy handle */
result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
static NTSTATUS rpc_group_rename_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
if (!NT_STATUS_IS_OK(result))
return result;
-
+
/* Get domain policy handle */
result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
argc, argv);
}
-/**
+/**
* 'net rpc group' entrypoint.
* @param argc Standard main() style argc
* @param argc Standard main() style argv. Initial components are already
{"rename", rpc_group_rename},
{NULL, NULL}
};
-
+
if (argc == 0) {
return run_rpc_command(c, NULL, PI_SAMR, 0,
rpc_group_list_internals,
return net_help_share(c, argc, argv);
}
-/**
+/**
* Add a share on a remote RPC server
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * 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.
**/
static NTSTATUS rpc_share_add_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,int argc,
argc, argv);
}
-/**
+/**
* Delete a share on a remote RPC server
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * 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.
**/
static NTSTATUS rpc_share_del_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
&result);
}
-/**
+/**
* Delete a share on a remote RPC server
*
* @param domain_sid The domain sid acquired from the remote server
return result;
}
-/**
+/**
* List shares on a remote RPC server
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * 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.
static NTSTATUS rpc_share_list_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
-/***
+/***
* 'net rpc share list' entrypoint.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
return False;
}
- if (!cli_tdis(cli))
+ if (!cli_tdis(cli))
return False;
return True;
/* skip builtin shares */
/* FIXME: should print$ be added too ? */
- if (strequal(netname,"IPC$") || strequal(netname,"ADMIN$") ||
- strequal(netname,"global"))
+ if (strequal(netname,"IPC$") || strequal(netname,"ADMIN$") ||
+ strequal(netname,"global"))
return False;
if (c->opt_exclude && in_list(netname, c->opt_exclude, False)) {
return check_share_availability(cli, netname);
}
-/**
+/**
* Migrate shares from a remote RPC server to the local RPC server
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passed through.
+ * argc, argv which are passed through.
*
* @param domain_sid The domain sid acquired from the remote server
* @param cli A cli_state connected to the server.
static NTSTATUS rpc_share_migrate_shares_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
if (!check_share_sanity(c, cli, info502.name, info502.type))
continue;
- /* finally add the share on the dst server */
+ /* finally add the share on the dst server */
printf("migrating: [%s], path: %s, comment: %s, without share-ACLs\n",
info502.name, info502.path, info502.comment);
}
-/**
+/**
* Migrate shares from a rpc-server to another
*
* @param argc Standard main() style argc
}
/**
- * Copy a file/dir
+ * Copy a file/dir
*
* @param f file_info
* @param mask current search mask
return;
}
- if (!NT_STATUS_IS_OK(nt_status))
- printf("could not handle dir %s: %s\n",
+ if (!NT_STATUS_IS_OK(nt_status))
+ printf("could not handle dir %s: %s\n",
dir, nt_errstr(nt_status));
/* search below that directory */
{
case NET_MODE_SHARE_MIGRATE:
nt_status = net_copy_file(c, local_state->mem_ctx,
- local_state->cli_share_src,
- local_state->cli_share_dst,
- filename, filename,
+ local_state->cli_share_src,
+ local_state->cli_share_dst,
+ filename, filename,
c->opt_acls? true : false,
c->opt_attrs? true : false,
c->opt_timestamps? true: false,
return;
}
- if (!NT_STATUS_IS_OK(nt_status))
- printf("could not handle file %s: %s\n",
+ if (!NT_STATUS_IS_OK(nt_status))
+ printf("could not handle file %s: %s\n",
filename, nt_errstr(nt_status));
}
/**
- * sync files, can be called recursivly to list files
- * and then call copy_fn for each file
+ * sync files, can be called recursivly to list files
+ * and then call copy_fn for each file
*
* @param cp_clistate pointer to the copy_clistate we work with
* @param mask the current search mask
}
if (cli_list(targetcli, targetpath, cp_clistate->attribute, copy_fn, cp_clistate) == -1) {
- d_fprintf(stderr, "listing %s failed with error: %s\n",
+ d_fprintf(stderr, "listing %s failed with error: %s\n",
mask, cli_errstr(targetcli));
return False;
}
DEBUG(3,("calling net_copy_fileattr for '.' directory in share %s\n", sharename));
nt_status = net_copy_fileattr(c,
cp_clistate->mem_ctx,
- cp_clistate->cli_share_src,
+ cp_clistate->cli_share_src,
cp_clistate->cli_share_dst,
"\\", "\\",
c->opt_acls? true : false,
return True;
}
-/**
+/**
* Sync all files inside a remote share to another share (over smb)
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * 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.
static NTSTATUS rpc_share_migrate_files_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
argc, argv);
}
-/**
+/**
* Migrate share-ACLs from a remote RPC server to the local RPC srever
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * 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.
static NTSTATUS rpc_share_migrate_security_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
}
-/**
+/**
* Migrate share-acls from a rpc-server to another
*
* @param argc Standard main() style argc
argc, argv);
}
-/**
+/**
* Migrate shares (including share-definitions, share-acls and files with acls/attrs)
* from one server to another
*
/* order is important. we don't want to be locked out by the share-acl
* before copying files - gd */
-
+
ret = run_rpc_command(c, NULL, PI_SRVSVC, 0,
rpc_share_migrate_shares_internals, argc, argv);
if (ret)
rpc_share_migrate_files_internals, argc, argv);
if (ret)
return ret;
-
+
return run_rpc_command(c, NULL, PI_SRVSVC, 0,
rpc_share_migrate_security_internals, argc,
argv);
}
-/**
+/**
* 'net rpc share migrate' entrypoint.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
NTSTATUS result;
POLICY_HND lsa_pol;
- result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True,
+ result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&lsa_pol);
if (!NT_STATUS_IS_OK(result))
const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
if (!NT_STATUS_IS_OK(result))
goto done;
-
+
result = rpc_fetch_domain_aliases(pipe_hnd, mem_ctx, &connect_pol,
&global_sid_Builtin);
if (!NT_STATUS_IS_OK(result))
goto done;
-
+
result = rpc_fetch_domain_aliases(pipe_hnd, mem_ctx, &connect_pol,
domain_sid);
return true;
}
-
+
/**
* Get a list of all user tokens we want to look at
**/
{
return;
}
-
-/**
+
+/**
* List shares on a remote RPC server, including the security descriptors
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * 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.
return -1;
}
-/**
+/**
* 'net rpc share' entrypoint.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
return net_help_file(c, argc, argv);
}
-/**
+/**
* Close a file on a remote RPC server
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * argc, argv which are passes through.
*
* @param c A net_context structure
* @param domain_sid The domain sid acquired from the remote server
**/
static NTSTATUS rpc_file_close_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
- return rpccli_srvsvc_NetFileClose(pipe_hnd, mem_ctx,
+ return rpccli_srvsvc_NetFileClose(pipe_hnd, mem_ctx,
pipe_hnd->desthost,
atoi(argv[0]), NULL);
}
-/**
+/**
* Close a file on a remote RPC server
*
* @param argc Standard main() style argc
argc, argv);
}
-/**
- * Formatted print of open file info
+/**
+ * Formatted print of open file info
*
* @param r struct srvsvc_NetFileInfo3 contents
**/
r->fid, r->user, r->permissions, r->num_locks, r->path);
}
-/**
+/**
* List open files on a remote RPC server
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * argc, argv which are passes through.
*
* @param c A net_context structure
* @param domain_sid The domain sid acquired from the remote server
static NTSTATUS rpc_file_list_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
}
-/**
+/**
* List files for a user on a remote RPC server
*
* @param argc Standard main() style argc
argc, argv);
}
-/**
+/**
* 'net rpc file' entrypoint.
* @param argc Standard main() style argc
* @param argv Standard main() style argv. Initial components are already
return net_run_function(c, argc, argv, func, rpc_file_usage);
}
-/**
+/**
* ABORT the shutdown of a remote RPC Server over, initshutdown pipe
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passed through.
+ * argc, argv which are passed through.
*
* @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
static NTSTATUS rpc_shutdown_abort_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
- struct cli_state *cli,
+ const char *domain_name,
+ struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
- const char **argv)
+ const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
+
result = rpccli_initshutdown_Abort(pipe_hnd, mem_ctx, NULL, NULL);
-
+
if (NT_STATUS_IS_OK(result)) {
d_printf("\nShutdown successfully aborted\n");
DEBUG(5,("cmd_shutdown_abort: query succeeded\n"));
} else
DEBUG(5,("cmd_shutdown_abort: query failed\n"));
-
+
return result;
}
-/**
+/**
* ABORT the shutdown of a remote RPC Server, over winreg pipe
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passed through.
+ * argc, argv which are passed through.
*
* @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
static NTSTATUS rpc_reg_shutdown_abort_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
- struct cli_state *cli,
+ const char *domain_name,
+ struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
- const char **argv)
+ const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
-
+
result = rpccli_winreg_AbortSystemShutdown(pipe_hnd, mem_ctx, NULL, NULL);
-
+
if (NT_STATUS_IS_OK(result)) {
d_printf("\nShutdown successfully aborted\n");
DEBUG(5,("cmd_reg_abort_shutdown: query succeeded\n"));
} else
DEBUG(5,("cmd_reg_abort_shutdown: query failed\n"));
-
+
return result;
}
-/**
+/**
* ABORT the Shut down of a remote RPC server
*
* @param argc Standard main() style argc
argc, argv);
}
-/**
+/**
* Shut down a remote RPC Server via initshutdown pipe
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * argc, argv which are passes through.
*
* @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
NTSTATUS rpc_init_shutdown_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
- struct cli_state *cli,
- struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
- int argc,
- const char **argv)
+ const char *domain_name,
+ struct cli_state *cli,
+ struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
const char *msg = "This machine will be shutdown shortly";
return result;
}
-/**
+/**
* Shut down a remote RPC Server via winreg pipe
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passes through.
+ * argc, argv which are passes through.
*
* @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
NTSTATUS rpc_reg_shutdown_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
- struct cli_state *cli,
- struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
- int argc,
- const char **argv)
+ const char *domain_name,
+ struct cli_state *cli,
+ struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
{
const char *msg = "This machine will be shutdown shortly";
uint32 timeout = 20;
return result;
}
-/**
+/**
* Shut down a remote RPC server
*
* @param argc Standard main() style argc
static NTSTATUS rpc_trustdom_add_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
static NTSTATUS rpc_trustdom_del_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
return NT_STATUS_INVALID_PARAMETER;
}
- /*
+ /*
* Make valid trusting domain account (ie. uppercased and with '$' appended)
*/
acct_name = talloc_asprintf(mem_ctx, "%s$", argv[0]);
/*
* Call LsaOpenPolicy and LsaQueryInfo
*/
-
+
pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_LSARPC, &nt_status);
if (!pipe_hnd) {
DEBUG(0, ("Could not initialise lsa pipe. Error was %s\n", nt_errstr(nt_status) ));
/* There should be actually query info level 3 (following nt serv behaviour),
but I still don't know if it's _really_ necessary */
-
+
/*
* Store the password in secrets db
*/
talloc_destroy(mem_ctx);
return -1;
}
-
+
/*
* Close the pipes and clean up
*/
-
+
nt_status = rpccli_lsa_Close(pipe_hnd, mem_ctx, &connect_hnd);
if (NT_STATUS_IS_ERR(nt_status)) {
DEBUG(0, ("Couldn't close LSA pipe. Error was %s\n",
}
cli_shutdown(cli);
-
+
talloc_destroy(mem_ctx);
-
+
d_printf("Trust to domain %s established\n", domain_name);
return 0;
}
int rc = -1;
if (argc < 1) return -1;
-
+
/* generate upper cased domain name */
domain_name = smb_xstrdup(argv[0]);
strupper_m(domain_name);
domain_name));
goto done;
};
-
+
rc = 0;
done:
SAFE_FREE(domain_name);
*
* @return Integer status returned to shell
**/
-
+
static int rpc_trustdom_usage(struct net_context *c, int argc,
const char **argv)
{
static NTSTATUS rpc_query_domain_sid(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
pad_len = col_len - strlen(trusted_dom_name);
padding[pad_len] = 0;
do padding[--pad_len] = ' '; while (pad_len);
-
+
d_printf("%s%s%s\n", trusted_dom_name, padding, ascii_sid);
}
static NTSTATUS vampire_trusted_domain(struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *pol,
- DOM_SID dom_sid,
+ TALLOC_CTX *mem_ctx,
+ POLICY_HND *pol,
+ DOM_SID dom_sid,
const char *trusted_dom_name)
{
NTSTATUS nt_status;
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
-
+
if (!pdb_set_trusteddom_pw(trusted_dom_name, cleartextpwd, &dom_sid)) {
DEBUG(0, ("Storing password for trusted domain failed.\n"));
nt_status = NT_STATUS_UNSUCCESSFUL;
/* close lsarpc pipe and connection to IPC$ */
cli_shutdown(cli);
- talloc_destroy(mem_ctx);
+ talloc_destroy(mem_ctx);
return 0;
}
* set domain and pdc name to local samba server (default)
* or to remote one given in command line
*/
-
+
if (StrCaseCmp(c->opt_workgroup, lp_workgroup())) {
domain_name = c->opt_workgroup;
c->opt_target_workgroup = c->opt_workgroup;
talloc_destroy(mem_ctx);
return -1;
};
-
+
/*
* perform actual enumeration
*/
-
+
enum_ctx = 0; /* reset enumeration context from last enumeration */
do {
d_fprintf(stderr, "couldn't get domain's sid\n");
cli_shutdown(remote_cli);
-
+
} else {
d_fprintf(stderr, "domain controller is not "
"responding: %s\n",
nt_errstr(nt_status));
};
};
-
+
if (!num_domains) d_printf("none\n");
-
+
} while (NT_STATUS_EQUAL(nt_status, STATUS_MORE_ENTRIES));
/* close opened samr and domain policy handles */
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Couldn't properly close domain policy handle for domain %s\n", domain_name));
};
-
+
nt_status = rpccli_samr_Close(pipe_hnd, mem_ctx, &connect_hnd);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("Couldn't properly close samr policy handle for domain %s\n", domain_name));
};
-
+
/* close samr pipe and connection to IPC$ */
cli_shutdown(cli);
- talloc_destroy(mem_ctx);
+ talloc_destroy(mem_ctx);
return 0;
}
rpc_vampire_internals, argc, argv);
}
-/**
+/**
* Migrate everything from a print-server
*
* @param c A net_context structure
}
-/**
+/**
* Migrate print-drivers from a print-server
*
* @param c A net_context structure
argc, argv);
}
-/**
+/**
* Migrate print-forms from a print-server
*
* @param c A net_context structure
argc, argv);
}
-/**
+/**
* Migrate printers from a print-server
*
* @param c A net_context structure
argc, argv);
}
-/**
+/**
* Migrate printer-ACLs from a print-server
*
* @param c A net_context structure
argc, argv);
}
-/**
+/**
* Migrate printer-settings from a print-server
*
* @param c A net_context structure
argc, argv);
}
-/**
+/**
* 'net rpc printer' entrypoint.
*
* @param c A net_context structure
}
-/**
+/**
* List printers on a remote RPC server
*
* @param c A net_context structure
argc, argv);
}
-/**
+/**
* List printer-drivers on a remote RPC server
*
* @param c A net_context structure
argc, argv);
}
-/**
+/**
* Publish printer in ADS via MSRPC
*
* @param c A net_context structure
argc, argv);
}
-/**
+/**
* Update printer in ADS via MSRPC
*
* @param c A net_context structure
argc, argv);
}
-/**
+/**
* UnPublish printer in ADS via MSRPC
*
* @param c A net_context structure
argc, argv);
}
-/**
+/**
* List published printers via MSRPC
*
* @param c A net_context structure
}
-/**
+/**
* Publish printer in ADS
*
* @param c A net_context structure
}
-/**
+/**
* Display rpc printer help page.
*
* @param c A net_context structure
return net_help_printer(c, argc, argv);
}
-/**
+/**
* 'net rpc printer' entrypoint.
*
* @param c A net_context structure
/****************************************************************************/
-/**
+/**
* Basic usage function for 'net rpc'
*
* @param c A net_context structure
return net_run_function(c, argc, argv, func, rpc_user_usage);
}
-/**
+/**
* 'net rpc' entrypoint.
*
* @param c A net_context structure
-/*
- Samba Unix/Linux SMB client library
- Distributed SMB/CIFS Server Management Utility
+/*
+ Samba Unix/Linux SMB client library
+ Distributed SMB/CIFS Server Management Utility
Copyright (C) 2001 Andrew Bartlett (abartlet@samba.org)
Copyright (C) Tim Potter 2001
Copyright (C) 2008 Guenther Deschner
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 "utils/net.h"
printf("Joined domain %s.\n",domain);
}
}
-
+
cli_shutdown(cli);
SAFE_FREE(clear_trust_password);
-/*
- Samba Unix/Linux SMB client library
- Distributed SMB/CIFS Server Management Utility
+/*
+ Samba Unix/Linux SMB client library
+ Distributed SMB/CIFS Server Management Utility
Copyright (C) 2004 Guenther Deschner (gd@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/>.
*/
fstring dependentfiles = "";
fstring monitorname = "";
fstring defaultdatatype = "";
-
+
int length=0;
bool valid = True;
-
+
if (i1 == NULL)
return;
while (valid) {
rpcstr_pull(dependentfiles, i1->dependentfiles+length, sizeof(dependentfiles), -1, STR_TERMINATE);
-
+
length+=strlen(dependentfiles)+1;
-
+
if (strlen(dependentfiles) > 0) {
d_printf ("\tDependentfiles: [%s]\n", dependentfiles);
} else {
valid = False;
}
}
-
+
printf ("\n");
d_printf ("\tMonitorname: [%s]\n", monitorname);
d_printf ("\tDefaultdatatype: [%s]\n\n", defaultdatatype);
- return;
+ return;
}
static void display_reg_value(const char *subkey, REGISTRY_VALUE value)
switch(value.type) {
case REG_DWORD:
- d_printf("\t[%s:%s]: REG_DWORD: 0x%08x\n", subkey, value.valuename,
+ d_printf("\t[%s:%s]: REG_DWORD: 0x%08x\n", subkey, value.valuename,
*((uint32 *) value.data_p));
break;
break;
case REG_BINARY:
- d_printf("\t[%s:%s]: REG_BINARY: unknown length value not displayed\n",
+ d_printf("\t[%s:%s]: REG_BINARY: unknown length value not displayed\n",
subkey, value.valuename);
break;
default:
d_printf("\t%s: unknown type %d\n", value.valuename, value.type);
}
-
+
}
/**
- * Copies ACLs, DOS-attributes and timestamps from one
- * file or directory from one connected share to another connected share
+ * Copies ACLs, DOS-attributes and timestamps from one
+ * file or directory from one connected share to another connected share
*
* @param c A net_context structure
* @param mem_ctx A talloc-context
- * @param cli_share_src A connected cli_state
- * @param cli_share_dst A connected cli_state
+ * @param cli_share_src A connected cli_state
+ * @param cli_share_dst A connected cli_state
* @param src_file The source file-name
* @param dst_file The destination file-name
* @param copy_acls Whether to copy acls
* @param is_file Whether this file is a file or a dir
*
* @return Normal NTSTATUS return.
- **/
+ **/
NTSTATUS net_copy_fileattr(struct net_context *c,
TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
- struct cli_state *cli_share_dst,
+ struct cli_state *cli_share_dst,
const char *src_name, const char *dst_name,
bool copy_acls, bool copy_attrs,
bool copy_timestamps, bool is_file)
/* open file/dir on the originating server */
- DEBUGADD(3,("opening %s %s on originating server\n",
+ DEBUGADD(3,("opening %s %s on originating server\n",
is_file?"file":"dir", src_name));
fnum_src = cli_nt_create(cli_share_src, src_name, READ_CONTROL_ACCESS);
if (fnum_src == -1) {
- DEBUGADD(0,("cannot open %s %s on originating server %s\n",
+ DEBUGADD(0,("cannot open %s %s on originating server %s\n",
is_file?"file":"dir", src_name, cli_errstr(cli_share_src)));
nt_status = cli_nt_error(cli_share_src);
goto out;
if (copy_attrs || copy_timestamps) {
/* get file attributes */
- if (!cli_getattrE(cli_share_src, fnum_src, &attr, NULL,
+ if (!cli_getattrE(cli_share_src, fnum_src, &attr, NULL,
&f_ctime, &f_atime, &f_mtime)) {
- DEBUG(0,("failed to get file-attrs: %s\n",
+ DEBUG(0,("failed to get file-attrs: %s\n",
cli_errstr(cli_share_src)));
nt_status = cli_nt_error(cli_share_src);
goto out;
}
- /* open the file/dir on the destination server */
+ /* open the file/dir on the destination server */
fnum_dst = cli_nt_create(cli_share_dst, dst_name, WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS);
if (fnum_dst == -1) {
/* closing files */
if (!cli_close(cli_share_src, fnum_src)) {
- d_fprintf(stderr, "could not close %s on originating server: %s\n",
+ d_fprintf(stderr, "could not close %s on originating server: %s\n",
is_file?"file":"dir", cli_errstr(cli_share_src));
nt_status = cli_nt_error(cli_share_src);
goto out;
}
if (!cli_close(cli_share_dst, fnum_dst)) {
- d_fprintf(stderr, "could not close %s on destination server: %s\n",
+ d_fprintf(stderr, "could not close %s on destination server: %s\n",
is_file?"file":"dir", cli_errstr(cli_share_dst));
nt_status = cli_nt_error(cli_share_dst);
goto out;
}
/**
- * Copy a file or directory from a connected share to another connected share
+ * Copy a file or directory from a connected share to another connected share
*
* @param c A net_context structure
* @param mem_ctx A talloc-context
- * @param cli_share_src A connected cli_state
- * @param cli_share_dst A connected cli_state
+ * @param cli_share_src A connected cli_state
+ * @param cli_share_dst A connected cli_state
* @param src_file The source file-name
* @param dst_file The destination file-name
* @param copy_acls Whether to copy acls
* @param is_file Whether this file is a file or a dir
*
* @return Normal NTSTATUS return.
- **/
+ **/
NTSTATUS net_copy_file(struct net_context *c,
TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
- struct cli_state *cli_share_dst,
+ struct cli_state *cli_share_dst,
const char *src_name, const char *dst_name,
bool copy_acls, bool copy_attrs,
bool copy_timestamps, bool is_file)
goto out;
if (cli_share_src == NULL || cli_share_dst == NULL)
- goto out;
-
+ goto out;
+
/* open on the originating server */
- DEBUGADD(3,("opening %s %s on originating server\n",
+ DEBUGADD(3,("opening %s %s on originating server\n",
is_file ? "file":"dir", src_name));
if (is_file)
fnum_src = cli_open(cli_share_src, src_name, O_RDONLY, DENY_NONE);
/* open file on the destination server */
DEBUGADD(3,("opening file %s on destination server\n", dst_name));
- fnum_dst = cli_open(cli_share_dst, dst_name,
+ fnum_dst = cli_open(cli_share_dst, dst_name,
O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
if (fnum_dst == -1) {
if (c->opt_verbose) {
d_printf("copying [\\\\%s\\%s%s] => [\\\\%s\\%s%s] "
- "%s ACLs and %s DOS Attributes %s\n",
+ "%s ACLs and %s DOS Attributes %s\n",
cli_share_src->desthost, cli_share_src->share, src_name,
cli_share_dst->desthost, cli_share_dst->share, dst_name,
- copy_acls ? "with" : "without",
+ copy_acls ? "with" : "without",
copy_attrs ? "with" : "without",
copy_timestamps ? "(preserving timestamps)" : "" );
}
/* copying file */
int n, ret;
- n = cli_read(cli_share_src, fnum_src, data, nread,
+ n = cli_read(cli_share_src, fnum_src, data, nread,
read_size);
if (n <= 0)
break;
- ret = cli_write(cli_share_dst, fnum_dst, 0, data,
+ ret = cli_write(cli_share_dst, fnum_dst, 0, data,
nread, n);
if (n != ret) {
- d_fprintf(stderr, "Error writing file: %s\n",
+ d_fprintf(stderr, "Error writing file: %s\n",
cli_errstr(cli_share_dst));
nt_status = cli_nt_error(cli_share_dst);
goto out;
if (!is_file && !cli_chkpath(cli_share_dst, dst_name)) {
/* creating dir */
- DEBUGADD(3,("creating dir %s on the destination server\n",
+ DEBUGADD(3,("creating dir %s on the destination server\n",
dst_name));
if (!cli_mkdir(cli_share_dst, dst_name)) {
/* closing files */
if (!cli_close(cli_share_src, fnum_src)) {
- d_fprintf(stderr, "could not close file on originating server: %s\n",
+ d_fprintf(stderr, "could not close file on originating server: %s\n",
cli_errstr(cli_share_src));
nt_status = cli_nt_error(cli_share_src);
goto out;
}
if (is_file && !cli_close(cli_share_dst, fnum_dst)) {
- d_fprintf(stderr, "could not close file on destination server: %s\n",
+ d_fprintf(stderr, "could not close file on destination server: %s\n",
cli_errstr(cli_share_dst));
nt_status = cli_nt_error(cli_share_dst);
goto out;
/* possibly we have to copy some file-attributes / acls / sd */
nt_status = net_copy_fileattr(c, mem_ctx, cli_share_src, cli_share_dst,
- src_name, dst_name, copy_acls,
+ src_name, dst_name, copy_acls,
copy_attrs, copy_timestamps, is_file);
if (!NT_STATUS_IS_OK(nt_status))
goto out;
}
/**
- * Copy a driverfile from on connected share to another connected share
- * This silently assumes that a driver-file is picked up from
+ * Copy a driverfile from on connected share to another connected share
+ * This silently assumes that a driver-file is picked up from
*
- * \\src_server\print$\{arch}\{version}\file
+ * \\src_server\print$\{arch}\{version}\file
*
* and copied to
*
- * \\dst_server\print$\{arch}\file
- *
+ * \\dst_server\print$\{arch}\file
+ *
* to be added via setdriver-calls later.
* @param c A net_context structure
* @param mem_ctx A talloc-context
* @param cli_share_src A cli_state connected to source print$-share
* @param cli_share_dst A cli_state connected to destination print$-share
- * @param file The file-name to be copied
+ * @param file The file-name to be copied
* @param short_archi The name of the driver-architecture (short form)
*
* @return Normal NTSTATUS return.
- **/
+ **/
static NTSTATUS net_copy_driverfile(struct net_context *c,
TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
- struct cli_state *cli_share_dst,
+ struct cli_state *cli_share_dst,
char *file, const char *short_archi) {
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
char *filename;
char *tok;
- /* scroll through the file until we have the part
+ /* scroll through the file until we have the part
beyond archi_table.short_archi */
p = file;
while (next_token_talloc(mem_ctx, &p, &tok, "\\")) {
}
/* build source file name */
- if (asprintf(&src_name, "\\%s\\%s\\%s", short_archi, version, filename) < 0 )
+ if (asprintf(&src_name, "\\%s\\%s\\%s", short_archi, version, filename) < 0 )
return NT_STATUS_NO_MEMORY;
return NT_STATUS_NO_MEMORY;
}
- DEBUG(10,("creating print-driver dir for architecture: %s\n",
+ DEBUG(10,("creating print-driver dir for architecture: %s\n",
short_archi));
if (!cli_mkdir(cli_share, dir)) {
}
if (!cli_chkpath(cli_share, dir)) {
- d_fprintf(stderr, "cannot check %s: %s\n",
+ d_fprintf(stderr, "cannot check %s: %s\n",
dir, cli_errstr(cli_share));
goto out;
}
}
/**
- * Copy a print-driver (level 3) from one connected print$-share to another
+ * Copy a print-driver (level 3) from one connected print$-share to another
* connected print$-share
*
* @param c A net_context structure
static NTSTATUS copy_print_driver_3(struct net_context *c,
TALLOC_CTX *mem_ctx,
- struct cli_state *cli_share_src,
- struct cli_state *cli_share_dst,
+ struct cli_state *cli_share_src,
+ struct cli_state *cli_share_dst,
const char *short_archi, DRIVER_INFO_3 *i1)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
int length = 0;
bool valid = True;
-
+
fstring name = "";
fstring driverpath = "";
fstring datafile = "";
fstring configfile = "";
fstring helpfile = "";
fstring dependentfiles = "";
-
+
if (i1 == NULL)
return nt_status;
if (c->opt_verbose)
- d_printf("copying driver: [%s], for architecture: [%s], version: [%d]\n",
+ d_printf("copying driver: [%s], for architecture: [%s], version: [%d]\n",
name, short_archi, i1->version);
-
+
nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
driverpath, short_archi);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
-
+
nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
datafile, short_archi);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
-
+
nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
configfile, short_archi);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
-
+
nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
helpfile, short_archi);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
while (valid) {
-
+
rpcstr_pull(dependentfiles, i1->dependentfiles+length, sizeof(dependentfiles), -1, STR_TERMINATE);
length += strlen(dependentfiles)+1;
-
+
if (strlen(dependentfiles) > 0) {
nt_status = net_copy_driverfile(c, mem_ctx,
- cli_share_src, cli_share_dst,
+ cli_share_src, cli_share_dst,
dependentfiles, short_archi);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
*
* the net_spoolss-functions aim to simplify spoolss-client-functions
* required during the migration-process wrt buffer-sizes, returned
- * error-codes, etc.
+ * error-codes, etc.
*
* this greatly reduces the complexitiy of the migrate-functions.
*
**/
static bool net_spoolss_enum_printers(struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
char *name,
uint32 flags,
- uint32 level,
+ uint32 level,
uint32 *num_printers,
PRINTER_INFO_CTR *ctr)
{
static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
const char *printername,
- uint32 access_required,
+ uint32 access_required,
const char *username,
POLICY_HND *hnd)
{
fstrcat(printername2, "\\");
fstrcat(printername2, printername);
- DEBUG(10,("connecting to: %s as %s for %s and access: %x\n",
+ DEBUG(10,("connecting to: %s as %s for %s and access: %x\n",
servername, username, printername2, access_required));
/* open printer */
/* be more verbose */
if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) {
- d_fprintf(stderr, "no access to printer [%s] on [%s] for user [%s] granted\n",
+ d_fprintf(stderr, "no access to printer [%s] on [%s] for user [%s] granted\n",
printername2, servername, username);
return False;
}
if (!W_ERROR_IS_OK(result)) {
- d_fprintf(stderr, "cannot open printer %s on server %s: %s\n",
+ d_fprintf(stderr, "cannot open printer %s on server %s: %s\n",
printername2, servername, dos_errstr(result));
return False;
}
- DEBUG(2,("got printer handle for printer: %s, server: %s\n",
+ DEBUG(2,("got printer handle for printer: %s, server: %s\n",
printername2, servername));
return True;
static bool net_spoolss_getprinter(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
POLICY_HND *hnd,
- uint32 level,
+ uint32 level,
PRINTER_INFO_CTR *ctr)
{
WERROR result;
static bool net_spoolss_setprinter(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
POLICY_HND *hnd,
- uint32 level,
+ uint32 level,
PRINTER_INFO_CTR *ctr)
{
WERROR result;
REGISTRY_VALUE *value)
{
WERROR result;
-
+
/* setprinterdata call */
result = rpccli_spoolss_setprinterdata(pipe_hnd, mem_ctx, hnd, value);
/* enumprinterkey call */
result = rpccli_spoolss_enumprinterkey(pipe_hnd, mem_ctx, hnd, keyname, keylist, NULL);
-
+
if (!W_ERROR_IS_OK(result)) {
printf("enumprinterkey failed: %s\n", dos_errstr(result));
return False;
}
-
+
return True;
}
static bool net_spoolss_enumprinterdataex(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
- uint32 offered,
+ uint32 offered,
POLICY_HND *hnd,
- const char *keyname,
- REGVAL_CTR *ctr)
+ const char *keyname,
+ REGVAL_CTR *ctr)
{
WERROR result;
/* enumprinterdataex call */
result = rpccli_spoolss_enumprinterdataex(pipe_hnd, mem_ctx, hnd, keyname, ctr);
-
+
if (!W_ERROR_IS_OK(result)) {
printf("enumprinterdataex failed: %s\n", dos_errstr(result));
return False;
}
-
+
return True;
}
static bool net_spoolss_setprinterdataex(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
POLICY_HND *hnd,
- char *keyname,
+ char *keyname,
REGISTRY_VALUE *value)
{
WERROR result;
/* setprinterdataex call */
- result = rpccli_spoolss_setprinterdataex(pipe_hnd, mem_ctx, hnd,
+ result = rpccli_spoolss_setprinterdataex(pipe_hnd, mem_ctx, hnd,
keyname, value);
-
+
if (!W_ERROR_IS_OK(result)) {
printf("could not set printerdataex: %s\n", dos_errstr(result));
return False;
}
-
+
return True;
}
printf("could not enum forms: %s\n", dos_errstr(result));
return False;
}
-
+
return True;
}
}
static bool net_spoolss_getprinterdriver(struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *hnd, uint32 level,
- const char *env, int version,
+ TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd, uint32 level,
+ const char *env, int version,
PRINTER_DRIVER_CTR *ctr)
{
WERROR result;
-
+
/* getprinterdriver call */
result = rpccli_spoolss_getprinterdriver(
pipe_hnd, mem_ctx, hnd, level,
env, version, ctr);
if (!W_ERROR_IS_OK(result)) {
- DEBUG(1,("cannot get driver (for architecture: %s): %s\n",
+ DEBUG(1,("cannot get driver (for architecture: %s): %s\n",
env, dos_errstr(result)));
if (W_ERROR_V(result) != W_ERROR_V(WERR_UNKNOWN_PRINTER_DRIVER) &&
W_ERROR_V(result) != W_ERROR_V(WERR_INVALID_ENVIRONMENT)) {
}
/**
- * abstraction function to get uint32 num_printers and PRINTER_INFO_CTR ctr
- * for a single printer or for all printers depending on argc/argv
+ * abstraction function to get uint32 num_printers and PRINTER_INFO_CTR ctr
+ * for a single printer or for all printers depending on argc/argv
**/
static bool get_printer_info(struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int level,
int argc,
- const char **argv,
+ const char **argv,
uint32 *num_printers,
PRINTER_INFO_CTR *ctr)
{
/* no arguments given, enumerate all printers */
if (argc == 0) {
- if (!net_spoolss_enum_printers(pipe_hnd, mem_ctx, NULL,
- PRINTER_ENUM_LOCAL|PRINTER_ENUM_SHARED,
- level, num_printers, ctr))
+ if (!net_spoolss_enum_printers(pipe_hnd, mem_ctx, NULL,
+ PRINTER_ENUM_LOCAL|PRINTER_ENUM_SHARED,
+ level, num_printers, ctr))
return False;
goto out;
}
-/**
+/**
* List print-queues (including local printers that are not shared)
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passed through.
+ * argc, argv which are passed through.
*
* @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
NTSTATUS rpc_printer_list_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- uint32 i, num_printers;
+ uint32 i, num_printers;
uint32 level = 2;
char *printername, *sharename;
PRINTER_INFO_CTR ctr;
return NT_STATUS_OK;
}
-/**
- * List printer-drivers from a server
+/**
+ * List printer-drivers from a server
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passed through.
+ * argc, argv which are passed through.
*
* @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
NTSTATUS rpc_printer_driver_list_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
uint32 i;
- uint32 level = 3;
+ uint32 level = 3;
PRINTER_DRIVER_CTR drv_ctr_enum;
int d;
-
+
ZERO_STRUCT(drv_ctr_enum);
printf("listing printer-drivers\n");
/* enum remote drivers */
if (!net_spoolss_enumprinterdrivers(pipe_hnd, mem_ctx, level,
- archi_table[i].long_archi,
+ archi_table[i].long_archi,
&num_drivers, &drv_ctr_enum)) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
if (num_drivers == 0) {
- d_printf ("no drivers found on server for architecture: [%s].\n",
+ d_printf ("no drivers found on server for architecture: [%s].\n",
archi_table[i].long_archi);
continue;
- }
-
- d_printf("got %d printer-drivers for architecture: [%s]\n",
+ }
+
+ d_printf("got %d printer-drivers for architecture: [%s]\n",
num_drivers, archi_table[i].long_archi);
display_print_driver_3(&(drv_ctr_enum.info3[d]));
}
}
-
+
nt_status = NT_STATUS_OK;
done:
}
-/**
+/**
* Publish print-queues with args-wrapper
*
* @param cli A cli_state connected to the server.
**/
static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv,
uint32 action)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- uint32 i, num_printers;
+ uint32 i, num_printers;
uint32 level = 7;
char *printername, *sharename;
PRINTER_INFO_CTR ctr, ctr_pub;
got_hnd = True;
/* check for existing dst printer */
- if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub))
+ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub))
goto done;
/* check action and set string */
nt_status = NT_STATUS_OK;
done:
- if (got_hnd)
+ if (got_hnd)
rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd);
-
+
return nt_status;
}
NTSTATUS rpc_printer_publish_publish_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
NTSTATUS rpc_printer_publish_unpublish_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
NTSTATUS rpc_printer_publish_update_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, SPOOL_DS_UPDATE);
}
-/**
+/**
* List print-queues w.r.t. their publishing state
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passed through.
+ * argc, argv which are passed through.
*
* @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- uint32 i, num_printers;
+ uint32 i, num_printers;
uint32 level = 7;
char *printername, *sharename;
char *guid;
/* open printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
- PRINTER_ALL_ACCESS, cli->user_name, &hnd))
+ PRINTER_ALL_ACCESS, cli->user_name, &hnd))
goto done;
got_hnd = True;
/* check for existing dst printer */
- if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub))
+ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub))
goto done;
rpcstr_pull_talloc(mem_ctx,
nt_status = NT_STATUS_OK;
done:
- if (got_hnd)
+ if (got_hnd)
rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd);
-
+
return nt_status;
}
-/**
+/**
* Migrate Printer-ACLs from a source server to the destination server
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passed through.
+ * argc, argv which are passed through.
*
* @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
- /* TODO: what now, info2 or info3 ?
+ /* TODO: what now, info2 or info3 ?
convince jerry that we should add clientside setacls level 3 at least
*/
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
get any real NT_STATUS-codes anymore from now on */
nt_status = NT_STATUS_UNSUCCESSFUL;
- d_printf("migrating printer ACLs for: [%s] / [%s]\n",
+ d_printf("migrating printer ACLs for: [%s] / [%s]\n",
printername, sharename);
- /* according to msdn you have specify these access-rights
+ /* according to msdn you have specify these access-rights
to see the security descriptor
- READ_CONTROL (DACL)
- ACCESS_SYSTEM_SECURITY (SACL)
/* open src printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
- MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
+ MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
got_hnd_src = True;
/* open dst printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
- PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst))
+ PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst))
goto done;
got_hnd_dst = True;
/* check for existing dst printer */
- if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst))
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst))
goto done;
/* check for existing src printer */
- if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, 3, &ctr_src))
+ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, 3, &ctr_src))
goto done;
/* Copy Security Descriptor */
/* copy secdesc (info level 2) */
- ctr_dst.printers_2->devmode = NULL;
+ ctr_dst.printers_2->devmode = NULL;
ctr_dst.printers_2->secdesc = dup_sec_desc(mem_ctx, ctr_src.printers_3->secdesc);
if (c->opt_verbose)
display_sec_desc(ctr_dst.printers_2->secdesc);
-
- if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &ctr_dst))
+
+ if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &ctr_dst))
goto done;
-
+
DEBUGADD(1,("\tSetPrinter of SECDESC succeeded\n"));
}
}
-
+
nt_status = NT_STATUS_OK;
done:
return nt_status;
}
-/**
+/**
* Migrate printer-forms from a src server to the dst server
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passed through.
+ * argc, argv which are passed through.
*
* @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
/* open src printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
- MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
+ MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
got_hnd_src = True;
/* open dst printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
- PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst))
+ PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst))
goto done;
got_hnd_dst = True;
/* check for existing dst printer */
- if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst))
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst))
goto done;
/* finally migrate forms */
FORM form;
fstring form_name;
-
- /* only migrate FORM_PRINTER types, according to jerry
+
+ /* only migrate FORM_PRINTER types, according to jerry
FORM_BUILTIN-types are hard-coded in samba */
if (forms[f].flag != FORM_PRINTER)
continue;
sizeof(form_name), -1, STR_TERMINATE);
if (c->opt_verbose)
- d_printf("\tmigrating form # %d [%s] of type [%d]\n",
+ d_printf("\tmigrating form # %d [%s] of type [%d]\n",
f, form_name, forms[f].flag);
/* is there a more elegant way to do that ? */
form.top = forms[f].top;
form.right = forms[f].right;
form.bottom = forms[f].bottom;
-
+
init_unistr2(&form.name, form_name, UNI_STR_TERMINATE);
- /* FIXME: there might be something wrong with samba's
+ /* FIXME: there might be something wrong with samba's
builtin-forms */
- result = rpccli_spoolss_addform(pipe_hnd_dst, mem_ctx,
+ result = rpccli_spoolss_addform(pipe_hnd_dst, mem_ctx,
&hnd_dst, 1, &form);
if (!W_ERROR_IS_OK(result)) {
- d_printf("\tAddForm form %d: [%s] refused.\n",
+ d_printf("\tAddForm form %d: [%s] refused.\n",
f, form_name);
continue;
}
-
+
DEBUGADD(1,("\tAddForm of [%s] succeeded\n", form_name));
}
return nt_status;
}
-/**
+/**
* Migrate printer-drivers from a src server to the dst server
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passed through.
+ * argc, argv which are passed through.
*
* @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
goto done;
}
- /* we can reset NT_STATUS here because we do not
+ /* we can reset NT_STATUS here because we do not
get any real NT_STATUS-codes anymore from now on */
nt_status = NT_STATUS_UNSUCCESSFUL;
- d_printf("migrating printer driver for: [%s] / [%s]\n",
+ d_printf("migrating printer driver for: [%s] / [%s]\n",
printername, sharename);
/* open dst printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
- PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst))
+ PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst))
goto done;
got_hnd_dst = True;
/* check for existing dst printer */
- if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_ctr_dst))
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_ctr_dst))
goto done;
/* in a first step call getdriver for each shared printer (per arch)
to get a list of all files that have to be copied */
-
+
for (i=0; archi_table[i].long_archi!=NULL; i++) {
/* getdriver src */
- if (!net_spoolss_getprinterdriver(pipe_hnd, mem_ctx, &hnd_src,
- level, archi_table[i].long_archi,
- archi_table[i].version, &drv_ctr_src))
+ if (!net_spoolss_getprinterdriver(pipe_hnd, mem_ctx, &hnd_src,
+ level, archi_table[i].long_archi,
+ archi_table[i].version, &drv_ctr_src))
continue;
- rpcstr_pull(drivername, drv_ctr_src.info3->name.buffer,
+ rpcstr_pull(drivername, drv_ctr_src.info3->name.buffer,
sizeof(drivername), -1, STR_TERMINATE);
if (c->opt_verbose)
/* copy driver-files */
nt_status = copy_print_driver_3(c, mem_ctx, cli_share_src, cli_share_dst,
- archi_table[i].short_archi,
+ archi_table[i].short_archi,
drv_ctr_src.info3);
if (!NT_STATUS_IS_OK(nt_status))
goto done;
/* adddriver dst */
- if (!net_spoolss_addprinterdriver(pipe_hnd_dst, mem_ctx, level, &drv_ctr_src)) {
+ if (!net_spoolss_addprinterdriver(pipe_hnd_dst, mem_ctx, level, &drv_ctr_src)) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
-
- DEBUGADD(1,("Sucessfully added driver [%s] for printer [%s]\n",
+
+ DEBUGADD(1,("Sucessfully added driver [%s] for printer [%s]\n",
drivername, printername));
}
/* setdriver dst */
init_unistr(&info_ctr_dst.printers_2->drivername, drivername);
-
- if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_ctr_dst)) {
+
+ if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_ctr_dst)) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
- DEBUGADD(1,("Sucessfully set driver %s for printer %s\n",
+ DEBUGADD(1,("Sucessfully set driver %s for printer %s\n",
drivername, printername));
/* close dst */
}
-/**
+/**
* Migrate printer-queues from a src to the dst server
* (requires a working "addprinter command" to be installed for the local smbd)
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passed through.
+ * argc, argv which are passed through.
*
* @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
get any real NT_STATUS-codes anymore from now on */
nt_status = NT_STATUS_UNSUCCESSFUL;
- d_printf("migrating printer queue for: [%s] / [%s]\n",
+ d_printf("migrating printer queue for: [%s] / [%s]\n",
printername, sharename);
/* open dst printer handle */
- if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
+ if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst)) {
-
+
DEBUG(1,("could not open printer: %s\n", sharename));
} else {
got_hnd_dst = True;
continue;
}
- /* now get again src printer ctr via getprinter,
+ /* now get again src printer ctr via getprinter,
we first need a handle for that */
/* open src printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
- MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
+ MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
got_hnd_src = True;
/* getprinter on the src server */
- if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, level, &ctr_src))
+ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, level, &ctr_src))
goto done;
- /* copy each src printer to a dst printer 1:1,
+ /* copy each src printer to a dst printer 1:1,
maybe some values have to be changed though */
d_printf("creating printer: %s\n", printername);
result = rpccli_spoolss_addprinterex (pipe_hnd_dst, mem_ctx, level, &ctr_src);
if (W_ERROR_IS_OK(result))
d_printf ("printer [%s] successfully added.\n", printername);
- else if (W_ERROR_V(result) == W_ERROR_V(WERR_PRINTER_ALREADY_EXISTS))
+ else if (W_ERROR_V(result) == W_ERROR_V(WERR_PRINTER_ALREADY_EXISTS))
d_fprintf (stderr, "printer [%s] already exists.\n", printername);
else {
d_fprintf (stderr, "could not create printer [%s]\n", printername);
return nt_status;
}
-/**
+/**
* Migrate Printer-Settings from a src server to the dst server
* (for this to work, printers and drivers already have to be migrated earlier)
*
* All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passed through.
+ * argc, argv which are passed through.
*
* @param c A net_context structure
* @param domain_sid The domain sid aquired from the remote server
NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv)
{
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
- /* we can reset NT_STATUS here because we do not
+ /* we can reset NT_STATUS here because we do not
get any real NT_STATUS-codes anymore from now on */
nt_status = NT_STATUS_UNSUCCESSFUL;
- d_printf("migrating printer settings for: [%s] / [%s]\n",
+ d_printf("migrating printer settings for: [%s] / [%s]\n",
printername, sharename);
/* open src printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
- MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
+ MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
got_hnd_src = True;
/* open dst printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
- PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst))
+ PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst))
goto done;
got_hnd_dst = True;
/* check for existing dst printer */
- if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst,
- level, &ctr_dst))
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst,
+ level, &ctr_dst))
goto done;
- /* STEP 1: COPY DEVICE-MODE and other
+ /* STEP 1: COPY DEVICE-MODE and other
PRINTER_INFO_2-attributes
*/
ctr_dst.printers_2 = &ctr_enum.printers_2[i];
- /* why is the port always disconnected when the printer
+ /* why is the port always disconnected when the printer
is correctly installed (incl. driver ???) */
init_unistr( &ctr_dst.printers_2->portname, SAMBA_PRINTER_PORT_NAME);
- /* check if printer is published */
+ /* check if printer is published */
if (ctr_enum.printers_2[i].attributes & PRINTER_ATTRIBUTE_PUBLISHED) {
/* check for existing dst printer */
}
init_unistr(&ctr_dst.printers_2->devmode->devicename,
- devicename);
+ devicename);
#endif
if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst,
- level, &ctr_dst))
+ level, &ctr_dst))
goto done;
-
+
DEBUGADD(1,("\tSetPrinter of DEVICEMODE succeeded\n"));
}
/* STEP 2: COPY REGISTRY VALUES */
-
- /* please keep in mind that samba parse_spools gives horribly
- crippled results when used to rpccli_spoolss_enumprinterdataex
+
+ /* please keep in mind that samba parse_spools gives horribly
+ crippled results when used to rpccli_spoolss_enumprinterdataex
a win2k3-server. (Bugzilla #1851)
- FIXME: IIRC I've seen it too on a win2k-server
+ FIXME: IIRC I've seen it too on a win2k-server
*/
/* enumerate data on src handle */
/* loop for all printerdata of "PrinterDriverData" */
while (W_ERROR_IS_OK(result)) {
-
+
REGISTRY_VALUE value;
-
+
result = rpccli_spoolss_enumprinterdata(
pipe_hnd, mem_ctx, &hnd_src, p++, val_needed,
data_needed, 0, 0, &value);
display_reg_value(SPOOL_PRINTERDATA_KEY, value);
/* set_value */
- if (!net_spoolss_setprinterdata(pipe_hnd_dst, mem_ctx,
- &hnd_dst, &value))
+ if (!net_spoolss_setprinterdata(pipe_hnd_dst, mem_ctx,
+ &hnd_dst, &value))
goto done;
- DEBUGADD(1,("\tSetPrinterData of [%s] succeeded\n",
+ DEBUGADD(1,("\tSetPrinterData of [%s] succeeded\n",
value.valuename));
}
}
-
+
/* STEP 3: COPY SUBKEY VALUES */
- /* here we need to enum all printer_keys and then work
+ /* here we need to enum all printer_keys and then work
on the result with enum_printer_key_ex. nt4 does not
- respond to enumprinterkey, win2k does, so continue
+ respond to enumprinterkey, win2k does, so continue
in case of an error */
if (!net_spoolss_enumprinterkey(pipe_hnd, mem_ctx, &hnd_src, "", &keylist)) {
}
- /* work on a list of printer keys
+ /* work on a list of printer keys
each key has to be enumerated to get all required
- information. information is then set via setprinterdataex-calls */
+ information. information is then set via setprinterdataex-calls */
if (keylist == NULL)
continue;
return NT_STATUS_NO_MEMORY;
/* enumerate all src subkeys */
- if (!net_spoolss_enumprinterdataex(pipe_hnd, mem_ctx, 0,
- &hnd_src, subkey,
- reg_ctr))
+ if (!net_spoolss_enumprinterdataex(pipe_hnd, mem_ctx, 0,
+ &hnd_src, subkey,
+ reg_ctr))
goto done;
for (j=0; j < reg_ctr->num_values; j++) {
-
+
REGISTRY_VALUE value;
UNISTR2 data;
-
- /* although samba replies with sane data in most cases we
+
+ /* although samba replies with sane data in most cases we
should try to avoid writing wrong registry data */
-
- if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_PORTNAME) ||
+
+ if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_PORTNAME) ||
strequal(reg_ctr->values[j]->valuename, SPOOL_REG_UNCNAME) ||
strequal(reg_ctr->values[j]->valuename, SPOOL_REG_URL) ||
strequal(reg_ctr->values[j]->valuename, SPOOL_REG_SHORTSERVERNAME) ||
strequal(reg_ctr->values[j]->valuename, SPOOL_REG_SERVERNAME)) {
if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_PORTNAME)) {
-
+
/* although windows uses a multi-sz, we use a sz */
init_unistr2(&data, SAMBA_PRINTER_PORT_NAME, UNI_STR_TERMINATE);
fstrcpy(value.valuename, SPOOL_REG_PORTNAME);
}
-
+
if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_UNCNAME)) {
-
+
if (asprintf(&unc_name, "\\\\%s\\%s", longname, sharename) < 0) {
nt_status = NT_STATUS_NO_MEMORY;
goto done;
display_reg_value(subkey, value);
/* here we have to set all subkeys on the dst server */
- if (!net_spoolss_setprinterdataex(pipe_hnd_dst, mem_ctx, &hnd_dst,
- subkey, &value))
+ if (!net_spoolss_setprinterdataex(pipe_hnd_dst, mem_ctx, &hnd_dst,
+ subkey, &value))
goto done;
-
+
} else {
if (c->opt_verbose)
display_reg_value(subkey, *(reg_ctr->values[j]));
/* here we have to set all subkeys on the dst server */
- if (!net_spoolss_setprinterdataex(pipe_hnd_dst, mem_ctx, &hnd_dst,
- subkey, reg_ctr->values[j]))
+ if (!net_spoolss_setprinterdataex(pipe_hnd_dst, mem_ctx, &hnd_dst,
+ subkey, reg_ctr->values[j]))
goto done;
}
- DEBUGADD(1,("\tSetPrinterDataEx of key [%s\\%s] succeeded\n",
+ DEBUGADD(1,("\tSetPrinterDataEx of key [%s\\%s] succeeded\n",
subkey, reg_ctr->values[j]->valuename));
}
}
}
-
+
nt_status = NT_STATUS_OK;
done:
{
(*reg_type) = HKEY_LOCAL_MACHINE;
} else if (strequal(hivename, "HKCR") ||
- strequal(hivename, "HKEY_CLASSES_ROOT"))
+ strequal(hivename, "HKEY_CLASSES_ROOT"))
{
(*reg_type) = HKEY_CLASSES_ROOT;
} else if (strequal(hivename, "HKU") ||
status = rpccli_winreg_EnumKey(pipe_hnd, mem_ctx, key_hnd,
i, &name_buf, &class_buf,
&modtime, &werr);
-
+
if (W_ERROR_EQUAL(werr,
WERR_NO_MORE_ITEMS) ) {
status = NT_STATUS_OK;
static NTSTATUS rpc_registry_setvalue_internal(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv )
{
NTSTATUS status;
struct registry_value value;
- status = registry_openkey(mem_ctx, pipe_hnd, argv[0],
+ status = registry_openkey(mem_ctx, pipe_hnd, argv[0],
SEC_RIGHTS_MAXIMUM_ALLOWED,
&hive_hnd, &key_hnd);
if (!NT_STATUS_IS_OK(status)) {
static NTSTATUS rpc_registry_deletevalue_internal(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv )
{
static NTSTATUS rpc_registry_createkey_internal(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv )
{
static NTSTATUS rpc_registry_deletekey_internal(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv )
{
static NTSTATUS rpc_registry_enumerate_internal(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv )
{
- POLICY_HND pol_hive, pol_key;
+ POLICY_HND pol_hive, pol_key;
NTSTATUS status;
uint32 num_subkeys = 0;
uint32 num_values = 0;
NTTIME **modtimes = NULL;
uint32 i;
struct registry_value **values = NULL;
-
+
if (argc != 1 ) {
d_printf("Usage: net rpc registry enumerate <path>\n");
d_printf("Example: net rpc registry enumerate 'HKLM\\Software\\Samba'\n");
static NTSTATUS rpc_registry_save_internal(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv )
{
WERROR result = WERR_GENERAL_FAILURE;
- POLICY_HND pol_hive, pol_key;
+ POLICY_HND pol_hive, pol_key;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
struct winreg_String filename;
-
+
if (argc != 2 ) {
d_printf("Usage: net rpc registry backup <path> <file> \n");
return NT_STATUS_INVALID_PARAMETER;
}
-
+
status = registry_openkey(mem_ctx, pipe_hnd, argv[0], REG_KEY_ALL,
&pol_hive, &pol_key);
if (!NT_STATUS_IS_OK(status)) {
if ( !W_ERROR_IS_OK(result) ) {
d_fprintf(stderr, "Unable to save [%s] to %s:%s\n", argv[0], cli->desthost, argv[1]);
}
-
+
/* cleanup */
-
+
rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key, NULL);
rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive, NULL);
/********************************************************************
********************************************************************/
-static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
+static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
REGF_NK_REC *parent, REGF_FILE *outfile,
const char *parentpath )
{
{
REGF_FILE *registry;
REGF_NK_REC *nk;
-
+
if (argc != 1 ) {
d_printf("Usage: net rpc registry dump <file> \n");
return -1;
}
-
+
d_printf("Opening %s....", argv[0]);
if ( !(registry = regfio_open( argv[0], O_RDONLY, 0)) ) {
d_fprintf(stderr, "Failed to open %s for reading\n", argv[0]);
return 1;
}
d_printf("ok\n");
-
+
/* get the root of the registry file */
-
+
if ((nk = regfio_rootkey( registry )) == NULL) {
d_fprintf(stderr, "Could not get rootkey\n");
regfio_close( registry );
#if 0
talloc_report_full( registry->mem_ctx, stderr );
-#endif
+#endif
d_printf("Closing registry...");
regfio_close( registry );
d_printf("ok\n");
REGF_FILE *infile = NULL, *outfile = NULL;
REGF_NK_REC *nk;
int result = 1;
-
+
if (argc != 2 ) {
d_printf("Usage: net rpc registry copy <srcfile> <newfile>\n");
return -1;
}
-
+
d_printf("Opening %s....", argv[0]);
if ( !(infile = regfio_open( argv[0], O_RDONLY, 0 )) ) {
d_fprintf(stderr, "Failed to open %s for reading\n", argv[0]);
goto out;
}
d_printf("ok\n");
-
+
/* get the root of the registry file */
-
+
if ((nk = regfio_rootkey( infile )) == NULL) {
d_fprintf(stderr, "Could not get rootkey\n");
goto out;
"Get security descriptor" },
{NULL, NULL, NULL}
};
-
+
return net_run_function2(c, argc, argv, "net rpc registry", func);
}
-/*
- Samba Unix/Linux SMB client library
- Distributed SMB/CIFS Server Management Utility
+/*
+ Samba Unix/Linux SMB client library
+ Distributed SMB/CIFS Server Management Utility
Copyright (C) Gerald (Jerry) Carter 2004
Copyright (C) Guenther Deschner 2008
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/>.
*/
NTSTATUS result;
char **domains = NULL, **names = NULL;
- result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True,
+ result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True,
SEC_RIGHTS_MAXIMUM_ALLOWED, &pol);
-
+
if ( !NT_STATUS_IS_OK(result) )
return result;
result = rpccli_lsa_lookup_sids(pipe_hnd, 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] );
return NT_STATUS_OK;
}
- result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True,
+ result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True,
SEC_RIGHTS_MAXIMUM_ALLOWED, &pol);
-
+
if ( !NT_STATUS_IS_OK(result) )
return result;
result = rpccli_lsa_lookup_names(pipe_hnd, mem_ctx, &pol, 1, &name,
NULL, 1, &sids, &sid_types);
-
+
if ( NT_STATUS_IS_OK(result) )
sid_copy( sid, &sids[0] );
if (!NT_STATUS_IS_OK(result))
return result;
-
+
d_printf("%s:\n", privilege);
for ( i=0; i<sid_array.num_sids; i++ ) {
continue;
}
- /* try to convert the SID to a name. Fall back to
+ /* try to convert the SID to a name. Fall back to
printing the raw SID if necessary */
result = sid_to_name( pipe_hnd, ctx, sid_array.sids[i].sid, name );
if ( !NT_STATUS_IS_OK (result) )
for ( i=0; i<sid_array.num_sids; i++ ) {
- /* try to convert the SID to a name. Fall back to
+ /* try to convert the SID to a name. Fall back to
printing the raw SID if necessary */
result = sid_to_name(pipe_hnd, ctx, sid_array.sids[i].sid, name);
static NTSTATUS rpc_rights_list_internal(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv )
{
uint16 lang_id = 0;
uint16 lang_id_sys = 0;
uint16 lang_id_desc;
-
- result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True,
+
+ result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True,
SEC_RIGHTS_MAXIMUM_ALLOWED, &pol);
if ( !NT_STATUS_IS_OK(result) )
return result;
-
+
/* backwards compatibility; just list available privileges if no arguement */
-
+
if (argc == 0) {
result = enum_privileges(pipe_hnd, mem_ctx, &pol );
goto done;
fstrcpy(privname, argv[i]);
init_lsa_String(&lsa_name, argv[i]);
i++;
-
+
/* verify that this is a valid privilege for error reporting */
result = rpccli_lsa_LookupPrivDisplayName(pipe_hnd, mem_ctx,
&pol,
d_fprintf(stderr, "Error resolving privilege display name [%s].\n", nt_errstr(result));
continue;
}
-
+
result = enum_accounts_for_privilege(pipe_hnd, mem_ctx, &pol, privname);
if (!NT_STATUS_IS_OK(result)) {
d_fprintf(stderr, "Error enumerating accounts for privilege %s [%s].\n",
}
/* special case to enumerate all privileged SIDs with associated rights */
-
+
if (strequal( argv[0], "accounts")) {
int i = 1;
static NTSTATUS rpc_rights_grant_internal(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv )
{
result = name_to_sid(pipe_hnd, mem_ctx, &sid, argv[0]);
if (!NT_STATUS_IS_OK(result))
- return result;
+ return result;
- result = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, True,
+ result = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, True,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&dom_pol);
if (!NT_STATUS_IS_OK(result))
- return result;
+ return result;
rights.count = argc-1;
rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge,
if (!NT_STATUS_IS_OK(result))
goto done;
-
+
d_printf("Successfully granted rights.\n");
done:
if ( !NT_STATUS_IS_OK(result) ) {
- d_fprintf(stderr, "Failed to grant privileges for %s (%s)\n",
+ d_fprintf(stderr, "Failed to grant privileges for %s (%s)\n",
argv[0], nt_errstr(result));
}
-
+
rpccli_lsa_Close(pipe_hnd, mem_ctx, &dom_pol);
-
+
return result;
}
static NTSTATUS rpc_rights_revoke_internal(struct net_context *c,
const DOM_SID *domain_sid,
- const char *domain_name,
+ const char *domain_name,
struct cli_state *cli,
struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
int argc,
const char **argv )
{
result = name_to_sid(pipe_hnd, mem_ctx, &sid, argv[0]);
if (!NT_STATUS_IS_OK(result))
- return result;
+ return result;
- result = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, True,
+ result = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, True,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&dom_pol);
if (!NT_STATUS_IS_OK(result))
- return result;
+ return result;
rights.count = argc-1;
rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge,
done:
if ( !NT_STATUS_IS_OK(result) ) {
- d_fprintf(stderr, "Failed to revoke privileges for %s (%s)\n",
+ d_fprintf(stderr, "Failed to revoke privileges for %s (%s)\n",
argv[0], nt_errstr(result));
}
-
+
rpccli_lsa_Close(pipe_hnd, mem_ctx, &dom_pol);
return result;
-}
+}
/********************************************************************
d_printf("net rpc rights list [{accounts|privileges} [name|SID]] 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 rights grant 'VALE\\biddle' SePrintOperatorPrivilege SeDiskOperatorPrivilege\n");
d_printf("\nwould grant the printer admin and disk manager rights to the user 'VALE\\biddle'\n\n");
-
+
return -1;
}
{"revoke", rpc_rights_revoke},
{NULL, NULL}
};
-
+
if ( argc )
return net_run_function(c, argc, argv, func, net_help_rights );
-
+
return net_help_rights(c, argc, argv );
}
-/*
- Samba Unix/Linux SMB client library
- Distributed SMB/CIFS Server Management Utility
+/*
+ Samba Unix/Linux SMB client library
+ Distributed SMB/CIFS Server Management Utility
Copyright (C) 2006 Volker Lendecke (vl@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/>.
*/
if (!NT_STATUS_IS_OK(result)) {
goto done;
}
-
+
/* Get domain policy handle */
result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
d_printf("User must logon to change password: %s\n",
(i1->password_properties & 0x2) ? "yes" : "no");
-
+
return 0; /* Don't save */
}
" \"<account policy>\" \n");
return -1;
}
-
+
account_policy = argv[0];
field = account_policy_name_to_fieldnum(account_policy);
"fetch value!\n");
return -1;
}
-
+
printf("Account policy \"%s\" description: %s\n",
account_policy, account_policy_get_desc(field));
printf("Account policy \"%s\" value is: %d\n", account_policy,
}
/* validate the name and get the group */
-
+
fstrcpy( groupname, "BUILTIN\\" );
fstrcat( groupname, argv[0] );
-
+
if ( !lookup_name(talloc_tos(), groupname, LOOKUP_NAME_ALL, NULL,
NULL, &sid, &type)) {
d_fprintf(stderr, "%s is not a BUILTIN group\n", argv[0]);
return -1;
}
-
+
if ( !sid_peek_rid( &sid, &rid ) ) {
d_fprintf(stderr, "Failed to get RID for %s\n", argv[0]);
return -1;
}
if ( !lookup_sid(talloc_tos(), &member, &memberdomain,
- &membername, &membertype) )
+ &membername, &membertype) )
{
d_fprintf(stderr, "Could not resolve SID %s\n", argv[1]);
return -1;
return -1;
}
- d_printf("Added %s\\%s to %s\\%s\n", memberdomain, membername,
+ d_printf("Added %s\\%s to %s\\%s\n", memberdomain, membername,
groupdomain, groupname);
return 0;
(grouptype == SID_NAME_WKN_GRP)) {
DOM_SID *members = NULL;
size_t i, num_members = 0;
-
+
status = pdb_enum_aliasmem(&group, &members, &num_members);
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "You are not root, most things won't "
"work\n");
}
-
+
return net_run_function2(c, argc, argv, "net sam", func);
}
-/*
- Samba Unix/Linux SMB client library
+/*
+ Samba Unix/Linux SMB client library
net status command -- possible replacement for smbstatus
Copyright (C) 2003 Volker Lendecke (vl@samba.org)
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/>. */
if (*parseable) {
d_printf("%s\\%s\\%s\\%s\\%s\n",
procid_str_static(&sessionid.pid), uidtoname(sessionid.uid),
- gidtoname(sessionid.gid),
+ gidtoname(sessionid.gid),
sessionid.remote_machine, sessionid.hostname);
} else {
d_printf("%7s %-12s %-12s %-12s (%s)\n",
procid_str_static(&sessionid.pid), uidtoname(sessionid.uid),
- gidtoname(sessionid.gid),
+ gidtoname(sessionid.gid),
sessionid.remote_machine, sessionid.hostname);
}
memcpy(&sessionid, dbuf.dptr, sizeof(sessionid));
- if (!process_exists(sessionid.pid))
+ if (!process_exists(sessionid.pid))
return 0;
ids->num_entries += 1;
crec->servicename,procid_str_static(&crec->pid),
guest ? "" : uidtoname(ids->entries[i].uid),
guest ? "" : gidtoname(ids->entries[i].gid),
- crec->machine,
+ crec->machine,
guest ? "" : ids->entries[i].hostname,
time_to_asc(crec->start));
-/*
- Samba Unix/Linux SMB client library
+/*
+ Samba Unix/Linux SMB client library
net time command
Copyright (C) 2001 Andrew Tridgell (tridge@samba.org)
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/>.
*/
-/*
- Samba Unix/Linux SMB client library
- Distributed SMB/CIFS Server Management Utility
+/*
+ Samba Unix/Linux SMB client library
+ Distributed SMB/CIFS Server Management Utility
Copyright (C) Jeremy Allison (jra@samba.org) 2005
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/>.
*/
{"HELP", net_usershare_help},
{NULL, NULL}
};
-
+
if (lp_usershare_max_shares() == 0) {
d_fprintf(stderr, "net usershare: usershares are currently disabled\n");
return -1;