#include "includes.h"
+extern bool AllowDebugChange;
+
static int test_args;
#define CREATE_ACCESS_READ READ_CONTROL_ACCESS
char **domain, char **name)
{
uint16 orig_cnum = cli->cnum;
- struct rpc_pipe_client *p;
+ struct rpc_pipe_client *p = NULL;
struct policy_handle handle;
NTSTATUS status;
TALLOC_CTX *frame = talloc_stackframe();
static int cacl_dump(struct cli_state *cli, char *filename)
{
int result = EXIT_FAILED;
- int fnum = -1;
+ uint16_t fnum = (uint16_t)-1;
SEC_DESC *sd;
if (test_args)
return EXIT_OK;
- fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ);
-
- if (fnum == -1) {
+ if (!NT_STATUS_IS_OK(cli_ntcreate(cli, filename, 0, CREATE_ACCESS_READ, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
printf("Failed to open %s: %s\n", filename, cli_errstr(cli));
goto done;
}
result = EXIT_OK;
done:
- if (fnum != -1)
+ if (fnum != (uint16_t)-1)
cli_close(cli, fnum);
return result;
static int owner_set(struct cli_state *cli, enum chown_mode change_mode,
const char *filename, const char *new_username)
{
- int fnum;
+ uint16_t fnum;
DOM_SID sid;
SEC_DESC *sd, *old;
size_t sd_size;
- fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ);
-
- if (fnum == -1) {
+ if (!NT_STATUS_IS_OK(cli_ntcreate(cli, filename, 0, CREATE_ACCESS_READ, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
printf("Failed to open %s: %s\n", filename, cli_errstr(cli));
return EXIT_FAILED;
}
(change_mode == REQUEST_CHGRP) ? &sid : NULL,
NULL, NULL, &sd_size);
- fnum = cli_nt_create(cli, filename, WRITE_OWNER_ACCESS);
-
- if (fnum == -1) {
+ if (!NT_STATUS_IS_OK(cli_ntcreate(cli, filename, 0, WRITE_OWNER_ACCESS, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
printf("Failed to open %s: %s\n", filename, cli_errstr(cli));
return EXIT_FAILED;
}
uint32 i;
if (!the_acl) return;
- qsort(the_acl->aces, the_acl->num_aces, sizeof(the_acl->aces[0]), QSORT_CAST ace_compare);
+ TYPESAFE_QSORT(the_acl->aces, the_acl->num_aces, ace_compare);
for (i=1;i<the_acl->num_aces;) {
if (sec_ace_equal(&the_acl->aces[i-1], &the_acl->aces[i])) {
static int cacl_set(struct cli_state *cli, char *filename,
char *the_acl, enum acl_mode mode)
{
- int fnum;
+ uint16_t fnum;
SEC_DESC *sd, *old;
uint32 i, j;
size_t sd_size;
/* The desired access below is the only one I could find that works
with NT4, W2KP and Samba */
- fnum = cli_nt_create(cli, filename, CREATE_ACCESS_READ);
-
- if (fnum == -1) {
+ if (!NT_STATUS_IS_OK(cli_ntcreate(cli, filename, 0, CREATE_ACCESS_READ, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
printf("cacl_set failed to open %s: %s\n", filename, cli_errstr(cli));
return EXIT_FAILED;
}
old->owner_sid, old->group_sid,
NULL, old->dacl, &sd_size);
- fnum = cli_nt_create(cli, filename, WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS);
-
- if (fnum == -1) {
+ if (!NT_STATUS_IS_OK(cli_ntcreate(cli, filename, 0, WRITE_DAC_ACCESS|WRITE_OWNER_ACCESS, 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum))) {
printf("cacl_set failed to open %s: %s\n", filename, cli_errstr(cli));
return EXIT_FAILED;
}
return NULL;
}
- if (!get_cmdline_auth_info_got_pass(auth_info)) {
- char *pass = getpass("Password: ");
- if (pass) {
- set_cmdline_auth_info_password(auth_info, pass);
- }
- }
+ set_cmdline_auth_info_getpass(auth_info);
nt_status = cli_full_connection(&c, global_myname(), server,
&ss, 0,
DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
dbf = x_stderr;
x_setbuf( x_stderr, NULL );
+ AllowDebugChange = false;
setlinebuf(stdout);