~ubuntu-branches/ubuntu/gutsy/samba/gutsy-updates

« back to all changes in this revision

Viewing changes to source/libsmb/smb_share_modes.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2006-11-28 20:14:37 UTC
  • mfrom: (0.10.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061128201437-a6x4lzlhempazocp
Tags: 3.0.23d-1ubuntu1
* Merge from debian unstable.
* Drop python2.4-samba, replace with python-samba. Added Conflicts/Replaces
  on python2.4-samba
* Drop track-connection-dos.patch, ubuntu-winbind-panic.patch, 
  ubuntu-fix-ldap.patch, ubuntu-setlocale.patch, ubuntu-setlocale-fixes.patch
* Remaining Ubuntu changes:
  - Revert Debian's installation of mount.cifs and umount.cifs as suid
  - Comment out the default [homes] shares and add more verbose comments to
    explain what they do and how they work (closes: launchpad.net/27608)
  - Add a "valid users = %S" stanza to the commented-out [homes] section, to
    show users how to restrict access to \\server\username to only username.
  - Change the (commented-out) "printer admin" example to use "@lpadmin"
    instead of "@ntadmin", since the lpadmin group is used for spool admin.
  - Alter the panic-action script to encourage users to report their
    bugs in Ubuntu packages to Ubuntu, rather than reporting to Debian.
    Modify text to more closely match the Debian script
  - Munge our init script to deal with the fact that our implementation
    (or lack thereof) of log_daemon_msg and log_progress_msg differs
    from Debian's implementation of the same (Ubuntu #19691)
  - Kept ubuntu-auxsrc.patch: some auxilliary sources (undocumented in 
    previous changelogs)
  - Set default workgroup to MSHOME

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
   Samba share mode database library external interface library.
3
3
   Used by non-Samba products needing access to the Samba share mode db.
4
4
                                                                                                                                  
5
 
   Copyright (C) Jeremy Allison 2005.
 
5
   Copyright (C) Jeremy Allison 2005 - 2006
6
6
 
7
7
   sharemodes_procid functions (C) Copyright (C) Volker Lendecke 2005
8
8
 
115
115
        return tdb_chainunlock(db_ctx->smb_tdb, get_locking_key(dev, ino));
116
116
}
117
117
 
118
 
/* Internal structure of Samba share mode db. */
119
 
/* FIXME ! This should be moved into a Samba include file. */
120
 
 
121
 
struct locking_data {
122
 
        union {
123
 
                struct {
124
 
                        int num_share_mode_entries;
125
 
                        BOOL delete_on_close;
126
 
                } s;
127
 
                struct share_mode_entry dummy; /* Needed for alignment. */
128
 
        } u;
129
 
        /* the following two entries are implicit
130
 
           struct share_mode_entry modes[num_share_mode_entries];
131
 
           char file_name[];
132
 
        */
133
 
};
134
 
 
135
118
/*
136
119
 * Check if an external smb_share_mode_entry and an internal share_mode entry match.
137
120
 */
138
121
 
139
 
static int share_mode_entry_equal(const struct smb_share_mode_entry *e_entry, const struct share_mode_entry *entry)
 
122
static int share_mode_entry_equal(const struct smb_share_mode_entry *e_entry,
 
123
                                const struct share_mode_entry *entry)
140
124
{
141
125
        return (sharemodes_procid_equal(&e_entry->pid, &entry->pid) &&
142
126
                e_entry->file_id == (uint32_t)entry->share_file_id &&
152
136
 * Create an internal Samba share_mode entry from an external smb_share_mode_entry.
153
137
 */
154
138
 
155
 
static void create_share_mode_entry(struct share_mode_entry *out, const struct smb_share_mode_entry *in)
 
139
static void create_share_mode_entry(struct share_mode_entry *out,
 
140
                                const struct smb_share_mode_entry *in)
156
141
{
157
142
        memset(out, '\0', sizeof(struct share_mode_entry));
158
143
 
164
149
        out->access_mask = in->access_mask;
165
150
        out->dev = (SMB_DEV_T)in->dev;
166
151
        out->inode = (SMB_INO_T)in->ino;
 
152
        out->uid = (uint32)geteuid();
167
153
}
168
154
 
169
155
/*
280
266
                        return -1;
281
267
                }
282
268
                ld = (struct locking_data *)db_data.dptr;
 
269
                memset(ld, '\0', sizeof(struct locking_data));
283
270
                ld->u.s.num_share_mode_entries = 1;
284
271
                ld->u.s.delete_on_close = 0;
 
272
                ld->u.s.initial_delete_on_close = 0;
 
273
                ld->u.s.delete_token_size = 0;
285
274
                shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct share_mode_entry));
286
275
                create_share_mode_entry(shares, new_entry);
287
276
 
326
315
        ld = (struct locking_data *)new_data_p;
327
316
        ld->u.s.num_share_mode_entries++;
328
317
 
329
 
        /* Append the original filename */
 
318
        /* Append the original delete_token and filenames. */
330
319
        memcpy(new_data_p + ((ld->u.s.num_share_mode_entries+1)*sizeof(struct share_mode_entry)),
331
320
                db_data.dptr + ((orig_num_share_modes+1)*sizeof(struct share_mode_entry)),
332
321
                db_data.dsize - ((orig_num_share_modes+1) * sizeof(struct share_mode_entry)));
376
365
        struct locking_data *ld = NULL; /* internal samba db state. */
377
366
        struct share_mode_entry *shares = NULL;
378
367
        char *new_data_p = NULL;
379
 
        size_t filename_size = 0;
 
368
        size_t remaining_size = 0;
380
369
        size_t i, num_share_modes;
381
 
        const char *fname_ptr = NULL;
 
370
        const char *remaining_ptr = NULL;
382
371
 
383
372
        db_data = tdb_fetch(db_ctx->smb_tdb, locking_key);
384
373
        if (!db_data.dptr) {
438
427
                return tdb_delete(db_ctx->smb_tdb, locking_key);
439
428
        }
440
429
 
441
 
        /* Copy the terminating filename. */
442
 
        fname_ptr = db_data.dptr + ((orig_num_share_modes+1) * sizeof(struct share_mode_entry));
443
 
        filename_size = db_data.dsize - (fname_ptr - db_data.dptr);
 
430
        /* Copy any delete token plus the terminating filenames. */
 
431
        remaining_ptr = db_data.dptr + ((orig_num_share_modes+1) * sizeof(struct share_mode_entry));
 
432
        remaining_size = db_data.dsize - (remaining_ptr - db_data.dptr);
444
433
 
445
434
        memcpy(new_data_p + ((num_share_modes+1)*sizeof(struct share_mode_entry)),
446
 
                fname_ptr,
447
 
                filename_size);
 
435
                remaining_ptr,
 
436
                remaining_size);
448
437
 
449
438
        free(db_data.dptr);
450
439
 
454
443
        ld = (struct locking_data *)db_data.dptr;
455
444
        ld->u.s.num_share_mode_entries = num_share_modes;
456
445
 
457
 
        db_data.dsize = ((num_share_modes+1)*sizeof(struct share_mode_entry)) + filename_size;
 
446
        db_data.dsize = ((num_share_modes+1)*sizeof(struct share_mode_entry)) + remaining_size;
458
447
 
459
448
        if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) == -1) {
460
449
                free(db_data.dptr);