Beispiel #1
0
int SMBSetNetworkIdentity(SMBHANDLE inConnection, void *network_sid, char *account, char *domain)
{
    NTSTATUS	status;
    int			error;
    void		*hContext = NULL;
    ntsid_t		*ntsid = (ntsid_t *)network_sid;
    struct smbioc_ntwrk_identity ntwrkID;

    status = SMBServerContext(inConnection, &hContext);
    if (!NT_SUCCESS(status)) {
        /* Couldn't get the context? */
        return EINVAL;
    }
    memset(&ntwrkID, 0, sizeof(ntwrkID));
    ntwrkID.ioc_version = SMB_IOC_STRUCT_VERSION;
    ntwrkID.ioc_ntsid_len = sizeof(*ntsid);
    ntwrkID.ioc_ntsid = *ntsid;
    if (account) {
        strlcpy(ntwrkID.ioc_ntwrk_account, account, sizeof(ntwrkID.ioc_ntwrk_account));
    }
    if (domain) {
        strlcpy(ntwrkID.ioc_ntwrk_domain, domain, sizeof(ntwrkID.ioc_ntwrk_domain));
    }
    if (smb_ioctl_call(((struct smb_ctx *)hContext)->ct_fd, SMBIOC_NTWRK_IDENTITY, &ntwrkID) == -1) {
        error = errno;
        smb_log_info("The SMBIOC_NTWRK_IDENTITY call failed, syserr = %s",
                     ASL_LEVEL_DEBUG, strerror(error));
        return error;
    }
    return 0;
}
Beispiel #2
0
Datei: raw.c Projekt: B1NG0/cifs
static int
smb_ioc_request(
        void *				hContext,
        struct smb_header *	header,
        const mbuf_t		words,
        const mbuf_t		bytes,
        mbuf_t				response)
{
    struct smbioc_rq krq;

	bzero(&krq, sizeof(krq));
    krq.ioc_version = SMB_IOC_STRUCT_VERSION;
    krq.ioc_cmd = header->command;

    /* XXX For large I/O requests where the uint16_t byte count
     * (ioc_tbc) wraps to 0, this interface will get horribly
     * confused. I don't think we can fix this without revving the
     * ioctl version -- jpeach
     */

    /* Set transmit words buffer ... */
    krq.ioc_twc = mbuf_len(words) / sizeof(uint16_t);
    krq.ioc_twords = mbuf_data(words);
    /* Set transmit bytes buffer ... */
    krq.ioc_tbc = mbuf_len(bytes);
    krq.ioc_tbytes = mbuf_data(bytes);
    /* Set receive buffer, reserving space for the word count and byte count ... */
    krq.ioc_rpbufsz = (int32_t)mbuf_maxlen(response);
    krq.ioc_rpbuf = mbuf_data(response);

    if (smb_ioctl_call(((struct smb_ctx *)hContext)->ct_fd,
                SMBIOC_REQUEST, &krq) == -1) {
        return errno;
    }
	
	header->flags = krq.ioc_flags;
	header->flags2 = krq.ioc_flags2;
	header->status = krq.ioc_ntstatus;
	mbuf_setlen(response, krq.ioc_rpbufsz);

    return 0;
}