static NTSTATUS dcesrv_unixinfo_SidToGid(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct unixinfo_SidToGid *r) { NTSTATUS status; struct sidmap_context *sidmap; gid_t gid; sidmap = sidmap_open(mem_ctx); if (sidmap == NULL) { DEBUG(10, ("sidmap_open failed\n")); return NT_STATUS_NO_MEMORY; } status = sidmap_sid_to_unixgid(sidmap, &r->in.sid, &gid); NT_STATUS_NOT_OK_RETURN(status); *r->out.gid = gid; return NT_STATUS_OK; }
static NTSTATUS dcesrv_unixinfo_GidToSid(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct unixinfo_GidToSid *r) { struct sidmap_context *sidmap; gid_t gid; sidmap = sidmap_open(mem_ctx); if (sidmap == NULL) { DEBUG(10, ("sidmap_open failed\n")); return NT_STATUS_NO_MEMORY; } gid = r->in.gid; /* This cuts gid to (probably) 32 bit */ if ((uint64_t)gid != r->in.gid) { DEBUG(10, ("gid out of range\n")); return NT_STATUS_INVALID_PARAMETER; } return sidmap_gid_to_sid(sidmap, mem_ctx, gid, &r->out.sid); }
/* connect to a share - used when a tree_connect operation comes in. For a disk based backend we needs to ensure that the base directory exists (tho it doesn't need to be accessible by the user, that comes later) */ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs, struct ntvfs_request *req, const char *sharename) { struct pvfs_state *pvfs; struct stat st; char *base_directory; NTSTATUS status; pvfs = talloc_zero(ntvfs, struct pvfs_state); NT_STATUS_HAVE_NO_MEMORY(pvfs); /* for simplicity of path construction, remove any trailing slash now */ base_directory = talloc_strdup(pvfs, share_string_option(ntvfs->ctx->config, SHARE_PATH, "")); NT_STATUS_HAVE_NO_MEMORY(base_directory); if (strcmp(base_directory, "/") != 0) { trim_string(base_directory, NULL, "/"); } pvfs->ntvfs = ntvfs; pvfs->base_directory = base_directory; /* the directory must exist. Note that we deliberately don't check that it is readable */ if (stat(pvfs->base_directory, &st) != 0 || !S_ISDIR(st.st_mode)) { DEBUG(0,("pvfs_connect: '%s' is not a directory, when connecting to [%s]\n", pvfs->base_directory, sharename)); return NT_STATUS_BAD_NETWORK_NAME; } ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:"); NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); ntvfs->private_data = pvfs; pvfs->brl_context = brl_init(pvfs, pvfs->ntvfs->ctx->server_id, pvfs->ntvfs->ctx->msg_ctx); if (pvfs->brl_context == NULL) { return NT_STATUS_INTERNAL_DB_CORRUPTION; } pvfs->odb_context = odb_init(pvfs, pvfs->ntvfs->ctx); if (pvfs->odb_context == NULL) { return NT_STATUS_INTERNAL_DB_CORRUPTION; } /* allow this to be NULL - we just disable change notify */ pvfs->notify_context = notify_init(pvfs, pvfs->ntvfs->ctx->server_id, pvfs->ntvfs->ctx->msg_ctx, event_context_find(pvfs), pvfs->ntvfs->ctx->config); pvfs->sidmap = sidmap_open(pvfs); if (pvfs->sidmap == NULL) { return NT_STATUS_INTERNAL_DB_CORRUPTION; } /* allocate the search handle -> ptr tree */ pvfs->search.idtree = idr_init(pvfs); NT_STATUS_HAVE_NO_MEMORY(pvfs->search.idtree); status = pvfs_mangle_init(pvfs); NT_STATUS_NOT_OK_RETURN(status); pvfs_setup_options(pvfs); talloc_set_destructor(pvfs, pvfs_state_destructor); #ifdef SIGXFSZ /* who had the stupid idea to generate a signal on a large file write instead of just failing it!? */ BlockSignals(True, SIGXFSZ); #endif return NT_STATUS_OK; }