srvsvc 0x27 patch

Jim McDonough jmcd at us.ibm.com
Mon Jun 18 15:43:06 GMT 2001


Mike,
Have you gotten the latest CVS or just my first patch?  The latest CVS is
what allows both viewing and changing.

I'm trying to reproduce your explorer crash.  I've had it work, and I've
had "The remote procedure call failed" errors on directories.  I'll try a
different client (VMware is my friend here)...each one behaves a little
different.

Obviously, there are some things to be ironed out here.  I'll keep working
on them.

AFA the usernames that show up and can be searched, I don't know any of
that code yet.  After I get this working for directories on all
clients....or so I hope...maybe I'll take a look at that.  Anybody else
want to answer this?

Jim

----------------------------
Jim McDonough
Linux Technology Center
IBM Boulder

Notes: Jim McDonough/Boulder/IBM @ IBMUS
VNET: JMCD at IBMUSM54
Internet: jmcd at us.ibm.com

Phone: (303) 924-5822
T/L: 263-5822


"Mike Pain" <mtp at blaby.gov.uk> on 06/18/2001 04:15:49 AM

To:   Jim McDonough/Boulder/IBM at IBMUS
cc:   <samba-technical at samba.org>
Subject:  Re: srvsvc 0x27 patch



Jim,
thanks a LOT for this - it works fine, but interestingly I CAN set and
change permissions on a file from my Win98SE PC.

The only weird thing (this also occurs from an NT client) is that when I
select ADD for a new user to be given permissions, I get two options in the
"List Names From:" pull down - the NT domain and the linux server,  so I
select the linux server.  If I then select  Show Users, I only get
individual users from the smbpasswd file, not other users on the server.
BUT, if  I click on Search, I can search for any user in /etc/passwd.  This
is what I would prefer, as we do security=domain validation, so users are
only set up in /etc/passwd and not in the smbpasswd file.  Still, I can't
be
picky as this fix has solved a BIG problem for me.

Thanks again.

Mike
----- Original Message -----
From: "Jim McDonough" <jmcd at us.ibm.com>
To: <samba-technical at samba.org>
Cc: <jeremy at valinux.com>; <mtp at blaby.gov.uk>
Sent: Friday, June 15, 2001 8:33 PM
Subject: srvsvc 0x27 patch


> Ok, the remaining bug wasn't with my code, but the rpc_parse/parse_samr.c
> function samr_io_q_lookup_names.  On line 4357, it read:
>           if (!q_u->hdr_name || q_u->uni_name)
>                return False;
> but it should read
>           if (!q_u->hdr_name || !q_u->uni_name)
>                return False;
> It was erroring when both allocations were successful.
>
> Now, the following patch does work (for me at least) to view the
> permissions.  It does not however, allow permissions to be set.  That
would
> be srvsvc opnum 0x28 (no surprise here).  I'll work on that next.
>
> Should I close the connection I open up in _srv_net_file_query_secdesc in
> srv_srvsvc_nt.c?
>
> Jim
> ----------------------------
> Jim McDonough
> Linux Technology Center
> IBM Boulder
>
> Notes: Jim McDonough/Boulder/IBM @ IBMUS
> VNET: JMCD at IBMUSM54
> Internet: jmcd at us.ibm.com
>
> Phone: (303) 924-5822
> T/L: 263-5822
>
> diff -urx*CVS* ./include/proto.h
/samba/mine/samba-2.2/source/include/proto.h
> --- ./include/proto.h    Fri Jun 15 09:34:19 2001
> +++ /samba/mine/samba-2.2/source/include/proto.h   Wed Jun 13 09:09:23
2001
> @@ -3554,6 +3554,9 @@
>  BOOL srv_io_r_net_share_add(char *desc, SRV_R_NET_SHARE_ADD *q_n,
prs_struct *ps, int depth);
>  BOOL srv_io_q_net_share_del(char *desc, SRV_Q_NET_SHARE_DEL *q_n,
prs_struct *ps, int depth);
>  BOOL srv_io_r_net_share_del(char *desc, SRV_R_NET_SHARE_DEL *q_n,
prs_struct *ps, int depth);
> +BOOL srv_io_q_net_file_query_secdesc (char *desc,
SRV_Q_NET_FILE_QUERY_SECDESC *q_n, prs_struct *ps, int depth);
> +BOOL srv_io_r_net_file_query_secdesc (char *desc,
SRV_R_NET_FILE_QUERY_SECDESC *q_n, prs_struct *ps, int depth);
> +
>  void init_srv_sess_info0_str(SESS_INFO_0_STR *ss0, char *name);
>  void init_srv_sess_info0(SESS_INFO_0 *ss0, char *name);
>  void init_srv_sess_info1_str(SESS_INFO_1_STR *ss1, char *name, char
*user);
> @@ -3843,6 +3846,7 @@
>  uint32 _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u,
SRV_R_NET_REMOTE_TOD *r_u);
>  uint32 _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u,
SRV_R_NET_DISK_ENUM *r_u);
>  uint32 _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE
*q_u, SRV_R_NET_NAME_VALIDATE *r_u);
> +uint32 _srv_net_file_query_secdesc(pipes_struct *p,
SRV_Q_NET_FILE_QUERY_SECDESC *q_u, SRV_R_NET_FILE_QUERY_SECDESC *r_u);
>
>  /*The following definitions come from  rpc_server/srv_util.c  */
>
> diff -urx*CVS* ./include/rpc_srvsvc.h
/samba/mine/samba-2.2/source/include/rpc_srvsvc.h
> --- ./include/rpc_srvsvc.h    Tue May  1 13:47:46 2001
> +++ /samba/mine/samba-2.2/source/include/rpc_srvsvc.h   Fri Jun  8
14:12:14 2001
> @@ -40,6 +40,7 @@
>  #define SRV_NET_REMOTE_TOD     0x1c
>  #define SRV_NET_NAME_VALIDATE  0x21
>  #define SRV_NETSHAREENUM       0x24
> +#define SRV_NETFILEQUERYSECDESC 0x27
>
>  #define MAX_SERVER_DISK_ENTRIES 15
>
> @@ -763,5 +764,27 @@
>
>  } SRV_R_NET_REMOTE_TOD;
>
> -
> +/* SRV_Q_NET_FILE_QUERY_SECDESC */
> +typedef struct q_net_file_query_secdesc
> +{
> +    uint32  ptr_srv_name;
> +    UNISTR2 uni_srv_name;
> +    uint32  ptr_qual_name;
> +    UNISTR2 uni_qual_name;
> +    UNISTR2 uni_file_name;
> +    uint32  unknown1;
> +    uint32  unknown2;
> +    uint32  unknown3;
> +} SRV_Q_NET_FILE_QUERY_SECDESC;
> +
> +/* SRV_R_NET_FILE_QUERY_SECDESC */
> +typedef struct r_net_file_query_secdesc
> +{
> +    uint32 ptr_response;
> +    uint32 size_response;
> +    uint32 ptr_secdesc;
> +    uint32 size_secdesc;
> +    SEC_DESC *sec_desc;
> +    uint32 status;
> +} SRV_R_NET_FILE_QUERY_SECDESC;
>  #endif /* _RPC_SRVSVC_H */
> diff -urx*CVS* ./rpc_parse/parse_samr.c
/samba/mine/samba-2.2/source/rpc_parse/parse_samr.c
> --- ./rpc_parse/parse_samr.c  Fri Jun 15 09:34:20 2001
> +++ /samba/mine/samba-2.2/source/rpc_parse/parse_samr.c      Fri Jun 15
13:21:25 2001
> @@ -4354,7 +4354,7 @@
>                                    q_u->num_names2);
>           q_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, sizeof(UNISTR2) *
>                                     q_u->num_names2);
> -         if (!q_u->hdr_name || q_u->uni_name)
> +         if (!q_u->hdr_name || !q_u->uni_name)
>                return False;
>      }
>
> diff -urx*CVS* ./rpc_parse/parse_srv.c
/samba/mine/samba-2.2/source/rpc_parse/parse_srv.c
> --- ./rpc_parse/parse_srv.c   Tue May  1 13:47:49 2001
> +++ /samba/mine/samba-2.2/source/rpc_parse/parse_srv.c  Thu Jun 14
13:42:20 2001
> @@ -2560,3 +2560,87 @@
>
>      return True;
>  }
> +
> +/*******************************************************************
> + Reads or writes a structure.
> + ********************************************************************/
> +
> +BOOL srv_io_q_net_file_query_secdesc(char *desc,
SRV_Q_NET_FILE_QUERY_SECDESC *q_n, prs_struct *ps, int depth)
> +{
> +        if (q_n == NULL)
> +                return False;
> +
> +        prs_debug(ps, depth, desc, "srv_io_q_net_file_query_secdesc");
> +        depth++;
> +
> +        if(!prs_align(ps))
> +                return False;
> +
> +        if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))
> +                return False;
> +
> +        if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))
> +                return False;
> +
> +        if(!prs_align(ps))
> +                return False;
> +
> +    if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))
> +         return False;
> +
> +    if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth))
> +         return False;
> +        if(!prs_align(ps))
> +                return False;
> +
> +        if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth))
> +                return False;
> +
> +    if(!prs_uint32("unknown1", ps, depth, &q_n->unknown1))
> +         return False;
> +        if(!prs_uint32("unknown2", ps, depth, &q_n->unknown2))
> +                return False;
> +        if(!prs_uint32("unknown3", ps, depth, &q_n->unknown3))
> +                return False;
> +
> +        return True;
> +}
> +
> +/*******************************************************************
> + Reads or writes a structure.
> + ********************************************************************/
> +
> +BOOL srv_io_r_net_file_query_secdesc(char *desc,
SRV_R_NET_FILE_QUERY_SECDESC *r_n, prs_struct *ps, int depth)
> +{
> +        if (r_n == NULL)
> +                return False;
> +
> +        prs_debug(ps, depth, desc, "srv_io_r_net_file_query_secdesc");
> +        depth++;
> +
> +        if(!prs_align(ps))
> +                return False;
> +
> +    if(!prs_uint32("ptr_response", ps, depth, &r_n->ptr_response))
> +         return False;
> +
> +    if(!prs_uint32("size_response", ps, depth, &r_n->size_response))
> +         return False;
> +
> +        if(!prs_uint32("ptr_secdesc", ps, depth, &r_n->ptr_secdesc))
> +                return False;
> +
> +        if(!prs_uint32("size_secdesc", ps, depth, &r_n->size_secdesc))
> +                return False;
> +
> +    if(!sec_io_desc("sec_desc", &r_n->sec_desc, ps, depth))
> +         return False;
> +
> +    if(!prs_align(ps))
> +         return False;
> +        if(!prs_uint32("status", ps, depth, &r_n->status))
> +                return False;
> +
> +        return True;
> +}
> +
> diff -urx*CVS* ./rpc_server/srv_srvsvc.c
/samba/mine/samba-2.2/source/rpc_server/srv_srvsvc.c
> --- ./rpc_server/srv_srvsvc.c Tue May  1 13:47:50 2001
> +++ /samba/mine/samba-2.2/source/rpc_server/srv_srvsvc.c     Thu Jun 14
13:34:40 2001
> @@ -405,6 +405,35 @@
>  }
>
>  /*******************************************************************
> + NetFileQuerySecdesc (opnum 0x27)
> +*******************************************************************/
> +
> +static BOOL api_srv_net_file_query_secdesc(pipes_struct *p)
> +{
> +    SRV_Q_NET_FILE_QUERY_SECDESC q_u;
> +    SRV_R_NET_FILE_QUERY_SECDESC r_u;
> +        prs_struct *data = &p->in_data.data;
> +        prs_struct *rdata = &p->out_data.rdata;
> +
> +        ZERO_STRUCT(q_u);
> +        ZERO_STRUCT(r_u);
> +
> +        /* Unmarshall the net file get info from Win9x */
> +        if(!srv_io_q_net_file_query_secdesc("", &q_u, data, 0)) {
> +                DEBUG(0,("api_srv_net_file_query_secdesc: Failed to
unmarshall SRV_Q_NET_FILE_QUERY_SECDESC.\n"));
> +                return False;
> +        }
> +
> +        r_u.status = _srv_net_file_query_secdesc(p, &q_u, &r_u);
> +
> +        if(!srv_io_r_net_file_query_secdesc("", &r_u, rdata, 0)) {
> +                DEBUG(0,("api_srv_net_file_query_secdesc: Failed to
marshall SRV_R_NET_FILE_QUERY_SECDESC.\n"));
> +                return False;
> +        }
> +
> +        return True;
> +}
> +/*******************************************************************
>  \PIPE\srvsvc commands
>  ********************************************************************/
>
> @@ -423,6 +452,7 @@
>      { "SRV_NET_REMOTE_TOD"    , SRV_NET_REMOTE_TOD    ,
api_srv_net_remote_tod   },
>      { "SRV_NET_DISK_ENUM"     , SRV_NET_DISK_ENUM     ,
api_srv_net_disk_enum    },
>      { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE ,
api_srv_net_name_validate},
> +    {
"SRV_NETFILEQUERYSECDESC",SRV_NETFILEQUERYSECDESC,api_srv_net_file_query_sec

desc},
>      { NULL                    , 0                     ,
     }
>  };
>
> diff -urx*CVS* ./rpc_server/srv_srvsvc_nt.c
/samba/mine/samba-2.2/source/rpc_server/srv_srvsvc_nt.c
> --- ./rpc_server/srv_srvsvc_nt.c   Fri Jun 15 09:34:21 2001
> +++ /samba/mine/samba-2.2/source/rpc_server/srv_srvsvc_nt.c  Fri Jun 15
13:31:23 2001
> @@ -1675,3 +1675,44 @@
>
>      return r_u->status;
>  }
> +
> +uint32 _srv_net_file_query_secdesc(pipes_struct *p,
SRV_Q_NET_FILE_QUERY_SECDESC *q_u, SRV_R_NET_FILE_QUERY_SECDESC *r_u)
> +{
> +    SEC_DESC *psd = NULL;
> +    size_t sd_size;
> +    fstring filename;
> +    fstring qualname;
> +    fstring null_pw;
> +    files_struct *fsp = NULL;
> +    SMB_STRUCT_STAT st;
> +    BOOL bad_path;
> +    int access_mode;
> +    int action;
> +    int ecode;
> +    connection_struct *conn;
> +
> +    unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname));
> +    *null_pw = '\0';
> +    conn = make_connection(qualname, p->conn->user, null_pw, 0, "A:",
p->conn->vuid, &ecode);
> +    unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename));
> +    unix_convert(filename, conn, NULL, &bad_path, &st);
> +    fsp = open_file_shared(conn, filename, &st,
SET_OPEN_MODE(DOS_OPEN_RDONLY), (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN),
0, 0, &access_mode,
> &action);
> +
> +    sd_size = conn->vfs_ops.get_nt_acl(fsp, fsp->fsp_name, &psd);
> +
> +    r_u->ptr_response = 1;
> +    r_u->size_response = sd_size;
> +    r_u->ptr_secdesc = 1;
> +    r_u->size_secdesc = sd_size;
> +    r_u->sec_desc = psd;
> +
> +    psd->dacl->revision = (uint16) NT4_ACL_REVISION;
> +
> +        r_u->status=NT_STATUS_NOPROBLEMO;
> +    fsp->conn->vfs_ops.close(fsp, fsp->fd);
> +    file_free(fsp);
> +    /* jmcd at us.ibm.com should the connection be closed?
> +    close_cnum(conn, p->conn->vuid); */
> +        return r_u->status;
> +}
> +
>
>
>



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This message has been scanned for viruses.
Blaby District Council - 0116 275 0555
**********************************************************************







More information about the samba-technical mailing list