summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/net.c38
-rw-r--r--source3/utils/net_ads.c88
-rw-r--r--source3/utils/net_ads_cldap.c12
-rw-r--r--source3/utils/net_cache.c14
-rw-r--r--source3/utils/net_groupmap.c78
-rw-r--r--source3/utils/net_idmap.c28
-rw-r--r--source3/utils/net_rap.c2
-rw-r--r--source3/utils/net_rpc.c110
-rw-r--r--source3/utils/net_rpc_join.c8
-rw-r--r--source3/utils/net_rpc_printer.c24
-rw-r--r--source3/utils/net_rpc_registry.c30
-rw-r--r--source3/utils/net_rpc_rights.c10
-rw-r--r--source3/utils/net_rpc_samsync.c33
-rw-r--r--source3/utils/net_rpc_service.c32
-rw-r--r--source3/utils/net_status.c16
-rw-r--r--source3/utils/net_time.c10
16 files changed, 278 insertions, 255 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c
index 839f6f1b01..a2a9ac6a39 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -128,7 +128,7 @@ int net_run_function(int argc, const char **argv, struct functable *table,
if (StrCaseCmp(argv[0], table[i].funcname) == 0)
return table[i].fn(argc-1, argv+1);
}
- d_printf("No command: %s\n", argv[0]);
+ d_fprintf(stderr, "No command: %s\n", argv[0]);
return usage_fn(argc, argv);
}
@@ -158,21 +158,21 @@ NTSTATUS connect_to_service(struct cli_state **c, struct in_addr *server_ip,
if (NT_STATUS_IS_OK(nt_status)) {
return nt_status;
} else {
- d_printf("Could not connect to server %s\n", server_name);
+ d_fprintf(stderr, "Could not connect to server %s\n", server_name);
/* Display a nicer message depending on the result */
if (NT_STATUS_V(nt_status) ==
NT_STATUS_V(NT_STATUS_LOGON_FAILURE))
- d_printf("The username or password was not correct.\n");
+ d_fprintf(stderr, "The username or password was not correct.\n");
if (NT_STATUS_V(nt_status) ==
NT_STATUS_V(NT_STATUS_ACCOUNT_LOCKED_OUT))
- d_printf("The account was locked out.\n");
+ d_fprintf(stderr, "The account was locked out.\n");
if (NT_STATUS_V(nt_status) ==
NT_STATUS_V(NT_STATUS_ACCOUNT_DISABLED))
- d_printf("The account was disabled.\n");
+ d_fprintf(stderr, "The account was disabled.\n");
return nt_status;
}
@@ -257,7 +257,7 @@ int net_use_machine_password(void)
char *user_name = NULL;
if (!secrets_init()) {
- d_printf("ERROR: Unable to open secrets database\n");
+ d_fprintf(stderr, "ERROR: Unable to open secrets database\n");
exit(1);
}
@@ -362,7 +362,7 @@ struct cli_state *net_make_ipc_connection(unsigned flags)
NTSTATUS nt_status;
if (!net_find_server(flags, &server_ip, &server_name)) {
- d_printf("\nUnable to find a suitable server\n");
+ d_fprintf(stderr, "\nUnable to find a suitable server\n");
return NULL;
}
@@ -409,7 +409,7 @@ static int net_join(int argc, const char **argv)
if (net_ads_join(argc, argv) == 0)
return 0;
else
- d_printf("ADS join did not work, falling back to RPC...\n");
+ d_fprintf(stderr, "ADS join did not work, falling back to RPC...\n");
}
return net_rpc_join(argc, argv);
}
@@ -431,7 +431,7 @@ static int net_changesecretpw(int argc, const char **argv)
trust_pw = getpass("Enter machine password: ");
if (!secrets_store_machine_password(trust_pw, lp_workgroup(), sec_channel_type)) {
- d_printf("Unable to write the machine account password in the secrets database");
+ d_fprintf(stderr, "Unable to write the machine account password in the secrets database");
return 1;
}
else {
@@ -486,7 +486,7 @@ static int net_getlocalsid(int argc, const char **argv)
panic when we can't. */
if (!secrets_init()) {
- d_printf("Unable to open secrets.tdb. Can't fetch domain SID for name: %s\n", name);
+ d_fprintf(stderr, "Unable to open secrets.tdb. Can't fetch domain SID for name: %s\n", name);
return 1;
}
@@ -536,14 +536,14 @@ static int net_getdomainsid(int argc, const char **argv)
get_global_sam_sid();
if (!secrets_fetch_domain_sid(global_myname(), &domain_sid)) {
- d_printf("Could not fetch local SID\n");
+ d_fprintf(stderr, "Could not fetch local SID\n");
return 1;
}
sid_to_string(sid_str, &domain_sid);
d_printf("SID for domain %s is: %s\n", global_myname(), sid_str);
if (!secrets_fetch_domain_sid(opt_workgroup, &domain_sid)) {
- d_printf("Could not fetch domain SID\n");
+ d_fprintf(stderr, "Could not fetch domain SID\n");
return 1;
}
@@ -575,22 +575,22 @@ static int net_afs_key(int argc, const char **argv)
}
if (!secrets_init()) {
- d_printf("Could not open secrets.tdb\n");
+ d_fprintf(stderr, "Could not open secrets.tdb\n");
return -1;
}
if ((fd = open(argv[0], O_RDONLY, 0)) < 0) {
- d_printf("Could not open %s\n", argv[0]);
+ d_fprintf(stderr, "Could not open %s\n", argv[0]);
return -1;
}
if (read(fd, &keyfile, sizeof(keyfile)) != sizeof(keyfile)) {
- d_printf("Could not read keyfile\n");
+ d_fprintf(stderr, "Could not read keyfile\n");
return -1;
}
if (!secrets_store_afs_keyfile(argv[1], &keyfile)) {
- d_printf("Could not write keyfile to secrets.tdb\n");
+ d_fprintf(stderr, "Could not write keyfile to secrets.tdb\n");
return -1;
}
@@ -642,7 +642,7 @@ static BOOL search_maxrid(struct pdb_search *search, const char *type,
uint32 i, num_entries;
if (search == NULL) {
- d_printf("get_maxrid: Could not search %s\n", type);
+ d_fprintf(stderr, "get_maxrid: Could not search %s\n", type);
return False;
}
@@ -799,7 +799,7 @@ static struct functable net_func[] = {
case 'I':
opt_dest_ip = *interpret_addr2(poptGetOptArg(pc));
if (is_zero_ip(opt_dest_ip))
- d_printf("\nInvalid ip address specified\n");
+ d_fprintf(stderr, "\nInvalid ip address specified\n");
else
opt_have_ip = True;
break;
@@ -813,7 +813,7 @@ static struct functable net_func[] = {
}
break;
default:
- d_printf("\nInvalid option %s: %s\n",
+ d_fprintf(stderr, "\nInvalid option %s: %s\n",
poptBadOption(pc, 0), poptStrerror(opt));
net_help(argc, argv);
exit(1);
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 49a7f1cc2d..f54896b3a8 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -78,7 +78,7 @@ static int net_ads_lookup(int argc, const char **argv)
ads_connect(ads);
if (!ads) {
- d_printf("Didn't find the cldap server!\n");
+ d_fprintf(stderr, "Didn't find the cldap server!\n");
return -1;
} if (!ads->config.realm) {
ads->config.realm = CONST_DISCARD(char *, opt_target_workgroup);
@@ -108,7 +108,7 @@ static int net_ads_info(int argc, const char **argv)
ads_connect(ads);
if (!ads || !ads->config.realm) {
- d_printf("Didn't find the ldap server!\n");
+ d_fprintf(stderr, "Didn't find the ldap server!\n");
return -1;
}
@@ -229,7 +229,7 @@ static int net_ads_workgroup(int argc, const char **argv)
}
if (!ADS_ERR_OK(ads_workgroup_name(ads, ctx, &workgroup))) {
- d_printf("Failed to find workgroup for realm '%s'\n",
+ d_fprintf(stderr, "Failed to find workgroup for realm '%s'\n",
ads->config.realm);
talloc_destroy(ctx);
ads_destroy(&ads);
@@ -295,12 +295,12 @@ static int ads_user_add(int argc, const char **argv)
status = ads_find_user_acct(ads, &res, argv[0]);
if (!ADS_ERR_OK(status)) {
- d_printf("ads_user_add: %s\n", ads_errstr(status));
+ d_fprintf(stderr, "ads_user_add: %s\n", ads_errstr(status));
goto done;
}
if (ads_count_replies(ads, res)) {
- d_printf("ads_user_add: User %s already exists\n", argv[0]);
+ d_fprintf(stderr, "ads_user_add: User %s already exists\n", argv[0]);
goto done;
}
@@ -311,7 +311,7 @@ static int ads_user_add(int argc, const char **argv)
status = ads_add_user_acct(ads, argv[0], opt_container, opt_comment);
if (!ADS_ERR_OK(status)) {
- d_printf("Could not add user %s: %s\n", argv[0],
+ d_fprintf(stderr, "Could not add user %s: %s\n", argv[0],
ads_errstr(status));
goto done;
}
@@ -335,7 +335,7 @@ static int ads_user_add(int argc, const char **argv)
}
/* password didn't set, delete account */
- d_printf("Could not add user %s. Error setting password %s\n",
+ d_fprintf(stderr, "Could not add user %s. Error setting password %s\n",
argv[0], ads_errstr(status));
ads_msgfree(ads, res);
status=ads_find_user_acct(ads, &res, argv[0]);
@@ -373,7 +373,7 @@ static int ads_user_info(int argc, const char **argv)
}
if (!escaped_user) {
- d_printf("ads_user_info: failed to escape user %s\n", argv[0]);
+ d_fprintf(stderr, "ads_user_info: failed to escape user %s\n", argv[0]);
ads_destroy(&ads);
return -1;
}
@@ -383,7 +383,7 @@ static int ads_user_info(int argc, const char **argv)
safe_free(searchstring);
if (!ADS_ERR_OK(rc)) {
- d_printf("ads_search: %s\n", ads_errstr(rc));
+ d_fprintf(stderr, "ads_search: %s\n", ads_errstr(rc));
ads_destroy(&ads);
return -1;
}
@@ -436,7 +436,7 @@ static int ads_user_delete(int argc, const char **argv)
ads_destroy(&ads);
return 0;
}
- d_printf("Error deleting user %s: %s\n", argv[0],
+ d_fprintf(stderr, "Error deleting user %s: %s\n", argv[0],
ads_errstr(rc));
ads_destroy(&ads);
return -1;
@@ -501,12 +501,12 @@ static int ads_group_add(int argc, const char **argv)
status = ads_find_user_acct(ads, &res, argv[0]);
if (!ADS_ERR_OK(status)) {
- d_printf("ads_group_add: %s\n", ads_errstr(status));
+ d_fprintf(stderr, "ads_group_add: %s\n", ads_errstr(status));
goto done;
}
if (ads_count_replies(ads, res)) {
- d_printf("ads_group_add: Group %s already exists\n", argv[0]);
+ d_fprintf(stderr, "ads_group_add: Group %s already exists\n", argv[0]);
ads_msgfree(ads, res);
goto done;
}
@@ -521,7 +521,7 @@ static int ads_group_add(int argc, const char **argv)
d_printf("Group %s added\n", argv[0]);
rc = 0;
} else {
- d_printf("Could not add group %s: %s\n", argv[0],
+ d_fprintf(stderr, "Could not add group %s: %s\n", argv[0],
ads_errstr(status));
}
@@ -562,7 +562,7 @@ static int ads_group_delete(int argc, const char **argv)
ads_destroy(&ads);
return 0;
}
- d_printf("Error deleting group %s: %s\n", argv[0],
+ d_fprintf(stderr, "Error deleting group %s: %s\n", argv[0],
ads_errstr(rc));
ads_destroy(&ads);
return -1;
@@ -614,13 +614,13 @@ static int net_ads_status(int argc, const char **argv)
rc = ads_find_machine_acct(ads, &res, global_myname());
if (!ADS_ERR_OK(rc)) {
- d_printf("ads_find_machine_acct: %s\n", ads_errstr(rc));
+ d_fprintf(stderr, "ads_find_machine_acct: %s\n", ads_errstr(rc));
ads_destroy(&ads);
return -1;
}
if (ads_count_replies(ads, res) == 0) {
- d_printf("No machine account for '%s' found\n", global_myname());
+ d_fprintf(stderr, "No machine account for '%s' found\n", global_myname());
ads_destroy(&ads);
return -1;
}
@@ -650,7 +650,7 @@ static int net_ads_leave(int argc, const char **argv)
rc = ads_leave_realm(ads, global_myname());
if (!ADS_ERR_OK(rc)) {
- d_printf("Failed to delete host '%s' from the '%s' realm.\n",
+ d_fprintf(stderr, "Failed to delete host '%s' from the '%s' realm.\n",
global_myname(), ads->config.realm);
ads_destroy(&ads);
return -1;
@@ -734,13 +734,13 @@ int net_ads_join(int argc, const char **argv)
}
if (!*lp_realm()) {
- d_printf("realm must be set in in smb.conf for ADS join to succeed.\n");
+ d_fprintf(stderr, "realm must be set in in smb.conf for ADS join to succeed.\n");
ads_destroy(&ads);
return -1;
}
if (strcmp(ads->config.realm, lp_realm()) != 0) {
- d_printf("realm of remote server (%s) and realm in smb.conf (%s) DO NOT match. Aborting join\n", ads->config.realm, lp_realm());
+ d_fprintf(stderr, "realm of remote server (%s) and realm in smb.conf (%s) DO NOT match. Aborting join\n", ads->config.realm, lp_realm());
ads_destroy(&ads);
return -1;
}
@@ -753,7 +753,7 @@ int net_ads_join(int argc, const char **argv)
ads_msgfree(ads, res);
if (rc.error_type == ENUM_ADS_ERROR_LDAP && rc.err.rc == LDAP_NO_SUCH_OBJECT) {
- d_printf("ads_join_realm: organizational unit %s does not exist (dn:%s)\n",
+ d_fprintf(stderr, "ads_join_realm: organizational unit %s does not exist (dn:%s)\n",
org_unit, dn);
ads_destroy(&ads);
return -1;
@@ -761,34 +761,34 @@ int net_ads_join(int argc, const char **argv)
free(dn);
if (!ADS_ERR_OK(rc)) {
- d_printf("ads_join_realm: %s\n", ads_errstr(rc));
+ d_fprintf(stderr, "ads_join_realm: %s\n", ads_errstr(rc));
ads_destroy(&ads);
return -1;
}
rc = ads_join_realm(ads, global_myname(), account_type, org_unit);
if (!ADS_ERR_OK(rc)) {
- d_printf("ads_join_realm: %s\n", ads_errstr(rc));
+ d_fprintf(stderr, "ads_join_realm: %s\n", ads_errstr(rc));
ads_destroy(&ads);
return -1;
}
rc = ads_domain_sid(ads, &dom_sid);
if (!ADS_ERR_OK(rc)) {
- d_printf("ads_domain_sid: %s\n", ads_errstr(rc));
+ d_fprintf(stderr, "ads_domain_sid: %s\n", ads_errstr(rc));
ads_destroy(&ads);
return -1;
}
if (asprintf(&machine_account, "%s$", global_myname()) == -1) {
- d_printf("asprintf failed\n");
+ d_fprintf(stderr, "asprintf failed\n");
ads_destroy(&ads);
return -1;
}
rc = ads_set_machine_password(ads, machine_account, password);
if (!ADS_ERR_OK(rc)) {
- d_printf("ads_set_machine_password: %s\n", ads_errstr(rc));
+ d_fprintf(stderr, "ads_set_machine_password: %s\n", ads_errstr(rc));
ads_destroy(&ads);
return -1;
}
@@ -796,7 +796,7 @@ int net_ads_join(int argc, const char **argv)
/* make sure we get the right workgroup */
if ( !(ctx = talloc_init("net ads join")) ) {
- d_printf("talloc_init() failed!\n");
+ d_fprintf(stderr, "talloc_init() failed!\n");
ads_destroy(&ads);
return -1;
}
@@ -904,14 +904,14 @@ static int net_ads_printer_search(int argc, const char **argv)
rc = ads_find_printers(ads, &res);
if (!ADS_ERR_OK(rc)) {
- d_printf("ads_find_printer: %s\n", ads_errstr(rc));
+ d_fprintf(stderr, "ads_find_printer: %s\n", ads_errstr(rc));
ads_msgfree(ads, res);
ads_destroy(&ads);
return -1;
}
if (ads_count_replies(ads, res) == 0) {
- d_printf("No results found\n");
+ d_fprintf(stderr, "No results found\n");
ads_msgfree(ads, res);
ads_destroy(&ads);
return -1;
@@ -949,14 +949,14 @@ static int net_ads_printer_info(int argc, const char **argv)
rc = ads_find_printer_on_server(ads, &res, printername, servername);
if (!ADS_ERR_OK(rc)) {
- d_printf("ads_find_printer_on_server: %s\n", ads_errstr(rc));
+ d_fprintf(stderr, "ads_find_printer_on_server: %s\n", ads_errstr(rc));
ads_msgfree(ads, res);
ads_destroy(&ads);
return -1;
}
if (ads_count_replies(ads, res) == 0) {
- d_printf("Printer '%s' not found\n", printername);
+ d_fprintf(stderr, "Printer '%s' not found\n", printername);
ads_msgfree(ads, res);
ads_destroy(&ads);
return -1;
@@ -1018,7 +1018,7 @@ static int net_ads_printer_publish(int argc, const char **argv)
Undefined, NULL);
if (NT_STATUS_IS_ERR(nt_status)) {
- d_printf("Unable to open a connnection to %s to obtain data "
+ d_fprintf(stderr, "Unable to open a connnection to %s to obtain data "
"for %s\n", servername, printername);
ads_destroy(&ads);
return -1;
@@ -1029,7 +1029,7 @@ static int net_ads_printer_publish(int argc, const char **argv)
ads_find_machine_acct(ads, &res, servername);
if (ads_count_replies(ads, res) == 0) {
- d_printf("Could not find machine account for server %s\n",
+ d_fprintf(stderr, "Could not find machine account for server %s\n",
servername);
ads_destroy(&ads);
return -1;
@@ -1046,7 +1046,7 @@ static int net_ads_printer_publish(int argc, const char **argv)
rc = ads_add_printer_entry(ads, prt_dn, mem_ctx, &mods);
if (!ADS_ERR_OK(rc)) {
- d_printf("ads_publish_printer: %s\n", ads_errstr(rc));
+ d_fprintf(stderr, "ads_publish_printer: %s\n", ads_errstr(rc));
ads_destroy(&ads);
return -1;
}
@@ -1082,14 +1082,14 @@ static int net_ads_printer_remove(int argc, const char **argv)
rc = ads_find_printer_on_server(ads, &res, argv[0], servername);
if (!ADS_ERR_OK(rc)) {
- d_printf("ads_find_printer_on_server: %s\n", ads_errstr(rc));
+ d_fprintf(stderr, "ads_find_printer_on_server: %s\n", ads_errstr(rc));
ads_msgfree(ads, res);
ads_destroy(&ads);
return -1;
}
if (ads_count_replies(ads, res) == 0) {
- d_printf("Printer '%s' not found\n", argv[1]);
+ d_fprintf(stderr, "Printer '%s' not found\n", argv[1]);
ads_msgfree(ads, res);
ads_destroy(&ads);
return -1;
@@ -1101,7 +1101,7 @@ static int net_ads_printer_remove(int argc, const char **argv)
ads_memfree(ads, prt_dn);
if (!ADS_ERR_OK(rc)) {
- d_printf("ads_del_dn: %s\n", ads_errstr(rc));
+ d_fprintf(stderr, "ads_del_dn: %s\n", ads_errstr(rc));
ads_destroy(&ads);
return -1;
}
@@ -1136,12 +1136,12 @@ static int net_ads_password(int argc, const char **argv)
ADS_STATUS ret;
if (opt_user_name == NULL || opt_password == NULL) {
- d_printf("You must supply an administrator username/password\n");
+ d_fprintf(stderr, "You must supply an administrator username/password\n");
return -1;
}
if (argc < 1) {
- d_printf("ERROR: You must say which username to change password for\n");
+ d_fprintf(stderr, "ERROR: You must say which username to change password for\n");
return -1;
}
@@ -1170,7 +1170,7 @@ static int net_ads_password(int argc, const char **argv)
ads_connect(ads);
if (!ads || !ads->config.realm) {
- d_printf("Didn't find the kerberos server!\n");
+ d_fprintf(stderr, "Didn't find the kerberos server!\n");
return -1;
}
@@ -1185,7 +1185,7 @@ static int net_ads_password(int argc, const char **argv)
ret = kerberos_set_password(ads->auth.kdc_server, auth_principal,
auth_password, user, new_password, ads->auth.time_offset);
if (!ADS_ERR_OK(ret)) {
- d_printf("Password change failed :-( ...\n");
+ d_fprintf(stderr, "Password change failed :-( ...\n");
ads_destroy(&ads);
return -1;
}
@@ -1224,7 +1224,7 @@ int net_ads_changetrustpw(int argc, const char **argv)
ret = ads_change_trust_account_password(ads, host_principal);
if (!ADS_ERR_OK(ret)) {
- d_printf("Password change failed :-( ...\n");
+ d_fprintf(stderr, "Password change failed :-( ...\n");
ads_destroy(&ads);
SAFE_FREE(host_principal);
return -1;
@@ -1288,7 +1288,7 @@ static int net_ads_search(int argc, const char **argv)
LDAP_SCOPE_SUBTREE,
ldap_exp, attrs, &res);
if (!ADS_ERR_OK(rc)) {
- d_printf("search failed: %s\n", ads_errstr(rc));
+ d_fprintf(stderr, "search failed: %s\n", ads_errstr(rc));
ads_destroy(&ads);
return -1;
}
@@ -1348,7 +1348,7 @@ static int net_ads_dn(int argc, const char **argv)
LDAP_SCOPE_BASE,
"(objectclass=*)", attrs, &res);
if (!ADS_ERR_OK(rc)) {
- d_printf("search failed: %s\n", ads_errstr(rc));
+ d_fprintf(stderr, "search failed: %s\n", ads_errstr(rc));
ads_destroy(&ads);
return -1;
}
@@ -1495,7 +1495,7 @@ int net_ads(int argc, const char **argv)
static int net_ads_noads(void)
{
- d_printf("ADS support not compiled in\n");
+ d_fprintf(stderr, "ADS support not compiled in\n");
return -1;
}
diff --git a/source3/utils/net_ads_cldap.c b/source3/utils/net_ads_cldap.c
index 9f70a5b725..2e7a28b322 100644
--- a/source3/utils/net_ads_cldap.c
+++ b/source3/utils/net_ads_cldap.c
@@ -93,7 +93,7 @@ static unsigned pull_netlogon_string(char *ret, const char *ptr,
uint8 len = (uint8)*(ptr++);
if ((pret - ret + len + 1) >= MAX_DNS_LABEL) {
- d_printf("DC returning too long DNS name\n");
+ d_fprintf(stderr, "DC returning too long DNS name\n");
return 0;
}
@@ -178,13 +178,13 @@ static int send_cldap_netlogon(int sock, const char *domain,
asn1_pop_tag(&data);
if (data.has_error) {
- d_printf("Failed to build cldap netlogon at offset %d\n", (int)data.ofs);
+ d_fprintf(stderr, "Failed to build cldap netlogon at offset %d\n", (int)data.ofs);
asn1_free(&data);
return -1;
}
if (write(sock, data.data, data.length) != (ssize_t)data.length) {
- d_printf("failed to send cldap query (%s)\n", strerror(errno));
+ d_fprintf(stderr, "failed to send cldap query (%s)\n", strerror(errno));
}
asn1_free(&data);
@@ -210,7 +210,7 @@ static int recv_cldap_netlogon(int sock, struct cldap_netlogon_reply *reply)
ret = read(sock, blob.data, blob.length);
if (ret <= 0) {
- d_printf("no reply received to cldap netlogon\n");
+ d_fprintf(stderr, "no reply received to cldap netlogon\n");
return -1;
}
blob.length = ret;
@@ -232,7 +232,7 @@ static int recv_cldap_netlogon(int sock, struct cldap_netlogon_reply *reply)
asn1_end_tag(&data);
if (data.has_error) {
- d_printf("Failed to parse cldap reply\n");
+ d_fprintf(stderr, "Failed to parse cldap reply\n");
return -1;
}
@@ -284,7 +284,7 @@ int ads_cldap_netlogon(ADS_STRUCT *ads)
sock = open_udp_socket(target, ads->ldap_port);
if (sock == -1) {
- d_printf("Failed to open udp socket to %s:%u\n",
+ d_fprintf(stderr, "Failed to open udp socket to %s:%u\n",
inet_ntoa(ads->ldap_ip),
ads->ldap_port);
return -1;
diff --git a/source3/utils/net_cache.c b/source3/utils/net_cache.c
index 6bbab1c817..0c107a5f01 100644
--- a/source3/utils/net_cache.c
+++ b/source3/utils/net_cache.c
@@ -64,7 +64,7 @@ static void delete_cache_entry(const char* keystr, const char* datastr,
const time_t timeout, void* dptr)
{
if (!gencache_del(keystr))
- d_printf("Couldn't delete entry! key = %s\n", keystr);
+ d_fprintf(stderr, "Couldn't delete entry! key = %s\n", keystr);
}
@@ -147,7 +147,7 @@ static int net_cache_add(int argc, const char **argv)
/* parse timeout given in command line */
timeout = parse_timeout(timeout_str);
if (!timeout) {
- d_printf("Invalid timeout argument.\n");
+ d_fprintf(stderr, "Invalid timeout argument.\n");
return -1;
}
@@ -157,7 +157,7 @@ static int net_cache_add(int argc, const char **argv)
return 0;
}
- d_printf("Entry couldn't be added. Perhaps there's already such a key.\n");
+ d_fprintf(stderr, "Entry couldn't be added. Perhaps there's already such a key.\n");
gencache_shutdown();
return -1;
}
@@ -187,7 +187,7 @@ static int net_cache_set(int argc, const char **argv)
/* parse timeout given in command line */
timeout = parse_timeout(timeout_str);
if (!timeout) {
- d_printf("Invalid timeout argument.\n");
+ d_fprintf(stderr, "Invalid timeout argument.\n");
return -1;
}
@@ -197,7 +197,7 @@ static int net_cache_set(int argc, const char **argv)
return 0;
}
- d_printf("Entry couldn't be set. Perhaps there's no such a key.\n");
+ d_fprintf(stderr, "Entry couldn't be set. Perhaps there's no such a key.\n");
gencache_shutdown();
return -1;
}
@@ -223,7 +223,7 @@ static int net_cache_del(int argc, const char **argv)
return 0;
}
- d_printf("Couldn't delete specified entry\n");
+ d_fprintf(stderr, "Couldn't delete specified entry\n");
return -1;
}
@@ -250,7 +250,7 @@ static int net_cache_get(int argc, const char **argv)
return 0;
}
- d_printf("Failed to find entry\n");
+ d_fprintf(stderr, "Failed to find entry\n");
return -1;
}
diff --git a/source3/utils/net_groupmap.c b/source3/utils/net_groupmap.c
index 89bad6ea51..1cff120c39 100644
--- a/source3/utils/net_groupmap.c
+++ b/source3/utils/net_groupmap.c
@@ -122,19 +122,19 @@ static int net_groupmap_list(int argc, const char **argv)
else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
fstrcpy( ntgroup, get_string_param( argv[i] ) );
if ( !ntgroup[0] ) {
- d_printf("must supply a name\n");
+ d_fprintf(stderr, "must supply a name\n");
return -1;
}
}
else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
fstrcpy( sid_string, get_string_param( argv[i] ) );
if ( !sid_string[0] ) {
- d_printf("must supply a SID\n");
+ d_fprintf(stderr, "must supply a SID\n");
return -1;
}
}
else {
- d_printf("Bad option: %s\n", argv[i]);
+ d_fprintf(stderr, "Bad option: %s\n", argv[i]);
return -1;
}
}
@@ -153,7 +153,7 @@ static int net_groupmap_list(int argc, const char **argv)
/* Get the current mapping from the database */
if(!pdb_getgrsid(&map, sid)) {
- d_printf("Failure to local group SID in the database\n");
+ d_fprintf(stderr, "Failure to local group SID in the database\n");
return -1;
}
@@ -197,35 +197,35 @@ static int net_groupmap_add(int argc, const char **argv)
if ( !StrnCaseCmp(argv[i], "rid", strlen("rid")) ) {
rid = get_int_param(argv[i]);
if ( rid < DOMAIN_GROUP_RID_ADMINS ) {
- d_printf("RID must be greater than %d\n", (uint32)DOMAIN_GROUP_RID_ADMINS-1);
+ d_fprintf(stderr, "RID must be greater than %d\n", (uint32)DOMAIN_GROUP_RID_ADMINS-1);
return -1;
}
}
else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) {
fstrcpy( unixgrp, get_string_param( argv[i] ) );
if ( !unixgrp[0] ) {
- d_printf("must supply a name\n");
+ d_fprintf(stderr, "must supply a name\n");
return -1;
}
}
else if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
fstrcpy( ntgroup, get_string_param( argv[i] ) );
if ( !ntgroup[0] ) {
- d_printf("must supply a name\n");
+ d_fprintf(stderr, "must supply a name\n");
return -1;
}
}
else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
fstrcpy( string_sid, get_string_param( argv[i] ) );
if ( !string_sid[0] ) {
- d_printf("must supply a SID\n");
+ d_fprintf(stderr, "must supply a SID\n");
return -1;
}
}
else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
fstrcpy( ntcomment, get_string_param( argv[i] ) );
if ( !ntcomment[0] ) {
- d_printf("must supply a comment string\n");
+ d_fprintf(stderr, "must supply a comment string\n");
return -1;
}
}
@@ -247,7 +247,7 @@ static int net_groupmap_add(int argc, const char **argv)
}
}
else {
- d_printf("Bad option: %s\n", argv[i]);
+ d_fprintf(stderr, "Bad option: %s\n", argv[i]);
return -1;
}
}
@@ -258,7 +258,7 @@ static int net_groupmap_add(int argc, const char **argv)
}
if ( (gid = nametogid(unixgrp)) == (gid_t)-1 ) {
- d_printf("Can't lookup UNIX group %s\n", unixgrp);
+ d_fprintf(stderr, "Can't lookup UNIX group %s\n", unixgrp);
return -1;
}
@@ -296,7 +296,7 @@ static int net_groupmap_add(int argc, const char **argv)
if (!add_initial_entry(gid, string_sid, sid_type, ntgroup, ntcomment)) {
- d_printf("adding entry for group %s failed!\n", ntgroup);
+ d_fprintf(stderr, "adding entry for group %s failed!\n", ntgroup);
return -1;
}
@@ -322,28 +322,28 @@ static int net_groupmap_modify(int argc, const char **argv)
if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
fstrcpy( ntgroup, get_string_param( argv[i] ) );
if ( !ntgroup[0] ) {
- d_printf("must supply a name\n");
+ d_fprintf(stderr, "must supply a name\n");
return -1;
}
}
else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
fstrcpy( sid_string, get_string_param( argv[i] ) );
if ( !sid_string[0] ) {
- d_printf("must supply a name\n");
+ d_fprintf(stderr, "must supply a name\n");
return -1;
}
}
else if ( !StrnCaseCmp(argv[i], "comment", strlen("comment")) ) {
fstrcpy( ntcomment, get_string_param( argv[i] ) );
if ( !ntcomment[0] ) {
- d_printf("must supply a comment string\n");
+ d_fprintf(stderr, "must supply a comment string\n");
return -1;
}
}
else if ( !StrnCaseCmp(argv[i], "unixgroup", strlen("unixgroup")) ) {
fstrcpy( unixgrp, get_string_param( argv[i] ) );
if ( !unixgrp[0] ) {
- d_printf("must supply a group name\n");
+ d_fprintf(stderr, "must supply a group name\n");
return -1;
}
}
@@ -361,7 +361,7 @@ static int net_groupmap_modify(int argc, const char **argv)
}
}
else {
- d_printf("Bad option: %s\n", argv[i]);
+ d_fprintf(stderr, "Bad option: %s\n", argv[i]);
return -1;
}
}
@@ -388,7 +388,7 @@ static int net_groupmap_modify(int argc, const char **argv)
/* Get the current mapping from the database */
if(!pdb_getgrsid(&map, sid)) {
- d_printf("Failure to local group SID in the database\n");
+ d_fprintf(stderr, "Failure to local group SID in the database\n");
return -1;
}
@@ -398,7 +398,7 @@ static int net_groupmap_modify(int argc, const char **argv)
*/
if (sid_type != SID_NAME_UNKNOWN) {
if (map.sid_name_use == SID_NAME_WKN_GRP) {
- d_printf("You can only change between domain and local groups.\n");
+ d_fprintf(stderr, "You can only change between domain and local groups.\n");
return -1;
}
@@ -415,7 +415,7 @@ static int net_groupmap_modify(int argc, const char **argv)
if ( unixgrp[0] ) {
gid = nametogid( unixgrp );
if ( gid == -1 ) {
- d_printf("Unable to lookup UNIX group %s. Make sure the group exists.\n",
+ d_fprintf(stderr, "Unable to lookup UNIX group %s. Make sure the group exists.\n",
unixgrp);
return -1;
}
@@ -424,7 +424,7 @@ static int net_groupmap_modify(int argc, const char **argv)
}
if ( !pdb_update_group_mapping_entry(&map) ) {
- d_printf("Could not update group database\n");
+ d_fprintf(stderr, "Could not update group database\n");
return -1;
}
@@ -445,19 +445,19 @@ static int net_groupmap_delete(int argc, const char **argv)
if ( !StrnCaseCmp(argv[i], "ntgroup", strlen("ntgroup")) ) {
fstrcpy( ntgroup, get_string_param( argv[i] ) );
if ( !ntgroup[0] ) {
- d_printf("must supply a name\n");
+ d_fprintf(stderr, "must supply a name\n");
return -1;
}
}
else if ( !StrnCaseCmp(argv[i], "sid", strlen("sid")) ) {
fstrcpy( sid_string, get_string_param( argv[i] ) );
if ( !sid_string[0] ) {
- d_printf("must supply a SID\n");
+ d_fprintf(stderr, "must supply a SID\n");
return -1;
}
}
else {
- d_printf("Bad option: %s\n", argv[i]);
+ d_fprintf(stderr, "Bad option: %s\n", argv[i]);
return -1;
}
}
@@ -473,12 +473,12 @@ static int net_groupmap_delete(int argc, const char **argv)
fstrcpy( ntgroup, sid_string );
if ( !get_sid_from_input(&sid, ntgroup) ) {
- d_printf("Unable to resolve group %s to a SID\n", ntgroup);
+ d_fprintf(stderr, "Unable to resolve group %s to a SID\n", ntgroup);
return -1;
}
if ( !pdb_delete_group_mapping_entry(sid) ) {
- printf("Failed to removing group %s from the mapping db!\n", ntgroup);
+ d_fprintf(stderr, "Failed to removing group %s from the mapping db!\n", ntgroup);
return -1;
}
@@ -511,7 +511,7 @@ static int net_groupmap_set(int argc, const char **argv)
grp = getgrnam(argv[1]);
if (grp == NULL) {
- d_printf("Could not find unix group %s\n", argv[1]);
+ d_fprintf(stderr, "Could not find unix group %s\n", argv[1]);
return -1;
}
}
@@ -530,7 +530,7 @@ static int net_groupmap_set(int argc, const char **argv)
/* Ok, add it */
if (grp == NULL) {
- d_printf("Could not find group mapping for %s\n",
+ d_fprintf(stderr, "Could not find group mapping for %s\n",
ntgroup);
return -1;
}
@@ -549,7 +549,7 @@ static int net_groupmap_set(int argc, const char **argv)
fstrcpy(map.comment, "");
if (!pdb_add_group_mapping_entry(&map)) {
- d_printf("Could not add mapping entry for %s\n",
+ d_fprintf(stderr, "Could not add mapping entry for %s\n",
ntgroup);
return -1;
}
@@ -559,7 +559,7 @@ static int net_groupmap_set(int argc, const char **argv)
if ( opt_localgroup || opt_domaingroup ) {
if (map.sid_name_use == SID_NAME_WKN_GRP) {
- d_printf("Can't change type of the BUILTIN group %s\n",
+ d_fprintf(stderr, "Can't change type of the BUILTIN group %s\n",
map.nt_name);
return -1;
}
@@ -583,7 +583,7 @@ static int net_groupmap_set(int argc, const char **argv)
map.gid = grp->gr_gid;
if (!pdb_update_group_mapping_entry(&map)) {
- d_printf("Could not update group mapping for %s\n", ntgroup);
+ d_fprintf(stderr, "Could not update group mapping for %s\n", ntgroup);
return -1;
}
@@ -597,7 +597,7 @@ static int net_groupmap_cleanup(int argc, const char **argv)
if (!pdb_enum_group_mapping(SID_NAME_UNKNOWN, &map, &entries,
ENUM_ALL_MAPPED)) {
- d_printf("Could not list group mappings\n");
+ d_fprintf(stderr, "Could not list group mappings\n");
return -1;
}
@@ -634,7 +634,7 @@ static int net_groupmap_addmem(int argc, const char **argv)
}
if (!pdb_add_aliasmem(&alias, &member)) {
- d_printf("Could not add sid %s to alias %s\n",
+ d_fprintf(stderr, "Could not add sid %s to alias %s\n",
argv[1], argv[0]);
return -1;
}
@@ -654,7 +654,7 @@ static int net_groupmap_delmem(int argc, const char **argv)
}
if (!pdb_del_aliasmem(&alias, &member)) {
- d_printf("Could not delete sid %s from alias %s\n",
+ d_fprintf(stderr, "Could not delete sid %s from alias %s\n",
argv[1], argv[0]);
return -1;
}
@@ -678,7 +678,7 @@ static int net_groupmap_listmem(int argc, const char **argv)
num = 0;
if (!pdb_enum_aliasmem(&alias, &members, &num)) {
- d_printf("Could not list members for sid %s\n", argv[0]);
+ d_fprintf(stderr, "Could not list members for sid %s\n", argv[0]);
return -1;
}
@@ -703,7 +703,7 @@ static BOOL print_alias_memberships(TALLOC_CTX *mem_ctx,
if (!pdb_enum_alias_memberships(mem_ctx, domain_sid, member, 1,
&alias_rids, &num_alias_rids)) {
- d_printf("Could not list memberships for sid %s\n",
+ d_fprintf(stderr, "Could not list memberships for sid %s\n",
sid_string_static(member));
return False;
}
@@ -731,14 +731,14 @@ static int net_groupmap_memberships(int argc, const char **argv)
mem_ctx = talloc_init("net_groupmap_memberships");
if (mem_ctx == NULL) {
- d_printf("talloc_init failed\n");
+ d_fprintf(stderr, "talloc_init failed\n");
return -1;
}
domain_sid = get_global_sam_sid();
builtin_sid = string_sid_talloc(mem_ctx, "S-1-5-32");
if ((domain_sid == NULL) || (builtin_sid == NULL)) {
- d_printf("Could not get domain sid\n");
+ d_fprintf(stderr, "Could not get domain sid\n");
return -1;
}
@@ -800,7 +800,7 @@ int net_groupmap(int argc, const char **argv)
/* we shouldn't have silly checks like this */
if (getuid() != 0) {
- d_printf("You must be root to edit group mappings.\nExiting...\n");
+ d_fprintf(stderr, "You must be root to edit group mappings.\nExiting...\n");
return -1;
}
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c
index 8109bef522..0b5f68101e 100644
--- a/source3/utils/net_idmap.c
+++ b/source3/utils/net_idmap.c
@@ -59,7 +59,7 @@ static int net_idmap_dump(int argc, const char **argv)
idmap_tdb = tdb_open_log(argv[0], 0, TDB_DEFAULT, O_RDONLY, 0);
if (idmap_tdb == NULL) {
- d_printf("Could not open idmap: %s\n", argv[0]);
+ d_fprintf(stderr, "Could not open idmap: %s\n", argv[0]);
return -1;
}
@@ -102,7 +102,7 @@ static int net_idmap_find_max_id(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA data,
}
if (idptr == NULL) {
- d_printf("Illegal idmap entry: [%s]->[%s]\n",
+ d_fprintf(stderr, "Illegal idmap entry: [%s]->[%s]\n",
key.dptr, data.dptr);
hwms->ok = False;
return -1;
@@ -132,7 +132,7 @@ static NTSTATUS net_idmap_fixup_hwm(void)
if (!lp_idmap_uid(&hwms.user_hwm, &highest.user_hwm) ||
!lp_idmap_gid(&hwms.group_hwm, &highest.group_hwm)) {
- d_printf("idmap range missing\n");
+ d_fprintf(stderr, "idmap range missing\n");
return NT_STATUS_UNSUCCESSFUL;
}
@@ -145,7 +145,7 @@ static NTSTATUS net_idmap_fixup_hwm(void)
idmap_tdb = tdb_open_log(tdbfile, 0, TDB_DEFAULT, O_RDWR, 0);
if (idmap_tdb == NULL) {
- d_printf("Could not open idmap: %s\n", tdbfile);
+ d_fprintf(stderr, "Could not open idmap: %s\n", tdbfile);
return NT_STATUS_NO_SUCH_FILE;
}
@@ -161,18 +161,18 @@ static NTSTATUS net_idmap_fixup_hwm(void)
hwms.user_hwm, hwms.group_hwm);
if (hwms.user_hwm >= highest.user_hwm) {
- d_printf("Highest UID out of uid range\n");
+ d_fprintf(stderr, "Highest UID out of uid range\n");
goto done;
}
if (hwms.group_hwm >= highest.group_hwm) {
- d_printf("Highest GID out of gid range\n");
+ d_fprintf(stderr, "Highest GID out of gid range\n");
goto done;
}
if ((tdb_store_int32(idmap_tdb, "USER HWM", (int32)hwms.user_hwm) != 0) ||
(tdb_store_int32(idmap_tdb, "GROUP HWM", (int32)hwms.group_hwm) != 0)) {
- d_printf("Could not store HWMs\n");
+ d_fprintf(stderr, "Could not store HWMs\n");
goto done;
}
@@ -188,7 +188,7 @@ static NTSTATUS net_idmap_fixup_hwm(void)
static int net_idmap_restore(int argc, const char **argv)
{
if (!idmap_init(lp_idmap_backend())) {
- d_printf("Could not init idmap\n");
+ d_fprintf(stderr, "Could not init idmap\n");
return -1;
}
@@ -230,7 +230,7 @@ static int net_idmap_restore(int argc, const char **argv)
}
if (!NT_STATUS_IS_OK(idmap_set_mapping(&sid, id, type))) {
- d_printf("Could not set mapping of %s %lu to sid %s\n",
+ d_fprintf(stderr, "Could not set mapping of %s %lu to sid %s\n",
(type == ID_GROUPID) ? "GID" : "UID",
(type == ID_GROUPID) ? (unsigned long)id.gid:
(unsigned long)id.uid,
@@ -260,14 +260,14 @@ static int net_idmap_delete(int argc, const char **argv)
idmap_tdb = tdb_open_log(argv[0], 0, TDB_DEFAULT, O_RDWR, 0);
if (idmap_tdb == NULL) {
- d_printf("Could not open idmap: %s\n", argv[0]);
+ d_fprintf(stderr, "Could not open idmap: %s\n", argv[0]);
return -1;
}
fstrcpy(sid, argv[1]);
if (strncmp(sid, "S-1-5-", strlen("S-1-5-")) != 0) {
- d_printf("Can only delete SIDs, %s is does not start with "
+ d_fprintf(stderr, "Can only delete SIDs, %s is does not start with "
"S-1-5-\n", sid);
return -1;
}
@@ -278,17 +278,17 @@ static int net_idmap_delete(int argc, const char **argv)
data = tdb_fetch(idmap_tdb, key);
if (data.dptr == NULL) {
- d_printf("Could not find sid %s\n", argv[1]);
+ d_fprintf(stderr, "Could not find sid %s\n", argv[1]);
return -1;
}
if (tdb_delete(idmap_tdb, key) != 0) {
- d_printf("Could not delete key %s\n", argv[1]);
+ d_fprintf(stderr, "Could not delete key %s\n", argv[1]);
return -1;
}
if (tdb_delete(idmap_tdb, data) != 0) {
- d_printf("Could not delete key %s\n", data.dptr);
+ d_fprintf(stderr, "Could not delete key %s\n", data.dptr);
return -1;
}
diff --git a/source3/utils/net_rap.c b/source3/utils/net_rap.c
index 8205fe3fda..e80beb3645 100644
--- a/source3/utils/net_rap.c
+++ b/source3/utils/net_rap.c
@@ -112,7 +112,7 @@ static int rap_file_user(int argc, const char **argv)
if (argc == 0)
return net_rap_file_usage(argc, argv);
- d_printf("net rap file user not implemented yet\n");
+ d_fprintf(stderr, "net rap file user not implemented yet\n");
return -1;
}
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index d2cecd2435..0495a7b92c 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -347,7 +347,7 @@ static int net_rpc_oldjoin(int argc, const char **argv)
int rc = net_rpc_perform_oldjoin(argc, argv);
if (rc) {
- d_printf("Failed to join domain\n");
+ d_fprintf(stderr, "Failed to join domain\n");
}
return rc;
@@ -607,7 +607,7 @@ static NTSTATUS rpc_user_add_internals(const DOM_SID *domain_sid,
done:
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Failed to add user %s - %s\n", acct_name,
+ d_fprintf(stderr, "Failed to add user %s - %s\n", acct_name,
nt_errstr(result));
} else {
d_printf("Added user %s\n", acct_name);
@@ -714,7 +714,7 @@ static NTSTATUS rpc_user_del_internals(const DOM_SID *domain_sid,
/* Display results */
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Failed to delete user account - %s\n", nt_errstr(result));
+ d_fprintf(stderr, "Failed to delete user account - %s\n", nt_errstr(result));
} else {
d_printf("Deleted user account\n");
}
@@ -829,7 +829,7 @@ static NTSTATUS rpc_user_rename_internals(const DOM_SID *domain_sid,
done:
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Failed to rename user from %s to %s - %s\n", old_name, new_name,
+ d_fprintf(stderr, "Failed to rename user from %s to %s - %s\n", old_name, new_name,
nt_errstr(result));
} else {
d_printf("Renamed user from %s to %s\n", old_name, new_name);
@@ -1280,7 +1280,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
&connect_pol);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Request samr_connect failed\n");
+ d_fprintf(stderr, "Request samr_connect failed\n");
goto done;
}
@@ -1289,7 +1289,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
domain_sid, &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Request open_domain failed\n");
+ d_fprintf(stderr, "Request open_domain failed\n");
goto done;
}
@@ -1299,7 +1299,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
&name_types);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Lookup of '%s' failed\n",argv[0]);
+ d_fprintf(stderr, "Lookup of '%s' failed\n",argv[0]);
goto done;
}
@@ -1310,7 +1310,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
MAXIMUM_ALLOWED_ACCESS,
group_rids[0], &group_pol);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Request open_group failed");
+ d_fprintf(stderr, "Request open_group failed");
goto done;
}
@@ -1321,7 +1321,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
&group_attrs);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Unable to query group members of %s",argv[0]);
+ d_fprintf(stderr, "Unable to query group members of %s",argv[0]);
goto done;
}
@@ -1338,7 +1338,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
group_rids[i], &user_pol);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Unable to open group member %d\n",group_rids[i]);
+ d_fprintf(stderr, "Unable to open group member %d\n",group_rids[i]);
goto done;
}
@@ -1348,7 +1348,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
21, &user_ctr);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Unable to lookup userinfo for group member %d\n",group_rids[i]);
+ d_fprintf(stderr, "Unable to lookup userinfo for group member %d\n",group_rids[i]);
goto done;
}
@@ -1364,8 +1364,8 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
}
if (group_is_primary) {
- d_printf("Unable to delete group because some of it's "
- "members have it as primary group\n");
+ d_fprintf(stderr, "Unable to delete group because some "
+ "of it's members have it as primary group\n");
result = NT_STATUS_MEMBERS_PRIMARY_GROUP;
goto done;
}
@@ -1397,14 +1397,14 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
group_rids[0], &group_pol);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Request open_alias failed\n");
+ d_fprintf(stderr, "Request open_alias failed\n");
goto done;
}
result = rpccli_samr_delete_dom_alias(pipe_hnd, mem_ctx, &group_pol);
break;
default:
- d_printf("%s is of type %s. This command is only for deleting local or global groups\n",
+ d_fprintf(stderr, "%s is of type %s. This command is only for deleting local or global groups\n",
argv[0],sid_type_lookup(name_types[0]));
result = NT_STATUS_UNSUCCESSFUL;
goto done;
@@ -1415,7 +1415,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid,
if (opt_verbose)
d_printf("Deleted %s '%s'\n",sid_type_lookup(name_types[0]),argv[0]);
} else {
- d_printf("Deleting of %s failed: %s\n",argv[0],
+ d_fprintf(stderr, "Deleting of %s failed: %s\n",argv[0],
get_friendly_nt_error_msg(result));
}
@@ -1482,7 +1482,7 @@ static NTSTATUS rpc_group_add_internals(const DOM_SID *domain_sid,
if (NT_STATUS_IS_OK(result))
DEBUG(5, ("add group succeeded\n"));
else
- d_printf("add group failed: %s\n", nt_errstr(result));
+ d_fprintf(stderr, "add group failed: %s\n", nt_errstr(result));
return result;
}
@@ -1538,7 +1538,7 @@ static NTSTATUS rpc_alias_add_internals(const DOM_SID *domain_sid,
if (NT_STATUS_IS_OK(result))
DEBUG(5, ("add alias succeeded\n"));
else
- d_printf("add alias failed: %s\n", nt_errstr(result));
+ d_fprintf(stderr, "add alias failed: %s\n", nt_errstr(result));
return result;
}
@@ -1652,7 +1652,7 @@ static NTSTATUS rpc_add_groupmem(struct rpc_pipe_client *pipe_hnd,
&num_rids, &rids, &rid_types);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Could not lookup up group member %s\n", member);
+ d_fprintf(stderr, "Could not lookup up group member %s\n", member);
goto done;
}
@@ -1696,7 +1696,7 @@ static NTSTATUS rpc_add_aliasmem(struct rpc_pipe_client *pipe_hnd,
&member_sid, &member_type);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Could not lookup up group member %s\n", member);
+ d_fprintf(stderr, "Could not lookup up group member %s\n", member);
return result;
}
@@ -1752,7 +1752,7 @@ static NTSTATUS rpc_group_addmem_internals(const DOM_SID *domain_sid,
if (!NT_STATUS_IS_OK(get_sid_from_name(cli, mem_ctx, argv[0],
&group_sid, &group_type))) {
- d_printf("Could not lookup group name %s\n", argv[0]);
+ d_fprintf(stderr, "Could not lookup group name %s\n", argv[0]);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -1761,7 +1761,7 @@ static NTSTATUS rpc_group_addmem_internals(const DOM_SID *domain_sid,
&group_sid, argv[1]);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Could not add %s to %s: %s\n",
+ d_fprintf(stderr, "Could not add %s to %s: %s\n",
argv[1], argv[0], nt_errstr(result));
}
return result;
@@ -1772,14 +1772,14 @@ static NTSTATUS rpc_group_addmem_internals(const DOM_SID *domain_sid,
&group_sid, argv[1]);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Could not add %s to %s: %s\n",
+ d_fprintf(stderr, "Could not add %s to %s: %s\n",
argv[1], argv[0], nt_errstr(result));
}
return result;
}
- d_printf("Can only add members to global or local groups which "
- "%s is not\n", argv[0]);
+ d_fprintf(stderr, "Can only add members to global or local groups "
+ "which %s is not\n", argv[0]);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -1830,7 +1830,7 @@ static NTSTATUS rpc_del_groupmem(struct rpc_pipe_client *pipe_hnd,
&num_rids, &rids, &rid_types);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Could not lookup up group member %s\n", member);
+ d_fprintf(stderr, "Could not lookup up group member %s\n", member);
goto done;
}
@@ -1872,7 +1872,7 @@ static NTSTATUS rpc_del_aliasmem(struct rpc_pipe_client *pipe_hnd,
&member_sid, &member_type);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Could not lookup up group member %s\n", member);
+ d_fprintf(stderr, "Could not lookup up group member %s\n", member);
return result;
}
@@ -1926,7 +1926,7 @@ static NTSTATUS rpc_group_delmem_internals(const DOM_SID *domain_sid,
if (!NT_STATUS_IS_OK(get_sid_from_name(cli, mem_ctx, argv[0],
&group_sid, &group_type))) {
- d_printf("Could not lookup group name %s\n", argv[0]);
+ d_fprintf(stderr, "Could not lookup group name %s\n", argv[0]);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -1935,7 +1935,7 @@ static NTSTATUS rpc_group_delmem_internals(const DOM_SID *domain_sid,
&group_sid, argv[1]);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Could not del %s from %s: %s\n",
+ d_fprintf(stderr, "Could not del %s from %s: %s\n",
argv[1], argv[0], nt_errstr(result));
}
return result;
@@ -1946,14 +1946,14 @@ static NTSTATUS rpc_group_delmem_internals(const DOM_SID *domain_sid,
&group_sid, argv[1]);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Could not del %s from %s: %s\n",
+ d_fprintf(stderr, "Could not del %s from %s: %s\n",
argv[1], argv[0], nt_errstr(result));
}
return result;
}
- d_printf("Can only delete members from global or local groups which "
- "%s is not\n", argv[0]);
+ d_fprintf(stderr, "Can only delete members from global or local groups "
+ "which %s is not\n", argv[0]);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -2281,7 +2281,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd,
&num_members, &alias_sids);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Couldn't list alias members\n");
+ d_fprintf(stderr, "Couldn't list alias members\n");
return result;
}
@@ -2291,7 +2291,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd,
lsa_pipe = cli_rpc_pipe_open_noauth(pipe_hnd->cli, PI_LSARPC, &result);
if (!lsa_pipe) {
- d_printf("Couldn't open LSA pipe. Error was %s\n",
+ d_fprintf(stderr, "Couldn't open LSA pipe. Error was %s\n",
nt_errstr(result) );
return result;
}
@@ -2300,7 +2300,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd,
SEC_RIGHTS_MAXIMUM_ALLOWED, &lsa_pol);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Couldn't open LSA policy handle\n");
+ d_fprintf(stderr, "Couldn't open LSA policy handle\n");
cli_rpc_pipe_close(lsa_pipe);
return result;
}
@@ -2311,7 +2311,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd,
if (!NT_STATUS_IS_OK(result) &&
!NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED)) {
- d_printf("Couldn't lookup SIDs\n");
+ d_fprintf(stderr, "Couldn't lookup SIDs\n");
cli_rpc_pipe_close(lsa_pipe);
return result;
}
@@ -2383,7 +2383,7 @@ static NTSTATUS rpc_group_members_internals(const DOM_SID *domain_sid,
&sid_Builtin, &domain_pol);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Couldn't find group %s\n", argv[0]);
+ d_fprintf(stderr, "Couldn't find group %s\n", argv[0]);
return result;
}
@@ -2392,13 +2392,13 @@ static NTSTATUS rpc_group_members_internals(const DOM_SID *domain_sid,
&rids, &rid_types);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Couldn't find group %s\n", argv[0]);
+ d_fprintf(stderr, "Couldn't find group %s\n", argv[0]);
return result;
}
}
if (num_rids != 1) {
- d_printf("Couldn't find group %s\n", argv[0]);
+ d_fprintf(stderr, "Couldn't find group %s\n", argv[0]);
return result;
}
@@ -2466,12 +2466,12 @@ static NTSTATUS rpc_group_rename_internals(const DOM_SID *domain_sid,
1, argv, &num_rids, &rids, &rid_types);
if (num_rids != 1) {
- d_printf("Couldn't find group %s\n", argv[0]);
+ d_fprintf(stderr, "Couldn't find group %s\n", argv[0]);
return result;
}
if (rid_types[0] != SID_NAME_DOM_GRP) {
- d_printf("Can only rename domain groups\n");
+ d_fprintf(stderr, "Can only rename domain groups\n");
return NT_STATUS_UNSUCCESSFUL;
}
@@ -3057,7 +3057,7 @@ static void copy_fn(const char *mnt, file_info *f, const char *mask, void *state
False);
break;
default:
- d_printf("Unsupported mode %d\n", net_mode_share);
+ d_fprintf(stderr, "Unsupported mode %d\n", net_mode_share);
return;
}
@@ -3099,7 +3099,7 @@ static void copy_fn(const char *mnt, file_info *f, const char *mask, void *state
True);
break;
default:
- d_printf("Unsupported file mode %d\n", net_mode_share);
+ d_fprintf(stderr, "Unsupported file mode %d\n", net_mode_share);
return;
}
@@ -3124,7 +3124,7 @@ BOOL sync_files(struct copy_clistate *cp_clistate, pstring mask)
DEBUG(3,("calling cli_list with mask: %s\n", mask));
if (cli_list(cp_clistate->cli_share_src, mask, cp_clistate->attribute, copy_fn, cp_clistate) == -1) {
- d_printf("listing %s failed with error: %s\n",
+ d_fprintf(stderr, "listing %s failed with error: %s\n",
mask, cli_errstr(cp_clistate->cli_share_src));
return False;
}
@@ -3156,7 +3156,7 @@ BOOL copy_top_level_perms(struct copy_clistate *cp_clistate,
False);
break;
default:
- d_printf("Unsupported mode %d\n", net_mode_share);
+ d_fprintf(stderr, "Unsupported mode %d\n", net_mode_share);
break;
}
@@ -3233,7 +3233,7 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
printf("syncing");
break;
default:
- d_printf("Unsupported mode %d\n", net_mode_share);
+ d_fprintf(stderr, "Unsupported mode %d\n", net_mode_share);
break;
}
printf(" [%s] files and directories %s ACLs, %s DOS Attributes %s\n",
@@ -3268,13 +3268,13 @@ static NTSTATUS rpc_share_migrate_files_internals(const DOM_SID *domain_sid,
}
if (!copy_top_level_perms(&cp_clistate, netname)) {
- d_printf("Could not handle the top level directory permissions for the share: %s\n", netname);
+ d_fprintf(stderr, "Could not handle the top level directory permissions for the share: %s\n", netname);
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
if (!sync_files(&cp_clistate, mask)) {
- d_printf("could not handle files for share: %s\n", netname);
+ d_fprintf(stderr, "could not handle files for share: %s\n", netname);
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
@@ -3878,8 +3878,8 @@ static BOOL get_user_tokens(int *num_tokens, struct user_token **user_tokens)
if (lp_winbind_use_default_domain() &&
(opt_target_workgroup == NULL)) {
- d_printf("winbind use default domain = yes set, please "
- "specify a workgroup\n");
+ d_fprintf(stderr, "winbind use default domain = yes set, "
+ "please specify a workgroup\n");
return False;
}
@@ -4681,11 +4681,11 @@ static NTSTATUS rpc_reg_shutdown_internals(const DOM_SID *domain_sid,
if (W_ERROR_IS_OK(result)) {
d_printf("\nShutdown of remote machine succeeded\n");
} else {
- d_printf("\nShutdown of remote machine failed\n");
+ d_fprintf(stderr, "\nShutdown of remote machine failed\n");
if (W_ERROR_EQUAL(result,WERR_MACHINE_LOCKED))
- d_printf("\nMachine locked, use -f switch to force\n");
+ d_fprintf(stderr, "\nMachine locked, use -f switch to force\n");
else
- d_printf("\nresult was: %s\n", dos_errstr(result));
+ d_fprintf(stderr, "\nresult was: %s\n", dos_errstr(result));
}
return werror_to_ntstatus(result);
@@ -5634,12 +5634,12 @@ static int rpc_trustdom_list(int argc, const char **argv)
if (remote_cli) {
/* query for domain's sid */
if (run_rpc_command(remote_cli, PI_LSARPC, 0, rpc_query_domain_sid, argc, argv))
- d_printf("couldn't get domain's sid\n");
+ d_fprintf(stderr, "couldn't get domain's sid\n");
cli_shutdown(remote_cli);
} else {
- d_printf("domain controller is not responding\n");
+ d_fprintf(stderr, "domain controller is not responding\n");
};
};
diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c
index 12e51a85d1..6a5a7559c3 100644
--- a/source3/utils/net_rpc_join.c
+++ b/source3/utils/net_rpc_join.c
@@ -202,14 +202,14 @@ int net_rpc_join_newstyle(int argc, const char **argv)
if (!NT_STATUS_IS_OK(result) &&
!NT_STATUS_EQUAL(result, NT_STATUS_USER_EXISTS)) {
- d_printf("Creation of workstation account failed\n");
+ d_fprintf(stderr, "Creation of workstation account failed\n");
/* If NT_STATUS_ACCESS_DENIED then we have a valid
username/password combo but the user does not have
administrator access. */
if (NT_STATUS_V(result) == NT_STATUS_V(NT_STATUS_ACCESS_DENIED))
- d_printf("User specified does not have administrator privileges\n");
+ d_fprintf(stderr, "User specified does not have administrator privileges\n");
goto done;
}
@@ -317,7 +317,7 @@ int net_rpc_join_newstyle(int argc, const char **argv)
if ( NT_STATUS_EQUAL(result, NT_STATUS_ACCESS_DENIED) &&
(sec_channel_type == SEC_CHAN_BDC) ) {
- d_printf("Please make sure that no computer account\n"
+ d_fprintf(stderr, "Please make sure that no computer account\n"
"named like this machine (%s) exists in the domain\n",
global_myname());
}
@@ -338,7 +338,7 @@ int net_rpc_join_newstyle(int argc, const char **argv)
if ( NT_STATUS_EQUAL(result, NT_STATUS_ACCESS_DENIED) &&
(sec_channel_type == SEC_CHAN_BDC) ) {
- d_printf("Please make sure that no computer account\n"
+ d_fprintf(stderr, "Please make sure that no computer account\n"
"named like this machine (%s) exists in the domain\n",
global_myname());
}
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index d8f3099dec..5e282403a2 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -403,14 +403,14 @@ NTSTATUS net_copy_fileattr(TALLOC_CTX *mem_ctx,
/* closing files */
if (!cli_close(cli_share_src, fnum_src)) {
- d_printf("could not close %s on originating server: %s\n",
+ d_fprintf(stderr, "could not close %s on originating server: %s\n",
is_file?"file":"dir", cli_errstr(cli_share_src));
nt_status = cli_nt_error(cli_share_src);
goto out;
}
if (!cli_close(cli_share_dst, fnum_dst)) {
- d_printf("could not close %s on destination server: %s\n",
+ d_fprintf(stderr, "could not close %s on destination server: %s\n",
is_file?"file":"dir", cli_errstr(cli_share_dst));
nt_status = cli_nt_error(cli_share_dst);
goto out;
@@ -504,7 +504,7 @@ NTSTATUS net_copy_file(TALLOC_CTX *mem_ctx,
/* allocate memory */
if (!(data = (char *)SMB_MALLOC(read_size))) {
- d_printf("malloc fail for size %d\n", read_size);
+ d_fprintf(stderr, "malloc fail for size %d\n", read_size);
nt_status = NT_STATUS_NO_MEMORY;
goto out;
}
@@ -538,7 +538,7 @@ NTSTATUS net_copy_file(TALLOC_CTX *mem_ctx,
nread + start, n);
if (n != ret) {
- d_printf("Error writing file: %s\n",
+ d_fprintf(stderr, "Error writing file: %s\n",
cli_errstr(cli_share_dst));
nt_status = cli_nt_error(cli_share_dst);
goto out;
@@ -561,7 +561,7 @@ NTSTATUS net_copy_file(TALLOC_CTX *mem_ctx,
}
if (!cli_chkpath(cli_share_dst, dst_name)) {
- d_printf("cannot check for directory %s: %s\n",
+ d_fprintf(stderr, "cannot check for directory %s: %s\n",
dst_name, cli_errstr(cli_share_dst));
goto out;
}
@@ -570,14 +570,14 @@ NTSTATUS net_copy_file(TALLOC_CTX *mem_ctx,
/* closing files */
if (!cli_close(cli_share_src, fnum_src)) {
- d_printf("could not close file on originating server: %s\n",
+ d_fprintf(stderr, "could not close file on originating server: %s\n",
cli_errstr(cli_share_src));
nt_status = cli_nt_error(cli_share_src);
goto out;
}
if (is_file && !cli_close(cli_share_dst, fnum_dst)) {
- d_printf("could not close file on destination server: %s\n",
+ d_fprintf(stderr, "could not close file on destination server: %s\n",
cli_errstr(cli_share_dst));
nt_status = cli_nt_error(cli_share_dst);
goto out;
@@ -704,7 +704,7 @@ static NTSTATUS check_arch_dir(struct cli_state *cli_share, const char *short_ar
}
if (!cli_chkpath(cli_share, dir)) {
- d_printf("cannot check %s: %s\n",
+ d_fprintf(stderr, "cannot check %s: %s\n",
dir, cli_errstr(cli_share));
goto out;
}
@@ -859,13 +859,13 @@ static BOOL net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd,
/* be more verbose */
if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) {
- d_printf("no access to printer [%s] on [%s] for user [%s] granted\n",
+ d_fprintf(stderr, "no access to printer [%s] on [%s] for user [%s] granted\n",
printername2, servername, username);
return False;
}
if (!W_ERROR_IS_OK(result)) {
- d_printf("cannot open printer %s on server %s: %s\n",
+ d_fprintf(stderr, "cannot open printer %s on server %s: %s\n",
printername2, servername, dos_errstr(result));
return False;
}
@@ -2134,9 +2134,9 @@ NTSTATUS rpc_printer_migrate_printers_internals(const DOM_SID *domain_sid,
if (W_ERROR_IS_OK(result))
d_printf ("printer [%s] successfully added.\n", printername);
else if (W_ERROR_V(result) == W_ERROR_V(WERR_PRINTER_ALREADY_EXISTS))
- d_printf ("printer [%s] already exists.\n", printername);
+ d_fprintf (stderr, "printer [%s] already exists.\n", printername);
else {
- printf ("could not create printer\n");
+ d_fprintf (stderr, "could not create printer [%s]\n", printername);
goto done;
}
diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c
index 4ce0b44e4c..9852fe4a94 100644
--- a/source3/utils/net_rpc_registry.c
+++ b/source3/utils/net_rpc_registry.c
@@ -105,7 +105,7 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
}
if ( !reg_split_hive( argv[0], &hive, subpath ) ) {
- d_printf("invalid registry path\n");
+ d_fprintf(stderr, "invalid registry path\n");
return NT_STATUS_OK;
}
@@ -113,14 +113,14 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Unable to connect to remote registry\n");
+ d_fprintf(stderr, "Unable to connect to remote registry\n");
return werror_to_ntstatus(result);
}
if ( strlen( subpath ) != 0 ) {
result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Unable to open [%s]\n", argv[0]);
+ d_fprintf(stderr, "Unable to open [%s]\n", argv[0]);
return werror_to_ntstatus(result);
}
}
@@ -223,7 +223,7 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid,
}
if ( !reg_split_hive( argv[0], &hive, subpath ) ) {
- d_printf("invalid registry path\n");
+ d_fprintf(stderr, "invalid registry path\n");
return NT_STATUS_OK;
}
@@ -231,19 +231,19 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid,
result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Unable to connect to remote registry\n");
+ d_fprintf(stderr, "Unable to connect to remote registry\n");
return werror_to_ntstatus(result);
}
result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Unable to open [%s]\n", argv[0]);
+ d_fprintf(stderr, "Unable to open [%s]\n", argv[0]);
return werror_to_ntstatus(result);
}
result = rpccli_reg_save_key(pipe_hnd, mem_ctx, &pol_key, argv[1] );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Unable to save [%s] to %s:%s\n", argv[0], cli->desthost, argv[1]);
+ d_fprintf(stderr, "Unable to save [%s] to %s:%s\n", argv[0], cli->desthost, argv[1]);
}
@@ -329,7 +329,7 @@ static BOOL dump_registry_tree( REGF_FILE *file, REGF_NK_REC *nk, const char *pa
d_printf("\n");
dump_registry_tree( file, key, regpath );
}
-
+
return True;
}
@@ -401,7 +401,7 @@ static int rpc_registry_dump( int argc, const char **argv )
d_printf("Opening %s....", argv[0]);
if ( !(registry = regfio_open( argv[0], O_RDONLY, 0)) ) {
- d_printf("Failed to open %s for reading\n", argv[0]);
+ d_fprintf(stderr, "Failed to open %s for reading\n", argv[0]);
return 1;
}
d_printf("ok\n");
@@ -432,6 +432,7 @@ static int rpc_registry_copy( int argc, const char **argv )
{
REGF_FILE *infile, *outfile;
REGF_NK_REC *nk;
+ int result = 1;
if (argc != 2 ) {
d_printf("Usage: net rpc copy <srcfile> <newfile>\n");
@@ -440,15 +441,15 @@ static int rpc_registry_copy( int argc, const char **argv )
d_printf("Opening %s....", argv[0]);
if ( !(infile = regfio_open( argv[0], O_RDONLY, 0 )) ) {
- d_printf("Failed to open %s for reading\n", argv[0]);
+ d_fprintf(stderr, "Failed to open %s for reading\n", argv[0]);
return 1;
}
d_printf("ok\n");
d_printf("Opening %s....", argv[1]);
if ( !(outfile = regfio_open( argv[1], (O_RDWR|O_CREAT|O_TRUNC), (S_IREAD|S_IWRITE) )) ) {
- d_printf("Failed to open %s for writing\n", argv[1]);
- return 1;
+ d_fprintf(stderr, "Failed to open %s for writing\n", argv[1]);
+ goto out_close_infile;
}
d_printf("ok\n");
@@ -459,15 +460,18 @@ static int rpc_registry_copy( int argc, const char **argv )
write_registry_tree( infile, nk, NULL, outfile, "" );
+ result = 0;
+
d_printf("Closing %s...", argv[1]);
regfio_close( outfile );
d_printf("ok\n");
+out_close_infile:
d_printf("Closing %s...", argv[0]);
regfio_close( infile );
d_printf("ok\n");
- return 0;
+ return( result);
}
/********************************************************************
diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c
index a563475ee1..2c15fef5a0 100644
--- a/source3/utils/net_rpc_rights.c
+++ b/source3/utils/net_rpc_rights.c
@@ -335,15 +335,15 @@ static NTSTATUS rpc_rights_list_internal(const DOM_SID *domain_sid,
if ( !NT_STATUS_IS_OK(result) ) {
if ( NT_STATUS_EQUAL( result, NT_STATUS_NO_SUCH_PRIVILEGE ) )
- d_printf("No such privilege exists: %s.\n", privname);
+ d_fprintf(stderr, "No such privilege exists: %s.\n", privname);
else
- d_printf("Error resolving privilege display name [%s].\n", nt_errstr(result));
+ d_fprintf(stderr, "Error resolving privilege display name [%s].\n", nt_errstr(result));
continue;
}
result = enum_accounts_for_privilege(pipe_hnd, mem_ctx, &pol, privname);
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Error enumerating accounts for privilege %s [%s].\n",
+ d_fprintf(stderr, "Error enumerating accounts for privilege %s [%s].\n",
privname, nt_errstr(result));
continue;
}
@@ -437,7 +437,7 @@ static NTSTATUS rpc_rights_grant_internal(const DOM_SID *domain_sid,
done:
if ( !NT_STATUS_IS_OK(result) ) {
- d_printf("Failed to grant privileges for %s (%s)\n",
+ d_fprintf(stderr, "Failed to grant privileges for %s (%s)\n",
argv[0], nt_errstr(result));
}
@@ -488,7 +488,7 @@ static NTSTATUS rpc_rights_revoke_internal(const DOM_SID *domain_sid,
done:
if ( !NT_STATUS_IS_OK(result) ) {
- d_printf("Failed to revoke privileges for %s (%s)",
+ d_fprintf(stderr, "Failed to revoke privileges for %s (%s)",
argv[0], nt_errstr(result));
}
diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c
index f4a0ab90e8..09e62d9def 100644
--- a/source3/utils/net_rpc_samsync.c
+++ b/source3/utils/net_rpc_samsync.c
@@ -536,7 +536,7 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta)
/* try and find the possible unix account again */
if ( !(passwd = Get_Pwnam(account)) ) {
- d_printf("Could not create posix account info for '%s'\n", account);
+ d_fprintf(stderr, "Could not create posix account info for '%s'\n", account);
nt_ret = NT_STATUS_NO_SUCH_USER;
goto done;
}
@@ -1847,7 +1847,7 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd,
const char *add_ldif = "/tmp/add.ldif", *mod_ldif = "/tmp/mod.ldif";
FILE *add_fd, *mod_fd, *ldif_fd;
char sys_cmd[1024];
- int num_alloced = 0, g_index = 0, a_index = 0;
+ int num_alloced = 0, g_index = 0, a_index = 0, sys_cmd_result;
/* Set up array for mapping accounts to groups */
/* Array element is the group rid */
@@ -2068,7 +2068,12 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd,
fflush(ldif_fd);
}
pstr_sprintf(sys_cmd, "cat %s >> %s", add_ldif, ldif_file);
- system(sys_cmd);
+ sys_cmd_result = system(sys_cmd);
+ if (sys_cmd_result) {
+ d_fprintf(stderr, "%s failed. Error was (%s)\n",
+ sys_cmd, strerror(errno));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
if (db_type == SAM_DATABASE_DOMAIN) {
fprintf(ldif_fd,
"# SAM_DATABASE_DOMAIN: MODIFY ENTITIES\n");
@@ -2083,11 +2088,21 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd,
fflush(ldif_fd);
}
pstr_sprintf(sys_cmd, "cat %s >> %s", mod_ldif, ldif_file);
- system(sys_cmd);
+ sys_cmd_result = system(sys_cmd);
+ if (sys_cmd_result) {
+ d_fprintf(stderr, "%s failed. Error was (%s)\n",
+ sys_cmd, strerror(errno));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
/* Delete the temporary ldif files */
pstr_sprintf(sys_cmd, "rm -f %s %s", add_ldif, mod_ldif);
- system(sys_cmd);
+ sys_cmd_result = system(sys_cmd);
+ if (sys_cmd_result) {
+ d_fprintf(stderr, "%s failed. Error was (%s)\n",
+ sys_cmd, strerror(errno));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
/* Close the ldif file */
fclose(ldif_fd);
@@ -2154,11 +2169,11 @@ NTSTATUS rpc_vampire_internals(const DOM_SID *domain_sid,
}
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Failed to fetch domain database: %s\n",
+ d_fprintf(stderr, "Failed to fetch domain database: %s\n",
nt_errstr(result));
if (NT_STATUS_EQUAL(result, NT_STATUS_NOT_SUPPORTED))
- d_printf("Perhaps %s is a Windows 2000 native mode "
- "domain?\n", domain_name);
+ d_fprintf(stderr, "Perhaps %s is a Windows 2000 native "
+ "mode domain?\n", domain_name);
goto fail;
}
@@ -2170,7 +2185,7 @@ NTSTATUS rpc_vampire_internals(const DOM_SID *domain_sid,
}
if (!NT_STATUS_IS_OK(result)) {
- d_printf("Failed to fetch builtin database: %s\n",
+ d_fprintf(stderr, "Failed to fetch builtin database: %s\n",
nt_errstr(result));
goto fail;
}
diff --git a/source3/utils/net_rpc_service.c b/source3/utils/net_rpc_service.c
index ed7d1dfab1..27127a1c3f 100644
--- a/source3/utils/net_rpc_service.c
+++ b/source3/utils/net_rpc_service.c
@@ -40,7 +40,7 @@ static WERROR query_service_state(struct rpc_pipe_client *pipe_hnd,
service, SC_RIGHT_SVC_QUERY_STATUS );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Failed to open service. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result));
return result;
}
@@ -110,7 +110,7 @@ static WERROR control_service(struct rpc_pipe_client *pipe_hnd,
service, (SC_RIGHT_SVC_STOP|SC_RIGHT_SVC_PAUSE_CONTINUE) );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Failed to open service. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result));
goto done;
}
@@ -120,7 +120,7 @@ static WERROR control_service(struct rpc_pipe_client *pipe_hnd,
control, &service_status );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Control service request failed. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Control service request failed. [%s]\n", dos_errstr(result));
goto done;
}
@@ -162,7 +162,7 @@ static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid,
result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Failed to open Service Control Manager. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result));
return werror_to_ntstatus(result);
}
@@ -170,7 +170,7 @@ static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid,
SVCCTL_STATE_ALL, &num_services, &services );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Failed to enumerate services. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Failed to enumerate services. [%s]\n", dos_errstr(result));
goto done;
}
@@ -219,7 +219,7 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid,
result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Failed to open Service Control Manager. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result));
return werror_to_ntstatus(result);
}
@@ -229,7 +229,7 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid,
(SC_RIGHT_SVC_QUERY_STATUS|SC_RIGHT_SVC_QUERY_CONFIG) );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Failed to open service. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result));
goto done;
}
@@ -237,7 +237,7 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid,
result = rpccli_svcctl_query_status(pipe_hnd, mem_ctx, &hService, &service_status );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Query status request failed. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Query status request failed. [%s]\n", dos_errstr(result));
goto done;
}
@@ -247,7 +247,7 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid,
result = rpccli_svcctl_query_config(pipe_hnd, mem_ctx, &hService, &config );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Query config request failed. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Query config request failed. [%s]\n", dos_errstr(result));
goto done;
}
@@ -318,7 +318,7 @@ static NTSTATUS rpc_service_stop_internal(const DOM_SID *domain_sid,
result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Failed to open Service Control Manager. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result));
return werror_to_ntstatus(result);
}
@@ -356,7 +356,7 @@ static NTSTATUS rpc_service_pause_internal(const DOM_SID *domain_sid,
result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Failed to open Service Control Manager. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result));
return werror_to_ntstatus(result);
}
@@ -394,7 +394,7 @@ static NTSTATUS rpc_service_resume_internal(const DOM_SID *domain_sid,
result = rpccli_svcctl_open_scm(pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Failed to open Service Control Manager. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result));
return werror_to_ntstatus(result);
}
@@ -433,7 +433,7 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid,
result = rpccli_svcctl_open_scm( pipe_hnd, mem_ctx, &hSCM, SC_RIGHT_MGR_ENUMERATE_SERVICE );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Failed to open Service Control Manager. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", dos_errstr(result));
return werror_to_ntstatus(result);
}
@@ -443,7 +443,7 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid,
servicename, SC_RIGHT_SVC_START );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Failed to open service. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Failed to open service. [%s]\n", dos_errstr(result));
goto done;
}
@@ -451,7 +451,7 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid,
result = rpccli_svcctl_start_service(pipe_hnd, mem_ctx, &hService, NULL, 0 );
if ( !W_ERROR_IS_OK(result) ) {
- d_printf("Query status request failed. [%s]\n", dos_errstr(result));
+ d_fprintf(stderr, "Query status request failed. [%s]\n", dos_errstr(result));
goto done;
}
@@ -460,7 +460,7 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid,
if ( W_ERROR_IS_OK(result) && (state == SVCCTL_RUNNING) )
d_printf("Successfully started service: %s\n", servicename );
else
- d_printf("Failed to start service: %s [%s]\n", servicename, dos_errstr(result) );
+ d_fprintf(stderr, "Failed to start service: %s [%s]\n", servicename, dos_errstr(result) );
done:
rpccli_svcctl_close_service(pipe_hnd, mem_ctx, &hService );
diff --git a/source3/utils/net_status.c b/source3/utils/net_status.c
index 31693affe7..d3b1bae276 100644
--- a/source3/utils/net_status.c
+++ b/source3/utils/net_status.c
@@ -74,7 +74,7 @@ static int net_status_sessions(int argc, const char **argv)
TDB_DEFAULT, O_RDONLY, 0);
if (tdb == NULL) {
- d_printf("%s not initialised\n", lock_path("sessionid.tdb"));
+ d_fprintf(stderr, "%s not initialised\n", lock_path("sessionid.tdb"));
return -1;
}
@@ -186,7 +186,7 @@ static int net_status_shares_parseable(int argc, const char **argv)
TDB_DEFAULT, O_RDONLY, 0);
if (tdb == NULL) {
- d_printf("%s not initialised\n", lock_path("sessionid.tdb"));
+ d_fprintf(stderr, "%s not initialised\n", lock_path("sessionid.tdb"));
return -1;
}
@@ -197,9 +197,9 @@ static int net_status_shares_parseable(int argc, const char **argv)
TDB_DEFAULT, O_RDONLY, 0);
if (tdb == NULL) {
- d_printf("%s not initialised\n", lock_path("connections.tdb"));
- d_printf("This is normal if no SMB client has ever connected "
- "to your server.\n");
+ d_fprintf(stderr, "%s not initialised\n", lock_path("connections.tdb"));
+ d_fprintf(stderr, "This is normal if no SMB client has ever "
+ "connected to your server.\n");
return -1;
}
@@ -226,10 +226,10 @@ static int net_status_shares(int argc, const char **argv)
TDB_DEFAULT, O_RDONLY, 0);
if (tdb == NULL) {
- d_printf("%s not initialised\n",
+ d_fprintf(stderr, "%s not initialised\n",
lock_path("connections.tdb"));
- d_printf("This is normal if no SMB client has ever "
- "connected to your server.\n");
+ d_fprintf(stderr, "This is normal if no SMB client has "
+ "ever connected to your server.\n");
return -1;
}
diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c
index 691adcea00..1a7116d447 100644
--- a/source3/utils/net_time.c
+++ b/source3/utils/net_time.c
@@ -99,6 +99,7 @@ static int net_time_set(int argc, const char **argv)
{
time_t t = nettime(NULL);
char *cmd;
+ int result;
if (t == 0) return -1;
@@ -106,10 +107,13 @@ static int net_time_set(int argc, const char **argv)
roll your own. I'm putting this in as it works on a large number
of systems and the user has a choice in whether its used or not */
asprintf(&cmd, "/bin/date %s", systime(t));
- system(cmd);
+ result = system(cmd);
+ if (result)
+ d_fprintf(stderr, "%s failed. Error was (%s)\n",
+ cmd, strerror(errno));
free(cmd);
- return 0;
+ return result;
}
/* display the time on a remote box in a format ready for /bin/date */
@@ -161,7 +165,7 @@ int net_time(int argc, const char **argv)
if (!opt_host && !opt_have_ip &&
!find_master_ip(opt_target_workgroup, &opt_dest_ip)) {
- d_printf("Could not locate a time server. Try "\
+ d_fprintf(stderr, "Could not locate a time server. Try "\
"specifying a target host.\n");
net_time_usage(argc,argv);
return -1;