~ubuntu-branches/ubuntu/vivid/samba/vivid

« back to all changes in this revision

Viewing changes to source4/ntvfs/posix/xattr_tdb.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:
20
20
*/
21
21
 
22
22
#include "includes.h"
 
23
#include "lib/util/tdb_wrap.h"
 
24
#include <tdb.h>
23
25
#include "vfs_posix.h"
24
 
#include "../tdb/include/tdb.h"
25
 
#include "tdb_wrap.h"
26
26
 
27
27
#define XATTR_LIST_ATTR ".xattr_list"
28
28
 
30
30
  we need to maintain a list of attributes on each file, so that unlink
31
31
  can automatically clean them up
32
32
*/
33
 
static NTSTATUS xattr_tdb_add_list(struct pvfs_state *pvfs, const char *attr_name, 
 
33
static NTSTATUS xattr_tdb_add_list(struct tdb_wrap *ea_tdb, TALLOC_CTX *ctx, const char *attr_name,
34
34
                                   const char *fname, int fd)
35
35
{
36
36
        DATA_BLOB blob;
43
43
                return NT_STATUS_OK;
44
44
        }
45
45
 
46
 
        mem_ctx = talloc_new(pvfs);
 
46
        mem_ctx = talloc_new(ctx);
47
47
 
48
 
        status = pull_xattr_blob_tdb(pvfs, mem_ctx, XATTR_LIST_ATTR, 
 
48
        status = pull_xattr_blob_tdb_raw(ea_tdb, mem_ctx, XATTR_LIST_ATTR,
49
49
                                     fname, fd, 100, &blob);
50
50
        if (!NT_STATUS_IS_OK(status)) {
51
51
                blob = data_blob(NULL, 0);
68
68
        memcpy(blob.data + blob.length, attr_name, len);
69
69
        blob.length += len;
70
70
 
71
 
        status = push_xattr_blob_tdb(pvfs, XATTR_LIST_ATTR, fname, fd, &blob);
 
71
        status = push_xattr_blob_tdb_raw(ea_tdb,ctx, XATTR_LIST_ATTR, fname, fd, &blob);
72
72
        talloc_free(mem_ctx);
73
73
 
74
74
        return status;
75
75
}
76
76
 
77
77
/*
78
 
  form a key for using in the ea_db
 
78
  form a key for using in the ea_tdb
79
79
*/
80
 
static NTSTATUS get_ea_db_key(TALLOC_CTX *mem_ctx,
 
80
static NTSTATUS get_ea_tdb_key(TALLOC_CTX *mem_ctx,
81
81
                              const char *attr_name,
82
82
                              const char *fname, int fd, 
83
83
                              TDB_DATA *key)
108
108
        return NT_STATUS_OK;
109
109
}
110
110
 
 
111
 
 
112
 
111
113
/*
112
 
  pull a xattr as a blob, using the ea_db tdb
 
114
  pull a xattr as a blob, using the ea_tdb_context tdb
113
115
*/
114
 
NTSTATUS pull_xattr_blob_tdb(struct pvfs_state *pvfs,
 
116
NTSTATUS pull_xattr_blob_tdb_raw(struct tdb_wrap *ea_tdb,
115
117
                             TALLOC_CTX *mem_ctx,
116
 
                             const char *attr_name, 
117
 
                             const char *fname, 
118
 
                             int fd, 
 
118
                             const char *attr_name,
 
119
                             const char *fname,
 
120
                             int fd,
119
121
                             size_t estimated_size,
120
122
                             DATA_BLOB *blob)
121
123
{
122
124
        TDB_DATA tkey, tdata;
123
125
        NTSTATUS status;
124
126
 
125
 
        status = get_ea_db_key(mem_ctx, attr_name, fname, fd, &tkey);
 
127
        status = get_ea_tdb_key(mem_ctx, attr_name, fname, fd, &tkey);
126
128
        if (!NT_STATUS_IS_OK(status)) {
127
129
                return status;
128
130
        }
129
131
 
130
 
        tdata = tdb_fetch(pvfs->ea_db->tdb, tkey);
 
132
        tdata = tdb_fetch(ea_tdb->tdb, tkey);
131
133
        if (tdata.dptr == NULL) {
132
134
                return NT_STATUS_NOT_FOUND;
133
135
        }
141
143
        return NT_STATUS_OK;    
142
144
}
143
145
 
 
146
NTSTATUS pull_xattr_blob_tdb(struct pvfs_state *pvfs,
 
147
                             TALLOC_CTX *mem_ctx,
 
148
                             const char *attr_name,
 
149
                             const char *fname,
 
150
                             int fd,
 
151
                             size_t estimated_size,
 
152
                             DATA_BLOB *blob)
 
153
{
 
154
        return pull_xattr_blob_tdb_raw(pvfs->ea_db,mem_ctx,attr_name,fname,fd,estimated_size,blob);
 
155
}
 
156
 
144
157
/*
145
 
  push a xattr as a blob, using ea_db
 
158
  push a xattr as a blob, using ea_tdb
146
159
*/
147
 
NTSTATUS push_xattr_blob_tdb(struct pvfs_state *pvfs,
148
 
                             const char *attr_name, 
149
 
                             const char *fname, 
150
 
                             int fd, 
 
160
NTSTATUS push_xattr_blob_tdb_raw(struct tdb_wrap *ea_tdb,
 
161
                             TALLOC_CTX *mem_ctx,
 
162
                             const char *attr_name,
 
163
                             const char *fname,
 
164
                             int fd,
151
165
                             const DATA_BLOB *blob)
152
166
{
153
167
        TDB_DATA tkey, tdata;
154
168
        NTSTATUS status;
155
169
 
156
 
        status = get_ea_db_key(pvfs, attr_name, fname, fd, &tkey);
 
170
        status = get_ea_tdb_key(mem_ctx, attr_name, fname, fd, &tkey);
157
171
        if (!NT_STATUS_IS_OK(status)) {
158
172
                return status;
159
173
        }
161
175
        tdata.dptr = blob->data;
162
176
        tdata.dsize = blob->length;
163
177
 
164
 
        if (tdb_chainlock(pvfs->ea_db->tdb, tkey) != 0) {
 
178
        if (tdb_chainlock(ea_tdb->tdb, tkey) != 0) {
165
179
                talloc_free(tkey.dptr);
166
180
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
167
181
        }
168
182
 
169
 
        status = xattr_tdb_add_list(pvfs, attr_name, fname, fd);
 
183
        status = xattr_tdb_add_list(ea_tdb,mem_ctx, attr_name, fname, fd);
170
184
        if (!NT_STATUS_IS_OK(status)) {
171
185
                goto done;
172
186
        }
173
187
 
174
 
        if (tdb_store(pvfs->ea_db->tdb, tkey, tdata, TDB_REPLACE) == -1) {
 
188
        if (tdb_store(ea_tdb->tdb, tkey, tdata, TDB_REPLACE) == -1) {
175
189
                status = NT_STATUS_INTERNAL_DB_CORRUPTION;
176
190
        }
177
191
 
178
192
done:
179
 
        tdb_chainunlock(pvfs->ea_db->tdb, tkey);
 
193
        tdb_chainunlock(ea_tdb->tdb, tkey);
180
194
        talloc_free(tkey.dptr);
181
195
        return status;  
182
196
}
 
197
NTSTATUS push_xattr_blob_tdb(struct pvfs_state *pvfs,
 
198
                             const char *attr_name,
 
199
                             const char *fname,
 
200
                             int fd,
 
201
                             const DATA_BLOB *blob)
 
202
{
 
203
        return push_xattr_blob_tdb_raw(pvfs->ea_db,pvfs,attr_name,fname,fd,blob);
 
204
}
183
205
 
184
206
 
185
207
/*
191
213
        TDB_DATA tkey;
192
214
        NTSTATUS status;
193
215
 
194
 
        status = get_ea_db_key(NULL, attr_name, fname, fd, &tkey);
 
216
        status = get_ea_tdb_key(NULL, attr_name, fname, fd, &tkey);
195
217
        if (!NT_STATUS_IS_OK(status)) {
196
218
                return status;
197
219
        }
217
239
        const char *s;
218
240
        NTSTATUS status;
219
241
 
220
 
        status = pull_xattr_blob_tdb(pvfs, mem_ctx, XATTR_LIST_ATTR, 
 
242
        status = pull_xattr_blob_tdb(pvfs, mem_ctx, XATTR_LIST_ATTR,
221
243
                                     fname, -1, 100, &blob);
222
244
        if (!NT_STATUS_IS_OK(status)) {
223
245
                talloc_free(mem_ctx);