From 4206d9754486d2c1e18217cbcdbaad8f31f5244b Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Thu, 8 May 2008 11:23:38 +0200 Subject: net: more whitespace cleanup (This used to be commit ef0184d580500734fc7af51e1c790b075180a3d0) --- source3/utils/net_cache.c | 60 ++--- source3/utils/net_groupmap.c | 82 +++--- source3/utils/net_help.c | 4 +- source3/utils/net_idmap.c | 10 +- source3/utils/net_lookup.c | 6 +- source3/utils/net_rap.c | 162 ++++++------ source3/utils/net_rpc.c | 520 +++++++++++++++++++-------------------- source3/utils/net_rpc_join.c | 14 +- source3/utils/net_rpc_printer.c | 510 +++++++++++++++++++------------------- source3/utils/net_rpc_registry.c | 66 ++--- source3/utils/net_rpc_rights.c | 88 +++---- source3/utils/net_rpc_sh_acct.c | 14 +- source3/utils/net_sam.c | 18 +- source3/utils/net_status.c | 16 +- source3/utils/net_time.c | 8 +- source3/utils/net_usershare.c | 12 +- 16 files changed, 795 insertions(+), 795 deletions(-) diff --git a/source3/utils/net_cache.c b/source3/utils/net_cache.c index e59a534e4a..091d8f2e55 100644 --- a/source3/utils/net_cache.c +++ b/source3/utils/net_cache.c @@ -1,18 +1,18 @@ -/* - 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 . */ @@ -57,11 +57,11 @@ static void print_cache_entry(const char* keystr, const char* datastr, 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, @@ -71,7 +71,7 @@ static void print_cache_entry(const char* keystr, const char* datastr, } timeout_str = alloc_str; } - + d_printf("Key: %s\t Timeout: %s\t Value: %s %s\n", keystr, timeout_str, datastr, timeout > now_t ? "": "(expired)"); @@ -105,7 +105,7 @@ static time_t parse_timeout(const char* timeout_str) } else { number_begin = 0; } - + /* unit detection */ len = strlen(timeout_str); switch (timeout_str[len - 1]) { @@ -115,12 +115,12 @@ static time_t parse_timeout(const char* timeout_str) 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); @@ -130,21 +130,21 @@ static time_t parse_timeout(const char* timeout_str) 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 @@ -153,29 +153,29 @@ static int net_cache_add(struct net_context *c, int argc, const char **argv) { const char *keystr, *datastr, *timeout_str; time_t timeout; - + if (argc < 3) { d_printf("\nUsage: net cache add \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; @@ -183,7 +183,7 @@ static int net_cache_add(struct net_context *c, int argc, const char **argv) /** * 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 @@ -191,12 +191,12 @@ static int net_cache_add(struct net_context *c, int argc, const char **argv) 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 \n"); return -1; } - + if(gencache_del(keystr)) { d_printf("Entry deleted.\n"); return 0; @@ -209,7 +209,7 @@ static int net_cache_del(struct net_context *c, int argc, const char **argv) /** * 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 @@ -224,7 +224,7 @@ static int net_cache_get(struct net_context *c, int argc, const char **argv) d_printf("\nUsage: net cache get \n"); return -1; } - + if (gencache_get(keystr, &valuestr, &timeout)) { print_cache_entry(keystr, valuestr, timeout, NULL); return 0; @@ -237,7 +237,7 @@ static int net_cache_get(struct net_context *c, int argc, const char **argv) /** * 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 @@ -245,12 +245,12 @@ static int net_cache_get(struct net_context *c, int argc, const char **argv) 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 \n"); return -1; } - + pattern = argv[0]; gencache_iterate(print_cache_entry, NULL, pattern); return 0; @@ -259,7 +259,7 @@ static int net_cache_search(struct net_context *c, int argc, const char **argv) /** * List the contents of the cache - * + * * @param c A net_context structure * @param argv ignored in this functionailty * @return always returns 0 @@ -275,7 +275,7 @@ static int net_cache_list(struct net_context *c, int argc, const char **argv) /** * Flush the whole cache - * + * * @param c A net_context structure * @param argv ignored in this functionality * @return always returns 0 diff --git a/source3/utils/net_groupmap.c b/source3/utils/net_groupmap.c index 0fdebcc912..9f54bdaa08 100644 --- a/source3/utils/net_groupmap.c +++ b/source3/utils/net_groupmap.c @@ -82,7 +82,7 @@ static int net_groupmap_list(struct net_context *c, int argc, const char **argv) if (c->opt_verbose || c->opt_long_list_entries) long_list = True; - + /* get the options */ for ( i=0; i|sid=} unixgroup= [type=] [ntgroup=] [comment=]\n"); return -1; } - + if ( (gid = nametogid(unixgrp)) == (gid_t)-1 ) { d_fprintf(stderr, "Can't lookup UNIX group %s\n", unixgrp); return -1; @@ -253,7 +253,7 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv) return -1; } } - + if ( (rid == 0) && (string_sid[0] == '\0') ) { d_printf("No rid or sid specified, choosing a RID\n"); if (pdb_rid_algorithm()) { @@ -289,10 +289,10 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv) 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; @@ -323,28 +323,28 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg 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] ) ); @@ -364,17 +364,17 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg return -1; } } - + if ( !ntgroup[0] && !sid_string[0] ) { d_printf("Usage: net groupmap modify {ntgroup=|sid=} [comment=] [unixgroup=] [type=]\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; } @@ -383,18 +383,18 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg 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; @@ -410,10 +410,10 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg /* 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 ) { @@ -421,7 +421,7 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg unixgrp); return -1; } - + map.gid = gid; } @@ -429,7 +429,7 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg d_fprintf(stderr, "Could not update group database\n"); return -1; } - + d_printf("Updated mapping entry for %s\n", map.nt_name); return 0; @@ -449,31 +449,31 @@ static int net_groupmap_delete(struct net_context *c, int argc, const char **arg 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=|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; @@ -632,7 +632,7 @@ static int net_groupmap_addmem(struct net_context *c, int argc, const char **arg { 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"); @@ -780,7 +780,7 @@ int net_help_groupmap(struct net_context *c, int argc, const char **argv) "\n Set group mapping\n"); d_printf("net groupmap cleanup"\ "\n Remove foreign group mapping entries\n"); - + return -1; } @@ -810,7 +810,7 @@ int net_groupmap(struct net_context *c, int argc, const char **argv) 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); diff --git a/source3/utils/net_help.c b/source3/utils/net_help.c index 61d4167019..923475ffff 100644 --- a/source3/utils/net_help.c +++ b/source3/utils/net_help.c @@ -140,7 +140,7 @@ int net_help_share(struct net_context *c, int argc, const char **argv) "net [] share MIGRATE SHARES [misc. options] [targets]" "\n\tMigrates shares from remote to local server\n\n" "net [] share MIGRATE SECURITY [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 [] share MIGRATE ALL [misc. options] [targets]" "\n\tMigrates shares (including directories, files) from remote\n" "\tto local server\n\n" @@ -253,7 +253,7 @@ static int net_usage(struct net_context *c, int argc, const char **argv) 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}, diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c index 74992933ba..f3d0c30a4d 100644 --- a/source3/utils/net_idmap.c +++ b/source3/utils/net_idmap.c @@ -1,18 +1,18 @@ -/* - 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 . */ diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c index f8491a2a2a..7e4d85d057 100644 --- a/source3/utils/net_lookup.c +++ b/source3/utils/net_lookup.c @@ -273,7 +273,7 @@ static int net_lookup_kdc(struct net_context *c, int argc, const char **argv) 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; } @@ -448,9 +448,9 @@ int net_lookup(struct net_context *c, int argc, const char **argv) 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); diff --git a/source3/utils/net_rap.c b/source3/utils/net_rap.c index cea3eaeca8..552f0b667a 100644 --- a/source3/utils/net_rap.c +++ b/source3/utils/net_rap.c @@ -1,6 +1,6 @@ -/* - 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) @@ -13,19 +13,19 @@ 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 . */ #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" @@ -55,14 +55,14 @@ int net_rap_file_usage(struct net_context *c, int argc, const char **argv) /*************************************************************************** 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"\ @@ -97,7 +97,7 @@ static int rap_file_info(struct net_context *c, int argc, const char **argv) 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; @@ -139,11 +139,11 @@ int net_rap_file(struct net_context *c, int argc, const char **argv) {"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; @@ -160,23 +160,23 @@ int net_rap_file(struct net_context *c, int argc, const char **argv) 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); @@ -186,7 +186,7 @@ static int rap_share_delete(struct net_context *c, int argc, const char **argv) { 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); @@ -204,7 +204,7 @@ static int rap_share_add(struct net_context *c, int argc, const char **argv) { struct cli_state *cli; int ret; - + RAP_SHARE_INFO_2 sinfo; char *p; char *sharename; @@ -213,7 +213,7 @@ static int rap_share_add(struct net_context *c, int argc, const char **argv) 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; @@ -234,7 +234,7 @@ static int rap_share_add(struct net_context *c, int argc, const char **argv) sinfo.path = p+1; memset(sinfo.password, '\0', sizeof(sinfo.password)); sinfo.reserved2 = '\0'; - + ret = cli_NetShareAdd(cli, &sinfo); cli_shutdown(cli); return ret; @@ -253,10 +253,10 @@ int net_rap_share(struct net_context *c, int argc, const char **argv) 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"\ @@ -272,7 +272,7 @@ int net_rap_share(struct net_context *c, int argc, const char **argv) 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( @@ -290,7 +290,7 @@ int net_rap_session_usage(struct net_context *c, int argc, const char **argv) 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) @@ -298,14 +298,14 @@ static void list_sessions_func(char *wsname, char *username, uint16 conns, 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; @@ -319,8 +319,8 @@ static void display_session_func(const char *wsname, const char *username, "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); } @@ -338,11 +338,11 @@ static int rap_session_info(struct net_context *c, int argc, const char **argv) 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]; @@ -364,11 +364,11 @@ static int rap_session_delete(struct net_context *c, int argc, const char **argv { 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]); @@ -388,7 +388,7 @@ int net_rap_session(struct net_context *c, int argc, const char **argv) if (argc == 0) { struct cli_state *cli; int ret; - + if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli))) return -1; @@ -404,7 +404,7 @@ int net_rap_session(struct net_context *c, int argc, const char **argv) return net_run_function(c, argc, argv, func, net_rap_session_usage); } - + /**************************************************************************** list a server name ****************************************************************************/ @@ -446,7 +446,7 @@ static int net_rap_server_name(struct net_context *c, int argc, const char *argv cli_shutdown(cli); return 0; } - + int net_rap_server(struct net_context *c, int argc, const char **argv) { struct cli_state *cli; @@ -470,12 +470,12 @@ int net_rap_server(struct net_context *c, int argc, const char **argv) "\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"\ @@ -489,7 +489,7 @@ int net_rap_domain(struct net_context *c, int argc, const char **argv) { struct cli_state *cli; int ret; - + if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli))) return -1; @@ -498,11 +498,11 @@ int net_rap_domain(struct net_context *c, int argc, const char **argv) "\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( @@ -519,12 +519,12 @@ int net_rap_printq_usage(struct net_context *c, int argc, const char **argv) 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); @@ -547,10 +547,10 @@ static void enum_queue(const char *queuename, uint16 pri, uint16 start, } } -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 ", @@ -583,8 +583,8 @@ static int rap_printq_info(struct net_context *c, int argc, const char **argv) { 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))) @@ -600,8 +600,8 @@ static int rap_printq_delete(struct net_context *c, int argc, const char **argv) { 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))) @@ -616,7 +616,7 @@ int net_rap_printq(struct net_context *c, int argc, const char **argv) { struct cli_state *cli; int ret; - + struct functable func[] = { {"INFO", rap_printq_info}, {"DELETE", rap_printq_delete}, @@ -639,15 +639,15 @@ int net_rap_printq(struct net_context *c, int argc, const char **argv) 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", @@ -663,7 +663,7 @@ static int rap_user_delete(struct net_context *c, int argc, const char **argv) { 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); @@ -690,15 +690,15 @@ static int rap_user_add(struct net_context *c, int argc, const char **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; @@ -746,7 +746,7 @@ int net_rap_user(struct net_context *c, int argc, const char **argv) cli_shutdown(cli); goto done; } - ret = cli_RNetUserEnum0(cli, user_fn, NULL); + ret = cli_RNetUserEnum0(cli, user_fn, NULL); cli_shutdown(cli); goto done; } @@ -806,12 +806,12 @@ static int rap_group_add(struct net_context *c, int argc, const char **argv) 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; @@ -837,7 +837,7 @@ int net_rap_group(struct net_context *c, int argc, const char **argv) cli_shutdown(cli); return ret; } - ret = cli_RNetGroupEnum0(cli, group_fn, NULL); + ret = cli_RNetGroupEnum0(cli, group_fn, NULL); cli_shutdown(cli); return ret; } @@ -885,7 +885,7 @@ static int rap_groupmember_delete(struct net_context *c, int argc, const char ** 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; @@ -906,7 +906,7 @@ static int rap_groupmember_list(struct net_context *c, int argc, const char **ar 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; } @@ -919,7 +919,7 @@ int net_rap_groupmember(struct net_context *c, int argc, const char **argv) {"DELETE", rap_groupmember_delete}, {NULL, NULL} }; - + return net_run_function(c, argc, argv, func, net_rap_groupmember_usage); } @@ -947,7 +947,7 @@ int net_rap_service_usage(struct net_context *c, int argc, const char **argv) "\n\tStart named service on remote server\n"); d_printf("\nnet rap service STOP [misc. options] [targets]\n"\ "\n\tStop named service on remote server\n"); - + net_common_flags_usage(c, argc, argv); return -1; } @@ -987,7 +987,7 @@ int net_rap_service(struct net_context *c, int argc, const char **argv) 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; } @@ -999,8 +999,8 @@ int net_rap_password_usage(struct net_context *c, int argc, const char **argv) { d_printf( "net rap password [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; } @@ -1009,8 +1009,8 @@ int net_rap_password(struct net_context *c, int argc, const char **argv) { 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))) @@ -1026,8 +1026,8 @@ int net_rap_admin_usage(struct net_context *c, int argc, const char **argv) { d_printf( "net rap admin [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; } @@ -1099,12 +1099,12 @@ int net_rap(struct net_context *c, int argc, const char **argv) {"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); } diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index be4440110c..642a4baa45 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -1,6 +1,6 @@ -/* - 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) @@ -11,15 +11,15 @@ 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 . */ - + #include "includes.h" #include "utils/net.h" @@ -32,8 +32,8 @@ static bool sync_files(struct copy_clistate *cp_clistate, const char *mask); * @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 @@ -43,7 +43,7 @@ static bool sync_files(struct copy_clistate *cp_clistate, const char *mask); /** * 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 * @@ -64,8 +64,8 @@ NTSTATUS net_get_remote_domain_sid(struct cli_state *cli, TALLOC_CTX *mem_ctx, 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)) { @@ -97,7 +97,7 @@ NTSTATUS net_get_remote_domain_sid(struct cli_state *cli, TALLOC_CTX *mem_ctx, * 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 @@ -111,7 +111,7 @@ int run_rpc_command(struct net_context *c, 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; @@ -137,13 +137,13 @@ int run_rpc_command(struct net_context *c, } /* 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)) { @@ -175,15 +175,15 @@ int run_rpc_command(struct net_context *c, } } } - + 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); @@ -194,16 +194,16 @@ int run_rpc_command(struct net_context *c, 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. @@ -217,18 +217,18 @@ int run_rpc_command(struct net_context *c, 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 @@ -245,15 +245,15 @@ int net_rpc_changetrustpw(struct net_context *c, int argc, const char **argv) 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. @@ -267,14 +267,14 @@ int net_rpc_changetrustpw(struct net_context *c, int argc, const char **argv) 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; @@ -289,7 +289,7 @@ static NTSTATUS rpc_oldjoin_internals(struct net_context *c, 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. */ @@ -298,7 +298,7 @@ static NTSTATUS rpc_oldjoin_internals(struct net_context *c, } else { sec_channel_type = get_sec_channel_type(NULL); } - + fstrcpy(trust_passwd, global_myname()); strlower_m(trust_passwd); @@ -327,7 +327,7 @@ static NTSTATUS rpc_oldjoin_internals(struct net_context *c, return result; } -/** +/** * Join a domain, the old way. * * @param argc Standard main() style argc @@ -340,14 +340,14 @@ static NTSTATUS rpc_oldjoin_internals(struct net_context *c, 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 @@ -368,7 +368,7 @@ static int net_rpc_oldjoin(struct net_context *c, int argc, const char **argv) 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 @@ -376,7 +376,7 @@ static int net_rpc_oldjoin(struct net_context *c, int argc, const char **argv) **/ static int rpc_join_usage(struct net_context *c, int argc, const char **argv) -{ +{ d_printf("net rpc join -U [%%password] [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"\ @@ -389,13 +389,13 @@ static int rpc_join_usage(struct net_context *c, int argc, const char **argv) 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. @@ -417,15 +417,15 @@ int net_rpc_join(struct net_context *c, int argc, const char **argv) 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. @@ -439,7 +439,7 @@ int net_rpc_join(struct net_context *c, int argc, const char **argv) 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, @@ -492,7 +492,7 @@ NTSTATUS rpc_info_internals(struct net_context *c, return result; } -/** +/** * 'net rpc info' entrypoint. * @param argc Standard main() style argc * @param argc Standard main() style argv. Initial components are already @@ -506,11 +506,11 @@ int net_rpc_info(struct net_context *c, int argc, const char **argv) 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. @@ -524,7 +524,7 @@ int net_rpc_info(struct net_context *c, int argc, const char **argv) 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, @@ -545,7 +545,7 @@ static NTSTATUS rpc_getsid_internals(struct net_context *c, return NT_STATUS_OK; } -/** +/** * 'net rpc getsid' entrypoint. * @param argc Standard main() style argc * @param argc Standard main() style argv. Initial components are already @@ -574,7 +574,7 @@ static int rpc_user_usage(struct net_context *c, int argc, const char **argv) return net_help_user(c, argc, argv); } -/** +/** * Add a new user to a remote RPC server * * @param argc Standard main() style argc @@ -617,11 +617,11 @@ static int rpc_user_add(struct net_context *c, int argc, const char **argv) 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. @@ -635,10 +635,10 @@ static int rpc_user_add(struct net_context *c, int argc, const char **argv) 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) { @@ -669,7 +669,7 @@ static NTSTATUS rpc_user_rename_internals(struct net_context *c, if (!NT_STATUS_IS_OK(result)) { goto done; } - + /* Get domain policy handle */ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx, @@ -736,7 +736,7 @@ static NTSTATUS rpc_user_rename_internals(struct net_context *c, return result; } -/** +/** * Rename a user on a remote RPC server * * @param argc Standard main() style argc @@ -752,7 +752,7 @@ static int rpc_user_rename(struct net_context *c, int argc, const char **argv) argc, argv); } -/** +/** * Delete a user from a remote RPC server * * @param argc Standard main() style argc @@ -786,11 +786,11 @@ static int rpc_user_delete(struct net_context *c, int argc, const char **argv) 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. @@ -804,10 +804,10 @@ static int rpc_user_delete(struct net_context *c, int argc, const char **argv) 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) { @@ -824,7 +824,7 @@ static NTSTATUS rpc_user_password_internals(struct net_context *c, rpc_user_usage(c, argc, argv); return NT_STATUS_OK; } - + user = argv[0]; if (argv[1]) { @@ -908,9 +908,9 @@ static NTSTATUS rpc_user_password_internals(struct net_context *c, done: return result; -} +} -/** +/** * Set a user's password on a remote RPC server * * @param argc Standard main() style argc @@ -926,11 +926,11 @@ static int rpc_user_password(struct net_context *c, int argc, const char **argv) 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. @@ -944,7 +944,7 @@ static int rpc_user_password(struct net_context *c, int argc, const char **argv) 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, @@ -974,7 +974,7 @@ static NTSTATUS rpc_user_info_internals(struct net_context *c, 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, @@ -1041,7 +1041,7 @@ static NTSTATUS rpc_user_info_internals(struct net_context *c, return result; } -/** +/** * List a user's groups from a remote RPC server * * @param argc Standard main() style argc @@ -1057,11 +1057,11 @@ static int rpc_user_info(struct net_context *c, int argc, const char **argv) 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. @@ -1075,7 +1075,7 @@ static int rpc_user_info(struct net_context *c, int argc, const char **argv) 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, @@ -1095,7 +1095,7 @@ static NTSTATUS rpc_user_list_internals(struct net_context *c, if (!NT_STATUS_IS_OK(result)) { goto done; } - + /* Get domain policy handle */ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx, @@ -1149,7 +1149,7 @@ static NTSTATUS rpc_user_list_internals(struct net_context *c, return result; } -/** +/** * 'net rpc user' entrypoint. * @param argc Standard main() style argc * @param argc Standard main() style argv. Initial components are already @@ -1566,7 +1566,7 @@ struct rpc_sh_cmd *net_rpc_user_cmds(struct net_context *c, { "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 } @@ -1604,7 +1604,7 @@ static int rpc_group_usage(struct net_context *c, int argc, const char **argv) * * @return Normal NTSTATUS return. **/ - + static NTSTATUS rpc_group_delete_internals(struct net_context *c, const DOM_SID *domain_sid, const char *domain_name, @@ -1690,7 +1690,7 @@ static NTSTATUS rpc_group_delete_internals(struct net_context *c, 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); @@ -1704,7 +1704,7 @@ static NTSTATUS rpc_group_delete_internals(struct net_context *c, 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]); @@ -1732,14 +1732,14 @@ static NTSTATUS rpc_group_delete_internals(struct net_context *c, 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++) { @@ -1757,7 +1757,7 @@ static NTSTATUS rpc_group_delete_internals(struct net_context *c, if (c->opt_verbose) d_printf("failed\n"); goto done; - } + } } result = rpccli_samr_DeleteDomainGroup(pipe_hnd, mem_ctx, @@ -1786,7 +1786,7 @@ static NTSTATUS rpc_group_delete_internals(struct net_context *c, 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]); @@ -1794,10 +1794,10 @@ static NTSTATUS rpc_group_delete_internals(struct net_context *c, 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) @@ -1808,7 +1808,7 @@ 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, @@ -1836,7 +1836,7 @@ static NTSTATUS rpc_group_add_internals(struct net_context *c, 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, @@ -1867,7 +1867,7 @@ static NTSTATUS rpc_group_add_internals(struct net_context *c, 4, &group_info); if (!NT_STATUS_IS_OK(result)) goto done; - + done: if (NT_STATUS_IS_OK(result)) DEBUG(5, ("add group succeeded\n")); @@ -1879,7 +1879,7 @@ static NTSTATUS rpc_group_add_internals(struct net_context *c, 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, @@ -1907,7 +1907,7 @@ static NTSTATUS rpc_alias_add_internals(struct net_context *c, 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, @@ -1939,7 +1939,7 @@ static NTSTATUS rpc_alias_add_internals(struct net_context *c, &alias_info); if (!NT_STATUS_IS_OK(result)) goto done; - + done: if (NT_STATUS_IS_OK(result)) DEBUG(5, ("add alias succeeded\n")); @@ -2163,7 +2163,7 @@ static NTSTATUS rpc_add_aliasmem(struct rpc_pipe_client *pipe_hnd, 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, @@ -2358,7 +2358,7 @@ static NTSTATUS rpc_del_aliasmem(struct rpc_pipe_client *pipe_hnd, 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, @@ -2391,7 +2391,7 @@ static NTSTATUS rpc_group_delmem_internals(struct net_context *c, } 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)) { @@ -2414,11 +2414,11 @@ static int rpc_group_delmem(struct net_context *c, int argc, const char **argv) 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. @@ -2432,7 +2432,7 @@ static int rpc_group_delmem(struct net_context *c, int argc, const char **argv) 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, @@ -2473,7 +2473,7 @@ static NTSTATUS rpc_group_list_internals(struct net_context *c, if (!NT_STATUS_IS_OK(result)) { goto done; } - + /* Get domain policy handle */ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx, @@ -2810,8 +2810,8 @@ static NTSTATUS rpc_list_alias_members(struct net_context *c, 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]) @@ -2824,10 +2824,10 @@ static NTSTATUS rpc_list_alias_members(struct net_context *c, 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, @@ -2848,7 +2848,7 @@ static NTSTATUS rpc_group_members_internals(struct net_context *c, if (!NT_STATUS_IS_OK(result)) return result; - + /* Get domain policy handle */ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx, @@ -2935,7 +2935,7 @@ static int rpc_group_members(struct net_context *c, int argc, const char **argv) 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, @@ -2962,7 +2962,7 @@ static NTSTATUS rpc_group_rename_internals(struct net_context *c, if (!NT_STATUS_IS_OK(result)) return result; - + /* Get domain policy handle */ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx, @@ -3026,7 +3026,7 @@ static int rpc_group_rename(struct net_context *c, int argc, const char **argv) argc, argv); } -/** +/** * 'net rpc group' entrypoint. * @param argc Standard main() style argc * @param argc Standard main() style argv. Initial components are already @@ -3045,7 +3045,7 @@ int net_rpc_group(struct net_context *c, int argc, const char **argv) {"rename", rpc_group_rename}, {NULL, NULL} }; - + if (argc == 0) { return run_rpc_command(c, NULL, PI_SAMR, 0, rpc_group_list_internals, @@ -3062,11 +3062,11 @@ static int rpc_share_usage(struct net_context *c, int argc, const char **argv) 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. @@ -3079,7 +3079,7 @@ static int rpc_share_usage(struct net_context *c, int argc, const char **argv) **/ 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, @@ -3137,11 +3137,11 @@ static int rpc_share_add(struct net_context *c, int argc, const char **argv) 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. @@ -3154,7 +3154,7 @@ static int rpc_share_add(struct net_context *c, int argc, const char **argv) **/ 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, @@ -3170,7 +3170,7 @@ static NTSTATUS rpc_share_del_internals(struct net_context *c, &result); } -/** +/** * Delete a share on a remote RPC server * * @param domain_sid The domain sid acquired from the remote server @@ -3300,11 +3300,11 @@ done: 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. @@ -3318,7 +3318,7 @@ done: 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, @@ -3355,7 +3355,7 @@ static NTSTATUS rpc_share_list_internals(struct net_context *c, 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 @@ -3374,7 +3374,7 @@ static bool check_share_availability(struct cli_state *cli, const char *netname) return False; } - if (!cli_tdis(cli)) + if (!cli_tdis(cli)) return False; return True; @@ -3391,8 +3391,8 @@ static bool check_share_sanity(struct net_context *c, struct cli_state *cli, /* 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)) { @@ -3403,11 +3403,11 @@ static bool check_share_sanity(struct net_context *c, struct cli_state *cli, 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. @@ -3421,10 +3421,10 @@ static bool check_share_sanity(struct net_context *c, struct cli_state *cli, 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) { @@ -3460,7 +3460,7 @@ static NTSTATUS rpc_share_migrate_shares_internals(struct net_context *c, 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); @@ -3498,7 +3498,7 @@ done: } -/** +/** * Migrate shares from a rpc-server to another * * @param argc Standard main() style argc @@ -3522,7 +3522,7 @@ static int rpc_share_migrate_shares(struct net_context *c, int argc, } /** - * Copy a file/dir + * Copy a file/dir * * @param f file_info * @param mask current search mask @@ -3576,8 +3576,8 @@ static void copy_fn(const char *mnt, file_info *f, 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 */ @@ -3605,9 +3605,9 @@ static void copy_fn(const char *mnt, file_info *f, { 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, @@ -3618,15 +3618,15 @@ static void copy_fn(const char *mnt, file_info *f, 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 @@ -3648,7 +3648,7 @@ static bool sync_files(struct copy_clistate *cp_clistate, const char *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; } @@ -3673,7 +3673,7 @@ bool copy_top_level_perms(struct net_context *c, 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, @@ -3695,11 +3695,11 @@ bool copy_top_level_perms(struct net_context *c, 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. @@ -3713,7 +3713,7 @@ bool copy_top_level_perms(struct net_context *c, 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, @@ -3834,11 +3834,11 @@ static int rpc_share_migrate_files(struct net_context *c, int argc, const char * 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. @@ -3852,10 +3852,10 @@ static int rpc_share_migrate_files(struct net_context *c, int argc, const char * 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) { @@ -3927,7 +3927,7 @@ done: } -/** +/** * Migrate share-acls from a rpc-server to another * * @param argc Standard main() style argc @@ -3950,7 +3950,7 @@ static int rpc_share_migrate_security(struct net_context *c, int argc, argc, argv); } -/** +/** * Migrate shares (including share-definitions, share-acls and files with acls/attrs) * from one server to another * @@ -3973,7 +3973,7 @@ static int rpc_share_migrate_all(struct net_context *c, int argc, /* 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) @@ -3983,14 +3983,14 @@ static int rpc_share_migrate_all(struct net_context *c, int argc, 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 @@ -4130,7 +4130,7 @@ static NTSTATUS rpc_aliaslist_dump(struct net_context *c, 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) { @@ -4138,7 +4138,7 @@ static NTSTATUS rpc_aliaslist_dump(struct net_context *c, 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)) @@ -4196,7 +4196,7 @@ static NTSTATUS rpc_aliaslist_internals(struct net_context *c, 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) { @@ -4210,13 +4210,13 @@ static NTSTATUS rpc_aliaslist_internals(struct net_context *c, 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); @@ -4408,7 +4408,7 @@ static bool get_user_sids(const char *domain, const char *user, NT_USER_TOKEN *t return true; } - + /** * Get a list of all user tokens we want to look at **/ @@ -4650,12 +4650,12 @@ static void rpc_share_userlist_usage(void) { 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. @@ -4808,7 +4808,7 @@ int net_usersidlist_usage(struct net_context *c, int argc, const char **argv) return -1; } -/** +/** * 'net rpc share' entrypoint. * @param argc Standard main() style argc * @param argv Standard main() style argv. Initial components are already @@ -4971,11 +4971,11 @@ static int rpc_file_usage(struct net_context *c, int argc, const char **argv) 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 @@ -4989,19 +4989,19 @@ static int rpc_file_usage(struct net_context *c, int argc, const char **argv) **/ 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 @@ -5022,8 +5022,8 @@ static int rpc_file_close(struct net_context *c, int argc, const char **argv) argc, argv); } -/** - * Formatted print of open file info +/** + * Formatted print of open file info * * @param r struct srvsvc_NetFileInfo3 contents **/ @@ -5034,11 +5034,11 @@ static void display_file_info_3(struct srvsvc_NetFileInfo3 *r) 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 @@ -5053,7 +5053,7 @@ static void display_file_info_3(struct srvsvc_NetFileInfo3 *r) 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, @@ -5104,7 +5104,7 @@ static NTSTATUS rpc_file_list_internals(struct net_context *c, 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 @@ -5126,7 +5126,7 @@ static int rpc_file_user(struct net_context *c, int argc, const char **argv) argc, argv); } -/** +/** * 'net rpc file' entrypoint. * @param argc Standard main() style argc * @param argv Standard main() style argv. Initial components are already @@ -5152,11 +5152,11 @@ int net_rpc_file(struct net_context *c, int argc, const char **argv) 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 @@ -5171,31 +5171,31 @@ int net_rpc_file(struct net_context *c, int argc, const char **argv) 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 @@ -5210,27 +5210,27 @@ static NTSTATUS rpc_shutdown_abort_internals(struct net_context *c, 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 @@ -5257,11 +5257,11 @@ static int rpc_shutdown_abort(struct net_context *c, int 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 @@ -5276,12 +5276,12 @@ static int rpc_shutdown_abort(struct net_context *c, int argc, 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"; @@ -5313,11 +5313,11 @@ NTSTATUS rpc_init_shutdown_internals(struct net_context *c, 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 @@ -5332,12 +5332,12 @@ NTSTATUS rpc_init_shutdown_internals(struct net_context *c, 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; @@ -5374,7 +5374,7 @@ NTSTATUS rpc_reg_shutdown_internals(struct net_context *c, return result; } -/** +/** * Shut down a remote RPC server * * @param argc Standard main() style argc @@ -5421,10 +5421,10 @@ static int rpc_shutdown(struct net_context *c, int argc, const char **argv) 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) { @@ -5584,10 +5584,10 @@ static int rpc_trustdom_add(struct net_context *c, 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) { @@ -5603,7 +5603,7 @@ static NTSTATUS rpc_trustdom_del_internals(struct net_context *c, return NT_STATUS_INVALID_PARAMETER; } - /* + /* * Make valid trusting domain account (ie. uppercased and with '$' appended) */ acct_name = talloc_asprintf(mem_ctx, "%s$", argv[0]); @@ -5858,7 +5858,7 @@ static int rpc_trustdom_establish(struct net_context *c, int argc, /* * 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) )); @@ -5895,7 +5895,7 @@ static int rpc_trustdom_establish(struct net_context *c, int argc, /* 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 */ @@ -5906,11 +5906,11 @@ static int rpc_trustdom_establish(struct net_context *c, int argc, 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", @@ -5921,9 +5921,9 @@ static int rpc_trustdom_establish(struct net_context *c, int argc, } cli_shutdown(cli); - + talloc_destroy(mem_ctx); - + d_printf("Trust to domain %s established\n", domain_name); return 0; } @@ -5945,7 +5945,7 @@ static int rpc_trustdom_revoke(struct net_context *c, int argc, int rc = -1; if (argc < 1) return -1; - + /* generate upper cased domain name */ domain_name = smb_xstrdup(argv[0]); strupper_m(domain_name); @@ -5956,7 +5956,7 @@ static int rpc_trustdom_revoke(struct net_context *c, int argc, domain_name)); goto done; }; - + rc = 0; done: SAFE_FREE(domain_name); @@ -5971,7 +5971,7 @@ done: * * @return Integer status returned to shell **/ - + static int rpc_trustdom_usage(struct net_context *c, int argc, const char **argv) { @@ -5987,7 +5987,7 @@ static int rpc_trustdom_usage(struct net_context *c, int argc, 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, @@ -6012,14 +6012,14 @@ static void print_trusted_domain(DOM_SID *dom_sid, const char *trusted_dom_name) 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; @@ -6054,7 +6054,7 @@ static NTSTATUS vampire_trusted_domain(struct rpc_pipe_client *pipe_hnd, 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; @@ -6214,7 +6214,7 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc, /* close lsarpc pipe and connection to IPC$ */ cli_shutdown(cli); - talloc_destroy(mem_ctx); + talloc_destroy(mem_ctx); return 0; } @@ -6252,7 +6252,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv) * 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; @@ -6396,11 +6396,11 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv) talloc_destroy(mem_ctx); return -1; }; - + /* * perform actual enumeration */ - + enum_ctx = 0; /* reset enumeration context from last enumeration */ do { @@ -6458,16 +6458,16 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv) 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 */ @@ -6475,16 +6475,16 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv) 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; } @@ -6569,7 +6569,7 @@ static int rpc_vampire(struct net_context *c, int argc, const char **argv) { rpc_vampire_internals, argc, argv); } -/** +/** * Migrate everything from a print-server * * @param c A net_context structure @@ -6623,7 +6623,7 @@ static int rpc_printer_migrate_all(struct net_context *c, int argc, } -/** +/** * Migrate print-drivers from a print-server * * @param c A net_context structure @@ -6646,7 +6646,7 @@ static int rpc_printer_migrate_drivers(struct net_context *c, int argc, argc, argv); } -/** +/** * Migrate print-forms from a print-server * * @param c A net_context structure @@ -6669,7 +6669,7 @@ static int rpc_printer_migrate_forms(struct net_context *c, int argc, argc, argv); } -/** +/** * Migrate printers from a print-server * * @param c A net_context structure @@ -6692,7 +6692,7 @@ static int rpc_printer_migrate_printers(struct net_context *c, int argc, argc, argv); } -/** +/** * Migrate printer-ACLs from a print-server * * @param c A net_context structure @@ -6715,7 +6715,7 @@ static int rpc_printer_migrate_security(struct net_context *c, int argc, argc, argv); } -/** +/** * Migrate printer-settings from a print-server * * @param c A net_context structure @@ -6738,7 +6738,7 @@ static int rpc_printer_migrate_settings(struct net_context *c, int argc, argc, argv); } -/** +/** * 'net rpc printer' entrypoint. * * @param c A net_context structure @@ -6769,7 +6769,7 @@ int rpc_printer_migrate(struct net_context *c, int argc, const char **argv) } -/** +/** * List printers on a remote RPC server * * @param c A net_context structure @@ -6787,7 +6787,7 @@ static int rpc_printer_list(struct net_context *c, int argc, const char **argv) argc, argv); } -/** +/** * List printer-drivers on a remote RPC server * * @param c A net_context structure @@ -6806,7 +6806,7 @@ static int rpc_printer_driver_list(struct net_context *c, int argc, argc, argv); } -/** +/** * Publish printer in ADS via MSRPC * * @param c A net_context structure @@ -6825,7 +6825,7 @@ static int rpc_printer_publish_publish(struct net_context *c, int argc, argc, argv); } -/** +/** * Update printer in ADS via MSRPC * * @param c A net_context structure @@ -6843,7 +6843,7 @@ static int rpc_printer_publish_update(struct net_context *c, int argc, const cha argc, argv); } -/** +/** * UnPublish printer in ADS via MSRPC * * @param c A net_context structure @@ -6862,7 +6862,7 @@ static int rpc_printer_publish_unpublish(struct net_context *c, int argc, argc, argv); } -/** +/** * List published printers via MSRPC * * @param c A net_context structure @@ -6882,7 +6882,7 @@ static int rpc_printer_publish_list(struct net_context *c, int argc, } -/** +/** * Publish printer in ADS * * @param c A net_context structure @@ -6915,7 +6915,7 @@ static int rpc_printer_publish(struct net_context *c, int argc, } -/** +/** * Display rpc printer help page. * * @param c A net_context structure @@ -6928,7 +6928,7 @@ int rpc_printer_usage(struct net_context *c, int argc, const char **argv) return net_help_printer(c, argc, argv); } -/** +/** * 'net rpc printer' entrypoint. * * @param c A net_context structure @@ -6957,7 +6957,7 @@ int net_rpc_printer(struct net_context *c, int argc, const char **argv) /****************************************************************************/ -/** +/** * Basic usage function for 'net rpc' * * @param c A net_context structure @@ -7033,7 +7033,7 @@ int net_rpc_help(struct net_context *c, int argc, const char **argv) return net_run_function(c, argc, argv, func, rpc_user_usage); } -/** +/** * 'net rpc' entrypoint. * * @param c A net_context structure diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c index 2777324e81..87a90550fa 100644 --- a/source3/utils/net_rpc_join.c +++ b/source3/utils/net_rpc_join.c @@ -1,6 +1,6 @@ -/* - 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 @@ -9,15 +9,15 @@ 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 . */ - + #include "includes.h" #include "utils/net.h" @@ -463,7 +463,7 @@ done: printf("Joined domain %s.\n",domain); } } - + cli_shutdown(cli); SAFE_FREE(clear_trust_password); diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index 4c1985a0af..9fcbb2272c 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -1,18 +1,18 @@ -/* - 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 . */ @@ -61,10 +61,10 @@ static void display_print_driver_3(DRIVER_INFO_3 *i1) fstring dependentfiles = ""; fstring monitorname = ""; fstring defaultdatatype = ""; - + int length=0; bool valid = True; - + if (i1 == NULL) return; @@ -88,22 +88,22 @@ static void display_print_driver_3(DRIVER_INFO_3 *i1) 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) @@ -112,7 +112,7 @@ 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; @@ -129,7 +129,7 @@ static void display_reg_value(const char *subkey, REGISTRY_VALUE value) 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; @@ -154,17 +154,17 @@ static void display_reg_value(const char *subkey, REGISTRY_VALUE value) 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 @@ -173,12 +173,12 @@ static void display_reg_value(const char *subkey, REGISTRY_VALUE value) * @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) @@ -196,12 +196,12 @@ NTSTATUS net_copy_fileattr(struct net_context *c, /* 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; @@ -227,9 +227,9 @@ NTSTATUS net_copy_fileattr(struct net_context *c, 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; @@ -237,7 +237,7 @@ NTSTATUS net_copy_fileattr(struct net_context *c, } - /* 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) { @@ -284,14 +284,14 @@ NTSTATUS net_copy_fileattr(struct net_context *c, /* 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; @@ -313,12 +313,12 @@ 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 @@ -327,12 +327,12 @@ out: * @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) @@ -350,10 +350,10 @@ NTSTATUS net_copy_file(struct net_context *c, 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); @@ -373,7 +373,7 @@ NTSTATUS net_copy_file(struct net_context *c, /* 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) { @@ -396,10 +396,10 @@ NTSTATUS net_copy_file(struct net_context *c, 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)" : "" ); } @@ -409,17 +409,17 @@ NTSTATUS net_copy_file(struct net_context *c, /* 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; @@ -432,7 +432,7 @@ NTSTATUS net_copy_file(struct net_context *c, 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)) { @@ -451,14 +451,14 @@ NTSTATUS net_copy_file(struct net_context *c, /* 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; @@ -466,7 +466,7 @@ NTSTATUS net_copy_file(struct net_context *c, /* 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; @@ -489,30 +489,30 @@ 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; @@ -523,7 +523,7 @@ static NTSTATUS net_copy_driverfile(struct net_context *c, 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, "\\")) { @@ -534,7 +534,7 @@ static NTSTATUS net_copy_driverfile(struct net_context *c, } /* 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; @@ -577,7 +577,7 @@ static NTSTATUS check_arch_dir(struct cli_state *cli_share, const char *short_ar 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)) { @@ -587,7 +587,7 @@ static NTSTATUS check_arch_dir(struct cli_state *cli_share, const char *short_ar } 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; } @@ -600,7 +600,7 @@ 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 @@ -615,21 +615,21 @@ out: 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; @@ -641,38 +641,38 @@ static NTSTATUS copy_print_driver_3(struct net_context *c, 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; @@ -690,17 +690,17 @@ static NTSTATUS copy_print_driver_3(struct net_context *c, * * 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) { @@ -721,7 +721,7 @@ static bool net_spoolss_enum_printers(struct rpc_pipe_client *pipe_hnd, 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) { @@ -735,7 +735,7 @@ static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_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 */ @@ -745,18 +745,18 @@ static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd, /* 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; @@ -765,7 +765,7 @@ static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd, 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; @@ -784,7 +784,7 @@ static bool net_spoolss_getprinter(struct rpc_pipe_client *pipe_hnd, 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; @@ -807,7 +807,7 @@ static bool net_spoolss_setprinterdata(struct rpc_pipe_client *pipe_hnd, REGISTRY_VALUE *value) { WERROR result; - + /* setprinterdata call */ result = rpccli_spoolss_setprinterdata(pipe_hnd, mem_ctx, hnd, value); @@ -830,32 +830,32 @@ static bool net_spoolss_enumprinterkey(struct rpc_pipe_client *pipe_hnd, /* 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; } @@ -863,20 +863,20 @@ static bool net_spoolss_enumprinterdataex(struct rpc_pipe_client *pipe_hnd, 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; } @@ -896,7 +896,7 @@ static bool net_spoolss_enumforms(struct rpc_pipe_client *pipe_hnd, printf("could not enum forms: %s\n", dos_errstr(result)); return False; } - + return True; } @@ -922,20 +922,20 @@ static bool net_spoolss_enumprinterdrivers (struct rpc_pipe_client *pipe_hnd, } 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)) { @@ -971,15 +971,15 @@ static bool net_spoolss_addprinterdriver(struct rpc_pipe_client *pipe_hnd, } /** - * 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) { @@ -989,9 +989,9 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd, /* 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; @@ -1021,11 +1021,11 @@ 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 @@ -1040,15 +1040,15 @@ out: 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; @@ -1080,11 +1080,11 @@ NTSTATUS rpc_printer_list_internals(struct net_context *c, 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 @@ -1099,19 +1099,19 @@ NTSTATUS rpc_printer_list_internals(struct net_context *c, 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"); @@ -1122,19 +1122,19 @@ NTSTATUS rpc_printer_driver_list_internals(struct net_context *c, /* 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); @@ -1143,7 +1143,7 @@ NTSTATUS rpc_printer_driver_list_internals(struct net_context *c, display_print_driver_3(&(drv_ctr_enum.info3[d])); } } - + nt_status = NT_STATUS_OK; done: @@ -1151,7 +1151,7 @@ done: } -/** +/** * Publish print-queues with args-wrapper * * @param cli A cli_state connected to the server. @@ -1165,13 +1165,13 @@ done: **/ 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; @@ -1207,7 +1207,7 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_ 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 */ @@ -1241,18 +1241,18 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_ 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) { @@ -1261,10 +1261,10 @@ NTSTATUS rpc_printer_publish_publish_internals(struct net_context *c, 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) { @@ -1273,21 +1273,21 @@ NTSTATUS rpc_printer_publish_unpublish_internals(struct net_context *c, 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 @@ -1302,15 +1302,15 @@ NTSTATUS rpc_printer_publish_update_internals(struct net_context *c, 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; @@ -1342,13 +1342,13 @@ NTSTATUS rpc_printer_publish_list_internals(struct net_context *c, /* 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, @@ -1382,17 +1382,17 @@ NTSTATUS rpc_printer_publish_list_internals(struct net_context *c, 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 @@ -1407,14 +1407,14 @@ done: 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; @@ -1473,10 +1473,10 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c, 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) @@ -1484,38 +1484,38 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c, /* 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")); @@ -1531,7 +1531,7 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c, } } - + nt_status = NT_STATUS_OK; done: @@ -1550,11 +1550,11 @@ 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 @@ -1569,10 +1569,10 @@ done: 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) { @@ -1639,7 +1639,7 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c, /* 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; @@ -1647,14 +1647,14 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c, /* 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 */ @@ -1668,8 +1668,8 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c, 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; @@ -1679,7 +1679,7 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c, 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 ? */ @@ -1690,19 +1690,19 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c, 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)); } @@ -1735,11 +1735,11 @@ done: 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 @@ -1754,10 +1754,10 @@ done: 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) { @@ -1839,22 +1839,22 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c, 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; @@ -1870,16 +1870,16 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c, /* 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) @@ -1894,19 +1894,19 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c, /* 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)); } @@ -1919,13 +1919,13 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c, /* 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 */ @@ -1965,12 +1965,12 @@ done: } -/** +/** * 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 @@ -1985,10 +1985,10 @@ done: 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) { @@ -2044,13 +2044,13 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c, 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; @@ -2069,28 +2069,28 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c, 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); @@ -2124,12 +2124,12 @@ done: 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 @@ -2144,10 +2144,10 @@ done: 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) { @@ -2218,17 +2218,17 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, 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; @@ -2236,29 +2236,29 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, /* 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 */ @@ -2293,21 +2293,21 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, } 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 */ @@ -2316,9 +2316,9 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, /* 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); @@ -2331,20 +2331,20 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, 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)) { @@ -2353,9 +2353,9 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, } - /* 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; @@ -2378,34 +2378,34 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, 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; @@ -2453,23 +2453,23 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, 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)); } @@ -2491,7 +2491,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c, } } - + nt_status = NT_STATUS_OK; done: diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c index 0dc53c3f6b..5da19934dc 100644 --- a/source3/utils/net_rpc_registry.c +++ b/source3/utils/net_rpc_registry.c @@ -47,7 +47,7 @@ static bool reg_hive_key(TALLOC_CTX *ctx, const char *fullname, { (*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") || @@ -172,7 +172,7 @@ static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx, 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; @@ -371,10 +371,10 @@ static NTSTATUS registry_setvalue(TALLOC_CTX *mem_ctx, 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 ) { @@ -382,7 +382,7 @@ static NTSTATUS rpc_registry_setvalue_internal(struct net_context *c, 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)) { @@ -441,10 +441,10 @@ static int rpc_registry_setvalue(struct net_context *c, int argc, 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 ) { @@ -594,10 +594,10 @@ static int rpc_registry_getvalue(struct net_context *c, int argc, 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 ) { @@ -666,10 +666,10 @@ static int rpc_registry_createkey(struct net_context *c, int argc, 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 ) { @@ -718,14 +718,14 @@ static int rpc_registry_deletekey(struct net_context *c, int argc, const char ** 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; @@ -733,7 +733,7 @@ static NTSTATUS rpc_registry_enumerate_internal(struct net_context *c, NTTIME **modtimes = NULL; uint32 i; struct registry_value **values = NULL; - + if (argc != 1 ) { d_printf("Usage: net rpc registry enumerate \n"); d_printf("Example: net rpc registry enumerate 'HKLM\\Software\\Samba'\n"); @@ -793,23 +793,23 @@ static int rpc_registry_enumerate(struct net_context *c, int argc, 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 \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)) { @@ -823,9 +823,9 @@ static NTSTATUS rpc_registry_save_internal(struct net_context *c, 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); @@ -923,7 +923,7 @@ static bool dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *pa /******************************************************************** ********************************************************************/ -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 ) { @@ -989,21 +989,21 @@ static int rpc_registry_dump(struct net_context *c, int argc, const char **argv) { REGF_FILE *registry; REGF_NK_REC *nk; - + if (argc != 1 ) { d_printf("Usage: net rpc registry dump \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 ); @@ -1017,7 +1017,7 @@ static int rpc_registry_dump(struct net_context *c, int argc, const char **argv) #if 0 talloc_report_full( registry->mem_ctx, stderr ); -#endif +#endif d_printf("Closing registry..."); regfio_close( registry ); d_printf("ok\n"); @@ -1033,12 +1033,12 @@ static int rpc_registry_copy(struct net_context *c, int argc, const char **argv REGF_FILE *infile = NULL, *outfile = NULL; REGF_NK_REC *nk; int result = 1; - + if (argc != 2 ) { d_printf("Usage: net rpc registry copy \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]); @@ -1052,9 +1052,9 @@ static int rpc_registry_copy(struct net_context *c, int argc, const char **argv 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; @@ -1196,6 +1196,6 @@ int net_rpc_registry(struct net_context *c, int argc, const char **argv) "Get security descriptor" }, {NULL, NULL, NULL} }; - + return net_run_function2(c, argc, argv, "net rpc registry", func); } diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c index 2824c55073..23ce467095 100644 --- a/source3/utils/net_rpc_rights.c +++ b/source3/utils/net_rpc_rights.c @@ -1,6 +1,6 @@ -/* - 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 @@ -8,12 +8,12 @@ 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 . */ @@ -33,14 +33,14 @@ static NTSTATUS sid_to_name(struct rpc_pipe_client *pipe_hnd, 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] ); @@ -69,15 +69,15 @@ static NTSTATUS name_to_sid(struct rpc_pipe_client *pipe_hnd, 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] ); @@ -232,7 +232,7 @@ static NTSTATUS enum_accounts_for_privilege(struct rpc_pipe_client *pipe_hnd, if (!NT_STATUS_IS_OK(result)) return result; - + d_printf("%s:\n", privilege); for ( i=0; i Assign privilege[s]\n"); d_printf("net rpc rights revoke 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; } @@ -614,10 +614,10 @@ int net_rpc_rights(struct net_context *c, int argc, const char **argv) {"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 ); } diff --git a/source3/utils/net_rpc_sh_acct.c b/source3/utils/net_rpc_sh_acct.c index 15a20891f2..ba2a8e28a0 100644 --- a/source3/utils/net_rpc_sh_acct.c +++ b/source3/utils/net_rpc_sh_acct.c @@ -1,18 +1,18 @@ -/* - 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 . */ @@ -57,7 +57,7 @@ static NTSTATUS rpc_sh_acct_do(struct net_context *c, if (!NT_STATUS_IS_OK(result)) { goto done; } - + /* Get domain policy handle */ result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx, @@ -203,7 +203,7 @@ static int account_show(struct net_context *c, d_printf("User must logon to change password: %s\n", (i1->password_properties & 0x2) ? "yes" : "no"); - + return 0; /* Don't save */ } diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c index 9199f70400..32656f0276 100644 --- a/source3/utils/net_sam.c +++ b/source3/utils/net_sam.c @@ -452,7 +452,7 @@ static int net_sam_policy_show(struct net_context *c, int argc, const char **arg " \"\" \n"); return -1; } - + account_policy = argv[0]; field = account_policy_name_to_fieldnum(account_policy); @@ -478,7 +478,7 @@ static int net_sam_policy_show(struct net_context *c, int argc, const char **arg "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, @@ -901,16 +901,16 @@ static int net_sam_createbuiltingroup(struct net_context *c, int argc, const cha } /* 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; @@ -964,7 +964,7 @@ static int net_sam_addmem(struct net_context *c, int argc, const char **argv) } if ( !lookup_sid(talloc_tos(), &member, &memberdomain, - &membername, &membertype) ) + &membername, &membertype) ) { d_fprintf(stderr, "Could not resolve SID %s\n", argv[1]); return -1; @@ -994,7 +994,7 @@ static int net_sam_addmem(struct net_context *c, int argc, const char **argv) 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; @@ -1086,7 +1086,7 @@ static int net_sam_listmem(struct net_context *c, int argc, const char **argv) (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)) { @@ -1691,7 +1691,7 @@ int net_sam(struct net_context *c, int argc, const char **argv) d_fprintf(stderr, "You are not root, most things won't " "work\n"); } - + return net_run_function2(c, argc, argv, "net sam", func); } diff --git a/source3/utils/net_status.c b/source3/utils/net_status.c index 4166c9462b..d4a95a7ca5 100644 --- a/source3/utils/net_status.c +++ b/source3/utils/net_status.c @@ -1,5 +1,5 @@ -/* - 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) @@ -7,12 +7,12 @@ 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 . */ @@ -37,12 +37,12 @@ static int show_session(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, 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); } @@ -119,7 +119,7 @@ static int collect_pid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, memcpy(&sessionid, dbuf.dptr, sizeof(sessionid)); - if (!process_exists(sessionid.pid)) + if (!process_exists(sessionid.pid)) return 0; ids->num_entries += 1; @@ -161,7 +161,7 @@ static int show_share_parseable(struct db_record *rec, 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)); diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c index 48417fbc0f..73f0315b1d 100644 --- a/source3/utils/net_time.c +++ b/source3/utils/net_time.c @@ -1,5 +1,5 @@ -/* - Samba Unix/Linux SMB client library +/* + Samba Unix/Linux SMB client library net time command Copyright (C) 2001 Andrew Tridgell (tridge@samba.org) @@ -7,12 +7,12 @@ 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 . */ diff --git a/source3/utils/net_usershare.c b/source3/utils/net_usershare.c index 02fa12a272..fe03cc615a 100644 --- a/source3/utils/net_usershare.c +++ b/source3/utils/net_usershare.c @@ -1,6 +1,6 @@ -/* - 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 @@ -8,12 +8,12 @@ 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 . */ @@ -1027,7 +1027,7 @@ int net_usershare(struct net_context *c, int argc, const char **argv) {"HELP", net_usershare_help}, {NULL, NULL} }; - + if (lp_usershare_max_shares() == 0) { d_fprintf(stderr, "net usershare: usershares are currently disabled\n"); return -1; -- cgit