~lefteris-nikoltsios/+junk/samba-lp1016895

« back to all changes in this revision

Viewing changes to source3/libsmb/clisecdesc.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
   Unix SMB/CIFS implementation.
3
3
   client security descriptor functions
4
4
   Copyright (C) Andrew Tridgell 2000
5
 
   
 
5
 
6
6
   This program is free software; you can redistribute it and/or modify
7
7
   it under the terms of the GNU General Public License as published by
8
8
   the Free Software Foundation; either version 3 of the License, or
9
9
   (at your option) any later version.
10
 
   
 
10
 
11
11
   This program is distributed in the hope that it will be useful,
12
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
14
   GNU General Public License for more details.
15
 
   
 
15
 
16
16
   You should have received a copy of the GNU General Public License
17
17
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
*/
19
19
 
20
20
#include "includes.h"
 
21
#include "libsmb/libsmb.h"
21
22
 
22
23
/****************************************************************************
23
24
  query the security descriptor for a open file
24
25
 ****************************************************************************/
25
 
SEC_DESC *cli_query_secdesc(struct cli_state *cli, uint16_t fnum, 
 
26
struct security_descriptor *cli_query_secdesc(struct cli_state *cli, uint16_t fnum,
26
27
                            TALLOC_CTX *mem_ctx)
27
28
{
28
29
        uint8_t param[8];
29
 
        uint8_t *rparam=NULL, *rdata=NULL;
30
 
        unsigned int rparam_count=0, rdata_count=0;
31
 
        SEC_DESC *psd = NULL;
 
30
        uint8_t *rdata=NULL;
 
31
        uint32_t rdata_count=0;
 
32
        struct security_descriptor *psd = NULL;
32
33
        NTSTATUS status;
33
34
 
34
35
        SIVAL(param, 0, fnum);
40
41
                           NULL, 0, 0, /* setup, length, max */
41
42
                           param, 8, 4, /* param, length, max */
42
43
                           NULL, 0, 0x10000, /* data, length, max */
43
 
                           NULL, NULL, /* rsetup, length */
44
 
                           &rparam, &rparam_count,
45
 
                           &rdata, &rdata_count);
 
44
                           NULL,             /* recv_flags2 */
 
45
                           NULL, 0, NULL, /* rsetup, length */
 
46
                           NULL, 0, NULL,
 
47
                           &rdata, 0, &rdata_count);
46
48
 
47
49
        if (!NT_STATUS_IS_OK(status)) {
48
50
                DEBUG(1, ("NT_TRANSACT_QUERY_SECURITY_DESC failed: %s\n",
61
63
 
62
64
 cleanup:
63
65
 
64
 
        TALLOC_FREE(rparam);
65
66
        TALLOC_FREE(rdata);
66
67
 
67
68
        return psd;
70
71
/****************************************************************************
71
72
  set the security descriptor for a open file
72
73
 ****************************************************************************/
73
 
bool cli_set_secdesc(struct cli_state *cli, uint16_t fnum, SEC_DESC *sd)
 
74
NTSTATUS cli_set_secdesc(struct cli_state *cli, uint16_t fnum,
 
75
                         struct security_descriptor *sd)
74
76
{
75
 
        char param[8];
76
 
        char *rparam=NULL, *rdata=NULL;
77
 
        unsigned int rparam_count=0, rdata_count=0;
 
77
        uint8_t param[8];
78
78
        uint32 sec_info = 0;
79
 
        TALLOC_CTX *frame = talloc_stackframe();
80
 
        bool ret = False;
81
79
        uint8 *data;
82
80
        size_t len;
83
81
        NTSTATUS status;
86
84
        if (!NT_STATUS_IS_OK(status)) {
87
85
                DEBUG(10, ("marshall_sec_desc failed: %s\n",
88
86
                           nt_errstr(status)));
89
 
                goto cleanup;
 
87
                return status;
90
88
        }
91
89
 
92
90
        SIVAL(param, 0, fnum);
93
91
 
94
92
        if (sd->dacl)
95
 
                sec_info |= DACL_SECURITY_INFORMATION;
 
93
                sec_info |= SECINFO_DACL;
96
94
        if (sd->owner_sid)
97
 
                sec_info |= OWNER_SECURITY_INFORMATION;
 
95
                sec_info |= SECINFO_OWNER;
98
96
        if (sd->group_sid)
99
 
                sec_info |= GROUP_SECURITY_INFORMATION;
 
97
                sec_info |= SECINFO_GROUP;
100
98
        SSVAL(param, 4, sec_info);
101
99
 
102
 
        if (!cli_send_nt_trans(cli, 
103
 
                               NT_TRANSACT_SET_SECURITY_DESC, 
104
 
                               0, 
105
 
                               NULL, 0, 0,
106
 
                               param, 8, 0,
107
 
                               (char *)data, len, 0)) {
108
 
                DEBUG(1,("Failed to send NT_TRANSACT_SET_SECURITY_DESC\n"));
109
 
                goto cleanup;
110
 
        }
111
 
 
112
 
 
113
 
        if (!cli_receive_nt_trans(cli, 
114
 
                                  &rparam, &rparam_count,
115
 
                                  &rdata, &rdata_count)) {
116
 
                DEBUG(1,("NT_TRANSACT_SET_SECURITY_DESC failed\n"));
117
 
                goto cleanup;
118
 
        }
119
 
 
120
 
        ret = True;
121
 
 
122
 
  cleanup:
123
 
 
124
 
        SAFE_FREE(rparam);
125
 
        SAFE_FREE(rdata);
126
 
 
127
 
        TALLOC_FREE(frame);
128
 
 
129
 
        return ret;
 
100
        status = cli_trans(talloc_tos(), cli, SMBnttrans,
 
101
                           NULL, -1, /* name, fid */
 
102
                           NT_TRANSACT_SET_SECURITY_DESC, 0,
 
103
                           NULL, 0, 0, /* setup */
 
104
                           param, 8, 0, /* param */
 
105
                           data, len, 0, /* data */
 
106
                           NULL,         /* recv_flags2 */
 
107
                           NULL, 0, NULL, /* rsetup */
 
108
                           NULL, 0, NULL, /* rparam */
 
109
                           NULL, 0, NULL); /* rdata */
 
110
        TALLOC_FREE(data);
 
111
        if (!NT_STATUS_IS_OK(status)) {
 
112
                DEBUG(1, ("Failed to send NT_TRANSACT_SET_SECURITY_DESC: %s\n",
 
113
                          nt_errstr(status)));
 
114
        }
 
115
        return status;
130
116
}