bool b2;
/* If the ACEs are equal, we have nothing more to do. */
- if (sec_ace_equal(ace1, ace2)) {
+ if (security_ace_equal(ace1, ace2)) {
return 0;
}
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])) {
+ if (security_ace_equal(&the_acl->aces[i-1],
+ &the_acl->aces[i])) {
int j;
for (j=i; j<the_acl->num_aces-1; j++) {
the_acl->aces[j] = the_acl->aces[j+1];
p++;
/* Try to parse numeric form */
- if (sscanf(p, "%i/%i/%i", &atype, &aflags, &amask) == 3 &&
+ if (sscanf(p, "%u/%u/%u", &atype, &aflags, &amask) == 3 &&
convert_string_to_sid(ipc_cli, pol, numeric, &sid, str)) {
goto done;
}
/* Only numeric form accepted for flags at present */
if (!(next_token_talloc(frame, &cp, &tok, "/") &&
- sscanf(tok, "%i", &aflags))) {
+ sscanf(tok, "%u", &aflags))) {
TALLOC_FREE(frame);
return false;
}
}
if (strncmp(tok, "0x", 2) == 0) {
- if (sscanf(tok, "%i", &amask) != 1) {
+ if (sscanf(tok, "%u", &amask) != 1) {
TALLOC_FREE(frame);
return false;
}
goto done;
}
- for (v = standard_values; v->perm; v++) {
+ for (v = standard_values; v != NULL; v++) {
if (strcmp(tok, v->perm) == 0) {
amask = v->mask;
goto done;
while(*p) {
bool found = False;
- for (v = special_values; v->perm; v++) {
+ for (v = special_values; v != NULL; v++) {
if (v->perm[0] == *p) {
amask |= v->mask;
found = True;
struct timespec write_time_ts;
struct timespec access_time_ts;
struct timespec change_time_ts;
- SMB_OFF_T size = 0;
+ off_t size = 0;
uint16 mode = 0;
SMB_INO_T inode = 0;
DOS_ATTR_DESC *ret;
&inode)) {
errno = SMBC_errno(context, srv->cli);
DEBUG(5, ("dos_attr_query Failed to query old attributes\n"));
+ TALLOC_FREE(ret);
return NULL;
}
}
if (strncasecmp_m(tok, "SIZE:", 5) == 0) {
- dad->size = (SMB_OFF_T)atof(tok+5);
+ dad->size = (off_t)atof(tok+5);
continue;
}
time_t write_time = (time_t)0;
time_t access_time = (time_t)0;
time_t change_time = (time_t)0;
- SMB_OFF_T size = 0;
+ off_t size = 0;
uint16 mode = 0;
SMB_INO_T ino = 0;
struct cli_state *cli = srv->cli;
/* Point to the portion after "system.nt_sec_desc." */
name += 19; /* if (all) this will be invalid but unused */
- if (!cli_resolve_path(ctx, "", context->internal->auth_info,
- cli, filename,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(
+ ctx, "", context->internal->auth_info,
+ cli, filename, &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(5, ("cacl_get Could not resolve %s\n",
filename));
errno = ENOENT;
status = cli_ntcreate(targetcli, targetpath, 0,
CREATE_ACCESS_READ, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
- FILE_OPEN, 0x0, 0x0, &fnum);
+ FILE_OPEN, 0x0, 0x0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5, ("cacl_get failed to open %s: %s\n",
targetpath, nt_errstr(status)));
return -1;
}
- sd = cli_query_secdesc(targetcli, fnum, ctx);
-
- if (!sd) {
- DEBUG(5,
- ("cacl_get Failed to query old descriptor\n"));
- errno = 0;
- return -1;
- }
+ status = cli_query_secdesc(targetcli, fnum, ctx, &sd);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(5,("cacl_get Failed to query old descriptor "
+ "of %s: %s\n",
+ targetpath, nt_errstr(status)));
+ errno = 0;
+ return -1;
+ }
cli_close(targetcli, fnum);
return -1;
}
- if (!cli_resolve_path(ctx, "", context->internal->auth_info,
- cli, filename,
- &targetcli, &targetpath)) {
+ status = cli_resolve_path(ctx, "", context->internal->auth_info,
+ cli, filename, &targetcli, &targetpath);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(5,("cacl_set: Could not resolve %s\n", filename));
errno = ENOENT;
return -1;
status = cli_ntcreate(targetcli, targetpath, 0, CREATE_ACCESS_READ, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN,
- 0x0, 0x0, &fnum);
+ 0x0, 0x0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5, ("cacl_set failed to open %s: %s\n",
targetpath, nt_errstr(status)));
return -1;
}
- old = cli_query_secdesc(targetcli, fnum, ctx);
-
- if (!old) {
- DEBUG(5, ("cacl_set Failed to query old descriptor\n"));
- errno = 0;
+ status = cli_query_secdesc(targetcli, fnum, ctx, &old);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(5,("cacl_set Failed to query old descriptor of %s: %s\n",
+ targetpath, nt_errstr(status)));
+ errno = 0;
return -1;
}
bool found = False;
for (j=0;old->dacl && j<old->dacl->num_aces;j++) {
- if (sec_ace_equal(&sd->dacl->aces[i],
- &old->dacl->aces[j])) {
+ if (security_ace_equal(&sd->dacl->aces[i],
+ &old->dacl->aces[j])) {
uint32 k;
for (k=j; k<old->dacl->num_aces-1;k++) {
old->dacl->aces[k] =
status = cli_ntcreate(targetcli, targetpath, 0,
WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS, 0,
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN,
- 0x0, 0x0, &fnum);
+ 0x0, 0x0, &fnum, NULL);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5, ("cacl_set failed to open %s: %s\n",
targetpath, nt_errstr(status)));
const char * write_time_attr;
const char * change_time_attr;
} attr_strings;
+ uint16_t port = 0;
TALLOC_CTX *frame = talloc_stackframe();
if (!context || !context->internal->initialized) {
fname,
&workgroup,
&server,
+ &port,
&share,
&path,
&user,
}
srv = SMBC_server(frame, context, True,
- server, share, &workgroup, &user, &password);
+ server, port, share, &workgroup, &user, &password);
if (!srv) {
TALLOC_FREE(frame);
return -1; /* errno set by SMBC_server */
}
if (! srv->no_nt_session) {
- ipc_srv = SMBC_attr_server(frame, context, server, share,
+ ipc_srv = SMBC_attr_server(frame, context, server, port, share,
&workgroup, &user, &password);
if (! ipc_srv) {
srv->no_nt_session = True;
const char * write_time_attr;
const char * change_time_attr;
} attr_strings;
+ uint16_t port = 0;
TALLOC_CTX *frame = talloc_stackframe();
if (!context || !context->internal->initialized) {
fname,
&workgroup,
&server,
+ &port,
&share,
&path,
&user,
}
srv = SMBC_server(frame, context, True,
- server, share, &workgroup, &user, &password);
+ server, port, share, &workgroup, &user, &password);
if (!srv) {
TALLOC_FREE(frame);
return -1; /* errno set by SMBC_server */
}
if (! srv->no_nt_session) {
- ipc_srv = SMBC_attr_server(frame, context, server, share,
+ ipc_srv = SMBC_attr_server(frame, context, server, port, share,
&workgroup, &user, &password);
+ /*
+ * SMBC_attr_server() can cause the original
+ * server to be removed from the cache.
+ * If so we must error out here as the srv
+ * pointer has been freed.
+ */
+ if (smbc_getFunctionGetCachedServer(context)(context,
+ server,
+ share,
+ workgroup,
+ user) != srv) {
+#if defined(ECONNRESET)
+ errno = ECONNRESET;
+#else
+ errno = ETIMEDOUT;
+#endif
+ TALLOC_FREE(frame);
+ return -1;
+ }
if (! ipc_srv) {
srv->no_nt_session = True;
}
char *password = NULL;
char *workgroup = NULL;
char *path = NULL;
+ uint16_t port = 0;
TALLOC_CTX *frame = talloc_stackframe();
if (!context || !context->internal->initialized) {
fname,
&workgroup,
&server,
+ &port,
&share,
&path,
&user,
}
srv = SMBC_server(frame, context, True,
- server, share, &workgroup, &user, &password);
+ server, port, share, &workgroup, &user, &password);
if (!srv) {
TALLOC_FREE(frame);
return -1; /* errno set by SMBC_server */
}
if (! srv->no_nt_session) {
- ipc_srv = SMBC_attr_server(frame, context, server, share,
+ int saved_errno;
+ ipc_srv = SMBC_attr_server(frame, context, server, port, share,
&workgroup, &user, &password);
+ saved_errno = errno;
+ /*
+ * SMBC_attr_server() can cause the original
+ * server to be removed from the cache.
+ * If so we must error out here as the srv
+ * pointer has been freed.
+ */
+ if (smbc_getFunctionGetCachedServer(context)(context,
+ server,
+ share,
+ workgroup,
+ user) != srv) {
+#if defined(ECONNRESET)
+ errno = ECONNRESET;
+#else
+ errno = ETIMEDOUT;
+#endif
+ TALLOC_FREE(frame);
+ return -1;
+ }
if (! ipc_srv) {
+ errno = saved_errno;
srv->no_nt_session = True;
}
} else {