~lefteris-nikoltsios/+junk/samba-lp1016895

« back to all changes in this revision

Viewing changes to source3/smbd/sec_ctx.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
   uid/user handling
4
4
   Copyright (C) Tim Potter 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 "smbd/smbd.h"
21
22
#include "smbd/globals.h"
 
23
#include "libcli/security/security_token.h"
 
24
#include "auth.h"
 
25
#include "smbprofile.h"
22
26
 
23
27
extern struct current_user current_user;
24
28
 
26
30
 Are two UNIX tokens equal ?
27
31
****************************************************************************/
28
32
 
29
 
bool unix_token_equal(const UNIX_USER_TOKEN *t1, const UNIX_USER_TOKEN *t2)
 
33
bool unix_token_equal(const struct security_unix_token *t1, const struct security_unix_token *t2)
30
34
{
31
35
        if (t1->uid != t2->uid || t1->gid != t2->gid ||
32
36
                        t1->ngroups != t2->ngroups) {
80
84
                        become_gid_done = true;
81
85
                }
82
86
        }
83
 
  
 
87
 
84
88
        /* Set effective group id */
85
89
 
86
90
        set_effective_gid(gid);
131
135
 Get the list of current groups.
132
136
****************************************************************************/
133
137
 
134
 
static int get_current_groups(gid_t gid, size_t *p_ngroups, gid_t **p_groups)
 
138
static int get_current_groups(gid_t gid, uint32_t *p_ngroups, gid_t **p_groups)
135
139
{
136
140
        int i;
137
141
        gid_t grp;
167
171
        (*p_ngroups) = ngroups;
168
172
        (*p_groups) = groups;
169
173
 
170
 
        DEBUG( 3, ( "get_current_groups: user is in %u groups: ", ngroups));
 
174
        DEBUG( 4, ( "get_current_groups: user is in %u groups: ", ngroups));
171
175
        for (i = 0; i < ngroups; i++ ) {
172
 
                DEBUG( 3, ( "%s%d", (i ? ", " : ""), (int)groups[i] ) );
 
176
                DEBUG( 4, ( "%s%d", (i ? ", " : ""), (int)groups[i] ) );
173
177
        }
174
 
        DEBUG( 3, ( "\n" ) );
 
178
        DEBUG( 4, ( "\n" ) );
175
179
 
176
180
        return ngroups;
177
181
 
206
210
        ctx_p->ut.uid = geteuid();
207
211
        ctx_p->ut.gid = getegid();
208
212
 
209
 
        DEBUG(3, ("push_sec_ctx(%u, %u) : sec_ctx_stack_ndx = %d\n", 
 
213
        DEBUG(4, ("push_sec_ctx(%u, %u) : sec_ctx_stack_ndx = %d\n", 
210
214
                  (unsigned int)ctx_p->ut.uid, (unsigned int)ctx_p->ut.gid, sec_ctx_stack_ndx ));
211
215
 
212
216
        ctx_p->token = dup_nt_token(NULL,
300
304
 Set the current security context to a given user.
301
305
****************************************************************************/
302
306
 
303
 
void set_sec_ctx(uid_t uid, gid_t gid, int ngroups, gid_t *groups, NT_USER_TOKEN *token)
 
307
void set_sec_ctx(uid_t uid, gid_t gid, int ngroups, gid_t *groups, struct security_token *token)
304
308
{
305
309
        struct sec_ctx *ctx_p = &sec_ctx_stack[sec_ctx_stack_ndx];
306
 
        
 
310
 
307
311
        /* Set the security context */
308
312
 
309
 
        DEBUG(3, ("setting sec ctx (%u, %u) - sec_ctx_stack_ndx = %d\n", 
 
313
        DEBUG(4, ("setting sec ctx (%u, %u) - sec_ctx_stack_ndx = %d\n", 
310
314
                (unsigned int)uid, (unsigned int)gid, sec_ctx_stack_ndx));
311
315
 
312
 
        debug_nt_user_token(DBGC_CLASS, 5, token);
 
316
        security_token_debug(DBGC_CLASS, 5, token);
313
317
        debug_unix_user_token(DBGC_CLASS, 5, uid, gid, ngroups, groups);
314
318
 
315
319
        /* Change uid, gid and supplementary group list. */
323
327
        }
324
328
 
325
329
        TALLOC_FREE(ctx_p->token);
326
 
        
 
330
 
327
331
        if (ngroups) {
328
332
                ctx_p->ut.groups = (gid_t *)memdup(groups,
329
333
                                                   sizeof(gid_t) * ngroups);
414
418
        current_user.ut.groups = prev_ctx_p->ut.groups;
415
419
        current_user.nt_user_token = prev_ctx_p->token;
416
420
 
417
 
        DEBUG(3, ("pop_sec_ctx (%u, %u) - sec_ctx_stack_ndx = %d\n", 
 
421
        DEBUG(4, ("pop_sec_ctx (%u, %u) - sec_ctx_stack_ndx = %d\n", 
418
422
                (unsigned int)geteuid(), (unsigned int)getegid(), sec_ctx_stack_ndx));
419
423
 
420
424
        return True;