summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/eventlogadm.c13
-rw-r--r--source3/utils/net.c20
-rw-r--r--source3/utils/net.h2
-rw-r--r--source3/utils/net_ads.c54
-rw-r--r--source3/utils/net_cache.c2
-rw-r--r--source3/utils/net_conf.c306
-rw-r--r--source3/utils/net_dom.c1
-rw-r--r--source3/utils/net_file.c2
-rw-r--r--source3/utils/net_g_lock.c4
-rw-r--r--source3/utils/net_group.c2
-rw-r--r--source3/utils/net_groupmap.c44
-rw-r--r--source3/utils/net_help.c2
-rw-r--r--source3/utils/net_idmap.c1
-rw-r--r--source3/utils/net_idmap_check.c5
-rw-r--r--source3/utils/net_join.c2
-rw-r--r--source3/utils/net_lookup.c6
-rw-r--r--source3/utils/net_printing.c19
-rw-r--r--source3/utils/net_proto.h1
-rw-r--r--source3/utils/net_rap.c5
-rw-r--r--source3/utils/net_registry.c147
-rw-r--r--source3/utils/net_rpc.c69
-rw-r--r--source3/utils/net_rpc_join.c13
-rw-r--r--source3/utils/net_rpc_printer.c133
-rw-r--r--source3/utils/net_rpc_registry.c21
-rw-r--r--source3/utils/net_rpc_rights.c6
-rw-r--r--source3/utils/net_rpc_samsync.c18
-rw-r--r--source3/utils/net_rpc_shell.c5
-rw-r--r--source3/utils/net_rpc_trust.c30
-rw-r--r--source3/utils/net_serverid.c16
-rw-r--r--source3/utils/net_share.c2
-rw-r--r--source3/utils/net_time.c21
-rw-r--r--source3/utils/net_user.c2
-rw-r--r--source3/utils/net_usershare.c2
-rw-r--r--source3/utils/net_util.c7
-rw-r--r--source3/utils/netlookup.c5
-rw-r--r--source3/utils/nmblookup.c24
-rw-r--r--source3/utils/ntlm_auth.c18
-rw-r--r--source3/utils/sharesec.c2
-rw-r--r--source3/utils/smbcacls.c12
-rw-r--r--source3/utils/smbcontrol.c13
-rw-r--r--source3/utils/smbcquotas.c3
-rw-r--r--source3/utils/smbget.c3
-rw-r--r--source3/utils/smbpasswd.c5
-rw-r--r--source3/utils/smbtree.c1
-rw-r--r--source3/utils/status.c2
-rw-r--r--source3/utils/testparm.c30
46 files changed, 595 insertions, 506 deletions
diff --git a/source3/utils/eventlogadm.c b/source3/utils/eventlogadm.c
index 9ddd9c7df8..d170604a1b 100644
--- a/source3/utils/eventlogadm.c
+++ b/source3/utils/eventlogadm.c
@@ -171,14 +171,14 @@ static bool eventlog_add_source( const char *eventlog, const char *sourcename,
if ( !already_in ) {
/* make a new list with an additional entry; copy values, add another */
- wp = TALLOC_ARRAY(ctx, const char *, numsources + 2 );
+ wp = talloc_array(ctx, const char *, numsources + 2 );
if ( !wp ) {
d_printf("talloc() failed \n");
return False;
}
memcpy( wp, wrklist, sizeof( char * ) * numsources );
- *( wp + numsources ) = ( char * ) sourcename;
+ *( wp + numsources ) = (const char * ) sourcename;
*( wp + numsources + 1 ) = NULL;
if (!push_reg_multi_sz(ctx, &blob, wp)) {
return false;
@@ -365,15 +365,12 @@ static int DoDumpCommand(int argc, char **argv, bool debugflag, char *exename)
{
ELOG_TDB *etdb;
TALLOC_CTX *mem_ctx = talloc_tos();
- const char *tdb_filename;
uint32_t count = 1;
if (argc > 2) {
return -1;
}
- tdb_filename = argv[0];
-
if (argc > 1) {
count = atoi(argv[1]);
}
@@ -475,16 +472,16 @@ int main( int argc, char *argv[] )
/* note that the separate command types should call usage if they need to... */
while ( 1 ) {
- if ( !StrCaseCmp( opname, "addsource" ) ) {
+ if ( !strcasecmp_m( opname, "addsource" ) ) {
rc = DoAddSourceCommand( argc, argv, opt_debug,
exename );
break;
}
- if ( !StrCaseCmp( opname, "write" ) ) {
+ if ( !strcasecmp_m( opname, "write" ) ) {
rc = DoWriteCommand( argc, argv, opt_debug, exename );
break;
}
- if ( !StrCaseCmp( opname, "dump" ) ) {
+ if ( !strcasecmp_m( opname, "dump" ) ) {
rc = DoDumpCommand( argc, argv, opt_debug, exename );
break;
}
diff --git a/source3/utils/net.c b/source3/utils/net.c
index c53b2859b0..95b937444e 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -243,7 +243,7 @@ static int net_getlocalsid(struct net_context *c, int argc, const char **argv)
name = argv[0];
}
else {
- name = global_myname();
+ name = lp_netbios_name();
}
if(!initialize_password_db(false, NULL)) {
@@ -286,7 +286,7 @@ static int net_setlocalsid(struct net_context *c, int argc, const char **argv)
return 1;
}
- if (!secrets_store_domain_sid(global_myname(), &sid)) {
+ if (!secrets_store_domain_sid(lp_netbios_name(), &sid)) {
DEBUG(0,("Can't store domain SID as a pdc/bdc.\n"));
return 1;
}
@@ -346,13 +346,13 @@ static int net_getdomainsid(struct net_context *c, int argc, const char **argv)
/* Generate one, if it doesn't exist */
get_global_sam_sid();
- if (!secrets_fetch_domain_sid(global_myname(), &domain_sid)) {
+ if (!secrets_fetch_domain_sid(lp_netbios_name(), &domain_sid)) {
d_fprintf(stderr, _("Could not fetch local SID\n"));
return 1;
}
sid_to_fstring(sid_str, &domain_sid);
d_printf(_("SID for local machine %s is: %s\n"),
- global_myname(), sid_str);
+ lp_netbios_name(), sid_str);
if (!secrets_fetch_domain_sid(c->opt_workgroup, &domain_sid)) {
d_fprintf(stderr, _("Could not fetch domain SID\n"));
@@ -880,6 +880,16 @@ static struct functable net_func[] = {
lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
+#if defined(HAVE_BIND_TEXTDOMAIN_CODESET)
+ /* Bind our gettext results to 'unix charset'
+
+ This ensures that the translations and any embedded strings are in the
+ same charset. It won't be the one from the user's locale (we no
+ longer auto-detect that), but it will be self-consistent.
+ */
+ bind_textdomain_codeset(MODULE_NAME, lp_unix_charset());
+#endif
+
argv_new = (const char **)poptGetArgs(pc);
argc_new = argc;
@@ -895,7 +905,7 @@ static struct functable net_func[] = {
}
if (c->opt_requester_name) {
- set_global_myname(c->opt_requester_name);
+ lp_set_cmdline("netbios name", c->opt_requester_name);
}
if (!c->opt_user_name && getenv("LOGNAME")) {
diff --git a/source3/utils/net.h b/source3/utils/net.h
index ac43068c12..1d1559f12d 100644
--- a/source3/utils/net.h
+++ b/source3/utils/net.h
@@ -22,6 +22,8 @@
* include
*/
+struct cli_state;
+
#include "../librpc/gen_ndr/lsa.h"
#include "intl.h"
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 4b4b0a8031..bb78ecbf12 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -36,6 +36,7 @@
#include "secrets.h"
#include "krb5_env.h"
#include "../libcli/security/security.h"
+#include "libsmb/libsmb.h"
#ifdef HAVE_ADS
@@ -60,7 +61,8 @@ static int net_ads_cldap_netlogon(struct net_context *c, ADS_STRUCT *ads)
struct NETLOGON_SAM_LOGON_RESPONSE_EX reply;
print_sockaddr(addr, sizeof(addr), &ads->ldap.ss);
- if ( !ads_cldap_netlogon_5(talloc_tos(), addr, ads->server.realm, &reply ) ) {
+
+ if ( !ads_cldap_netlogon_5(talloc_tos(), &ads->ldap.ss, ads->server.realm, &reply ) ) {
d_fprintf(stderr, _("CLDAP query failed!\n"));
return -1;
}
@@ -154,7 +156,7 @@ static int net_ads_lookup(struct net_context *c, int argc, const char **argv)
}
if (!ads->config.realm) {
- ads->config.realm = CONST_DISCARD(char *, c->opt_target_workgroup);
+ ads->config.realm = discard_const_p(char, c->opt_target_workgroup);
ads->ldap.port = 389;
}
@@ -383,7 +385,6 @@ int net_ads_check(struct net_context *c)
static int net_ads_workgroup(struct net_context *c, int argc, const char **argv)
{
ADS_STRUCT *ads;
- char addr[INET6_ADDRSTRLEN];
struct NETLOGON_SAM_LOGON_RESPONSE_EX reply;
if (c->display_usage) {
@@ -401,12 +402,11 @@ static int net_ads_workgroup(struct net_context *c, int argc, const char **argv)
}
if (!ads->config.realm) {
- ads->config.realm = CONST_DISCARD(char *, c->opt_target_workgroup);
+ ads->config.realm = discard_const_p(char, c->opt_target_workgroup);
ads->ldap.port = 389;
}
- print_sockaddr(addr, sizeof(addr), &ads->ldap.ss);
- if ( !ads_cldap_netlogon_5(talloc_tos(), addr, ads->server.realm, &reply ) ) {
+ if ( !ads_cldap_netlogon_5(talloc_tos(), &ads->ldap.ss, ads->server.realm, &reply ) ) {
d_fprintf(stderr, _("CLDAP query failed!\n"));
ads_destroy(&ads);
return -1;
@@ -441,10 +441,10 @@ static bool usergrp_display(ADS_STRUCT *ads, char *field, void **values, void *d
}
if (!values) /* must be new field, indicate string field */
return true;
- if (StrCaseCmp(field, "sAMAccountName") == 0) {
+ if (strcasecmp_m(field, "sAMAccountName") == 0) {
disp_fields[0] = SMB_STRDUP((char *) values[0]);
}
- if (StrCaseCmp(field, "description") == 0)
+ if (strcasecmp_m(field, "description") == 0)
disp_fields[1] = SMB_STRDUP((char *) values[0]);
return true;
}
@@ -915,7 +915,7 @@ static int net_ads_status(struct net_context *c, int argc, const char **argv)
return -1;
}
- rc = ads_find_machine_acct(ads, &res, global_myname());
+ rc = ads_find_machine_acct(ads, &res, lp_netbios_name());
if (!ADS_ERR_OK(rc)) {
d_fprintf(stderr, _("ads_find_machine_acct: %s\n"), ads_errstr(rc));
ads_destroy(&ads);
@@ -923,7 +923,7 @@ static int net_ads_status(struct net_context *c, int argc, const char **argv)
}
if (ads_count_replies(ads, res) == 0) {
- d_fprintf(stderr, _("No machine account for '%s' found\n"), global_myname());
+ d_fprintf(stderr, _("No machine account for '%s' found\n"), lp_netbios_name());
ads_destroy(&ads);
return -1;
}
@@ -1100,10 +1100,10 @@ static WERROR check_ads_config( void )
return WERR_INVALID_DOMAIN_ROLE;
}
- if (strlen(global_myname()) > 15) {
+ if (strlen(lp_netbios_name()) > 15) {
d_printf(_("Our netbios name can be at most 15 chars long, "
- "\"%s\" is %u chars long\n"), global_myname(),
- (unsigned int)strlen(global_myname()));
+ "\"%s\" is %u chars long\n"), lp_netbios_name(),
+ (unsigned int)strlen(lp_netbios_name()));
return WERR_INVALID_COMPUTERNAME;
}
@@ -1244,7 +1244,7 @@ static NTSTATUS net_update_dns_ext(TALLOC_CTX *mem_ctx, ADS_STRUCT *ads,
if (hostname) {
fstrcpy(machine_name, hostname);
} else {
- name_to_fqdn( machine_name, global_myname() );
+ name_to_fqdn( machine_name, lp_netbios_name() );
}
strlower_m( machine_name );
@@ -1349,25 +1349,25 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
/* process additional command line args */
for ( i=0; i<argc; i++ ) {
- if ( !StrnCaseCmp(argv[i], "createupn", strlen("createupn")) ) {
+ if ( !strncasecmp_m(argv[i], "createupn", strlen("createupn")) ) {
createupn = true;
machineupn = get_string_param(argv[i]);
}
- else if ( !StrnCaseCmp(argv[i], "createcomputer", strlen("createcomputer")) ) {
+ else if ( !strncasecmp_m(argv[i], "createcomputer", strlen("createcomputer")) ) {
if ( (create_in_ou = get_string_param(argv[i])) == NULL ) {
d_fprintf(stderr, _("Please supply a valid OU path.\n"));
werr = WERR_INVALID_PARAM;
goto fail;
}
}
- else if ( !StrnCaseCmp(argv[i], "osName", strlen("osName")) ) {
+ else if ( !strncasecmp_m(argv[i], "osName", strlen("osName")) ) {
if ( (os_name = get_string_param(argv[i])) == NULL ) {
d_fprintf(stderr, _("Please supply a operating system name.\n"));
werr = WERR_INVALID_PARAM;
goto fail;
}
}
- else if ( !StrnCaseCmp(argv[i], "osVer", strlen("osVer")) ) {
+ else if ( !strncasecmp_m(argv[i], "osVer", strlen("osVer")) ) {
if ( (os_version = get_string_param(argv[i])) == NULL ) {
d_fprintf(stderr, _("Please supply a valid operating system version.\n"));
werr = WERR_INVALID_PARAM;
@@ -1468,7 +1468,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv)
/* kinit with the machine password */
use_in_memory_ccache();
- if (asprintf( &ads_dns->auth.user_name, "%s$", global_myname()) == -1) {
+ if (asprintf( &ads_dns->auth.user_name, "%s$", lp_netbios_name()) == -1) {
goto fail;
}
ads_dns->auth.password = secrets_fetch_machine_password(
@@ -1756,7 +1756,7 @@ static int net_ads_printer_info(struct net_context *c, int argc, const char **ar
if (argc > 1) {
servername = argv[1];
} else {
- servername = global_myname();
+ servername = lp_netbios_name();
}
rc = ads_find_printer_on_server(ads, &res, printername, servername);
@@ -1819,14 +1819,14 @@ static int net_ads_printer_publish(struct net_context *c, int argc, const char *
if (argc == 2) {
servername = argv[1];
} else {
- servername = global_myname();
+ servername = lp_netbios_name();
}
/* Get printer data from SPOOLSS */
resolve_name(servername, &server_ss, 0x20, false);
- nt_status = cli_full_connection(&cli, global_myname(), servername,
+ nt_status = cli_full_connection(&cli, lp_netbios_name(), servername,
&server_ss, 0,
"IPC$", "IPC",
c->opt_user_name, c->opt_workgroup,
@@ -1942,7 +1942,7 @@ static int net_ads_printer_remove(struct net_context *c, int argc, const char **
if (argc > 1) {
servername = argv[1];
} else {
- servername = global_myname();
+ servername = lp_netbios_name();
}
rc = ads_find_printer_on_server(ads, &res, argv[0], servername);
@@ -2023,8 +2023,8 @@ static int net_ads_password(struct net_context *c, int argc, const char **argv)
ADS_STRUCT *ads;
const char *auth_principal = c->opt_user_name;
const char *auth_password = c->opt_password;
- char *realm = NULL;
- char *new_password = NULL;
+ const char *realm = NULL;
+ const char *new_password = NULL;
char *chr, *prompt;
const char *user;
ADS_STATUS ret;
@@ -2083,7 +2083,7 @@ static int net_ads_password(struct net_context *c, int argc, const char **argv)
}
if (argv[1]) {
- new_password = (char *)argv[1];
+ new_password = (const char *)argv[1];
} else {
if (asprintf(&prompt, _("Enter new password for %s:"), user) == -1) {
return -1;
@@ -2135,7 +2135,7 @@ int net_ads_changetrustpw(struct net_context *c, int argc, const char **argv)
return -1;
}
- fstrcpy(my_name, global_myname());
+ fstrcpy(my_name, lp_netbios_name());
strlower_m(my_name);
if (asprintf(&host_principal, "%s$@%s", my_name, ads->config.realm) == -1) {
ads_destroy(&ads);
diff --git a/source3/utils/net_cache.c b/source3/utils/net_cache.c
index 88aff4e16e..afcb7a1874 100644
--- a/source3/utils/net_cache.c
+++ b/source3/utils/net_cache.c
@@ -244,7 +244,7 @@ static int net_cache_get(struct net_context *c, int argc, const char **argv)
if (gencache_get_data_blob(keystr, &value, &timeout, NULL)) {
print_cache_entry(keystr, value, timeout, NULL);
- SAFE_FREE(value.data);
+ data_blob_free(&value);
return 0;
}
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index fd00c008dd..9381159814 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -174,12 +174,12 @@ static int net_conf_delincludes_usage(struct net_context *c, int argc,
/**
* This functions process a service previously loaded with libsmbconf.
*/
-static WERROR import_process_service(struct net_context *c,
+static sbcErr import_process_service(struct net_context *c,
struct smbconf_ctx *conf_ctx,
struct smbconf_service *service)
{
uint32_t idx;
- WERROR werr = WERR_OK;
+ sbcErr err = SBC_ERR_OK;
uint32_t num_includes = 0;
char **includes = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
@@ -200,54 +200,58 @@ static WERROR import_process_service(struct net_context *c,
}
if (smbconf_share_exists(conf_ctx, service->name)) {
- werr = smbconf_delete_share(conf_ctx, service->name);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_delete_share(conf_ctx, service->name);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
}
- werr = smbconf_create_share(conf_ctx, service->name);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_create_share(conf_ctx, service->name);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
for (idx = 0; idx < service->num_params; idx ++) {
if (strequal(service->param_names[idx], "include")) {
- includes = TALLOC_REALLOC_ARRAY(mem_ctx,
+ includes = talloc_realloc(mem_ctx,
includes,
char *,
num_includes+1);
if (includes == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
includes[num_includes] = talloc_strdup(includes,
service->param_values[idx]);
if (includes[num_includes] == NULL) {
- werr = WERR_NOMEM;
+ err = SBC_ERR_NOMEM;
goto done;
}
num_includes++;
} else {
- werr = smbconf_set_parameter(conf_ctx,
+ err = smbconf_set_parameter(conf_ctx,
service->name,
service->param_names[idx],
service->param_values[idx]);
- if (!W_ERROR_IS_OK(werr)) {
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr,
_("Error in section [%s], parameter \"%s\": %s\n"),
service->name, service->param_names[idx],
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
}
}
- werr = smbconf_set_includes(conf_ctx, service->name, num_includes,
- (const char **)includes);
+ err = smbconf_set_includes(conf_ctx, service->name, num_includes,
+ (const char **)includes);
+ if (!SBC_ERROR_IS_OK(err)) {
+ goto done;
+ }
+ err = SBC_ERR_OK;
done:
TALLOC_FREE(mem_ctx);
- return werr;
+ return err;
}
@@ -260,7 +264,7 @@ done:
static int net_conf_list(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
- WERROR werr = WERR_OK;
+ sbcErr err;
int ret = -1;
TALLOC_CTX *mem_ctx;
uint32_t num_shares;
@@ -274,10 +278,10 @@ static int net_conf_list(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto done;
}
- werr = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &shares);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_config(conf_ctx, mem_ctx, &num_shares, &shares);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error getting config: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
@@ -315,7 +319,7 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
char *conf_source = NULL;
TALLOC_CTX *mem_ctx;
struct smbconf_ctx *txt_ctx;
- WERROR werr;
+ sbcErr err;
if (c->display_usage)
return net_conf_import_usage(c, argc, argv);
@@ -347,10 +351,10 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto done;
}
- werr = smbconf_init(mem_ctx, &txt_ctx, conf_source);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_init(mem_ctx, &txt_ctx, conf_source);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error loading file '%s': %s\n"), filename,
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
@@ -362,37 +366,36 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
if (servicename != NULL) {
struct smbconf_service *service = NULL;
- werr = smbconf_get_share(txt_ctx, mem_ctx,
- servicename,
- &service);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_share(txt_ctx, mem_ctx,
+ servicename,
+ &service);
+ if (!SBC_ERROR_IS_OK(err)) {
goto cancel;
}
- werr = smbconf_transaction_start(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_start(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error starting transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
- werr = import_process_service(c, conf_ctx, service);
- if (!W_ERROR_IS_OK(werr)) {
+ err = import_process_service(c, conf_ctx, service);
+ if (!SBC_ERROR_IS_OK(err)) {
goto cancel;
}
} else {
struct smbconf_service **services = NULL;
uint32_t num_shares, sidx;
- werr = smbconf_get_config(txt_ctx, mem_ctx,
+ err = smbconf_get_config(txt_ctx, mem_ctx,
&num_shares,
&services);
- if (!W_ERROR_IS_OK(werr)) {
+ if (!SBC_ERROR_IS_OK(err)) {
goto cancel;
}
if (!c->opt_testmode) {
- werr = smbconf_drop(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ if (!SBC_ERROR_IS_OK(smbconf_drop(conf_ctx))) {
goto cancel;
}
}
@@ -405,17 +408,17 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
* imported shares, the MAX_TALLOC_SIZE of 256 MB
* was exceeded.
*/
- werr = smbconf_transaction_start(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_start(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error starting transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
for (sidx = 0; sidx < num_shares; sidx++) {
- werr = import_process_service(c, conf_ctx,
- services[sidx]);
- if (!W_ERROR_IS_OK(werr)) {
+ err = import_process_service(c, conf_ctx,
+ services[sidx]);
+ if (!SBC_ERROR_IS_OK(err)) {
goto cancel;
}
@@ -423,26 +426,26 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
continue;
}
- werr = smbconf_transaction_commit(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_commit(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error committing transaction: "
"%s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
- werr = smbconf_transaction_start(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_start(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error starting transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
}
}
- werr = smbconf_transaction_commit(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_commit(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error committing transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
} else {
ret = 0;
}
@@ -450,10 +453,10 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto done;
cancel:
- werr = smbconf_transaction_cancel(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_cancel(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error cancelling transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
}
done:
@@ -465,7 +468,7 @@ static int net_conf_listshares(struct net_context *c,
struct smbconf_ctx *conf_ctx, int argc,
const char **argv)
{
- WERROR werr = WERR_OK;
+ sbcErr err;
int ret = -1;
uint32_t count, num_shares = 0;
char **share_names = NULL;
@@ -478,9 +481,9 @@ static int net_conf_listshares(struct net_context *c,
goto done;
}
- werr = smbconf_get_share_names(conf_ctx, mem_ctx, &num_shares,
- &share_names);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_share_names(conf_ctx, mem_ctx, &num_shares,
+ &share_names);
+ if (!SBC_ERROR_IS_OK(err)) {
goto done;
}
@@ -500,17 +503,17 @@ static int net_conf_drop(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
int ret = -1;
- WERROR werr;
+ sbcErr err;
if (argc != 0 || c->display_usage) {
net_conf_drop_usage(c, argc, argv);
goto done;
}
- werr = smbconf_drop(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_drop(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error deleting configuration: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
@@ -525,7 +528,7 @@ static int net_conf_showshare(struct net_context *c,
const char **argv)
{
int ret = -1;
- WERROR werr = WERR_OK;
+ sbcErr err;
const char *sharename = NULL;
TALLOC_CTX *mem_ctx;
uint32_t count;
@@ -544,10 +547,10 @@ static int net_conf_showshare(struct net_context *c,
goto done;
}
- werr = smbconf_get_share(conf_ctx, mem_ctx, sharename, &service);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_get_share(conf_ctx, mem_ctx, sharename, &service);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error getting share parameters: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
@@ -576,13 +579,12 @@ static int net_conf_addshare(struct net_context *c,
const char **argv)
{
int ret = -1;
- WERROR werr = WERR_OK;
+ sbcErr err;
char *sharename = NULL;
const char *path = NULL;
const char *comment = NULL;
const char *guest_ok = "no";
const char *writeable = "no";
- SMB_STRUCT_STAT sbuf;
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (c->display_usage) {
@@ -682,30 +684,14 @@ static int net_conf_addshare(struct net_context *c,
goto done;
}
- if (sys_stat(path, &sbuf, false) != 0) {
- d_fprintf(stderr,
- _("ERROR: cannot stat path '%s' to ensure "
- "this is a directory.\n"
- "Error was '%s'.\n"),
- path, strerror(errno));
- goto done;
- }
-
- if (!S_ISDIR(sbuf.st_ex_mode)) {
- d_fprintf(stderr,
- _("ERROR: path '%s' is not a directory.\n"),
- path);
- goto done;
- }
-
/*
* start a transaction
*/
- werr = smbconf_transaction_start(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_start(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf("error starting transaction: %s\n",
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
@@ -713,10 +699,10 @@ static int net_conf_addshare(struct net_context *c,
* create the share
*/
- werr = smbconf_create_share(conf_ctx, sharename);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_create_share(conf_ctx, sharename);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error creating share %s: %s\n"),
- sharename, win_errstr(werr));
+ sharename, sbcErrorString(err));
goto cancel;
}
@@ -724,35 +710,35 @@ static int net_conf_addshare(struct net_context *c,
* fill the share with parameters
*/
- werr = smbconf_set_parameter(conf_ctx, sharename, "path", path);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, sharename, "path", path);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
- "path", win_errstr(werr));
+ "path", sbcErrorString(err));
goto cancel;
}
if (comment != NULL) {
- werr = smbconf_set_parameter(conf_ctx, sharename, "comment",
- comment);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, sharename, "comment",
+ comment);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
- "comment", win_errstr(werr));
+ "comment", sbcErrorString(err));
goto cancel;
}
}
- werr = smbconf_set_parameter(conf_ctx, sharename, "guest ok", guest_ok);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, sharename, "guest ok", guest_ok);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
- "'guest ok'", win_errstr(werr));
+ "'guest ok'", sbcErrorString(err));
goto cancel;
}
- werr = smbconf_set_parameter(conf_ctx, sharename, "writeable",
- writeable);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, sharename, "writeable",
+ writeable);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting parameter %s: %s\n"),
- "writeable", win_errstr(werr));
+ "writeable", sbcErrorString(err));
goto cancel;
}
@@ -760,10 +746,10 @@ static int net_conf_addshare(struct net_context *c,
* commit the whole thing
*/
- werr = smbconf_transaction_commit(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_commit(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf("error committing transaction: %s\n",
- win_errstr(werr));
+ sbcErrorString(err));
} else {
ret = 0;
}
@@ -771,10 +757,10 @@ static int net_conf_addshare(struct net_context *c,
goto done;
cancel:
- werr = smbconf_transaction_cancel(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_cancel(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf("error cancelling transaction: %s\n",
- win_errstr(werr));
+ sbcErrorString(err));
}
done:
@@ -788,7 +774,7 @@ static int net_conf_delshare(struct net_context *c,
{
int ret = -1;
const char *sharename = NULL;
- WERROR werr = WERR_OK;
+ sbcErr err;
TALLOC_CTX *mem_ctx = talloc_stackframe();
if (argc != 1 || c->display_usage) {
@@ -801,10 +787,10 @@ static int net_conf_delshare(struct net_context *c,
goto done;
}
- werr = smbconf_delete_share(conf_ctx, sharename);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_delete_share(conf_ctx, sharename);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error deleting share %s: %s\n"),
- sharename, win_errstr(werr));
+ sharename, sbcErrorString(err));
goto done;
}
@@ -818,7 +804,7 @@ static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
int ret = -1;
- WERROR werr = WERR_OK;
+ sbcErr err;
char *service = NULL;
char *param = NULL;
const char *value_str = NULL;
@@ -846,34 +832,33 @@ static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
}
value_str = argv[2];
- werr = smbconf_transaction_start(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_start(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error starting transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
goto done;
}
if (!smbconf_share_exists(conf_ctx, service)) {
- werr = smbconf_create_share(conf_ctx, service);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_create_share(conf_ctx, service);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error creating share '%s': %s\n"),
- service, win_errstr(werr));
+ service, sbcErrorString(err));
goto cancel;
}
}
- werr = smbconf_set_parameter(conf_ctx, service, param, value_str);
-
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_set_parameter(conf_ctx, service, param, value_str);
+ if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error setting value '%s': %s\n"),
- param, win_errstr(werr));
+ param, sbcErrorString(err));
goto cancel;
}
- werr = smbconf_transaction_commit(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_commit(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error committing transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
} else {
ret = 0;
}
@@ -881,10 +866,10 @@ static int net_conf_setparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto done;
cancel:
- werr = smbconf_transaction_cancel(conf_ctx);
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_transaction_cancel(conf_ctx);
+ if (!SBC_ERROR_IS_OK(err)) {
d_printf(_("error cancelling transaction: %s\n"),
- win_errstr(werr));
+ sbcErrorString(err));
}
done:
@@ -896,7 +881,7 @@ static int net_conf_getparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
int ret = -1;
- WERROR werr = WERR_OK;
+ sbcErr err;
char *service = NULL;
char *param = NULL;
char *valstr = NULL;
@@ -925,21 +910,20 @@ static int net_conf_getparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto done;
}
- werr = smbconf_get_parameter(conf_ctx, mem_ctx, service, param, &valstr);
-
- if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) {
+ err = smbconf_get_parameter(conf_ctx, mem_ctx, service, param, &valstr);
+ if (SBC_ERROR_EQUAL(err, SBC_ERR_NO_SUCH_SERVICE)) {
d_fprintf(stderr,
_("Error: given service '%s' does not exist.\n"),
service);
goto done;
- } else if (W_ERROR_EQUAL(werr, WERR_INVALID_PARAM)) {
+ } else if (SBC_ERROR_EQUAL(err, SBC_ERR_INVALID_PARAM)) {
d_fprintf(stderr,
_("Error: given parameter '%s' is not set.\n"),
param);
goto done;
- } else if (!W_ERROR_IS_OK(werr)) {
+ } else if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error getting value '%s': %s.\n"),
- param, win_errstr(werr));
+ param, sbcErrorString(err));
goto done;
}
@@ -955,7 +939,7 @@ static int net_conf_delparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
int ret = -1;
- WERROR werr = WERR_OK;
+ sbcErr err;
char *service = NULL;
char *param = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
@@ -981,21 +965,20 @@ static int net_conf_delparm(struct net_context *c, struct smbconf_ctx *conf_ctx,
goto done;
}
- werr = smbconf_delete_parameter(conf_ctx, service, param);
-
- if (W_ERROR_EQUAL(werr, WERR_NO_SUCH_SERVICE)) {
+ err = smbconf_delete_parameter(conf_ctx, service, param);
+ if (SBC_ERROR_EQUAL(err, SBC_ERR_NO_SUCH_SERVICE)) {
d_fprintf(stderr,
_("Error: given service '%s' does not exist.\n"),
service);
goto done;
- } else if (W_ERROR_EQUAL(werr, WERR_INVALID_PARAM)) {
+ } else if (SBC_ERROR_EQUAL(err, SBC_ERR_INVALID_PARAM)) {
d_fprintf(stderr,
_("Error: given parameter '%s' is not set.\n"),
param);
goto done;
- } else if (!W_ERROR_IS_OK(werr)) {
+ } else if (!SBC_ERROR_IS_OK(err)) {
d_fprintf(stderr, _("Error deleting value '%s': %s.\n"),
- param, win_errstr(werr));
+ param, sbcErrorString(err));
goto done;
}
@@ -1010,7 +993,7 @@ static int net_conf_getincludes(struct net_context *c,
struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
- WERROR werr;
+ sbcErr err;
uint32_t num_includes;
uint32_t count;
char *service;
@@ -1029,10 +1012,10 @@ static int net_conf_getincludes(struct net_context *c,
goto done;
}
- werr = smbconf_get_includes(conf_ctx, mem_ctx, service,
+ err = smbconf_get_includes(conf_ctx, mem_ctx, service,
&num_includes, &includes);
- if (!W_ERROR_IS_OK(werr)) {
- d_printf(_("error getting includes: %s\n"), win_errstr(werr));
+ if (!SBC_ERROR_IS_OK(err)) {
+ d_printf(_("error getting includes: %s\n"), sbcErrorString(err));
goto done;
}
@@ -1051,7 +1034,7 @@ static int net_conf_setincludes(struct net_context *c,
struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
- WERROR werr;
+ sbcErr err;
char *service;
uint32_t num_includes;
const char **includes;
@@ -1076,9 +1059,9 @@ static int net_conf_setincludes(struct net_context *c,
includes = argv + 1;
}
- werr = smbconf_set_includes(conf_ctx, service, num_includes, includes);
- if (!W_ERROR_IS_OK(werr)) {
- d_printf(_("error setting includes: %s\n"), win_errstr(werr));
+ err = smbconf_set_includes(conf_ctx, service, num_includes, includes);
+ if (!SBC_ERROR_IS_OK(err)) {
+ d_printf(_("error setting includes: %s\n"), sbcErrorString(err));
goto done;
}
@@ -1093,7 +1076,7 @@ static int net_conf_delincludes(struct net_context *c,
struct smbconf_ctx *conf_ctx,
int argc, const char **argv)
{
- WERROR werr;
+ sbcErr err;
char *service;
int ret = -1;
TALLOC_CTX *mem_ctx = talloc_stackframe();
@@ -1109,9 +1092,9 @@ static int net_conf_delincludes(struct net_context *c,
goto done;
}
- werr = smbconf_delete_includes(conf_ctx, service);
- if (!W_ERROR_IS_OK(werr)) {
- d_printf(_("error deleting includes: %s\n"), win_errstr(werr));
+ err = smbconf_delete_includes(conf_ctx, service);
+ if (!SBC_ERROR_IS_OK(err)) {
+ d_printf(_("error deleting includes: %s\n"), sbcErrorString(err));
goto done;
}
@@ -1140,14 +1123,13 @@ static int net_conf_wrap_function(struct net_context *c,
int, const char **),
int argc, const char **argv)
{
- WERROR werr;
+ sbcErr err;
TALLOC_CTX *mem_ctx = talloc_stackframe();
struct smbconf_ctx *conf_ctx;
int ret = -1;
- werr = smbconf_init(mem_ctx, &conf_ctx, "registry:");
-
- if (!W_ERROR_IS_OK(werr)) {
+ err = smbconf_init(mem_ctx, &conf_ctx, "registry:");
+ if (!SBC_ERROR_IS_OK(err)) {
return -1;
}
@@ -1184,7 +1166,7 @@ static int net_conf_run_function(struct net_context *c, int argc,
if (argc != 0) {
for (i=0; table[i].funcname; i++) {
- if (StrCaseCmp(argv[0], table[i].funcname) == 0)
+ if (strcasecmp_m(argv[0], table[i].funcname) == 0)
return net_conf_wrap_function(c, table[i].fn,
argc-1,
argv+1);
diff --git a/source3/utils/net_dom.c b/source3/utils/net_dom.c
index 4378d01fe7..2b67b7b2fe 100644
--- a/source3/utils/net_dom.c
+++ b/source3/utils/net_dom.c
@@ -23,6 +23,7 @@
#include "../librpc/gen_ndr/ndr_winreg.h"
#include "lib/netapi/netapi.h"
#include "lib/netapi/netapi_net.h"
+#include "libsmb/libsmb.h"
int net_dom_usage(struct net_context *c, int argc, const char **argv)
{
diff --git a/source3/utils/net_file.c b/source3/utils/net_file.c
index 27f2d24096..71a7e05fe7 100644
--- a/source3/utils/net_file.c
+++ b/source3/utils/net_file.c
@@ -44,7 +44,7 @@ int net_file(struct net_context *c, int argc, const char **argv)
if (argc < 1)
return net_file_usage(c, argc, argv);
- if (StrCaseCmp(argv[0], "HELP") == 0) {
+ if (strcasecmp_m(argv[0], "HELP") == 0) {
net_file_usage(c, argc, argv);
return 0;
}
diff --git a/source3/utils/net_g_lock.c b/source3/utils/net_g_lock.c
index 6ed5d1776a..f8a7a8b620 100644
--- a/source3/utils/net_g_lock.c
+++ b/source3/utils/net_g_lock.c
@@ -113,7 +113,7 @@ static int net_g_lock_dump_fn(struct server_id pid, enum g_lock_type lock_type,
{
char *pidstr;
- pidstr = procid_str(talloc_tos(), &pid);
+ pidstr = server_id_str(talloc_tos(), &pid);
d_printf("%s: %s (%s)\n", pidstr,
(lock_type & 1) ? "WRITE" : "READ",
(lock_type & G_LOCK_PENDING) ? "pending" : "holder");
@@ -175,7 +175,7 @@ done:
TALLOC_FREE(g_ctx);
TALLOC_FREE(msg);
TALLOC_FREE(ev);
- return ret;
+ return ret < 0 ? -1 : ret;
}
int net_g_lock(struct net_context *c, int argc, const char **argv)
diff --git a/source3/utils/net_group.c b/source3/utils/net_group.c
index 7114f1feea..505856a008 100644
--- a/source3/utils/net_group.c
+++ b/source3/utils/net_group.c
@@ -55,7 +55,7 @@ int net_group(struct net_context *c, int argc, const char **argv)
if (argc < 1)
return net_group_usage(c, argc, argv);
- if (StrCaseCmp(argv[0], "HELP") == 0) {
+ if (strcasecmp_m(argv[0], "HELP") == 0) {
net_group_usage(c, argc, argv);
return 0;
}
diff --git a/source3/utils/net_groupmap.c b/source3/utils/net_groupmap.c
index 818905e122..09f4bfd33a 100644
--- a/source3/utils/net_groupmap.c
+++ b/source3/utils/net_groupmap.c
@@ -35,7 +35,7 @@ static bool get_sid_from_input(struct dom_sid *sid, char *input)
{
GROUP_MAP map;
- if (StrnCaseCmp( input, "S-", 2)) {
+ if (strncasecmp_m( input, "S-", 2)) {
/* Perhaps its the NT group name? */
if (!pdb_getgrnam(&map, input)) {
printf(_("NT Group %s doesn't exist in mapping DB\n"),
@@ -100,17 +100,17 @@ static int net_groupmap_list(struct net_context *c, int argc, const char **argv)
/* get the options */
for ( i=0; i<argc; i++ ) {
- if ( !StrCaseCmp(argv[i], "verbose")) {
+ if ( !strcasecmp_m(argv[i], "verbose")) {
long_list = true;
}
- else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
+ else if ( !strncasecmp_m(argv[i], "ntgroup", strlen("ntgroup")) ) {
fstrcpy( ntgroup, get_string_param( argv[i] ) );
if ( !ntgroup[0] ) {
d_fprintf(stderr, _("must supply a name\n"));
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
+ else if ( !strncasecmp_m(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"));
@@ -130,7 +130,7 @@ static int net_groupmap_list(struct net_context *c, int argc, const char **argv)
GROUP_MAP map;
if ( sid_string[0] )
- fstrcpy( ntgroup, sid_string);
+ strlcpy(ntgroup, sid_string, sizeof(ntgroup));
if (!get_sid_from_input(&sid, ntgroup)) {
return -1;
@@ -201,7 +201,7 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
/* get the options */
for ( i=0; i<argc; i++ ) {
- if ( !StrnCaseCmp(argv[i], "rid", strlen("rid")) ) {
+ if ( !strncasecmp_m(argv[i], "rid", strlen("rid")) ) {
rid = get_int_param(argv[i]);
if ( rid < DOMAIN_RID_ADMINS ) {
d_fprintf(stderr,
@@ -210,28 +210,28 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) {
+ else if ( !strncasecmp_m(argv[i], "unixgroup", strlen("unixgroup")) ) {
fstrcpy( unixgrp, get_string_param( argv[i] ) );
if ( !unixgrp[0] ) {
d_fprintf(stderr,_( "must supply a name\n"));
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
+ else if ( !strncasecmp_m(argv[i], "ntgroup", strlen("ntgroup")) ) {
fstrcpy( ntgroup, get_string_param( argv[i] ) );
if ( !ntgroup[0] ) {
d_fprintf(stderr, _("must supply a name\n"));
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
+ else if ( !strncasecmp_m(argv[i], "sid", strlen("sid")) ) {
fstrcpy( string_sid, get_string_param( argv[i] ) );
if ( !string_sid[0] ) {
d_fprintf(stderr, _("must supply a SID\n"));
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
+ else if ( !strncasecmp_m(argv[i], "comment", strlen("comment")) ) {
fstrcpy( ntcomment, get_string_param( argv[i] ) );
if ( !ntcomment[0] ) {
d_fprintf(stderr,
@@ -239,7 +239,7 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "type", strlen("type")) ) {
+ else if ( !strncasecmp_m(argv[i], "type", strlen("type")) ) {
fstrcpy( type, get_string_param( argv[i] ) );
switch ( type[0] ) {
case 'b':
@@ -324,7 +324,7 @@ static int net_groupmap_add(struct net_context *c, int argc, const char **argv)
}
if (!ntgroup[0] )
- fstrcpy( ntgroup, unixgrp );
+ strlcpy(ntgroup, unixgrp, sizeof(ntgroup));
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);
@@ -361,21 +361,21 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
/* get the options */
for ( i=0; i<argc; i++ ) {
- if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
+ if ( !strncasecmp_m(argv[i], "ntgroup", strlen("ntgroup")) ) {
fstrcpy( ntgroup, get_string_param( argv[i] ) );
if ( !ntgroup[0] ) {
d_fprintf(stderr, _("must supply a name\n"));
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
+ else if ( !strncasecmp_m(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")) ) {
+ else if ( !strncasecmp_m(argv[i], "comment", strlen("comment")) ) {
fstrcpy( ntcomment, get_string_param( argv[i] ) );
if ( !ntcomment[0] ) {
d_fprintf(stderr,
@@ -383,7 +383,7 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) {
+ else if ( !strncasecmp_m(argv[i], "unixgroup", strlen("unixgroup")) ) {
fstrcpy( unixgrp, get_string_param( argv[i] ) );
if ( !unixgrp[0] ) {
d_fprintf(stderr,
@@ -391,7 +391,7 @@ static int net_groupmap_modify(struct net_context *c, int argc, const char **arg
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "type", strlen("type")) ) {
+ else if ( !strncasecmp_m(argv[i], "type", strlen("type")) ) {
fstrcpy( type, get_string_param( argv[i] ) );
switch ( type[0] ) {
case 'd':
@@ -457,10 +457,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 );
+ strlcpy(map.comment, ntcomment, sizeof(map.comment));
if ( ntgroup[0] )
- fstrcpy( map.nt_name, ntgroup );
+ strlcpy(map.nt_name, ntgroup, sizeof(map.nt_name));
if ( unixgrp[0] ) {
gid = nametogid( unixgrp );
@@ -500,14 +500,14 @@ static int net_groupmap_delete(struct net_context *c, int argc, const char **arg
/* get the options */
for ( i=0; i<argc; i++ ) {
- if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
+ if ( !strncasecmp_m(argv[i], "ntgroup", strlen("ntgroup")) ) {
fstrcpy( ntgroup, get_string_param( argv[i] ) );
if ( !ntgroup[0] ) {
d_fprintf(stderr, _("must supply a name\n"));
return -1;
}
}
- else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
+ else if ( !strncasecmp_m(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"));
@@ -528,7 +528,7 @@ static int net_groupmap_delete(struct net_context *c, int argc, const char **arg
/* give preference to the SID if we have that */
if ( sid_string[0] )
- fstrcpy( ntgroup, sid_string );
+ strlcpy(ntgroup, sid_string, sizeof(ntgroup));
if ( !get_sid_from_input(&sid, ntgroup) ) {
d_fprintf(stderr, _("Unable to resolve group %s to a SID\n"),
diff --git a/source3/utils/net_help.c b/source3/utils/net_help.c
index 4e326ba902..4aba1c5703 100644
--- a/source3/utils/net_help.c
+++ b/source3/utils/net_help.c
@@ -60,7 +60,7 @@ int net_help(struct net_context *c, int argc, const char **argv)
return net_usage(c, argc, argv);
}
- if (StrCaseCmp(argv[0], "help") == 0) {
+ if (strcasecmp_m(argv[0], "help") == 0) {
return net_help_usage(c, argc, argv);
}
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c
index e059a6432c..383035e906 100644
--- a/source3/utils/net_idmap.c
+++ b/source3/utils/net_idmap.c
@@ -25,6 +25,7 @@
#include "dbwrap.h"
#include "../libcli/security/security.h"
#include "net_idmap_check.h"
+#include "util_tdb.h"
#define ALLOC_CHECK(mem) do { \
if (!mem) { \
diff --git a/source3/utils/net_idmap_check.c b/source3/utils/net_idmap_check.c
index 88725e18a6..3adc060a7c 100644
--- a/source3/utils/net_idmap_check.c
+++ b/source3/utils/net_idmap_check.c
@@ -32,6 +32,7 @@
#include "cbuf.h"
#include "srprs.h"
#include <termios.h>
+#include "util_tdb.h"
static int traverse_commit(struct db_record *diff_rec, void* data);
static int traverse_check(struct db_record *rec, void* data);
@@ -345,7 +346,7 @@ fetch_record(struct check_ctx* ctx, TALLOC_CTX* mem_ctx, TDB_DATA key)
{
TDB_DATA tmp;
- if (ctx->diff->fetch(ctx->diff, mem_ctx, key, &tmp) == -1) {
+ if (ctx->diff->fetch(ctx->diff, mem_ctx, key, &tmp) != 0) {
DEBUG(0, ("Out of memory!\n"));
return tdb_null;
}
@@ -356,7 +357,7 @@ fetch_record(struct check_ctx* ctx, TALLOC_CTX* mem_ctx, TDB_DATA key)
return ret;
}
- if (ctx->db->fetch(ctx->db, mem_ctx, key, &tmp) == -1) {
+ if (ctx->db->fetch(ctx->db, mem_ctx, key, &tmp) != 0) {
DEBUG(0, ("Out of memory!\n"));
return tdb_null;
}
diff --git a/source3/utils/net_join.c b/source3/utils/net_join.c
index 9e9ef2af06..1493dff74d 100644
--- a/source3/utils/net_join.c
+++ b/source3/utils/net_join.c
@@ -34,7 +34,7 @@ int net_join_usage(struct net_context *c, int argc, const char **argv)
int net_join(struct net_context *c, int argc, const char **argv)
{
- if ((argc > 0) && (StrCaseCmp(argv[0], "HELP") == 0)) {
+ if ((argc > 0) && (strcasecmp_m(argv[0], "HELP") == 0)) {
net_join_usage(c, argc, argv);
return 0;
}
diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c
index 06aedbd473..febf481e55 100644
--- a/source3/utils/net_lookup.c
+++ b/source3/utils/net_lookup.c
@@ -290,10 +290,10 @@ static int net_lookup_kdc(struct net_context *c, int argc, const char **argv)
}
if (argc>0) {
- realm.data = CONST_DISCARD(char *, argv[0]);
+ realm.data = discard_const_p(char, argv[0]);
realm.length = strlen(argv[0]);
} else if (lp_realm() && *lp_realm()) {
- realm.data = lp_realm();
+ realm.data = discard_const_p(char, lp_realm());
realm.length = strlen((const char *)realm.data);
} else {
rc = krb5_get_host_realm(ctx, NULL, &realms);
@@ -457,7 +457,7 @@ int net_lookup(struct net_context *c, int argc, const char **argv)
return net_lookup_usage(c, argc, argv);
}
for (i=0; table[i].funcname; i++) {
- if (StrCaseCmp(argv[0], table[i].funcname) == 0)
+ if (strcasecmp_m(argv[0], table[i].funcname) == 0)
return table[i].fn(c, argc-1, argv+1);
}
diff --git a/source3/utils/net_printing.c b/source3/utils/net_printing.c
index 11c87bb5b4..2f8caad8fd 100644
--- a/source3/utils/net_printing.c
+++ b/source3/utils/net_printing.c
@@ -28,6 +28,7 @@
#include "rpc_client/cli_spoolss.h"
#include "../libcli/security/security.h"
#include "../librpc/gen_ndr/ndr_security.h"
+#include "util_tdb.h"
#define FORMS_PREFIX "FORMS/"
#define DRIVERS_PREFIX "DRIVERS/"
@@ -161,7 +162,7 @@ static int net_printing_dump(struct net_context *c, int argc,
int ret = -1;
TALLOC_CTX *ctx = talloc_stackframe();
TDB_CONTEXT *tdb;
- TDB_DATA kbuf, newkey, dbuf;
+ TDB_DATA kbuf, dbuf;
if (argc < 1 || c->display_usage) {
d_fprintf(stderr, "%s\nnet printing dump <file.tdb>\n",
@@ -175,11 +176,11 @@ static int net_printing_dump(struct net_context *c, int argc,
goto done;
}
- for (kbuf = tdb_firstkey(tdb);
+ for (kbuf = tdb_firstkey_compat(tdb);
kbuf.dptr;
- newkey = tdb_nextkey(tdb, kbuf), free(kbuf.dptr), kbuf=newkey)
+ kbuf = tdb_nextkey_compat(tdb, kbuf))
{
- dbuf = tdb_fetch(tdb, kbuf);
+ dbuf = tdb_fetch_compat(tdb, kbuf);
if (!dbuf.dptr) {
continue;
}
@@ -512,7 +513,7 @@ static NTSTATUS migrate_printer(TALLOC_CTX *mem_ctx,
continue;
}
- keyname = CONST_DISCARD(char *, r.printer_data[j].name);
+ keyname = discard_const_p(char, r.printer_data[j].name);
valuename = strchr(keyname, '\\');
if (valuename == NULL) {
continue;
@@ -636,7 +637,7 @@ static NTSTATUS printing_migrate_internal(struct net_context *c,
{
TALLOC_CTX *tmp_ctx;
TDB_CONTEXT *tdb;
- TDB_DATA kbuf, newkey, dbuf;
+ TDB_DATA kbuf, dbuf;
NTSTATUS status;
tmp_ctx = talloc_new(mem_ctx);
@@ -651,11 +652,11 @@ static NTSTATUS printing_migrate_internal(struct net_context *c,
goto done;
}
- for (kbuf = tdb_firstkey(tdb);
+ for (kbuf = tdb_firstkey_compat(tdb);
kbuf.dptr;
- newkey = tdb_nextkey(tdb, kbuf), free(kbuf.dptr), kbuf = newkey)
+ kbuf = tdb_nextkey_compat(tdb, kbuf))
{
- dbuf = tdb_fetch(tdb, kbuf);
+ dbuf = tdb_fetch_compat(tdb, kbuf);
if (!dbuf.dptr) {
continue;
}
diff --git a/source3/utils/net_proto.h b/source3/utils/net_proto.h
index ba3860a88d..ad20f6e074 100644
--- a/source3/utils/net_proto.h
+++ b/source3/utils/net_proto.h
@@ -23,6 +23,7 @@
#ifndef _NET_PROTO_H_
#define _NET_PROTO_H_
+#include "libads/ads_status.h"
/* The following definitions come from utils/net.c */
diff --git a/source3/utils/net_rap.c b/source3/utils/net_rap.c
index afda222740..36f6d33197 100644
--- a/source3/utils/net_rap.c
+++ b/source3/utils/net_rap.c
@@ -26,6 +26,7 @@
#include "../librpc/gen_ndr/rap.h"
#include "../librpc/gen_ndr/svcctl.h"
#include "utils/net.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
/* The following messages were for error checking that is not properly
@@ -824,7 +825,7 @@ 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((char *)userinfo.user_name, argv[0], sizeof(userinfo.user_name)-1);
+ strlcpy((char *)userinfo.user_name, argv[0], sizeof(userinfo.user_name));
if (c->opt_flags == 0)
c->opt_flags = 0x21;
@@ -969,7 +970,7 @@ static int rap_group_add(struct net_context *c, int argc, const char **argv)
return -1;
/* BB check for length 21 or smaller explicitly ? BB */
- safe_strcpy((char *)grinfo.group_name, argv[0], sizeof(grinfo.group_name)-1);
+ strlcpy((char *)grinfo.group_name, argv[0], sizeof(grinfo.group_name));
grinfo.reserved1 = '\0';
grinfo.comment = smb_xstrdup(c->opt_comment ? c->opt_comment : "");
diff --git a/source3/utils/net_registry.c b/source3/utils/net_registry.c
index 19405e2c08..086c4e7ccc 100644
--- a/source3/utils/net_registry.c
+++ b/source3/utils/net_registry.c
@@ -122,23 +122,88 @@ done:
return werr;
}
+static WERROR registry_enumkey(struct registry_key* parent, const char* keyname, bool recursive)
+{
+ WERROR werr;
+ TALLOC_CTX *ctx = talloc_stackframe();
+ char* subkey_name;
+ NTTIME modtime;
+ uint32_t count;
+ char* valname = NULL;
+ struct registry_value *valvalue = NULL;
+ struct registry_key* key = NULL;
+
+ werr = reg_openkey(ctx, parent, keyname, REG_KEY_READ, &key);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+
+ if (recursive) {
+ printf("[%s]\n\n", key->key->name);
+ } else {
+ for (count = 0;
+ werr = reg_enumkey(ctx, key, count, &subkey_name, &modtime),
+ W_ERROR_IS_OK(werr);
+ count++)
+ {
+ print_registry_key(subkey_name, &modtime);
+ }
+ if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
+ goto done;
+ }
+ }
+
+ for (count = 0;
+ werr = reg_enumvalue(ctx, key, count, &valname, &valvalue),
+ W_ERROR_IS_OK(werr);
+ count++)
+ {
+ print_registry_value_with_name(valname, valvalue);
+ }
+ if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
+ goto done;
+ }
+
+ if (!recursive) {
+ werr = WERR_OK;
+ goto done;
+ }
+
+ for (count = 0;
+ werr = reg_enumkey(ctx, key, count, &subkey_name, &modtime),
+ W_ERROR_IS_OK(werr);
+ count++)
+ {
+ werr = registry_enumkey(key, subkey_name, recursive);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+ }
+ if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
+ goto done;
+ }
+
+ werr = WERR_OK;
+
+done:
+ TALLOC_FREE(ctx);
+ return werr;
+}
+
+
+
/*
*
* the main "net registry" function implementations
*
*/
-
static int net_registry_enumerate(struct net_context *c, int argc,
const char **argv)
{
WERROR werr;
struct registry_key *key = NULL;
+ char* name = NULL;
TALLOC_CTX *ctx = talloc_stackframe();
- char *subkey_name;
- NTTIME modtime;
- uint32_t count;
- char *valname = NULL;
- struct registry_value *valvalue = NULL;
int ret = -1;
if (argc != 1 || c->display_usage) {
@@ -151,40 +216,56 @@ static int net_registry_enumerate(struct net_context *c, int argc,
goto done;
}
- werr = open_key(ctx, argv[0], REG_KEY_READ, &key);
+ werr = open_hive(ctx, argv[0], REG_KEY_READ, &key, &name);
if (!W_ERROR_IS_OK(werr)) {
d_fprintf(stderr, _("open_key failed: %s\n"), win_errstr(werr));
goto done;
}
- for (count = 0;
- werr = reg_enumkey(ctx, key, count, &subkey_name, &modtime),
- W_ERROR_IS_OK(werr);
- count++)
- {
- print_registry_key(subkey_name, &modtime);
+ werr = registry_enumkey(key, name, c->opt_reboot);
+ if (W_ERROR_IS_OK(werr)) {
+ ret = 0;
}
- if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
+done:
+ TALLOC_FREE(ctx);
+ return ret;
+}
+
+static int net_registry_enumerate_recursive(struct net_context *c, int argc,
+ const char **argv)
+{
+ WERROR werr;
+ struct registry_key *key = NULL;
+ char* name = NULL;
+ TALLOC_CTX *ctx = talloc_stackframe();
+ int ret = -1;
+
+ if (argc != 1 || c->display_usage) {
+ d_printf("%s\n%s",
+ _("Usage:"),
+ _("net registry enumerate <path>\n"));
+ d_printf("%s\n%s",
+ _("Example:"),
+ _("net registry enumerate 'HKLM\\Software\\Samba'\n"));
goto done;
}
- for (count = 0;
- werr = reg_enumvalue(ctx, key, count, &valname, &valvalue),
- W_ERROR_IS_OK(werr);
- count++)
- {
- print_registry_value_with_name(valname, valvalue);
- }
- if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
+ werr = open_hive(ctx, argv[0], REG_KEY_READ, &key, &name);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_fprintf(stderr, _("open_key failed: %s\n"), win_errstr(werr));
goto done;
}
- ret = 0;
+ werr = registry_enumkey(key, name, true);
+ if (W_ERROR_IS_OK(werr)) {
+ ret = 0;
+ }
done:
TALLOC_FREE(ctx);
return ret;
}
+
static int net_registry_createkey(struct net_context *c, int argc,
const char **argv)
{
@@ -958,9 +1039,11 @@ static int net_registry_import(struct net_context *c, int argc,
.createkey = (reg_import_callback_createkey_t)&import_create_key,
.deletekey = (reg_import_callback_deletekey_t)&import_delete_key,
.deleteval = (reg_import_callback_deleteval_t)&import_delete_val,
- .setval.registry_value = (reg_import_callback_setval_registry_value_t)
- &import_create_val,
- .setval_type = REGISTRY_VALUE,
+ .setval = {
+ .registry_value = (reg_import_callback_setval_registry_value_t)
+ &import_create_val,
+ },
+ .setval_type = REGISTRY_VALUE,
.data = &import_ctx
};
@@ -1019,7 +1102,6 @@ static int registry_export(TALLOC_CTX *ctx, /*const*/ struct registry_key* key,
struct registry_value *valvalue = NULL;
char *valname = NULL;
- struct registry_key* subkey = NULL;
char *subkey_name = NULL;
NTTIME modtime = 0;
@@ -1045,6 +1127,8 @@ static int registry_export(TALLOC_CTX *ctx, /*const*/ struct registry_key* key,
W_ERROR_IS_OK(werr);
count++)
{
+ struct registry_key* subkey = NULL;
+
werr = reg_openkey(ctx, key, subkey_name, REG_KEY_READ,
&subkey);
if (!W_ERROR_IS_OK(werr)) {
@@ -1054,6 +1138,7 @@ static int registry_export(TALLOC_CTX *ctx, /*const*/ struct registry_key* key,
}
registry_export(ctx, subkey, f);
+ TALLOC_FREE(subkey);
}
if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
d_fprintf(stderr, _("reg_enumkey failed: %s\n"),
@@ -1174,6 +1259,14 @@ int net_registry(struct net_context *c, int argc, const char **argv)
" Enumerate registry keys and values")
},
{
+ "enumerate_recursive",
+ net_registry_enumerate_recursive,
+ NET_TRANSPORT_LOCAL,
+ N_("Enumerate registry keys and values"),
+ N_("net registry enumerate_recursive\n"
+ " Enumerate registry keys and values")
+ },
+ {
"createkey",
net_registry_createkey,
NET_TRANSPORT_LOCAL,
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 4003b88d51..2ecf1aaa5a 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -39,6 +39,7 @@
#include "lib/netapi/netapi_net.h"
#include "rpc_client/init_lsa.h"
#include "../libcli/security/security.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
#include "nsswitch/libwbclient/wbclient.h"
#include "passdb.h"
@@ -365,7 +366,7 @@ static NTSTATUS rpc_oldjoin_internals(struct net_context *c,
sec_channel_type = get_sec_channel_type(NULL);
}
- fstrcpy(trust_passwd, global_myname());
+ fstrcpy(trust_passwd, lp_netbios_name());
strlower_m(trust_passwd);
/*
@@ -378,7 +379,7 @@ static NTSTATUS rpc_oldjoin_internals(struct net_context *c,
E_md4hash(trust_passwd, orig_trust_passwd_hash);
result = trust_pw_change_and_store_it(pipe_hnd, mem_ctx, c->opt_target_workgroup,
- global_myname(),
+ lp_netbios_name(),
orig_trust_passwd_hash,
sec_channel_type);
@@ -480,10 +481,10 @@ int net_rpc_join(struct net_context *c, int argc, const char **argv)
return -1;
}
- if (strlen(global_myname()) > 15) {
+ if (strlen(lp_netbios_name()) > 15) {
d_printf(_("Our netbios name can be at most 15 chars long, "
"\"%s\" is %u chars long\n"),
- global_myname(), (unsigned int)strlen(global_myname()));
+ lp_netbios_name(), (unsigned int)strlen(lp_netbios_name()));
return -1;
}
@@ -549,7 +550,7 @@ NTSTATUS rpc_info_internals(struct net_context *c,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -1622,7 +1623,7 @@ static NTSTATUS rpc_group_delete_internals(struct net_context *c,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -1976,7 +1977,7 @@ static NTSTATUS get_sid_from_name(struct cli_state *cli,
TALLOC_FREE(pipe_hnd);
}
- if (!NT_STATUS_IS_OK(status) && (StrnCaseCmp(name, "S-", 2) == 0)) {
+ if (!NT_STATUS_IS_OK(status) && (strncasecmp_m(name, "S-", 2) == 0)) {
/* Try as S-1-5-whatever */
@@ -2584,7 +2585,7 @@ static NTSTATUS rpc_group_list_internals(struct net_context *c,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -2710,7 +2711,7 @@ static NTSTATUS rpc_group_list_internals(struct net_context *c,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
+ discard_const_p(struct dom_sid2, &global_sid_Builtin),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -2956,7 +2957,7 @@ static NTSTATUS rpc_list_alias_members(struct net_context *c,
return result;
}
- alias_sids = TALLOC_ZERO_ARRAY(mem_ctx, struct dom_sid, num_members);
+ alias_sids = talloc_zero_array(mem_ctx, struct dom_sid, num_members);
if (!alias_sids) {
d_fprintf(stderr, _("Out of memory\n"));
TALLOC_FREE(lsa_pipe);
@@ -3032,7 +3033,7 @@ static NTSTATUS rpc_group_members_internals(struct net_context *c,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -3430,7 +3431,7 @@ static WERROR get_share_info(struct net_context *c,
{
struct srvsvc_NetShareCtr1 *ctr1;
- ctr1 = TALLOC_ZERO_P(mem_ctx, struct srvsvc_NetShareCtr1);
+ ctr1 = talloc_zero(mem_ctx, struct srvsvc_NetShareCtr1);
W_ERROR_HAVE_NO_MEMORY(ctr1);
ctr1->count = 1;
@@ -3444,7 +3445,7 @@ static WERROR get_share_info(struct net_context *c,
{
struct srvsvc_NetShareCtr2 *ctr2;
- ctr2 = TALLOC_ZERO_P(mem_ctx, struct srvsvc_NetShareCtr2);
+ ctr2 = talloc_zero(mem_ctx, struct srvsvc_NetShareCtr2);
W_ERROR_HAVE_NO_MEMORY(ctr2);
ctr2->count = 1;
@@ -3458,7 +3459,7 @@ static WERROR get_share_info(struct net_context *c,
{
struct srvsvc_NetShareCtr502 *ctr502;
- ctr502 = TALLOC_ZERO_P(mem_ctx, struct srvsvc_NetShareCtr502);
+ ctr502 = talloc_zero(mem_ctx, struct srvsvc_NetShareCtr502);
W_ERROR_HAVE_NO_MEMORY(ctr502);
ctr502->count = 1;
@@ -3730,7 +3731,7 @@ static NTSTATUS copy_fn(const char *mnt, struct file_info *f,
DEBUG(3,("got mask: %s, name: %s\n", mask, f->name));
/* DIRECTORY */
- if (f->mode & aDIR) {
+ if (f->mode & FILE_ATTRIBUTE_DIRECTORY) {
DEBUG(3,("got dir: %s\n", f->name));
@@ -3763,8 +3764,8 @@ static NTSTATUS copy_fn(const char *mnt, struct file_info *f,
}
/* search below that directory */
- fstrcpy(new_mask, dir);
- fstrcat(new_mask, "\\*");
+ strlcpy(new_mask, dir, sizeof(new_mask));
+ strlcat(new_mask, "\\*", sizeof(new_mask));
old_dir = local_state->cwd;
local_state->cwd = dir;
@@ -3968,7 +3969,7 @@ static NTSTATUS rpc_share_migrate_files_internals(struct net_context *c,
cp_clistate.cli_share_src = NULL;
cp_clistate.cli_share_dst = NULL;
cp_clistate.cwd = NULL;
- cp_clistate.attribute = aSYSTEM | aHIDDEN | aDIR;
+ cp_clistate.attribute = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY;
cp_clistate.c = c;
/* open share source */
@@ -4318,7 +4319,7 @@ static NTSTATUS rpc_fetch_domain_aliases(struct rpc_pipe_client *pipe_hnd,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -4802,7 +4803,7 @@ static bool get_user_tokens_from_file(FILE *f,
token = &((*tokens)[*num_tokens-1]);
- fstrcpy(token->name, line);
+ strlcpy(token->name, line, sizeof(token->name));
token->token.num_sids = 0;
token->token.sids = NULL;
continue;
@@ -5803,7 +5804,7 @@ static NTSTATUS rpc_trustdom_add_internals(struct net_context *c,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -5977,7 +5978,7 @@ static NTSTATUS rpc_trustdom_del_internals(struct net_context *c,
status = dcerpc_samr_OpenDomain(b, mem_ctx,
&connect_pol,
MAXIMUM_ALLOWED_ACCESS,
- CONST_DISCARD(struct dom_sid2 *, domain_sid),
+ discard_const_p(struct dom_sid2, domain_sid),
&domain_pol,
&result);
if (!NT_STATUS_IS_OK(status)) {
@@ -6500,7 +6501,6 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
struct rpc_pipe_client *pipe_hnd = NULL;
NTSTATUS nt_status, result;
const char *domain_name = NULL;
- struct dom_sid *queried_dom_sid;
struct policy_handle connect_hnd;
union lsa_PolicyInformation *info = NULL;
@@ -6531,11 +6531,11 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
* or to remote one given in command line
*/
- if (StrCaseCmp(c->opt_workgroup, lp_workgroup())) {
+ if (strcasecmp_m(c->opt_workgroup, lp_workgroup())) {
domain_name = c->opt_workgroup;
c->opt_target_workgroup = c->opt_workgroup;
} else {
- fstrcpy(pdc_name, global_myname());
+ fstrcpy(pdc_name, lp_netbios_name());
domain_name = talloc_strdup(mem_ctx, lp_workgroup());
c->opt_target_workgroup = domain_name;
};
@@ -6593,8 +6593,6 @@ static int rpc_trustdom_vampire(struct net_context *c, int argc,
return -1;
}
- queried_dom_sid = info->account_domain.sid;
-
/*
* Keep calling LsaEnumTrustdom over opened pipe until
* the end of enumeration is reached
@@ -6711,11 +6709,11 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
* or to remote one given in command line
*/
- if (StrCaseCmp(c->opt_workgroup, lp_workgroup())) {
+ if (strcasecmp_m(c->opt_workgroup, lp_workgroup())) {
domain_name = c->opt_workgroup;
c->opt_target_workgroup = c->opt_workgroup;
} else {
- fstrcpy(pdc_name, global_myname());
+ fstrcpy(pdc_name, lp_netbios_name());
domain_name = talloc_strdup(mem_ctx, lp_workgroup());
c->opt_target_workgroup = domain_name;
};
@@ -6937,7 +6935,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
for (i = 0; i < num_domains; i++) {
- char *str = CONST_DISCARD(char *, trusts->entries[i].name.string);
+ char *str = discard_const_p(char, trusts->entries[i].name.string);
found_domain = true;
@@ -7090,16 +7088,11 @@ bool net_rpc_check(struct net_context *c, unsigned flags)
if (!net_find_server(c, NULL, flags, &server_ss, &server_name))
return false;
- if ((cli = cli_initialise()) == NULL) {
+ status = cli_connect_nb(server_name, &server_ss, 0, 0x20,
+ lp_netbios_name(), Undefined, &cli);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
-
- status = cli_connect(cli, server_name, &server_ss);
- if (!NT_STATUS_IS_OK(status))
- goto done;
- if (!attempt_netbios_session_request(&cli, global_myname(),
- server_name, &server_ss))
- goto done;
status = cli_negprot(cli);
if (!NT_STATUS_IS_OK(status))
goto done;
diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c
index 1ca213d155..d228f92804 100644
--- a/source3/utils/net_rpc_join.c
+++ b/source3/utils/net_rpc_join.c
@@ -30,6 +30,7 @@
#include "rpc_client/cli_netlogon.h"
#include "secrets.h"
#include "rpc_client/init_lsa.h"
+#include "libsmb/libsmb.h"
/* Macro for checking RPC error codes to make things more readable */
@@ -306,7 +307,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
"could not open domain");
/* Create domain user */
- if ((acct_name = talloc_asprintf(mem_ctx, "%s$", global_myname())) == NULL) {
+ if ((acct_name = talloc_asprintf(mem_ctx, "%s$", lp_netbios_name())) == NULL) {
status = NT_STATUS_NO_MEMORY;
goto done;
}
@@ -442,8 +443,8 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
status = rpccli_netlogon_setup_creds(pipe_hnd,
cli->desthost, /* server name */
domain, /* domain */
- global_myname(), /* client name */
- global_myname(), /* machine account name */
+ lp_netbios_name(), /* client name */
+ lp_netbios_name(), /* machine account name */
md4_trust_password,
sec_channel_type,
&neg_flags);
@@ -457,7 +458,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
d_fprintf(stderr, _("Please make sure that no computer "
"account\nnamed like this machine "
"(%s) exists in the domain\n"),
- global_myname());
+ lp_netbios_name());
}
goto done;
@@ -486,7 +487,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
"computer account\nnamed "
"like this machine (%s) "
"exists in the domain\n"),
- global_myname());
+ lp_netbios_name());
}
goto done;
@@ -498,7 +499,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
/* Now store the secret in the secrets database */
- strupper_m(CONST_DISCARD(char *, domain));
+ strupper_m(discard_const_p(char, domain));
if (!secrets_store_domain_sid(domain, domain_sid)) {
DEBUG(0, ("error storing domain sid for %s\n", domain));
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index 7a22587174..272e0c9dfa 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -27,7 +27,7 @@
#include "registry/reg_objects.h"
#include "../libcli/security/security.h"
#include "../libcli/registry/util_reg.h"
-#include "ntdomain.h"
+#include "libsmb/libsmb.h"
/* support itanium as well */
static const struct print_architecture_table_node archi_table[]= {
@@ -70,7 +70,7 @@ static void display_print_driver3(struct spoolss_DriverInfo3 *r)
printf(_("\tConfigfile: [%s]\n\n"), r->config_file);
printf(_("\tHelpfile: [%s]\n\n"), r->help_file);
- for (i=0; r->dependent_files[i] != NULL; i++) {
+ for (i=0; r->dependent_files && r->dependent_files[i] != NULL; i++) {
printf(_("\tDependentfiles: [%s]\n"), r->dependent_files[i]);
}
@@ -158,14 +158,13 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
bool copy_acls, bool copy_attrs,
bool copy_timestamps, bool is_file)
{
- NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
+ NTSTATUS nt_status;
uint16_t fnum_src = 0;
uint16_t fnum_dst = 0;
struct security_descriptor *sd = NULL;
uint16_t attr;
time_t f_atime, f_ctime, f_mtime;
-
if (!copy_timestamps && !copy_acls && !copy_attrs)
return NT_STATUS_OK;
@@ -174,17 +173,17 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
DEBUGADD(3,("opening %s %s on originating server\n",
is_file?"file":"dir", src_name));
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli_share_src, src_name, 0, READ_CONTROL_ACCESS, 0,
- FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum_src))) {
+ nt_status = cli_ntcreate(cli_share_src, src_name, 0,
+ READ_CONTROL_ACCESS, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN,
+ 0x0, 0x0, &fnum_src);
+ if (!NT_STATUS_IS_OK(nt_status)) {
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);
+ is_file?"file":"dir", src_name, nt_errstr(nt_status)));
goto out;
}
-
if (copy_acls) {
-
/* get the security descriptor */
sd = cli_query_secdesc(cli_share_src, fnum_src, mem_ctx);
if (!sd) {
@@ -198,81 +197,74 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
display_sec_desc(sd);
}
-
if (copy_attrs || copy_timestamps) {
/* get file attributes */
- if (!NT_STATUS_IS_OK(cli_getattrE(cli_share_src, fnum_src, &attr, NULL,
- &f_ctime, &f_atime, &f_mtime))) {
+ nt_status = cli_getattrE(cli_share_src, fnum_src, &attr, NULL,
+ &f_ctime, &f_atime, &f_mtime);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("failed to get file-attrs: %s\n",
- cli_errstr(cli_share_src)));
- nt_status = cli_nt_error(cli_share_src);
+ nt_errstr(nt_status)));
goto out;
}
}
-
/* open the file/dir on the destination server */
-
- if (!NT_STATUS_IS_OK(cli_ntcreate(cli_share_dst, dst_name, 0, WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS, 0,
- FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum_dst))) {
+ nt_status = cli_ntcreate(cli_share_dst, dst_name, 0,
+ WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN,
+ 0x0, 0x0, &fnum_dst);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("failed to open %s on the destination server: %s: %s\n",
- is_file?"file":"dir", dst_name, cli_errstr(cli_share_dst)));
- nt_status = cli_nt_error(cli_share_dst);
+ is_file?"file":"dir", dst_name, nt_errstr(nt_status)));
goto out;
}
if (copy_timestamps) {
-
/* set timestamps */
- if (!NT_STATUS_IS_OK(cli_setattrE(cli_share_dst, fnum_dst, f_ctime, f_atime, f_mtime))) {
+ nt_status = cli_setattrE(cli_share_dst, fnum_dst, f_ctime, f_atime, f_mtime);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("failed to set file-attrs (timestamps): %s\n",
- cli_errstr(cli_share_dst)));
- nt_status = cli_nt_error(cli_share_dst);
+ nt_errstr(nt_status)));
goto out;
}
}
if (copy_acls) {
- NTSTATUS status;
-
/* set acls */
- status = cli_set_secdesc(cli_share_dst, fnum_dst, sd);
- if (!NT_STATUS_IS_OK(status)) {
+ nt_status = cli_set_secdesc(cli_share_dst, fnum_dst, sd);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("could not set secdesc on %s: %s\n",
- dst_name, nt_errstr(status)));
- nt_status = status;
+ dst_name, nt_errstr(nt_status)));
goto out;
}
}
if (copy_attrs) {
-
/* set attrs */
- if (!NT_STATUS_IS_OK(cli_setatr(cli_share_dst, dst_name, attr, 0))) {
+ nt_status = cli_setatr(cli_share_dst, dst_name, attr, 0);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("failed to set file-attrs: %s\n",
- cli_errstr(cli_share_dst)));
- nt_status = cli_nt_error(cli_share_dst);
+ nt_errstr(nt_status)));
goto out;
}
}
/* closing files */
-
- if (!NT_STATUS_IS_OK(cli_close(cli_share_src, fnum_src))) {
+ nt_status = cli_close(cli_share_src, fnum_src);
+ if (!NT_STATUS_IS_OK(nt_status)) {
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);
+ is_file?"file":"dir", nt_errstr(nt_status));
goto out;
}
- if (!NT_STATUS_IS_OK(cli_close(cli_share_dst, fnum_dst))) {
+ nt_status = cli_close(cli_share_dst, fnum_dst);
+ if (!NT_STATUS_IS_OK(nt_status)) {
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);
+ is_file?"file":"dir", nt_errstr(nt_status));
goto out;
}
@@ -343,7 +335,7 @@ NTSTATUS net_copy_file(struct net_context *c,
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUGADD(0,("cannot open %s %s on originating server %s\n",
is_file ? "file":"dir",
- src_name, cli_errstr(cli_share_src)));
+ src_name, nt_errstr(nt_status)));
goto out;
}
@@ -357,7 +349,7 @@ NTSTATUS net_copy_file(struct net_context *c,
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUGADD(1,("cannot create file %s on destination server: %s\n",
- dst_name, cli_errstr(cli_share_dst)));
+ dst_name, nt_errstr(nt_status)));
goto out;
}
@@ -387,20 +379,19 @@ NTSTATUS net_copy_file(struct net_context *c,
while (is_file) {
/* copying file */
- int n, ret;
+ int n;
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,
- nread, n);
+ nt_status = cli_writeall(cli_share_dst, fnum_dst, 0,
+ (uint8_t *)data, nread, n, NULL);
- if (n != ret) {
+ if (!NT_STATUS_IS_OK(nt_status)) {
d_fprintf(stderr, _("Error writing file: %s\n"),
- cli_errstr(cli_share_dst));
- nt_status = cli_nt_error(cli_share_dst);
+ nt_errstr(nt_status));
goto out;
}
@@ -414,36 +405,41 @@ NTSTATUS net_copy_file(struct net_context *c,
DEBUGADD(3,("creating dir %s on the destination server\n",
dst_name));
- if (!NT_STATUS_IS_OK(cli_mkdir(cli_share_dst, dst_name))) {
+ nt_status = cli_mkdir(cli_share_dst, dst_name);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("cannot create directory %s: %s\n",
- dst_name, cli_errstr(cli_share_dst)));
+ dst_name, nt_errstr(nt_status)));
nt_status = NT_STATUS_NO_SUCH_FILE;
}
- if (!NT_STATUS_IS_OK(cli_chkpath(cli_share_dst, dst_name))) {
+
+ nt_status = cli_chkpath(cli_share_dst, dst_name);
+ if (!NT_STATUS_IS_OK(nt_status)) {
d_fprintf(stderr,
_("cannot check for directory %s: %s\n"),
- dst_name, cli_errstr(cli_share_dst));
+ dst_name, nt_errstr(nt_status));
goto out;
}
}
/* closing files */
- if (!NT_STATUS_IS_OK(cli_close(cli_share_src, fnum_src))) {
+ nt_status = cli_close(cli_share_src, fnum_src);
+ if (!NT_STATUS_IS_OK(nt_status)) {
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);
+ nt_errstr(nt_status));
goto out;
}
- if (is_file && !NT_STATUS_IS_OK(cli_close(cli_share_dst, fnum_dst))) {
- d_fprintf(stderr,
+ if (is_file) {
+ nt_status = cli_close(cli_share_dst, fnum_dst);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ 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;
+ nt_errstr(nt_status));
+ goto out;
+ }
}
/* possibly we have to copy some file-attributes / acls / sd */
@@ -563,15 +559,16 @@ static NTSTATUS check_arch_dir(struct cli_state *cli_share, const char *short_ar
DEBUG(10,("creating print-driver dir for architecture: %s\n",
short_archi));
- if (!NT_STATUS_IS_OK(cli_mkdir(cli_share, dir))) {
+ nt_status = cli_mkdir(cli_share, dir);
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(1,("cannot create directory %s: %s\n",
- dir, cli_errstr(cli_share)));
- nt_status = NT_STATUS_NO_SUCH_FILE;
+ dir, nt_errstr(nt_status)));
}
- if (!NT_STATUS_IS_OK(cli_chkpath(cli_share, dir))) {
+ nt_status = cli_chkpath(cli_share, dir);
+ if (!NT_STATUS_IS_OK(nt_status)) {
d_fprintf(stderr, _("cannot check %s: %s\n"),
- dir, cli_errstr(cli_share));
+ dir, nt_errstr(nt_status));
goto out;
}
@@ -2547,7 +2544,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
if (strequal(info[j].value_name, SPOOL_REG_SHORTSERVERNAME)) {
- push_reg_sz(mem_ctx, &blob, global_myname());
+ push_reg_sz(mem_ctx, &blob, lp_netbios_name());
}
value = regval_compose(talloc_tos(),
diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c
index 31f4e3ec5f..9195bd477d 100644
--- a/source3/utils/net_rpc_registry.c
+++ b/source3/utils/net_rpc_registry.c
@@ -31,6 +31,7 @@
#include <assert.h>
#include "../libcli/security/display_sec.h"
#include "../libcli/registry/util_reg.h"
+#include "client.h"
/*******************************************************************
@@ -210,9 +211,9 @@ static NTSTATUS registry_enumkeys(TALLOC_CTX *ctx,
return NT_STATUS_OK;
}
- if ((!(names = TALLOC_ZERO_ARRAY(mem_ctx, char *, num_subkeys))) ||
- (!(classes = TALLOC_ZERO_ARRAY(mem_ctx, char *, num_subkeys))) ||
- (!(modtimes = TALLOC_ZERO_ARRAY(mem_ctx, NTTIME *,
+ if ((!(names = talloc_zero_array(mem_ctx, char *, num_subkeys))) ||
+ (!(classes = talloc_zero_array(mem_ctx, char *, num_subkeys))) ||
+ (!(modtimes = talloc_zero_array(mem_ctx, NTTIME *,
num_subkeys)))) {
status = NT_STATUS_NO_MEMORY;
goto error;
@@ -332,8 +333,8 @@ static NTSTATUS registry_enumvalues(TALLOC_CTX *ctx,
return NT_STATUS_OK;
}
- if ((!(names = TALLOC_ARRAY(mem_ctx, char *, num_values))) ||
- (!(values = TALLOC_ARRAY(mem_ctx, struct registry_value *,
+ if ((!(names = talloc_array(mem_ctx, char *, num_values))) ||
+ (!(values = talloc_array(mem_ctx, struct registry_value *,
num_values)))) {
status = NT_STATUS_NO_MEMORY;
goto error;
@@ -455,8 +456,8 @@ static NTSTATUS registry_enumvalues2(TALLOC_CTX *ctx,
return NT_STATUS_OK;
}
- if ((!(names = TALLOC_ARRAY(mem_ctx, char *, num_values))) ||
- (!(values = TALLOC_ARRAY(mem_ctx, struct regval_blob *,
+ if ((!(names = talloc_array(mem_ctx, char *, num_values))) ||
+ (!(values = talloc_array(mem_ctx, struct regval_blob *,
num_values)))) {
status = NT_STATUS_NO_MEMORY;
goto error;
@@ -1450,7 +1451,7 @@ static NTSTATUS rpc_registry_getsd_internal(struct net_context *c,
return status;
}
- sd = TALLOC_ZERO_P(mem_ctx, struct KeySecurityData);
+ sd = talloc_zero(mem_ctx, struct KeySecurityData);
if (!sd) {
status = NT_STATUS_NO_MEMORY;
goto out;
@@ -1958,7 +1959,9 @@ static NTSTATUS rpc_registry_import_internal(struct net_context *c,
.createkey = (reg_import_callback_createkey_t)&import_create_key,
.deletekey = (reg_import_callback_deletekey_t)&import_delete_key,
.deleteval = (reg_import_callback_deleteval_t)&import_delete_val,
- .setval.blob = (reg_import_callback_setval_blob_t)&import_create_val,
+ .setval = {
+ .blob = (reg_import_callback_setval_blob_t)&import_create_val,
+ },
.setval_type = BLOB,
.data = &import_ctx
};
diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c
index a2847749b7..737bfb0e86 100644
--- a/source3/utils/net_rpc_rights.c
+++ b/source3/utils/net_rpc_rights.c
@@ -190,7 +190,7 @@ static NTSTATUS check_privilege_for_user(struct rpc_pipe_client *pipe_hnd,
}
for (i = 0; i < rights.count; i++) {
- if (StrCaseCmp(rights.names[i].string, right) == 0) {
+ if (strcasecmp_m(rights.names[i].string, right) == 0) {
return NT_STATUS_OK;
}
}
@@ -506,7 +506,7 @@ static NTSTATUS rpc_rights_grant_internal(struct net_context *c,
return status;
rights.count = argc-1;
- rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge,
+ rights.names = talloc_array(mem_ctx, struct lsa_StringLarge,
rights.count);
if (!rights.names) {
return NT_STATUS_NO_MEMORY;
@@ -579,7 +579,7 @@ static NTSTATUS rpc_rights_revoke_internal(struct net_context *c,
return status;
rights.count = argc-1;
- rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge,
+ rights.names = talloc_array(mem_ctx, struct lsa_StringLarge,
rights.count);
if (!rights.names) {
return NT_STATUS_NO_MEMORY;
diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c
index 861f429559..04aefbb13f 100644
--- a/source3/utils/net_rpc_samsync.c
+++ b/source3/utils/net_rpc_samsync.c
@@ -51,50 +51,50 @@ static void parse_samsync_partial_replication_objects(TALLOC_CTX *mem_ctx,
ZERO_STRUCT(o);
- if (!StrnCaseCmp(argv[i], "user_rid=", strlen("user_rid="))) {
+ if (!strncasecmp_m(argv[i], "user_rid=", strlen("user_rid="))) {
o.object_identifier.rid = get_int_param(argv[i]);
o.object_type = NETR_DELTA_USER;
o.database_id = SAM_DATABASE_DOMAIN;
}
- if (!StrnCaseCmp(argv[i], "group_rid=", strlen("group_rid="))) {
+ if (!strncasecmp_m(argv[i], "group_rid=", strlen("group_rid="))) {
o.object_identifier.rid = get_int_param(argv[i]);
o.object_type = NETR_DELTA_GROUP;
o.database_id = SAM_DATABASE_DOMAIN;
}
- if (!StrnCaseCmp(argv[i], "group_member_rid=", strlen("group_member_rid="))) {
+ if (!strncasecmp_m(argv[i], "group_member_rid=", strlen("group_member_rid="))) {
o.object_identifier.rid = get_int_param(argv[i]);
o.object_type = NETR_DELTA_GROUP_MEMBER;
o.database_id = SAM_DATABASE_DOMAIN;
}
- if (!StrnCaseCmp(argv[i], "alias_rid=", strlen("alias_rid="))) {
+ if (!strncasecmp_m(argv[i], "alias_rid=", strlen("alias_rid="))) {
o.object_identifier.rid = get_int_param(argv[i]);
o.object_type = NETR_DELTA_ALIAS;
o.database_id = SAM_DATABASE_BUILTIN;
}
- if (!StrnCaseCmp(argv[i], "alias_member_rid=", strlen("alias_member_rid="))) {
+ if (!strncasecmp_m(argv[i], "alias_member_rid=", strlen("alias_member_rid="))) {
o.object_identifier.rid = get_int_param(argv[i]);
o.object_type = NETR_DELTA_ALIAS_MEMBER;
o.database_id = SAM_DATABASE_BUILTIN;
}
- if (!StrnCaseCmp(argv[i], "account_sid=", strlen("account_sid="))) {
+ if (!strncasecmp_m(argv[i], "account_sid=", strlen("account_sid="))) {
const char *sid_str = get_string_param(argv[i]);
string_to_sid(&o.object_identifier.sid, sid_str);
o.object_type = NETR_DELTA_ACCOUNT;
o.database_id = SAM_DATABASE_PRIVS;
}
- if (!StrnCaseCmp(argv[i], "policy_sid=", strlen("policy_sid="))) {
+ if (!strncasecmp_m(argv[i], "policy_sid=", strlen("policy_sid="))) {
const char *sid_str = get_string_param(argv[i]);
string_to_sid(&o.object_identifier.sid, sid_str);
o.object_type = NETR_DELTA_POLICY;
o.database_id = SAM_DATABASE_PRIVS;
}
- if (!StrnCaseCmp(argv[i], "trustdom_sid=", strlen("trustdom_sid="))) {
+ if (!strncasecmp_m(argv[i], "trustdom_sid=", strlen("trustdom_sid="))) {
const char *sid_str = get_string_param(argv[i]);
string_to_sid(&o.object_identifier.sid, sid_str);
o.object_type = NETR_DELTA_TRUSTED_DOMAIN;
o.database_id = SAM_DATABASE_PRIVS;
}
- if (!StrnCaseCmp(argv[i], "secret_name=", strlen("secret_name="))) {
+ if (!strncasecmp_m(argv[i], "secret_name=", strlen("secret_name="))) {
o.object_identifier.name = get_string_param(argv[i]);
o.object_type = NETR_DELTA_SECRET;
o.database_id = SAM_DATABASE_PRIVS;
diff --git a/source3/utils/net_rpc_shell.c b/source3/utils/net_rpc_shell.c
index 1985bf8b0b..42dfc48d4a 100644
--- a/source3/utils/net_rpc_shell.c
+++ b/source3/utils/net_rpc_shell.c
@@ -26,6 +26,7 @@
#include "lib/netapi/netapi.h"
#include "lib/netapi/netapi_net.h"
#include "../libcli/smbreadline/smbreadline.h"
+#include "libsmb/libsmb.h"
static NTSTATUS rpc_sh_info(struct net_context *c,
TALLOC_CTX *mem_ctx, struct rpc_sh_ctx *ctx,
@@ -153,7 +154,7 @@ static bool net_sh_process(struct net_context *c,
return true;
}
- new_ctx = TALLOC_P(ctx, struct rpc_sh_ctx);
+ new_ctx = talloc(ctx, struct rpc_sh_ctx);
if (new_ctx == NULL) {
d_fprintf(stderr, _("talloc failed\n"));
return false;
@@ -233,7 +234,7 @@ int net_rpc_shell(struct net_context *c, int argc, const char **argv)
libnetapi_set_use_kerberos(c->netapi_ctx);
}
- ctx = TALLOC_P(NULL, struct rpc_sh_ctx);
+ ctx = talloc(NULL, struct rpc_sh_ctx);
if (ctx == NULL) {
d_fprintf(stderr, _("talloc failed\n"));
return -1;
diff --git a/source3/utils/net_rpc_trust.c b/source3/utils/net_rpc_trust.c
index da0a7cca67..318c06ffe9 100644
--- a/source3/utils/net_rpc_trust.c
+++ b/source3/utils/net_rpc_trust.c
@@ -25,6 +25,7 @@
#include "../librpc/gen_ndr/ndr_lsa_c.h"
#include "../lib/crypto/crypto.h"
#include "../libcli/security/dom_sid.h"
+#include "libsmb/libsmb.h"
#define ARG_OTHERSERVER "otherserver="
@@ -418,19 +419,22 @@ static int rpc_trust_common(struct net_context *net_ctx, int argc,
struct other_dom_data *other_dom_data;
struct net_context *other_net_ctx = NULL;
struct dom_data dom_data[2];
+ void (*usage)(void);
+
+ switch (op) {
+ case TRUST_CREATE:
+ usage = print_trust_usage;
+ break;
+ case TRUST_DELETE:
+ usage = print_trust_delete_usage;
+ break;
+ default:
+ DEBUG(0, ("Unsupported trust operation.\n"));
+ return -1;
+ }
if (net_ctx->display_usage) {
- switch (op) {
- case TRUST_CREATE:
- print_trust_usage();
- break;
- case TRUST_DELETE:
- print_trust_delete_usage();
- break;
- default:
- DEBUG(0, ("Unsupported trust operation.\n"));
- return -1;
- }
+ usage();
return 0;
}
@@ -443,7 +447,7 @@ static int rpc_trust_common(struct net_context *net_ctx, int argc,
ret = parse_trust_args(mem_ctx, argc, argv, &other_dom_data, &trust_pw);
if (ret != 0) {
if (ret == EINVAL) {
- print_trust_usage();
+ usage();
} else {
DEBUG(0, ("Failed to parse arguments.\n"));
}
@@ -470,7 +474,7 @@ static int rpc_trust_common(struct net_context *net_ctx, int argc,
(dom_data[1].domain_name == NULL ||
dom_data[1].dns_domain_name == NULL))) {
DEBUG(0, ("Missing required argument.\n"));
- print_trust_usage();
+ usage();
goto done;
}
}
diff --git a/source3/utils/net_serverid.c b/source3/utils/net_serverid.c
index 08a1a7f298..4159eead7a 100644
--- a/source3/utils/net_serverid.c
+++ b/source3/utils/net_serverid.c
@@ -26,7 +26,7 @@
static int net_serverid_list_fn(const struct server_id *id,
uint32_t msg_flags, void *priv)
{
- char *str = procid_str(talloc_tos(), id);
+ char *str = server_id_str(talloc_tos(), id);
d_printf("%s %llu 0x%x\n", str, (unsigned long long)id->unique_id,
(unsigned int)msg_flags);
TALLOC_FREE(str);
@@ -37,7 +37,7 @@ static int net_serverid_list(struct net_context *c, int argc,
const char **argv)
{
d_printf("pid unique_id msg_flags\n");
- return serverid_traverse_read(net_serverid_list_fn, NULL) ? 0 : -1;
+ return serverid_traverse_read(net_serverid_list_fn, NULL) > 0 ? 0 : -1;
}
static int net_serverid_wipe_fn(struct db_record *rec,
@@ -51,7 +51,7 @@ static int net_serverid_wipe_fn(struct db_record *rec,
}
status = rec->delete_rec(rec);
if (!NT_STATUS_IS_OK(status)) {
- char *str = procid_str(talloc_tos(), id);
+ char *str = server_id_str(talloc_tos(), id);
DEBUG(1, ("Could not delete serverid.tdb record %s: %s\n",
str, nt_errstr(status)));
TALLOC_FREE(str);
@@ -62,7 +62,7 @@ static int net_serverid_wipe_fn(struct db_record *rec,
static int net_serverid_wipe(struct net_context *c, int argc,
const char **argv)
{
- return serverid_traverse(net_serverid_wipe_fn, NULL) ? 0 : -1;
+ return serverid_traverse(net_serverid_wipe_fn, NULL) > 0 ? 0 : -1;
}
static int net_serverid_wipedbs_conn(
@@ -75,13 +75,13 @@ static int net_serverid_wipedbs_conn(
NTSTATUS status;
DEBUG(10, ("Deleting connections.tdb record for pid %s\n",
- procid_str(talloc_tos(), &key->pid)));
+ server_id_str(talloc_tos(), &key->pid)));
status = rec->delete_rec(rec);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Could not delete connections.tdb record "
"for pid %s: %s\n",
- procid_str(talloc_tos(), &key->pid),
+ server_id_str(talloc_tos(), &key->pid),
nt_errstr(status)));
}
}
@@ -97,13 +97,13 @@ static int net_serverid_wipedbs_sessionid(struct db_record *rec,
NTSTATUS status;
DEBUG(10, ("Deleting sessionid.tdb record for pid %s\n",
- procid_str(talloc_tos(), &session->pid)));
+ server_id_str(talloc_tos(), &session->pid)));
status = rec->delete_rec(rec);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Could not delete session.tdb record "
"for pid %s: %s\n",
- procid_str(talloc_tos(), &session->pid),
+ server_id_str(talloc_tos(), &session->pid),
nt_errstr(status)));
}
}
diff --git a/source3/utils/net_share.c b/source3/utils/net_share.c
index 156b27b572..6eca9d64ce 100644
--- a/source3/utils/net_share.c
+++ b/source3/utils/net_share.c
@@ -62,7 +62,7 @@ int net_share_usage(struct net_context *c, int argc, const char **argv)
int net_share(struct net_context *c, int argc, const char **argv)
{
- if (argc > 0 && StrCaseCmp(argv[0], "HELP") == 0) {
+ if (argc > 0 && strcasecmp_m(argv[0], "HELP") == 0) {
net_share_usage(c, argc, argv);
return 0;
}
diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c
index fdb46dbba5..9b6293ed49 100644
--- a/source3/utils/net_time.c
+++ b/source3/utils/net_time.c
@@ -19,40 +19,25 @@
#include "includes.h"
#include "utils/net.h"
#include "libsmb/nmblib.h"
+#include "libsmb/libsmb.h"
/*
return the time on a server. This does not require any authentication
*/
static time_t cli_servertime(const char *host, struct sockaddr_storage *pss, int *zone)
{
- struct nmb_name calling, called;
time_t ret = 0;
struct cli_state *cli = NULL;
NTSTATUS status;
- cli = cli_initialise();
- if (!cli) {
- goto done;
- }
-
- status = cli_connect(cli, host, pss);
+ status = cli_connect_nb(host, pss, 0, 0x20, lp_netbios_name(),
+ Undefined, &cli);
if (!NT_STATUS_IS_OK(status)) {
fprintf(stderr, _("Can't contact server %s. Error %s\n"),
host, nt_errstr(status));
goto done;
}
- make_nmb_name(&calling, global_myname(), 0x0);
- if (host) {
- make_nmb_name(&called, host, 0x20);
- } else {
- make_nmb_name(&called, "*SMBSERVER", 0x20);
- }
-
- if (!cli_session_request(cli, &calling, &called)) {
- fprintf(stderr, _("Session request failed\n"));
- goto done;
- }
status = cli_negprot(cli);
if (!NT_STATUS_IS_OK(status)) {
fprintf(stderr, _("Protocol negotiation failed: %s\n"),
diff --git a/source3/utils/net_user.c b/source3/utils/net_user.c
index 2cf00170de..9fb6f80f92 100644
--- a/source3/utils/net_user.c
+++ b/source3/utils/net_user.c
@@ -50,7 +50,7 @@ int net_user(struct net_context *c, int argc, const char **argv)
if (argc < 1)
return net_user_usage(c, argc, argv);
- if (StrCaseCmp(argv[0], "HELP") == 0) {
+ if (strcasecmp_m(argv[0], "HELP") == 0) {
net_user_usage(c, argc, argv);
return 0;
}
diff --git a/source3/utils/net_usershare.c b/source3/utils/net_usershare.c
index 06ed4533d5..295f9ce4d9 100644
--- a/source3/utils/net_usershare.c
+++ b/source3/utils/net_usershare.c
@@ -278,7 +278,7 @@ static int get_share_list(TALLOC_CTX *ctx, const char *wcard, bool only_ours)
}
/* (Finally) - add to list. */
- fl = TALLOC_P(ctx, struct file_list);
+ fl = talloc(ctx, struct file_list);
if (!fl) {
sys_closedir(dp);
return -1;
diff --git a/source3/utils/net_util.c b/source3/utils/net_util.c
index ffcda14e7f..0b8bd839d1 100644
--- a/source3/utils/net_util.c
+++ b/source3/utils/net_util.c
@@ -27,6 +27,7 @@
#include "../librpc/gen_ndr/ndr_dssetup_c.h"
#include "secrets.h"
#include "../libcli/security/security.h"
+#include "libsmb/libsmb.h"
NTSTATUS net_rpc_lookup_name(struct net_context *c,
TALLOC_CTX *mem_ctx, struct cli_state *cli,
@@ -359,7 +360,7 @@ int net_use_krb_machine_account(struct net_context *c)
c->opt_password = secrets_fetch_machine_password(
c->opt_target_workgroup, NULL, NULL);
- if (asprintf(&user_name, "%s$@%s", global_myname(), lp_realm()) == -1) {
+ if (asprintf(&user_name, "%s$@%s", lp_netbios_name(), lp_realm()) == -1) {
return -1;
}
c->opt_user_name = user_name;
@@ -381,7 +382,7 @@ int net_use_machine_account(struct net_context *c)
c->opt_password = secrets_fetch_machine_password(
c->opt_target_workgroup, NULL, NULL);
- if (asprintf(&user_name, "%s$", global_myname()) == -1) {
+ if (asprintf(&user_name, "%s$", lp_netbios_name()) == -1) {
return -1;
}
c->opt_user_name = user_name;
@@ -585,7 +586,7 @@ int net_run_function(struct net_context *c, int argc, const char **argv,
if (argc != 0) {
for (i=0; table[i].funcname != NULL; i++) {
- if (StrCaseCmp(argv[0], table[i].funcname) == 0)
+ if (strcasecmp_m(argv[0], table[i].funcname) == 0)
return table[i].fn(c, argc-1, argv+1);
}
}
diff --git a/source3/utils/netlookup.c b/source3/utils/netlookup.c
index b160ee5586..5d81d43634 100644
--- a/source3/utils/netlookup.c
+++ b/source3/utils/netlookup.c
@@ -24,6 +24,7 @@
#include "rpc_client/cli_pipe.h"
#include "../librpc/gen_ndr/ndr_lsa.h"
#include "rpc_client/cli_lsarpc.h"
+#include "libsmb/libsmb.h"
/********************************************************
Connection cachine struct. Goes away when ctx destroyed.
@@ -77,7 +78,7 @@ static struct con_struct *create_cs(struct net_context *c,
return cs;
}
- cs = TALLOC_P(ctx, struct con_struct);
+ cs = talloc(ctx, struct con_struct);
if (!cs) {
*perr = NT_STATUS_NO_MEMORY;
return NULL;
@@ -97,7 +98,7 @@ static struct con_struct *create_cs(struct net_context *c,
}
#endif
- nt_status = cli_full_connection(&cs->cli, global_myname(), global_myname(),
+ nt_status = cli_full_connection(&cs->cli, lp_netbios_name(), lp_netbios_name(),
&loopback_ss, 0,
"IPC$", "IPC",
#if 0
diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c
index f8545401e6..73db278e36 100644
--- a/source3/utils/nmblookup.c
+++ b/source3/utils/nmblookup.c
@@ -168,27 +168,9 @@ static bool query_one(const char *lookup, unsigned int lookup_type)
&bcast_addr, talloc_tos(),
&ip_list, &count, &flags);
} else {
- const struct in_addr *bcast;
- for (j=iface_count() - 1;
- !ip_list && j >= 0;
- j--) {
- char addr[INET6_ADDRSTRLEN];
- struct sockaddr_storage bcast_ss;
-
- bcast = iface_n_bcast_v4(j);
- if (!bcast) {
- continue;
- }
- in_addr_to_sockaddr_storage(&bcast_ss, *bcast);
- print_sockaddr(addr, sizeof(addr), &bcast_ss);
- d_printf("querying %s on %s\n",
- lookup, addr);
- status = name_query(lookup,lookup_type,
- use_bcast,
- use_bcast?True:recursion_desired,
- &bcast_ss, talloc_tos(),
- &ip_list, &count, &flags);
- }
+ status = name_resolve_bcast(
+ lookup, lookup_type,
+ talloc_tos(), &ip_list, &count);
}
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
index 73f41a7fe6..ba11ec7368 100644
--- a/source3/utils/ntlm_auth.c
+++ b/source3/utils/ntlm_auth.c
@@ -217,7 +217,7 @@ const char *get_winbind_netbios_name(void)
if (winbindd_request_response(WINBINDD_NETBIOS_NAME, NULL, &response) !=
NSS_STATUS_SUCCESS) {
DEBUG(0, ("could not obtain winbind netbios name!\n"));
- return global_myname();
+ return lp_netbios_name();
}
fstrcpy(winbind_netbios_name, response.data.netbios_name);
@@ -313,13 +313,13 @@ int get_pam_winbind_config()
opt_pam_winbind_conf = PAM_WINBIND_CONFIG_FILE;
}
- d = iniparser_load(CONST_DISCARD(char *, opt_pam_winbind_conf));
+ d = iniparser_load(discard_const_p(char, opt_pam_winbind_conf));
if (!d) {
return 0;
}
- if (iniparser_getboolean(d, CONST_DISCARD(char *, "global:krb5_auth"), false)) {
+ if (iniparser_getboolean(d, discard_const_p(char, "global:krb5_auth"), false)) {
ctrl |= WINBIND_KRB5_AUTH;
}
@@ -657,7 +657,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_client(struct ntlmssp_state **client_ntl
}
status = ntlmssp_client_start(NULL,
- global_myname(),
+ lp_netbios_name(),
lp_workgroup(),
lp_client_ntlmv2_auth(),
client_ntlmssp_state);
@@ -711,7 +711,7 @@ static NTSTATUS ntlm_auth_start_ntlmssp_server(struct ntlmssp_state **ntlmssp_st
bool is_standalone = false;
if (opt_password) {
- netbios_name = global_myname();
+ netbios_name = lp_netbios_name();
netbios_domain = lp_workgroup();
} else {
netbios_name = get_winbind_netbios_name();
@@ -1182,7 +1182,7 @@ static void offer_gss_spnego_mechs(void) {
ZERO_STRUCT(spnego);
- myname_lower = talloc_strdup(ctx, global_myname());
+ myname_lower = talloc_strdup(ctx, lp_netbios_name());
if (!myname_lower) {
return;
}
@@ -1722,7 +1722,7 @@ static void manage_client_ntlmssp_targ(struct spnego_data spnego)
spnego.type = SPNEGO_NEG_TOKEN_TARG;
spnego.negTokenTarg.negResult = SPNEGO_ACCEPT_INCOMPLETE;
- spnego.negTokenTarg.supportedMech = (char *)OID_NTLMSSP;
+ spnego.negTokenTarg.supportedMech = (const char *)OID_NTLMSSP;
spnego.negTokenTarg.responseToken = request;
spnego.negTokenTarg.mechListMIC = null_blob;
@@ -2063,7 +2063,7 @@ static void manage_ntlm_server_1_request(struct ntlm_auth_state *state,
if (!NT_STATUS_IS_OK(
contact_winbind_auth_crap(username,
domain,
- global_myname(),
+ lp_netbios_name(),
&challenge,
&lm_response,
&nt_response,
@@ -2680,7 +2680,7 @@ enum {
break;
case OPT_REQUIRE_MEMBERSHIP:
- if (StrnCaseCmp("S-", require_membership_of, 2) == 0) {
+ if (strncasecmp_m("S-", require_membership_of, 2) == 0) {
require_membership_of_sid = require_membership_of;
}
break;
diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c
index 1d7c6c1294..ab52e4727a 100644
--- a/source3/utils/sharesec.c
+++ b/source3/utils/sharesec.c
@@ -312,7 +312,7 @@ static struct security_descriptor* parse_acl_string(TALLOC_CTX *mem_ctx, const c
pacl = szACL;
num_ace = count_chars( pacl, ',' ) + 1;
- if ( !(ace = TALLOC_ZERO_ARRAY( mem_ctx, struct security_ace, num_ace )) )
+ if ( !(ace = talloc_zero_array( mem_ctx, struct security_ace, num_ace )) )
return NULL;
for ( i=0; i<num_ace; i++ ) {
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c
index 45b4163c96..d226c84b9a 100644
--- a/source3/utils/smbcacls.c
+++ b/source3/utils/smbcacls.c
@@ -27,6 +27,7 @@
#include "../librpc/gen_ndr/ndr_lsa.h"
#include "rpc_client/cli_lsarpc.h"
#include "../libcli/security/security.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
#include "passdb/machine_sid.h"
@@ -359,7 +360,12 @@ static bool parse_ace_flags(const char *str, unsigned int *pflags)
return false;
}
- if (*p != '|' && *p != '\0') {
+ switch (*p) {
+ case '|':
+ p++;
+ case '\0':
+ continue;
+ default:
return false;
}
}
@@ -1044,7 +1050,7 @@ static int inherit(struct cli_state *cli, const char *filename,
/* Add inherited flag to all aces */
ace->flags=ace->flags|
SEC_ACE_FLAG_INHERITED_ACE;
- if ((oldattr & aDIR) == aDIR) {
+ if ((oldattr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {
if ((ace->flags & SEC_ACE_FLAG_CONTAINER_INHERIT) ==
SEC_ACE_FLAG_CONTAINER_INHERIT) {
add_ace(&old->dacl, ace);
@@ -1144,7 +1150,7 @@ static struct cli_state *connect_one(struct user_auth_info *auth_info,
set_cmdline_auth_info_getpass(auth_info);
- nt_status = cli_full_connection(&c, global_myname(), server,
+ nt_status = cli_full_connection(&c, lp_netbios_name(), server,
&ss, 0,
share, "?????",
get_cmdline_auth_info_username(auth_info),
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index ea1b681588..5520dcf608 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -31,6 +31,7 @@
#include "printing/notify.h"
#include "libsmb/nmblib.h"
#include "messages.h"
+#include "util_tdb.h"
#if HAVE_LIBUNWIND_H
#include <libunwind.h>
@@ -63,7 +64,7 @@ static bool send_message(struct messaging_context *msg_ctx,
if (procid_to_pid(&pid) != 0)
return NT_STATUS_IS_OK(
messaging_send_buf(msg_ctx, pid, msg_type,
- (uint8 *)buf, len));
+ (const uint8 *)buf, len));
ret = message_send_all(msg_ctx, msg_type, buf, len, &n_sent);
DEBUG(10,("smbcontrol/send_message: broadcast message to "
@@ -118,7 +119,7 @@ static void print_pid_string_cb(struct messaging_context *msg,
{
char *pidstr;
- pidstr = procid_str(talloc_tos(), &pid);
+ pidstr = server_id_str(talloc_tos(), &pid);
printf("PID %s: %.*s", pidstr, (int)data->length,
(const char *)data->data);
TALLOC_FREE(pidstr);
@@ -432,7 +433,7 @@ static void pong_cb(struct messaging_context *msg,
struct server_id pid,
DATA_BLOB *data)
{
- char *src_string = procid_str(NULL, &pid);
+ char *src_string = server_id_str(NULL, &pid);
printf("PONG from pid %s\n", src_string);
TALLOC_FREE(src_string);
num_replies++;
@@ -748,7 +749,7 @@ static bool do_printnotify(struct messaging_context *msg_ctx,
notify_printer_byname(messaging_event_context(msg_ctx),
msg_ctx, argv[2], attribute,
- CONST_DISCARD(char *, argv[4]));
+ discard_const_p(char, argv[4]));
goto send;
}
@@ -1142,7 +1143,7 @@ static void winbind_validate_cache_cb(struct messaging_context *msg,
struct server_id pid,
DATA_BLOB *data)
{
- char *src_string = procid_str(NULL, &pid);
+ char *src_string = server_id_str(NULL, &pid);
printf("Winbindd cache is %svalid. (answer from pid %s)\n",
(*(data->data) == 0 ? "" : "NOT "), src_string);
TALLOC_FREE(src_string);
@@ -1201,7 +1202,7 @@ static void my_make_nmb_name( struct nmb_name *n, const char *name, int type)
strupper_m(unix_name);
push_ascii(n->name, unix_name, sizeof(n->name), STR_TERMINATE);
n->name_type = (unsigned int)type & 0xFF;
- push_ascii(n->scope, global_scope(), 64, STR_TERMINATE);
+ push_ascii(n->scope, lp_netbios_scope(), 64, STR_TERMINATE);
}
static bool do_nodestatus(struct messaging_context *msg_ctx,
diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c
index 0efa60608b..9858e0a3a8 100644
--- a/source3/utils/smbcquotas.c
+++ b/source3/utils/smbcquotas.c
@@ -28,6 +28,7 @@
#include "rpc_client/cli_lsarpc.h"
#include "fake_file.h"
#include "../libcli/security/security.h"
+#include "libsmb/libsmb.h"
static char *server;
@@ -522,7 +523,7 @@ static struct cli_state *connect_one(const char *share)
set_cmdline_auth_info_getpass(smbcquotas_auth_info);
- nt_status = cli_full_connection(&c, global_myname(), server,
+ nt_status = cli_full_connection(&c, lp_netbios_name(), server,
&ss, 0,
share, "?????",
get_cmdline_auth_info_username(smbcquotas_auth_info),
diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c
index fc65b3b570..d60a13fd69 100644
--- a/source3/utils/smbget.c
+++ b/source3/utils/smbget.c
@@ -17,6 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "includes.h"
+#include "system/filesys.h"
#include "popt_common.h"
#include "libsmbclient.h"
@@ -669,7 +670,7 @@ int main(int argc, const char **argv)
if (smb_encrypt) {
SMBCCTX *smb_ctx = smbc_set_context(NULL);
smbc_option_set(smb_ctx,
- CONST_DISCARD(char *, "smb_encrypt_level"),
+ discard_const_p(char, "smb_encrypt_level"),
"require");
}
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index ada057c247..eeab4ef7de 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -107,6 +107,7 @@ static int process_options(int argc, char **argv, int local_flags)
break;
case 'c':
configfile = optarg;
+ set_dyn_CONFIGFILE(optarg);
break;
case 'a':
local_flags |= LOCAL_ADD_USER;
@@ -378,7 +379,7 @@ static int process_root(int local_flags)
*/
slprintf(buf, sizeof(buf)-1, "%s$", user_name);
- fstrcpy(user_name, buf);
+ strlcpy(user_name, buf, sizeof(user_name));
} else if (local_flags & LOCAL_INTERDOM_ACCOUNT) {
static fstring buf;
@@ -395,7 +396,7 @@ static int process_root(int local_flags)
/* prepare uppercased and '$' terminated username */
slprintf(buf, sizeof(buf) - 1, "%s$", user_name);
- fstrcpy(user_name, buf);
+ strlcpy(user_name, buf, sizeof(user_name));
} else {
diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c
index 3f7fc97698..41f4103e5a 100644
--- a/source3/utils/smbtree.c
+++ b/source3/utils/smbtree.c
@@ -23,6 +23,7 @@
#include "popt_common.h"
#include "rpc_client/cli_pipe.h"
#include "../librpc/gen_ndr/ndr_srvsvc_c.h"
+#include "libsmb/libsmb.h"
#include "libsmb/clirap.h"
static int use_bcast;
diff --git a/source3/utils/status.c b/source3/utils/status.c
index cf625fb73f..4d37f7e66e 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -474,7 +474,7 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
if (result == 0) {
d_printf("No locked files\n");
- } else if (result == -1) {
+ } else if (result < 0) {
d_printf("locked file list truncated\n");
}
diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c
index 978ada26c6..721034dedf 100644
--- a/source3/utils/testparm.c
+++ b/source3/utils/testparm.c
@@ -39,7 +39,7 @@
Check if a directory exists.
********************************************************************/
-static bool directory_exist_stat(char *dname,SMB_STRUCT_STAT *st)
+static bool directory_exist_stat(const char *dname,SMB_STRUCT_STAT *st)
{
SMB_STRUCT_STAT st2;
bool ret;
@@ -77,7 +77,7 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n");
ret = 1;
}
- if (strequal(lp_workgroup(), global_myname())) {
+ if (strequal(lp_workgroup(), lp_netbios_name())) {
fprintf(stderr, "WARNING: 'workgroup' and 'netbios name' " \
"must differ.\n");
ret = 1;
@@ -128,20 +128,35 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n");
* Password server sanity checks.
*/
- if((lp_security() == SEC_SERVER || lp_security() >= SEC_DOMAIN) && !lp_passwordserver()) {
+ if((lp_security() == SEC_SERVER || lp_security() >= SEC_DOMAIN) && !*lp_passwordserver()) {
const char *sec_setting;
if(lp_security() == SEC_SERVER)
sec_setting = "server";
else if(lp_security() == SEC_DOMAIN)
sec_setting = "domain";
+ else if(lp_security() == SEC_ADS)
+ sec_setting = "ads";
else
sec_setting = "";
- fprintf(stderr, "ERROR: The setting 'security=%s' requires the 'password server' parameter be set \
-to a valid password server.\n", sec_setting );
+ fprintf(stderr, "ERROR: The setting 'security=%s' requires the 'password server' parameter be set\n"
+ "to the default value * or a valid password server.\n", sec_setting );
ret = 1;
}
+ if((lp_security() >= SEC_DOMAIN) && (strcmp(lp_passwordserver(), "*") != 0)) {
+ const char *sec_setting;
+ if(lp_security() == SEC_DOMAIN)
+ sec_setting = "domain";
+ else if(lp_security() == SEC_ADS)
+ sec_setting = "ads";
+ else
+ sec_setting = "";
+
+ fprintf(stderr, "WARNING: The setting 'security=%s' should NOT be combined with the 'password server' parameter.\n"
+ "(by default Samba will discover the correct DC to contact automatically).\n", sec_setting );
+ }
+
/*
* Password chat sanity checks.
*/
@@ -246,6 +261,11 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_
fprintf(stderr,"WARNING: Maximum value for 'os level' is 255!\n");
}
+ if (strequal(lp_dos_charset(), "UTF8") || strequal(lp_dos_charset(), "UTF-8")) {
+ fprintf(stderr, "ERROR: 'dos charset' must not be UTF8\n");
+ ret = 1;
+ }
+
return ret;
}